Two things are required to expand a hardware module for Android:
1. Hardware and Kernel support.
2. Add the xml configuration file under/system/etc/permissions. /Framework/base/data/etc/Some of the following have been written, you can copy it as needed.
In this way, through the hassystemfeature or getsystemavailablefeatures of packagemanager, you can determine whether the system supports which module and then use the corresponding API.
No matter how many xml configuration files there are, they have the same syntax and can be fully put into an XML file.
Each XML file must have a top-level tag <permissions>. As for sub-tags, the following types of labels are supported:
Group: the Group ID of all APK files installed in the system.
Permission. You can specify a permission that corresponds to several group IDs. When an APK is granted this permission, it also belongs to these groups.
Assign-permission: assign a permission to a uid. This permission is granted when the process uses this UID to run.
Library to add some extension libraries for the system. Put the corresponding. jar file in the/system/framework/directory. For example, you can refer to the following references for libraries related to Google map.
Feature. Each time a hardware is added, the corresponding feature must be added.
The parsing of these XML files is handled by readpermissions () in/framework/base/services/Java/COM/Android/Server/packagemanagerservice. java. Other XML files are parsed before parsing platform. xml.
The resolution results are stored in msystempermissions, msharedlibraries, msettings. mpermissions, mavailablefeatures, and other sets for system query and permission configuration.
Two examples
Multi-touch:
After hardware and Kernel support
Several XML files under/system/etc/permission can be viewed in/framework/base/data/Android. Hardware. multitouch. * And added based on the supported functions.
Support for Google Maps
This does not require hardware support, but you need to add the Google Map Library first, and then add the corresponding XML file to/system/etc/permissions. For detailed procedures, refer to the following articles.
For example, gravity acceleration, multi-touch, and WiFi, you must add the corresponding xml configuration file to/system/etc/permissions/as long as the system supports it. Before using these features, the APK may call packagemanager. hassystemfeature to check whether this hardware module is supported.
/Framework/base/data/etc/handheld_core_hardware.xml contains some system core hardware module configuration files. The/framework/base/data/etc/Android. mk file copies the file to the/system/etc/permissions/directory during compilation. This part of the code is disabled by default and needs to be enabled.
References:
Add market and map applications for Android
Http://blog.csdn.net/a345017062/archive/2011/05/27/6450205.aspx