Change to make sure InboundSmsHandler stm gets out of DeliveringState
Amit Mahajan [Fri, 24 Jul 2015 21:59:17 +0000 (14:59 -0700)]
Bug: 22673185
Change-Id: Icdd972845660bab2b4b26e0c3fc3a174868dbb8b

src/java/com/android/internal/telephony/InboundSmsHandler.java

index 1ebcb89..27263ba 100644 (file)
@@ -409,8 +409,19 @@ public abstract class InboundSmsHandler extends StateMachine {
 
                 case EVENT_BROADCAST_SMS:
                     // if any broadcasts were sent, transition to waiting state
-                    if (processMessagePart((InboundSmsTracker) msg.obj)) {
+                    InboundSmsTracker inboundSmsTracker = (InboundSmsTracker) msg.obj;
+                    if (processMessagePart(inboundSmsTracker)) {
                         transitionTo(mWaitingState);
+                    } else {
+                        // if event is sent from SmsBroadcastUndelivered.broadcastSms(), and
+                        // processMessagePart() returns false, the state machine will be stuck in
+                        // DeliveringState until next message is received. Send message to
+                        // transition to idle to avoid that so that wakelock can be released
+                        log("No broadcast sent. Delete msg from raw table and return to idle " +
+                                "state");
+                        deleteFromRawTable(inboundSmsTracker.getDeleteWhere(),
+                                inboundSmsTracker.getDeleteWhereArgs());
+                        sendMessage(EVENT_RETURN_TO_IDLE);
                     }
                     return HANDLED;