joelmap / omnidroid

Automatically exported from code.google.com/p/omnidroid
Apache License 2.0
0 stars 0 forks source link

EventMonitoringService error during initialization #74

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run Android on the emulator with Omnidroid installed.

The logs will indicate that the EventMonitoringService failed to 
start some services: 

05-26 03:16:31.737: WARN/EventMonitoringService(189): 
edu.nyu.cs.omnidroid.external.attributes.PhoneRingingMonitor did 
not start. 
05-26 03:16:31.737: WARN/EventMonitoringService(189): The 
following error occurred: java.lang.ClassNotFoundException: 
edu.nyu.cs.omnidroid.external.attributes.PhoneRingingMonitoredu.
nyu.cs.omnidroid.external.attributes.PhoneRingingMonitor[Ljava.l
ang.StackTraceElement; @43762db8 
05-26 03:16:31.777: WARN/EventMonitoringService(189): 
edu.nyu.cs.omnidroid.external.attributes.LocationMonitor did not 
start. 
05-26 03:16:31.777: WARN/EventMonitoringService(189): The 
following error occurred: java.lang.ClassNotFoundException: 
edu.nyu.cs.omnidroid.external.attributes.LocationMonitoredu.nyu.
cs.omnidroid.external.attributes.LocationMonitor[Ljava.lang.Stac
kTraceElement;@437655c 8 
05-26 03:16:31.787: WARN/EventMonitoringService(189): 
edu.nyu.cs.omnidroid.external.attributes.TimeMonitor did not 
start. 
05-26 03:16:31.787: WARN/EventMonitoringService(189): The 
following error occurred: java.lang.ClassNotFoundException: 
edu.nyu.cs.omnidroid.external.attributes.TimeMonitoredu.nyu.cs.o
mnidroid.external.attributes.TimeMonitor[Ljava.lang.StackTraceEl
ement;@43767cf0 

Discussion on devel can be found on:
http://groups.google.com/group/omnidroid-
devel/browse_thread/thread/2204777d7899de1

Original issue reported on code.google.com by renc...@gmail.com on 26 May 2010 at 8:26

GoogleCodeExporter commented 9 years ago
Cause: The VM was not able to find the classes because the 
monitorPackage did not reflect the recent change in the directory 
structure made by r697. The effect of this is that Omnidroid rules 
related to phone ring, location change or time change will not work even 
when turned on.

Fix: Instead of relying on reflection to instantiate classes, I used the 
normal way - using the new operator. Apparently, the reason behind using 
the reflection utilities was to allow 3rd party developers to add their 
own monitor classes in our database and we could instatiate them 
dynamically using reflection. However, I believe the better and safer 
way is to let the 3rd party application start their own service by 
having its own manifest file, installation to the device, etc. 
Afterwards, they just need to send OmniDroid the necessary intents which 
is exactly what the current monitoring classes are doing right now (we 
still need the intrastracture to support this one).

I also took this opportunity to clean up the code in 
EventMonitoringService.java.

I also removed receiver element at the manifest file for TIME_TICK as it 
serves no purpose, and thus, misleading. In reference to to the Android 
API:

public static final String ACTION_TIME_TICK

Since: API Level 1
Broadcast Action: The current time has changed. Sent every minute. You 
can not receive this through components declared in manifests, only by 
explicitly registering for it with Context.registerReceiver().
This is a protected intent that can only be sent by the system.

Constant Value: "android.intent.action.TIME_TICK"

Tested rules with phone ring, location change and time events to be 
working on the emulator.

Original comment by renc...@gmail.com on 2 Jun 2010 at 3:53

GoogleCodeExporter commented 9 years ago
I have not tested or tried this yet, but I would also would like to add that I 
am quite 
skeptical that EventMonitoringService would be able to instantiate the classes 
outside 
of our project as every process has its own copy of the DVM, and what the 
original code 
was trying to do is like trying to dynamically link the codes.

Original comment by renc...@gmail.com on 2 Jun 2010 at 2:23

GoogleCodeExporter commented 9 years ago
Committed on r734.
Review path: http://codereview.appspot.com/1446043/

Original comment by renc...@gmail.com on 2 Jun 2010 at 7:59