rigelhope / omnidroid

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

Handler Service crashes when a rule with twitter action is triggered #102

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a new rule with a twitter action and save it.
2. Trigger the rule.

What is the expected output? What do you see instead?
The action should be executed, but the android os displays a dialog asking the 
user to force close omnidroid.

Excerpt from log file:
D/AndroidRuntime(  422): Shutting down VM

W/dalvikvm(  422): threadid=3: thread exiting with uncaught exception 
(group=0x4001b188)

E/AndroidRuntime(  422): Uncaught handler: thread main exiting due to uncaught 
exception

E/AndroidRuntime(  422): java.lang.RuntimeException: Unable to start service 
edu.nyu.cs.omnidroid.app.controller.HandlerService@43d11e58 with Intent { 
act=PHONE_RINGING flg=0x10000000 
cmp=edu.nyu.cs.omnidroid.app/.controller.HandlerService (has extras) }: 
java.lang.NullPointerException

E/AndroidRuntime(  422):    at 
android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2882)

E/AndroidRuntime(  422):    at 
android.app.ActivityThread.access$3500(ActivityThread.java:119)

E/AndroidRuntime(  422):    at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)

E/AndroidRuntime(  422):    at android.os.Handler.dispatchMessage(Handler.java:99)

E/AndroidRuntime(  422):    at android.os.Looper.loop(Looper.java:123)

E/AndroidRuntime(  422):    at 
android.app.ActivityThread.main(ActivityThread.java:4363)

E/AndroidRuntime(  422):    at java.lang.reflect.Method.invokeNative(Native 
Method)

E/AndroidRuntime(  422):    at java.lang.reflect.Method.invoke(Method.java:521)

E/AndroidRuntime(  422):    at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)

E/AndroidRuntime(  422):    at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

E/AndroidRuntime(  422):    at dalvik.system.NativeStart.main(Native Method)

E/AndroidRuntime(  422): Caused by: java.lang.NullPointerException

E/AndroidRuntime(  422):    at 
edu.nyu.cs.omnidroid.app.controller.Action.getAppName(Action.java:86)

E/AndroidRuntime(  422):    at 
edu.nyu.cs.omnidroid.app.model.ActionLog.<init>(ActionLog.java:50)

E/AndroidRuntime(  422):    at 
edu.nyu.cs.omnidroid.app.controller.HandlerService.onStart(HandlerService.java:8
3)

E/AndroidRuntime(  422):    at 
android.app.Service.onStartCommand(Service.java:306)

E/AndroidRuntime(  422):    at 
android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2873)

E/AndroidRuntime(  422):    ... 10 more

Found another issue in the same logs where the database is not properly closed 
(silent error, since user is not informed):
E/Database(  285): Leak found

E/Database(  285): java.lang.IllegalStateException: 
/data/data/edu.nyu.cs.omnidroid.app/databases/omnidroid SQLiteDatabase created 
and never closed

E/Database(  285):  at 
android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1694)

E/Database(  285):  at 
android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:738)

E/Database(  285):  at 
android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:
760)

E/Database(  285):  at 
android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:
753)

E/Database(  285):  at 
android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:473)

E/Database(  285):  at 
android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193)

E/Database(  285):  at 
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.ja
va:98)

E/Database(  285):  at 
edu.nyu.cs.omnidroid.app.model.CoreLogsDbHelper.<init>(CoreLogsDbHelper.java:53)

E/Database(  285):  at 
edu.nyu.cs.omnidroid.app.model.CoreGeneralLogsDbHelper.<init>(CoreGeneralLogsDbH
elper.java:40)

E/Database(  285):  at 
edu.nyu.cs.omnidroid.app.model.GeneralLog.<init>(GeneralLog.java:39)

E/Database(  285):  at 
edu.nyu.cs.omnidroid.app.controller.HandlerService.onStart(HandlerService.java:8
7)

Original issue reported on code.google.com by renc...@gmail.com on 29 Jun 2010 at 5:00

Attachments:

GoogleCodeExporter commented 8 years ago
Code review:
http://codereview.appspot.com/1705050

Caused by:
Root of the null pointer exceptions points to:
getIntent().getComponent().getClassName()

which means there are cases when the component is null.

Fixed by:
added a guard condition to check whether component is null or not before 
accessing getClassName.

Original comment by renc...@gmail.com on 29 Jun 2010 at 5:42

GoogleCodeExporter commented 8 years ago
Created a separate issue 103 for the database leak problem found in logs.

Original comment by renc...@gmail.com on 29 Jun 2010 at 5:47

GoogleCodeExporter commented 8 years ago
Checked-in on r780.

Original comment by renc...@gmail.com on 29 Jun 2010 at 7:38

GoogleCodeExporter commented 8 years ago

Original comment by renc...@gmail.com on 29 Jun 2010 at 7:38

GoogleCodeExporter commented 8 years ago
Refix checked-in on r783.

Original comment by renc...@gmail.com on 30 Jun 2010 at 3:56