Some thoughts about AppOpsManager and 4.4

Android 4.3 introduced a new hidden feature: AppOps.
Android 4.4 improved this feature, but it is still hidden.

Someone talks about it as an "App Permission Manager".
We have very few information about it, but it is a lot more than a simple permission manager.

Currently there is no action to launch it.

You can see it in Manifest.xml:
https://github.com/android/platform_packages_apps_settings/blob/master/AndroidManifest.xml#L802

A simple way could be this:
 Intent intent = new Intent("android.settings.SETTINGS");
        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
                "com.android.settings.applications.AppOpsSummary");
 startActivity(intent);


Here you can find info about apps which use location-permissions, contact-permissions, message-permissions....
In the list, for each app you can see the last use of this permission, and if you click on an item, you can see a full detail.

Pay attention!
You can disable permissions, but this can break your app!
Don't do it!!
Currently the devs can't check if a permission was removed.

With API 19 Google introduced new feature in 4.4. with this class: AppOpsManager.

Pay attention to comments inside it:
  This API is not generally intended for third party application developers; most
  features are only available to system applicatins. 
I suggest you not use this class!
I don't know much about this class, however just to try......
    //Don't use this code! 
    AppOpsManager mAppOps = (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE);

    PackageManager mPm = getPackageManager();
    PackageInfo mPackageInfo=null;
    try {
         mPackageInfo = mPm.getPackageInfo(packageName,
                    PackageManager.GET_DISABLED_COMPONENTS |
                            PackageManager.GET_UNINSTALLED_PACKAGES);
    } catch (Exception e) {//only for test!}

    int permission= mAppOps.noteOp(AppOpsManager.OPSTR_FINE_LOCATION,
                                 mPackageInfo.applicationInfo.uid,
                                 packageName);


You can get code from GitHub:

Popular posts from this blog

Expand and collapse animation

How to centralize the support libraries dependencies in gradle

Android-5: Card and images with rounded corners in Android 4