Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIUI8.1 系统可以正常打开app权限页面,但是添加AccessibilityService就出现以下异常 #1

Open
Javen205 opened this issue Dec 26, 2016 · 8 comments

Comments

@Javen205
Copy link

第一次使用辅助功能望指点

public void openMiuiPermissionActivity(Context context) {
        Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");

        if ("V5".equals(getProperty())) {
            PackageInfo pInfo = null;
            try {
                pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            } catch (PackageManager.NameNotFoundException e) {
                Log.e("canking", "error");
            }
            intent.setClassName("com.miui.securitycenter", "com.miui.securitycenter.permission.AppPermissionsEditor");
            intent.putExtra("extra_package_uid", pInfo.applicationInfo.uid);
        } else if ("V8".equals(getProperty())) {
            PackageInfo pInfo = null;
            try {
                pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            } catch (PackageManager.NameNotFoundException e) {
                Log.e("canking", "error");
            }
            intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.RealAppPermissionsEditorActivity");
            intent.putExtra("extra_package_uid", pInfo.applicationInfo.uid);
        } else {
            intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
            intent.putExtra("extra_pkgname", context.getPackageName());
        }

        if (isActivityAvailable(context, intent)) {
            if (context instanceof Activity) {
                Activity a = (Activity) context;
                a.startActivityForResult(intent, 2);
            }
        } else {
            Log.e("canking", "Intent is not available!");
        }
    }
12-26 11:13:10.123 25016-25016/com.javen.callphone I/System.out: 小米rom的版本名>V8
12-26 11:13:10.127 25016-25016/com.javen.callphone E/Javen: com.javen.callphone.utils.AppLogger.log(): 0 invoke 1
12-26 11:13:10.127 25016-25016/com.javen.callphone I/System.out: 判断MIUI的悬浮窗权限:false
12-26 11:13:10.128 25016-25016/com.javen.callphone E/Javen: com.javen.callphone.utils.AppLogger.log(): 0 invoke 1
12-26 11:13:10.131 25016-25016/com.javen.callphone I/Timeline: Timeline: Activity_launch_request time:122171774
12-26 11:13:10.136 25016-25016/com.javen.callphone D/AndroidRuntime: Shutting down VM
12-26 11:13:10.137 25016-25016/com.javen.callphone E/AndroidRuntime: FATAL EXCEPTION: main
                                                                     Process: com.javen.callphone, PID: 25016
                                                                     java.lang.IllegalStateException: Could not execute method for android:onClick
                                                                         at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
                                                                         at android.view.View.performClick(View.java:5207)
                                                                         at android.view.View$PerformClick.run(View.java:21177)
                                                                         at android.os.Handler.handleCallback(Handler.java:739)
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                         at android.os.Looper.loop(Looper.java:148)
                                                                         at android.app.ActivityThread.main(ActivityThread.java:5441)
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
                                                                      Caused by: java.lang.reflect.InvocationTargetException
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
                                                                         at android.view.View.performClick(View.java:5207) 
                                                                         at android.view.View$PerformClick.run(View.java:21177) 
                                                                         at android.os.Handler.handleCallback(Handler.java:739) 
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                         at android.os.Looper.loop(Looper.java:148) 
                                                                         at android.app.ActivityThread.main(ActivityThread.java:5441) 
                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738) 
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628) 
                                                                      Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=miui.intent.action.APP_PERM_EDITOR cmp=com.miui.securitycenter/com.miui.permcenter.permissions.RealAppPermissionsEditorActivity (has extras) } from ProcessRecord{1d88e87 25016:com.javen.callphone/u0a325} (pid=25016, uid=10325) requires android.permission.CHANGE_COMPONENT_ENABLED_STATE
                                                                         at android.os.Parcel.readException(Parcel.java:1620)
                                                                         at android.os.Parcel.readException(Parcel.java:1573)
                                                                         at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2661)
                                                                         at android.app.Instrumentation.execStartActivity(Instrumentation.java:1509)
                                                                         at android.app.Activity.startActivityForResult(Activity.java:3978)
                                                                         at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
                                                                         at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:77)
                                                                         at android.app.Activity.startActivityForResult(Activity.java:3939)
                                                                         at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
                                                                         at com.javen.callphone.ui.MiActivity.openMiuiPermissionActivity(MiActivity.java:115)
                                                                         at com.javen.callphone.ui.MiActivity.xiaomiPJ(MiActivity.java:66)
                                                                         at com.javen.callphone.ui.MiActivity.openAppPermissionView(MiActivity.java:52)
                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                         at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
                                                                         at android.view.View.performClick(View.java:5207) 
                                                                         at android.view.View$PerformClick.run(View.java:21177) 
                                                                         at android.os.Handler.handleCallback(Handler.java:739) 
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                         at android.os.Looper.loop(Looper.java:148) 
                                                                         at android.app.ActivityThread.main(ActivityThread.java:5441) 
                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738) 
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628) 
12-26 11:13:10.164 25016-25016/com.javen.callphone I/Process: Sending signal. PID: 25016 SIG: 9

手机版本

@CankingApp
Copy link
Owner

CankingApp commented Dec 27, 2016 via email

@Javen205
Copy link
Author

Javen205 commented Dec 28, 2016

android.permission.CHANGE_COMPONENT_ENABLED_STATE 这个权限是系统级别的权限 动态获取貌似也无法获取到

@CankingApp
Copy link
Owner

CankingApp commented Dec 29, 2016 via email

@Javen205
Copy link
Author

那有其他的解决方案提供参考吗?

@CankingApp
Copy link
Owner

CankingApp commented Jan 3, 2017 via email

@Speical
Copy link

Speical commented Jan 6, 2017

大神,你好,请问有研究MIUI8上 android.permission.CHANGE_COMPONENT_ENABLED_STATE 异常这个问题吗?或者除Toast以为的其他方案,因为我需要悬浮窗是可以拖动的。谢谢,望回复。

@CankingApp
Copy link
Owner

找到一个miui8 的手机,系统是6.10.27,运行正常,可以一键自动打开,
各位能提高下具体的版本号或是详细的log吗~

@CankingApp
Copy link
Owner

CankingApp commented Jan 10, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants