Not without modifying this,
public Intent registerReceiver(IApplicationThread caller, String
callerPackage,
IIntentReceiver receiver, IntentFilter filter, String
permission, int userId) {
enforceNotIsolatedCaller("registerReceiver");
...
}
Good luck !!!
On Dec 10, 12:33 pm, Quentin Swain <
qswa...@gmail.com> wrote:
> Hi,
>
> I am attempting to create a java service that runs outside of the system
> server and would be started from boot, which based on configuration can
> monitor an Android device and listen for broadcasts. I have not been able
> to find documentation on how to write a long running java service that runs
> as a process that isn't started by zygote. I am trying to modify the
> platform and this service would be added to a custom system.img generated
> by rebuilding the Android source.
>
> The service would be started similar to the script used to run am from adb.
>
> the idea would be to try and start the service as early as possible when
> device is booting with a script similar to the script that is used to run
> am or pm for instance
>
> The service would be started similar to the script used to run am from adb.
>
> base=/system
>
> export CLASSPATH=$base/framework/am.jar
>
> exec app_process $base/bin
com.android.commands.am.Am "$@"
>
> The only examples that I have found trying to add daemons have been to
> implement fully native services that run on the device.
https://groups.google.com/forum/?fromgroups=#!topic/android-porting/x...
>
> Embedded Android describes Android Userspace and some of the native daemons
> that run there and how to create services and add them to init to start at
> device boot at least prior to Zygote and the System Server ect.
http://shop.oreilly.com/product/0636920021094.do?sortby=publicationDate
>
> public class Monitor{
>
> public static void main(String [] args){
>
> new Monitor.run();
>
> }
>
> public void run(){
>
> Application app = new Application();
>
> Context con = app.getApplicationContext();
>
> BroadcastReceiver receiver = new BroadcastReceiver(){
>
> public void onReceive(Context context, Intent intent){
>
> Log.i(TAG, "Received intent:"+ intent.getAction());
>
> }
>
> }
>
> IntentFilter filter = new
> IntentFilter("android.intent.action.TIME_TICK")
>
> }
>
> }
>
> I also tried this based on a snippet of code from the
> ActivityManagerService.
>
> public class Monitor{
>
> private Context mContext;
>
> Monitor(){
>
> Looper.prepare()
>
> ActivityThread at = ActivityThread.systemMain();
>
> mContext = at.getSystemContext();
>
> }
>
> public static void main(String [] args){
>
> new Monitor.run();
>
> }
>
> public void run(){
>
> BroadcastReceiver receiver = new BroadcastReceiver(){
>
> public void onReceive(Context context, Intent intent){
>
> Log.i(TAG, "Received intent:"+ intent.getAction());
>
> }
>
> }
>
> IntentFilter filter = new
> IntentFiler("android.intent.action.AIRPLANE_MODE");
>
> mContext.registerReceiver(receiver,filter);
>
> }
>
> }
>
> I that intents/broadcasts can be generated from the commandline using adb
> and am but is there anyway to receive broadcasts or would i have to try to
> modify the ActivityManager or other parts of the platform to detemine when
> intents are being sent. . Any advice or suggestion is appreciated.
>
> [1]: