brok85 / omnidroid

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

Omnidroid force closes when trying to perform sms action #147

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a new rule (use any event except phone ringing)
2. Add an action with SMS with the parameter SMS message as 
"<omniArea><latitude>2.003333333333333</latitude><longititude>2.003333333333333<
/longititude><userInput>null</userInput><proximityDistance>0.0</proximityDistanc
e></omniArea>"
3. Save the rule.
4. Trigger the rule.

What is the expected output? What do you see instead?
Omnidroid force closes due to null pointer exception.

Excerpt from logs:
D/AndroidRuntime(  308): Shutting down VM
W/dalvikvm(  308): threadid=3: thread exiting with uncaught exception 
(group=0x4001b188)
E/AndroidRuntime(  308): Uncaught handler: thread main exiting due to uncaught 
exception
E/AndroidRuntime(  308): java.lang.NullPointerException
E/AndroidRuntime(  308):    at android.os.Parcel.readException(Parcel.java:1224)
E/AndroidRuntime(  308):    at android.os.Parcel.readException(Parcel.java:1206)
E/AndroidRuntime(  308):    at 
com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:369)
E/AndroidRuntime(  308):    at 
android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
E/AndroidRuntime(  308):    at 
edu.nyu.cs.omnidroid.app.controller.external.actions.SMSService$2.onCallStateCha
nged(SMSService.java:132)

Original issue reported on code.google.com by renc...@gmail.com on 27 Jul 2010 at 2:36

GoogleCodeExporter commented 8 years ago
Here's the log:
Note: I used GPS location changed as the event.

Original comment by renc...@gmail.com on 27 Jul 2010 at 2:39

Attachments:

GoogleCodeExporter commented 8 years ago
Apparently, having a very long text message has the same effect but the logs 
show a different place of failure:

D/AndroidRuntime(  570): Shutting down VM
W/dalvikvm(  570): threadid=3: thread exiting with uncaught exception 
(group=0x4001b188)
E/AndroidRuntime(  570): Uncaught handler: thread main exiting due to uncaught 
exception
E/AndroidRuntime(  570): java.lang.RuntimeException: Error receiving broadcast 
Intent { act=SMS_SENT } in 
edu.nyu.cs.omnidroid.app.controller.external.actions.SMSService$1@43c01ad8
E/AndroidRuntime(  570):    at 
android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThrea
d.java:765)
E/AndroidRuntime(  570):    at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(  570):    at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(  570):    at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  570):    at 
android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime(  570):    at java.lang.reflect.Method.invokeNative(Native 
Method)
E/AndroidRuntime(  570):    at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  570):    at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(  570):    at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(  570):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  570): Caused by: java.lang.NullPointerException
E/AndroidRuntime(  570):    at 
edu.nyu.cs.omnidroid.app.controller.ResultProcessor.process(ResultProcessor.java
:70)
E/AndroidRuntime(  570):    at 
edu.nyu.cs.omnidroid.app.controller.external.actions.SMSService$1.onReceive(SMSS
ervice.java:104)

P.S. This is the exact sms message I used:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345678901234
5678901234567890088765543321jjjjjjjjjjjiiiiiiiooooooiiiioooo99998887765443345776
4345678hygdrrdtvvvrgvfhltrdgfrgfcdv

Original comment by renc...@gmail.com on 27 Jul 2010 at 3:55

Attachments:

GoogleCodeExporter commented 8 years ago
Just to make sure, you're running this on the emulator or the test phone?

If the test phone, this could be caused by Issue 125.

I would think the long text message problem is probably a separate issue.

Original comment by case.and...@gmail.com on 27 Jul 2010 at 4:10

GoogleCodeExporter commented 8 years ago
Emulator running on API level 7.

Original comment by renc...@gmail.com on 27 Jul 2010 at 4:14

GoogleCodeExporter commented 8 years ago

Original comment by case.and...@gmail.com on 28 Jul 2010 at 9:11

GoogleCodeExporter commented 8 years ago

Original comment by renc...@gmail.com on 28 Jul 2010 at 11:09

GoogleCodeExporter commented 8 years ago
This seems like something that is tailor made for some unit tests.  If you're 
feeling up to it, see if you cna provide unit tests with this fix.  If you 
aren't feeling up to it, a TODO comment for them to be made in the future.

Original comment by case.and...@gmail.com on 28 Jul 2010 at 11:22

GoogleCodeExporter commented 8 years ago
Force close on 2nd log will be fixed by the changes made by issue 18 on 
SMSService.java.

Caused by:
The intent passed to the ResultProcessor is the one passed from the 
PendingIntent, which was different from the intent that started the SMSService, 
therefore, it does not have Action.ACTION_TYPE extra bundled with it. This will 
cause the actionType at ResultProcessor to be null, thus, attempting to call 
actionType.equals eventually triggers the Null Exception.

Fixed by:
The intent that started the SMSService was the one passed to the 
ResultProcessor.

Investigation will then proceed to the bug on the first log.

Original comment by renc...@gmail.com on 30 Jul 2010 at 2:59

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

Caused by:
Although this is not officially documented in the Android API, attempting to 
send sms message with more than 160 charaters with SmsManager.sendTextMessage 
will cause a null pointer exception. This is confirmed through experimentation 
and in various forums in the net.

Fix detail:
Split the sms message into managable chunks before sending them.

Test Cases:
1. Check that the correct SMS message is received at the receiving end and use 
logs to confirm that the contents of the original intent that started the 
SMSService is properly received at the ResultReceiver for the following cases:
  1.1 Create a rule with SMS action with SMS message > 160 characters and trigger the rule.
  1.2 Create a rule with SMS action with SMS message < 160 characters and trigger the rule.

Original comment by renc...@gmail.com on 30 Jul 2010 at 6:20

GoogleCodeExporter commented 8 years ago
Checked-in @ r845.

Original comment by renc...@gmail.com on 31 Jul 2010 at 9:48