Merge "Revert "Update Trusted Credentials screen in settings"" into lmp-dev
diff --git a/src/com/android/keychain/KeyChainActivity.java b/src/com/android/keychain/KeyChainActivity.java
index 822ae1a..3859f05 100644
--- a/src/com/android/keychain/KeyChainActivity.java
+++ b/src/com/android/keychain/KeyChainActivity.java
@@ -64,7 +64,7 @@
 
     private PendingIntent mSender;
 
-    private static enum State { INITIAL, UNLOCK_REQUESTED };
+    private static enum State { INITIAL, UNLOCK_REQUESTED, UNLOCK_CANCELED };
 
     private State mState;
 
@@ -124,6 +124,11 @@
                 // we've already asked, but have not heard back, probably just rotated.
                 // wait to hear back via onActivityResult
                 return;
+            case UNLOCK_CANCELED:
+                // User wanted to cancel the request, so exit.
+                mState = State.INITIAL;
+                finish();
+                return;
             default:
                 throw new AssertionError();
         }
@@ -356,12 +361,12 @@
     @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         switch (requestCode) {
             case REQUEST_UNLOCK:
-                mState = State.INITIAL;
                 if (mKeyStore.isUnlocked()) {
+                    mState = State.INITIAL;
                     showCertChooserDialog();
                 } else {
                     // user must have canceled unlock, give up
-                    finish(null);
+                    mState = State.UNLOCK_CANCELED;
                 }
                 return;
             default: