Hi I am adding my koushikservice in aospCodebase/frameworks/base/services/java/com/android/server/SystemServer.java like this
KoushikService koushikservice = null;
try{
traceBeginAndSlog("KOUSHIK_SERVICE adding trace");
koushikservice = new KoushikService(mSystemContext);
ServiceManager.addService(Context.KOUSHIK_SERVICE,koushikservice);
}catch(Throwable e){
Slog.e(TAG, "Starting KOUSHIK_SERVICE failed!!! ", e);
}
traceEnd();
I am getting "KOUSHIK_SERVICE adding trace" log but then getting avc denied. Please let me know if you need further info.
You need to add SELinux rules to allow that service. By default SELinux is deny unless explicitly allowed.
Your easiest way forward to do this would be to compare to an existing service and rules for that.
Otherise based on what I added for a service on my case, and assuming that value of
Context.KOUSHIK_SERVICE = "koushik"here's roughly what should be added :File: koushik.te
In file service_contexts, add:
In file service.te add:
In file system_server.te, add:
Lastly, if you want to allow a domain to find and use your service, for example from platform_app, you add in platform_app.te: