summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jaikumar Ganesh <jaikumar@google.com> 2011-11-29 10:09:38 -0800
committer Android Git Automerger <android-git-automerger@android.com> 2011-11-29 10:09:38 -0800
commit9ab5ef2741e2eaeb44218d802643de81ddb4b7a1 (patch)
tree4337194b8d8ca811b3720a6c9d832dbcd71ba1a1
parentc273cd318d8bb45c22a914ba88d4cb4dd94a768e (diff)
parent910ae39f8a12bcb917b7eb1da3f701925da79509 (diff)
am 910ae39f: am ff33b94e: Merge "Cleanup static references when quitting." into ics-mr1
* commit '910ae39f8a12bcb917b7eb1da3f701925da79509': Cleanup static references when quitting.
-rw-r--r--core/java/com/android/internal/util/StateMachine.java44
1 files changed, 34 insertions, 10 deletions
diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java
index 36f02469ae6a..72489a2b72d2 100644
--- a/core/java/com/android/internal/util/StateMachine.java
+++ b/core/java/com/android/internal/util/StateMachine.java
@@ -418,7 +418,7 @@ public class StateMachine {
public static final int SM_QUIT_CMD = -1;
/** 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
@@ -569,6 +569,13 @@ public class StateMachine {
}
/**
+ * Clear the list of Processed Message Info.
+ */
+ void cleanup() {
+ mMessages.clear();
+ }
+
+ /**
* @return the information on a particular record. 0 is the oldest
* record and size()-1 is the newest record. If the index is to
* large null is returned.
@@ -608,6 +615,7 @@ public class StateMachine {
}
}
+
private static class SmHandler extends Handler {
/** The debug flag */
@@ -782,15 +790,8 @@ public class StateMachine {
*/
if (destState != null) {
if (destState == mQuittingState) {
- /**
- * 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;
- }
+ cleanupAfterQuitting();
+
} else if (destState == mHaltingState) {
/**
* Call halting() if we've transitioned to the halting
@@ -803,6 +804,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.
*/
private final void completeConstruction() {