Search code examples
androidandroid-studioandroid-source

Use custom system service in app (Android Studio)


First of all, thank you for your help.

Here is my problem.

  1. I have made a custom system service (it does connect through the binder, and hooks into the system server, then into the HAL, etc). One of the main commands is isBacklightOn(). I also ran the make update-api to include it in my ROM build.
  2. I am now ready to test the functionality using an app. I am using the following code:

import android.os.BacklightManager; //My service manager name

...
BacklightManager bm = (BacklightManager) getSystemService(BACKLIGHT_SERVICE);
...

if(!bm.isBacklightOn()) {
  //Turn it on.
} else {
  //Other Things...
}

My problem occurs because Android Studio will not build the application due to not knowing what the BacklightManager is. How can I build this application to test my code? (import something into Android Manager, force a build ignoring errors, etc.)


Solution

  • It looks like the solution is to build a custom SDK within the AOSP build environment. And then import that into Android Studio