Re: Java daemon process not started by zygote and monitoring system events

130 views
Skip to first unread message

Ubuntu guy

unread,
Dec 10, 2012, 10:07:50 PM12/10/12
to android-platform
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]:

cary....@gmail.com

unread,
Dec 10, 2012, 10:31:38 PM12/10/12
to android-...@googlegroups.com
Hi, all
kernel 3.4 use ION replace pmem, So android_pmem.h has been moved
since 2012-01-28 on kernel-3.4 branch. but
/frameworks/native/libs/binder/MemoryHeapBase.cpp still include it,
And also , kernel-3.4 is not merge to kernel-3.4-compat, cause
kernel-3.4-compat+android-4.2_r1 can't pass compile phase
(ION_FLAG_CACHED_NEEDS_SYNC not defined in ion.h), can anyone fix this,
I also submit a issue on Google
groups(http://code.google.com/p/android/issues/detail?id=41173)

Quentin Swain

unread,
Dec 12, 2012, 8:32:30 AM12/12/12
to android-...@googlegroups.com
Thanks for the reply. I took a look through the ActivityManager. I'm gonna try a slightly different approach to try and avoid making too many changes in the ActivityManager. I really appreciate the advice and your time thanks again
Reply all
Reply to author
Forward
0 new messages