These two days the boss said to me to study the function of Android security software, first extracted a small module, research rights Management
Go to Packagemanager at the beginning. There are several ways to find out:
First go to see the Ipackagemanager inside the method:
There's a lot of me here that lists the permissions.
Permissioninfo Getpermissioninfo (String name,intflags); List<PermissionInfo> Querypermissionsbygroup (String Group,intflags); Permissiongroupinfo Getpermissiongroupinfo (String name,intflags); List<PermissionGroupInfo> Getallpermissiongroups (intflags); intcheckpermission (String permname, string pkgname); intCheckuidpermission (String Permname,intuid); Booleanaddpermission (in Permissioninfo info); voidremovepermission (String name); voidgrantpermission (String packagename, string permissionname); voidrevokepermission (String packagename, string permissionname); String[] Getappoppermissionpackages (String permissionname); Parceledlistslice getpackagesholdingpermissions (in string[] permissions,intFlagsintuserId); BooleanAddpermissionasync (in Permissioninfo info); voidsetpermissionenforced (String permission,Booleanenforced);
Look at the features on the security software:
Find permissions by package name
Find the package name through permissions
Disable prompt allows three states
First of all: There are 2 methods found:
void removepermission (String name); void
I was happy to start writing the code. Test Result: java.lang.SecurityException:Can' t change Android.permission.INTERNET. It's required by the application has been reporting this mistake
I went online to check some of the information: see this kind of appopsmanager I understand I found the corresponding server code iappopsservice:
InterfaceIappopsservice {//These first methods is also called by native code, so must//Be kept on sync with frameworks/native/include/binder/iappopsservice.h intCheckoperation (intCodeintuid, String packagename); intNoteoperation (intCodeintuid, String packagename); intStartoperation (IBinder token,intCodeintuid, String packagename); voidFinishoperation (IBinder token,intCodeintuid, String packagename); voidStartwatchingmode (intop, String packagename, Iappopscallback callback); voidStopwatchingmode (Iappopscallback callback); IBinder GetToken (IBinder clienttoken); //Remaining methods is only used in Java. intCheckpackage (intuid, String packagename); List<appopsmanager.packageops> Getpackagesforops (inint[] OPS); List<appopsmanager.packageops> Getopsforpackage (intUID, String PackageName, inint[] ops); voidSetMode (intCodeintUID, String PackageName,intmode);voidResetallmodes (intRequserid, String reqpackagename); intCheckaudiooperation (intCodeintUsageintuid, String packagename); voidSetaudiorestriction (intCodeintUsageintUidintmode, in string[] exceptionpackages); voidSetuserrestrictions (in Bundle restrictions,intuserhandle); voidRemoveuser (intuserhandle); }
It uses mode to set the state,
Permissions can be obtained by package name
You can also get the package name through permissions
More importantly, the return permissions are not all returned to you according to the level system.
You can get a rating based on permissions, and it's all clear.
Android Get other app permissions (Modify status)