How to add a system service to the Android Framework

前端 未结 4 690
死守一世寂寞
死守一世寂寞 2020-12-23 17:58

I want to add my own framework code that runs in the Android \"system_server\" (handles all the system level services). My service loads a JNI library that talks to a driver

4条回答
  •  醉酒成梦
    2020-12-23 18:32

    Follow the below steps for writing your own System Service in android framework.

    1. Write your Own Service/Manager with API's exposed by inheriting the stub.
    2. Create an aidl file for your service to expose & include in build.
    3. Add your service in System Server, you service will start along with all core services.
    4. Register your service context in context impl file.
    5. Use your service in application by calling getSystemService(Context of your service)

    PS; if your service get some fatal exception, device will soft reboot, as your service is running under system service.

提交回复
热议问题