[Practice] Android5.1.1 source code, android5.1.1 source code

Source: Internet
Author: User

[Practice] Android5.1.1 source code, android5.1.1 source code
Preface

In this article, we need to modify the Android source code. However, as long as the system service is written, the system_server process can be injected to load the system service to system_server.

Procedure

1. Add an aidl file. I will add the aidl file to this path:

Frameworks/base/core/java/android/content/bw/IBWService. aidl, IBWService. aidl is my aidl file. The following is an example:

 

2. in frameworks/base/Android. many aidl files are added to the LOCAL_SRC_FILES file of the mk file. We add a line in the file list added by the system: core/java/android/content/bw/IBWService. aidl

 

3. Write a service file to inherit the Stub class in aidl. I added this class to this path:

Frameworks/base/services/core/java/com/android/server/bw/BWService. java. Here is a tip: You can first write an aidl and a class that inherits its Stub in your Android project. When the code is written correctly, copy the two files to the Android source code directory. The following is an example of a service file:

 

4. Add custom system services to the SystemServer class. For details about how to add system services, refer to Android5.1.1 source code-Analysis of when Android system services will be added to ServiceManager. The following is an example of adding a custom system service:

 

5. because SeAndroid is available in Android5.1.1, a white list of system services is maintained in this system. If the system service you want to add is not in this white list, adding the system service will fail, the whitelist path is external/sepolicy/service_contexts.

 

The following is the line I added to the whitelist:

Bwservice u: object_r: system_server_service: s0

Bwservice is the service name entered when ServiceManager. addService is used.

Now the system service has been added. just re-compile the Android source code.

 

Author: xunyu @ Alibaba Cloud universal security. For more security technical articles, visit the Alibaba Cloud universal security blog.

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.