Android O Packageinstaller Parsing

Source: Internet
Author: User

Android O 8.0

1.src\com\android\packageinstaller\permission\mode\permissiongroups.java

@Override PublicList<permissiongroup>Loadinbackground () {Arrayset<String> launcherpkgs =utils.getlauncherpackages (GetContext ()); Permissionapps.pmcache Pmcache=NewPermissionapps.pmcache (GetContext (). Getpackagemanager ()); List<PermissionGroup> groups =NewArraylist<>(); Set<String> seenpermissions =NewArrayset<>(); Packagemanager Packagemanager=GetContext (). Getpackagemanager (); List<PermissionGroupInfo> Groupinfos = packagemanager.getallpermissiongroups (0);  for(Permissiongroupinfo groupinfo:groupinfos) {//Mare sure we respond to cancellation.                if(isloadinbackgroundcanceled ()) {returncollections.emptylist (); }                //get all permissions in the permission group//Get The permissions in this group.                FinalList<permissioninfo>grouppermissions; Try{grouppermissions= Packagemanager.querypermissionsbygroup (groupinfo.name, 0); } Catch(packagemanager.namenotfoundexception e) {Continue; }                BooleanHasruntimepermissions =false; //To see if a permission group contains run-time permissions//Cache seen permissions and see if group have runtime permissions.                 for(Permissioninfo grouppermission:grouppermissions) {seenpermissions.add (grouppermission.name); if((Grouppermission.protectionlevel &permissioninfo.protection_mask_base)==permissioninfo.protection_dangerous&& (Grouppermission.flags & permissioninfo.flag_installed)! = 0 && (grouppe Rmission.flags & permissioninfo.flag_removed) = = 0) {hasruntimepermissions=true; }                }                //there is no runtime permission in the permission group, we are not interested, continue to loop query//No Runtime Permissions-not interesting for us.                if(!hasruntimepermissions) {                    Continue; }                //If the permission group contains run-time permissions, continue down//gets the label of the permission groupCharsequence label =Loaditeminfolabel (GroupInfo); drawable icon=Loaditeminfoicon (GroupInfo); //Create a new Permissionapps object based on a permission group                PermissionappsPermapps =NewPermissionapps (GetContext (), Groupinfo.name,NULL, Pmcache);                Permapps.refreshsync (); //Create a Permissiongroup object//Create the group and add to the list.Permissiongroup Group =NewPermissiongroup (Groupinfo.name, groupinfo.packagename, label, Icon, Permapps.gettotalcount (Lau                ncherpkgs), Permapps.getgrantedcount (launcherpkgs));            Groups.add (group); }            //get all the installation package permissions//Make sure we add groups for lone runtime permissions.List<packageinfo> installedpackages =GetContext (). Getpackagemanager (). Getinstalledpackages (packagemanager.get_permissions); //We'll filter out the permissions that's no package requests.Set<string> requestedpermissions =NewArrayset<>();  for(PackageInfo installedpackage:installedpackages) {if(Installedpackage.requestedpermissions = =NULL) {                    Continue; }                //to add the permissions of the installation package request to the list                 for(String requestedPermission:installedPackage.requestedPermissions) {Requestedpermissions.add (re                Questedpermission); }            }             for(PackageInfo installedpackage:installedpackages) {if(Installedpackage.permissions = =NULL) {                    Continue; }                //Custom Permissions                 for(Permissioninfo permissionInfo:installedPackage.permissions) {//If We have handled the permission, no more work to do.                    if(!Seenpermissions.add (Permissioninfo.name)) {                        Continue; }                    //the concern is run-time permissions//We care is only about installed runtime permissions.                    if((Permissioninfo.protectionlevel &permissioninfo.protection_mask_base)!=permissioninfo.protection_dangerous|| (Permissioninfo.flags & permissioninfo.flag_installed) = = 0) {                        Continue; }                    //No app uses that custom permission//If No app uses this permission,                    if(!requestedpermissions.contains (Permissioninfo.name)) {                        Continue; } charsequence label=Loaditeminfolabel (Permissioninfo); drawable icon=Loaditeminfoicon (Permissioninfo);  permissionapps Permapps=NewPermissionapps (GetContext (), Permissioninfo.name,NULL, Pmcache);                    Permapps.refreshsync (); //Create the group and add to the list.                    PermissiongroupGroup =NewPermissiongroup (Permissioninfo.name, permissioninfo.packagename, label, icon,                    Permapps.gettotalcount (launcherpkgs), Permapps.getgrantedcount (launcherpkgs));                Groups.add (group);            }} collections.sort (groups); returngroups; }

2.permissionapps.java

  /** * Refresh the state and does not      return until it finishes. Shouldnot being called while a {@link     * #refresh Async Referesh} is in progress.      */     Public void Refreshsync () {        true;        Createmap (Loadpermissionapps ());    }

3.

Src\com\android\packageinstaller\permission\utils\eventlogger.java

/*** For each permission there is four events. The events is in the order of * #ALL_DANGEROUS_PERMISSIONS. The four events per permission is (in that order): "Requested", * "granted", "denied", and "revoked". */ Public classEventLogger {Private Static FinalString Log_tag = EventLogger.class. Getsimplename (); /**All dangerous permission names in the same order as the events in Metricsevent*/    Private Static FinalList<string> all_dangerous_permissions = Arrays.aslist (Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR, Ma            Nifest.permission.CAMERA, Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS, Manifest.permission.GET_ACCOUNTS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permiss Ion.            Access_coarse_location, Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_PHONE_STATE, Manifest.permission.CALL_PHONE, Manifest.permission.READ_CALL_LOG, Manifest.permission.WRITE_ Call_log, Manifest.permission.ADD_VOICEMAIL, Manifest.permission.USE_SIP, Manifest.permis Sion.            Process_outgoing_calls, Manifest.permission.READ_CELL_BROADCASTS, Manifest.permission.BODY_SENSORS, Manifest.permission.SEND_SMS, Manifest.permission.RECEIVE_SMS, Manifest.permission.READ_S            MsManifest.permission.RECEIVE_WAP_PUSH, Manifest.permission.RECEIVE_MMS, Manifest.permission.READ_EXTE            Rnal_storage, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_NUMBERS,     Manifest.permission.ANSWER_PHONE_CALLS, Manifest.permission.ACCEPT_HANDOVER);Private Static FinalList<string> all_appop_permissions =arrays.aslist (Manifest.permission.ACCESS_NOTIFICATIONS, Manifest.permission.SYSTEM_ALERT_WINDO W, Manifest.permission.WRITE_SETTINGS, Manifest.permission.REQUEST_INSTALL_PACKAGES);

4.

Src\com\android\packageinstaller\permission\utils\utils.java

     Public Static FinalString os_pkg = "Android";  Public Static Finalstring[] Modern_permission_groups ={Manifest.permission_group. CALENDAR, Manifest.permission_group. CAMERA, Manifest.permission_group. CONTACTS, Manifest.permission_group. Location, Manifest.permission_group. Sensors, Manifest.permission_group.SMS, Manifest.permission_group. PHONE, Manifest.permission_group. Microphone, Manifest.permission_group.    STORAGE}; Private Static FinalIntent launcher_intent =NewIntent (Intent.action_main,NULL). Addcategory (Intent.category_launcher);

Android O Packageinstaller Parsing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.