The Android 5.1 system gives the application open system permission through the package name

The common method of opening system permission to an application is to directly make the application into a system application (that is, add: Android: shareduserid = "Android. Uid. System" in the androidmanifest.xml file), but this method limits the freedom of the application itself, that is, the system application signed by the system can only be installed and used on the corresponding Android platform, It cannot be put into the Android Market like other applications, and is compatible with all Android devices.

Now we introduce a method to open system permissions on the Android platform by modifying the system layer code of the Android platform and giving the corresponding application the specified application package name. This not only does not affect the compatibility of the application, but also solves the problem that the application wants to call some system layer interfaces without permission.

The core of this method is to change both uid and GID to 0. 0 in the startprocesslocked interface of activitymanagerservice

Package name requiring open system permissions:

1、net.forclass.fcstudent

2、com.ckl.launcher

3、com.creative.fcstudent

@H_ 301_ 19 @ modification steps:

1. After the application is installed on the device, clicking start will call the startprocesslocked interface of activitymanagerservice to start a new process. In fact, the purpose of opening system permission to the application is to enable the application to become a super application and run in the system process. In this way, we only need to modify the UID of the application to 0 in the startprocesslocked interface.

2. The applyuidsecuritypolicy (arguments args, credentials peer, string peersecuritycontext) interface in zygoteconnection.java will judge the process ID if it is less than process.system_ Uid (1000) is considered illegal, and zygote is the only server with root permission. After judgment, you can determine whether to throw an exception by reading the value of the system attribute "sys. Permission. Enable" set earlier.

@H_ 301_ 19 @ summary

The above is the Android 5.1 system introduced to you by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>