Loading core/java/com/android/internal/util/StateMachine.java +34 −10 Original line number Original line Diff line number Diff line Loading @@ -418,7 +418,7 @@ public class StateMachine { public static final int SM_QUIT_CMD = -1; public static final int SM_QUIT_CMD = -1; /** Message.what value when initializing */ /** Message.what value when initializing */ public static final int SM_INIT_CMD = -1; public static final int SM_INIT_CMD = -2; /** /** * Convenience constant that maybe returned by processMessage * Convenience constant that maybe returned by processMessage Loading Loading @@ -568,6 +568,13 @@ public class StateMachine { return mCount; return mCount; } } /** * Clear the list of Processed Message Info. */ void cleanup() { mMessages.clear(); } /** /** * @return the information on a particular record. 0 is the oldest * @return the information on a particular record. 0 is the oldest * record and size()-1 is the newest record. If the index is to * record and size()-1 is the newest record. If the index is to Loading Loading @@ -608,6 +615,7 @@ public class StateMachine { } } } } private static class SmHandler extends Handler { private static class SmHandler extends Handler { /** The debug flag */ /** The debug flag */ Loading Loading @@ -782,15 +790,8 @@ public class StateMachine { */ */ if (destState != null) { if (destState != null) { if (destState == mQuittingState) { if (destState == mQuittingState) { /** cleanupAfterQuitting(); * We are quitting so ignore all messages. */ mSm.quitting(); if (mSm.mSmThread != null) { // If we made the thread then quit looper which stops the thread. getLooper().quit(); mSm.mSmThread = null; } } else if (destState == mHaltingState) { } else if (destState == mHaltingState) { /** /** * Call halting() if we've transitioned to the halting * Call halting() if we've transitioned to the halting Loading @@ -802,6 +803,29 @@ public class StateMachine { } } } } /** * Cleanup all the static variables and the looper after the SM has been quit. */ private final void cleanupAfterQuitting() { mSm.quitting(); if (mSm.mSmThread != null) { // If we made the thread then quit looper which stops the thread. getLooper().quit(); mSm.mSmThread = null; } mSm.mSmHandler = null; mSm = null; mMsg = null; mProcessedMessages.cleanup(); mStateStack = null; mTempStateStack = null; mStateInfo.clear(); mInitialState = null; mDestState = null; mDeferredMessages.clear(); } /** /** * Complete the construction of the state machine. * Complete the construction of the state machine. */ */ Loading Loading
core/java/com/android/internal/util/StateMachine.java +34 −10 Original line number Original line Diff line number Diff line Loading @@ -418,7 +418,7 @@ public class StateMachine { public static final int SM_QUIT_CMD = -1; public static final int SM_QUIT_CMD = -1; /** Message.what value when initializing */ /** Message.what value when initializing */ public static final int SM_INIT_CMD = -1; public static final int SM_INIT_CMD = -2; /** /** * Convenience constant that maybe returned by processMessage * Convenience constant that maybe returned by processMessage Loading Loading @@ -568,6 +568,13 @@ public class StateMachine { return mCount; return mCount; } } /** * Clear the list of Processed Message Info. */ void cleanup() { mMessages.clear(); } /** /** * @return the information on a particular record. 0 is the oldest * @return the information on a particular record. 0 is the oldest * record and size()-1 is the newest record. If the index is to * record and size()-1 is the newest record. If the index is to Loading Loading @@ -608,6 +615,7 @@ public class StateMachine { } } } } private static class SmHandler extends Handler { private static class SmHandler extends Handler { /** The debug flag */ /** The debug flag */ Loading Loading @@ -782,15 +790,8 @@ public class StateMachine { */ */ if (destState != null) { if (destState != null) { if (destState == mQuittingState) { if (destState == mQuittingState) { /** cleanupAfterQuitting(); * We are quitting so ignore all messages. */ mSm.quitting(); if (mSm.mSmThread != null) { // If we made the thread then quit looper which stops the thread. getLooper().quit(); mSm.mSmThread = null; } } else if (destState == mHaltingState) { } else if (destState == mHaltingState) { /** /** * Call halting() if we've transitioned to the halting * Call halting() if we've transitioned to the halting Loading @@ -802,6 +803,29 @@ public class StateMachine { } } } } /** * Cleanup all the static variables and the looper after the SM has been quit. */ private final void cleanupAfterQuitting() { mSm.quitting(); if (mSm.mSmThread != null) { // If we made the thread then quit looper which stops the thread. getLooper().quit(); mSm.mSmThread = null; } mSm.mSmHandler = null; mSm = null; mMsg = null; mProcessedMessages.cleanup(); mStateStack = null; mTempStateStack = null; mStateInfo.clear(); mInitialState = null; mDestState = null; mDeferredMessages.clear(); } /** /** * Complete the construction of the state machine. * Complete the construction of the state machine. */ */ Loading