Tracking KeyChain API refinements

Change-Id: Ib19f16bd7c9e9790e1183d3d2a9a84789661d7cf
diff --git a/src/com/android/keychain/KeyChainActivity.java b/src/com/android/keychain/KeyChainActivity.java
index f637b09..8b94344 100644
--- a/src/com/android/keychain/KeyChainActivity.java
+++ b/src/com/android/keychain/KeyChainActivity.java
@@ -21,7 +21,7 @@
 import android.os.Bundle;
 import android.os.RemoteException;
 import android.security.Credentials;
-import android.security.IKeyChainAliasResponse;
+import android.security.IKeyChainAliasCallback;
 import android.security.KeyChain;
 import android.security.KeyStore;
 import android.view.View;
@@ -147,8 +147,8 @@
             result.putExtra(Intent.EXTRA_TEXT, alias);
             setResult(RESULT_OK, result);
         }
-        IKeyChainAliasResponse keyChainAliasResponse
-                = IKeyChainAliasResponse.Stub.asInterface(
+        IKeyChainAliasCallback keyChainAliasResponse
+                = IKeyChainAliasCallback.Stub.asInterface(
                         getIntent().getIBinderExtra(KeyChain.EXTRA_RESPONSE));
         if (keyChainAliasResponse != null) {
             try {
diff --git a/src/com/android/keychain/KeyChainService.java b/src/com/android/keychain/KeyChainService.java
index 940c427..7ce176f 100644
--- a/src/com/android/keychain/KeyChainService.java
+++ b/src/com/android/keychain/KeyChainService.java
@@ -92,7 +92,7 @@
             String key = type + alias;
             byte[] bytes =  mKeyStore.get(key);
             if (bytes == null) {
-                throw new IllegalStateException("keystore value missing");
+                return null;
             }
             return bytes;
         }
diff --git a/tests/src/com/android/keychain/tests/KeyChainTestActivity.java b/tests/src/com/android/keychain/tests/KeyChainTestActivity.java
index 105e1f5..6c280a6 100644
--- a/tests/src/com/android/keychain/tests/KeyChainTestActivity.java
+++ b/tests/src/com/android/keychain/tests/KeyChainTestActivity.java
@@ -23,7 +23,8 @@
 import android.os.RemoteException;
 import android.security.Credentials;
 import android.security.KeyChain;
-import android.security.KeyChainAliasResponse;
+import android.security.KeyChainAliasCallback;
+import android.security.KeyChainException;
 import android.text.method.ScrollingMovementMethod;
 import android.util.Log;
 import android.widget.TextView;
@@ -94,7 +95,7 @@
             throw new AssertionError();
         } catch (InterruptedException e) {
             throw new AssertionError(e);
-        } catch (RemoteException e) {
+        } catch (KeyChainException e) {
             throw new AssertionError(e);
         } catch (NullPointerException expected) {
             log("KeyChain failed as expected with null argument.");
@@ -105,7 +106,7 @@
             throw new AssertionError();
         } catch (InterruptedException e) {
             throw new AssertionError(e);
-        } catch (RemoteException e) {
+        } catch (KeyChainException e) {
             throw new AssertionError(e);
         } catch (NullPointerException expected) {
             log("KeyChain failed as expected with null argument.");
@@ -116,7 +117,7 @@
             throw new AssertionError();
         } catch (InterruptedException e) {
             throw new AssertionError(e);
-        } catch (RemoteException e) {
+        } catch (KeyChainException e) {
             throw new AssertionError(e);
         } catch (NullPointerException expected) {
             log("KeyChain failed as expected with null argument.");
@@ -127,7 +128,7 @@
             throw new AssertionError();
         } catch (InterruptedException e) {
             throw new AssertionError(e);
-        } catch (RemoteException e) {
+        } catch (KeyChainException e) {
             throw new AssertionError(e);
         } catch (IllegalStateException expected) {
             log("KeyChain failed as expected on main thread.");
@@ -197,7 +198,8 @@
                                                   Socket socket) {
             log("KeyChainKeyManager chooseClientAlias...");
 
-            KeyChain.choosePrivateKeyAlias(KeyChainTestActivity.this, new AliasResponse());
+            KeyChain.choosePrivateKeyAlias(KeyChainTestActivity.this, new AliasResponse(),
+                                           null, null, null, -1);
             String alias;
             synchronized (mAliasLock) {
                 while (mAlias == null) {
@@ -230,7 +232,7 @@
             } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();
                 return null;
-            } catch (RemoteException e) {
+            } catch (KeyChainException e) {
                 throw new RuntimeException(e);
             }
         }
@@ -252,13 +254,13 @@
             } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();
                 return null;
-            } catch (RemoteException e) {
+            } catch (KeyChainException e) {
                 throw new RuntimeException(e);
             }
         }
     }
 
-    private class AliasResponse implements KeyChainAliasResponse {
+    private class AliasResponse implements KeyChainAliasCallback {
         @Override public void alias(String alias) {
             if (alias == null) {
                 log("AliasResponse empty!");