OSDN Git Service

Null pointer fix for StateMachine
authorBrad Ebinger <breadley@google.com>
Mon, 14 Dec 2015 16:46:49 +0000 (08:46 -0800)
committerBrad Ebinger <breadley@google.com>
Mon, 14 Dec 2015 17:02:38 +0000 (09:02 -0800)
Checks if StateMachine is null before calling callbacks.

Bug-Id: 26176787
Change-Id: I7ee92326e99e18a3b7045ccf098b52acfaff9a15

core/java/com/android/internal/util/StateMachine.java

index 8c4d078..406b487 100644 (file)
@@ -778,8 +778,11 @@ public class StateMachine {
          */
         @Override
         public final void handleMessage(Message msg) {
-            mSm.onPreHandleMessage(msg);
             if (!mHasQuit) {
+                if (mSm != null) {
+                    mSm.onPreHandleMessage(msg);
+                }
+
                 if (mDbg) mSm.log("handleMessage: E msg.what=" + msg.what);
 
                 /** Save the current message */
@@ -803,8 +806,11 @@ public class StateMachine {
 
                 // We need to check if mSm == null here as we could be quitting.
                 if (mDbg && mSm != null) mSm.log("handleMessage: X");
+
+                if (mSm != null) {
+                    mSm.onPostHandleMessage(msg);
+                }
             }
-            mSm.onPostHandleMessage(msg);
         }
 
         /**