Denial permission OPPO_COMPONENT_SAFE

可紊 提交于 2019-12-04 12:44:26

问题


I have service in my app which needs to be running in background in device OPPO. I have read somewhere that we need to enable auto start in settings for app to keep service running but I have a problem with permission.

java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.coloros.safecenter/.startupapp.StartupAppListActivity } from ProcessRecord{904a19d 12604:elite.driver.adsmove.com.settingpermission/u0a214} (pid=12604, uid=10214) requires oppo.permission.OPPO_COMPONENT_SAFE

When i try to do this

if (Build.MANUFACTURER.equals("OPPO")) {
    Intent[] AUTO_START_OPPO = {
        new Intent().setComponent(new ComponentName("com.coloros.safe", "com.coloros.safe.permission.startup.StartupAppListActivity")),
        new Intent().setComponent(new ComponentName("com.coloros.safe", "com.coloros.safe.permission.startupapp.StartupAppListActivity")),
        new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity")),
        new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startup.StartupAppListActivity"))
    };

    for (Intent intent : AUTO_START_OPPO) {
        if (getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
            try {
                startActivity(intent);
                break;
            } catch (Exception e) {
                Log.d(TAG, "OPPO - Exception: "+  e.toString());
            }
        }
    }
}

I also tried to add permission and request it but failed

<!--for OPPO-->
<uses-permission android:name="oppo.permission.OPPO_COMPONENT_SAFE" />

Looking forward to help from those who have experience about it, thank you!

来源:https://stackoverflow.com/questions/49814755/denial-permission-oppo-component-safe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!