Starting Android init.rc service from Activity

Before we get started, this is for our own Android device, not a phone or for deployment elsewhere.

We have a service in init.rc, which is the postgresql database server. This starts at startup and always runs in the background for the system. There is a possibility that it may close, and we would like to be able to stop and start this service from Android.

Is there a way to send init start command from Activity android? From the root shell, this will be the equivalent of starting "start servicename" and "stop servicename".

+6
source share
2 answers

To start the service declared in the init.rc file, I think you should change the system property "ctl.start" with the following commands:

In c file:

property_set("ctl.start", "<service_name>"); 

In java:

 SystemProperties.set("ctl.start", "<service_name>"); 

This means that your activity has system permissions (in the manifest):

 android:sharedUserId="android.uid.system" 

and signed by your system key (or install the platform in Android.mk)

As you can guess, to stop the service, use the following commands:

 property_set("ctl.stop", "<service_name>"); 

or

 SystemProperties.set("ctl.stop", "<service_name>"); 
+12
source

This command simply launches the service for which we are intended. property_set ("ctl.start", "");

But if we want to execute some kind of command. How can we do this?

Can I use the system command in Android? Or is there some other mechanism that I can use.

0
source

All Articles