Friday 6 March 2020

PackageManagerService AOSP

Hi Guys!!! Hope All is Well .

Today We are going to analyse PackageManagerService class in Android open source project (AOSP).

  • The Package Manager service is a central service in the Android system
  • It manages all the packages in the system and is central to platform security.
  • It maintains a mapping between user/group identifiers and higher-level permission strings
we will see how permissions are managed and granted by the Package Manager
service.
Path of Package Manager service
http://androidxref.com/8.1.0_r33/xref/frameworks/base/services/core/java/com/android/server/pm/

1. Built-in permission UID mappings are stored on the filesystem at
/system/etc/ permissions/platform.xml 
the code path in AOSP is
http://androidxref.com/8.1.0_r33/xref/frameworks/base/data/etc/platform.xml
This is loaded into the Package Manager service into the following variable:
final SparseArray<HashSet<String>> mSystemPermissions =
                                                                                   new SparseArray<HashSet<String>>();

2. User application permissions
The service maintains user application permissions in the filesystem at
/data/system/packages.xml 
Fire up the emulator and drop into an adb shell. We will inspect the contents of the packages.xml file . Obtain a copy with the following command:
adb pull /data/system/packages.xml

3. Open up the file(step 2) in a text editor and search for the term "UserId"

4. The Package Manager service stores and manages all configuration data in XML files with proper Linux permissions on these files. Internally, the service makes use of XML pull parsers to read and process these files. This service is interrogated by other services, most notably the Activity Manager service, as to whether a package possesses a certain permission or not.


1 comment:

Build a Custom Kernel Module for Android

Hi Guys!!!Hope you are doing well !!!. Today I will describe how you can write a custom kernel module(Hello world) for Android and load it a...