android怎么获取程序是否有自启动权限

我集成了推送,需要自启权限,保证消息送达。打开应用,跳转设置界面让用户去手动开启,但不能每次都去设置吧,所以需要判断应用是否获取自启动权限。是自启动的权限,我不做开机接收广播自启,那种还是会死。

ComponentName localComponentName = new ComponentName(MyApplication.getInstance(), BootCompletedReceiver.class);
int i = MyApplication.getInstance().getPackageManager().getComponentEnabledSetting(localComponentName);

android怎么获取程序是否有自启动权限
我在别的地方看到这种方法:
ComponentName localComponentName = new ComponentName(MyApplication.getInstance(), BootCompletedReceiver.class);
int i = MyApplication.getInstance().getPackageManager().getComponentEnabledSetting(localComponentName);
判断i的值,4个状态,0默认 1可用 2禁止 3user disable
但是不管开关打开还是关闭,都只能获取到0。
我是在小米2上测试的

追加:不要开机自启,监听开机广播啊!!!!!!!!!!!
不要开机自启,监听开机广播啊!!!!!!!!!!!
不要开机自启,监听开机广播啊!!!!!!!!!!!
不要开机自启,监听开机广播啊!!!!!!!!!!!
不要开机自启,监听开机广播啊!!!!!!!!!!!
我要怎么判断应用是否获取了自启动权限!!!!

楼主,可以参考下这个问题:
https://stackoverflow.com/questions/39366231/how-to-check-miui-autostart-permission-programatically/39366565

xml里先添加广播,如果是小米把miui优化关掉试试
public class MyReceiver extends BroadcastReceiver
{
public MyReceiver()
{
}

@Override
public void onReceive(Context context, Intent intent)
{
    if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
    {
        Intent i = new Intent(context, MainActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
    }
}

}