diff options
| -rw-r--r-- | core/java/com/android/internal/util/StateMachine.java | 5 | ||||
| -rw-r--r-- | core/tests/utiltests/src/com/android/internal/util/StateMachineTest.java | 24 |
2 files changed, 18 insertions, 11 deletions
diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java index 0c2406559dcc..7a79cc9ef868 100644 --- a/core/java/com/android/internal/util/StateMachine.java +++ b/core/java/com/android/internal/util/StateMachine.java @@ -2088,10 +2088,11 @@ public class StateMachine { pw.println(getName() + ":"); pw.println(" total records=" + getLogRecCount()); for (int i = 0; i < getLogRecSize(); i++) { - pw.println(" rec[" + i + "]: " + getLogRec(i).toString()); + pw.println(" rec[" + i + "]: " + getLogRec(i)); pw.flush(); } - pw.println("curState=" + getCurrentState().getName()); + final IState curState = getCurrentState(); + pw.println("curState=" + (curState == null ? "<QUIT>" : curState.getName())); } @Override diff --git a/core/tests/utiltests/src/com/android/internal/util/StateMachineTest.java b/core/tests/utiltests/src/com/android/internal/util/StateMachineTest.java index 76aa93f7e8be..edf473eac1b1 100644 --- a/core/tests/utiltests/src/com/android/internal/util/StateMachineTest.java +++ b/core/tests/utiltests/src/com/android/internal/util/StateMachineTest.java @@ -16,27 +16,25 @@ package com.android.internal.util; -import java.util.Collection; -import java.util.Iterator; - import android.os.Debug; import android.os.HandlerThread; import android.os.Looper; import android.os.Message; import android.os.SystemClock; import android.os.test.TestLooper; - -import android.test.suitebuilder.annotation.Suppress; -import com.android.internal.util.State; -import com.android.internal.util.StateMachine; -import com.android.internal.util.StateMachine.LogRec; - import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; +import com.android.internal.util.StateMachine.LogRec; + import junit.framework.TestCase; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Collection; +import java.util.Iterator; + /** * Test for StateMachine. */ @@ -2013,4 +2011,12 @@ public class StateMachineTest extends TestCase { private static void tloge(String s) { Log.e(TAG, s); } + + public void testDumpDoesNotThrowNpeAfterQuit() { + final Hsm1 sm = Hsm1.makeHsm1(); + sm.quitNow(); + final StringWriter stringWriter = new StringWriter(); + final PrintWriter printWriter = new PrintWriter(stringWriter); + sm.dump(null, printWriter, new String[0]); + } } |