About adding your own services to the system source code

About adding your own service in the system source code: After adding, you can get the instance object through getSystemService(Context.MCU_SERVICE) just like the system service. First, define the identification string of this service in the Context.java class, such as (public static final String MCU_SERVICE = "mcu"), and then go to
the startOtherServices() method in the SystemServer.java class to add the service, and add it to start the service code when the system is up, such as
(ServiceManager.addService(Context.MCU_SERVICE, rtmcu);); Then we need to go to the android\frameworks\base\ directory to create the .aidl file. In fact, it is best to install this file in a folder to avoid confusion. You can also create a new folder, android\frameworks\base Any directory under the \ directory can be used, because the relative path is written when the compiled module is added to the Android.mk file, preferably a subdirectory under the android\frameworks\base\ directory, because the Android.mk file Just in the android\frameworks\base\ directory, it is convenient to add the code for compiling the aidl file in the Android.mk file; then we create our own Service.java class in the android\frameworks\base\ subdirectory, preferably with . The aidl file is in the same directory, this class must inherit from [aidl filename.stub], and implement the Runnable interface if necessary;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326059093&siteId=291194637
Recommended