Avoid StrictMode violation by performing response callback off UI thread

Bug: 4982227
Change-Id: Ie72a3b1ae3329e0e97476e159cde47fc3c757489
diff --git a/src/com/android/keychain/KeyChainActivity.java b/src/com/android/keychain/KeyChainActivity.java
index 94c2097..80be9e9 100644
--- a/src/com/android/keychain/KeyChainActivity.java
+++ b/src/com/android/keychain/KeyChainActivity.java
@@ -357,15 +357,32 @@
                 = IKeyChainAliasCallback.Stub.asInterface(
                         getIntent().getIBinderExtra(KeyChain.EXTRA_RESPONSE));
         if (keyChainAliasResponse != null) {
+            new ResponseSender(keyChainAliasResponse, alias).execute();
+            return;
+        }
+        finish();
+    }
+
+    private class ResponseSender extends AsyncTask<Void, Void, Void> {
+        private IKeyChainAliasCallback mKeyChainAliasResponse;
+        private String mAlias;
+        private ResponseSender(IKeyChainAliasCallback keyChainAliasResponse, String alias) {
+            mKeyChainAliasResponse = keyChainAliasResponse;
+            mAlias = alias;
+        }
+        @Override protected Void doInBackground(Void... unused) {
             try {
-                keyChainAliasResponse.alias(alias);
+                mKeyChainAliasResponse.alias(mAlias);
             } catch (Exception ignored) {
                 // don't just catch RemoteException, caller could
                 // throw back a RuntimeException across processes
                 // which we should protect against.
             }
+            return null;
         }
-        finish();
+        @Override protected void onPostExecute(Void unused) {
+            finish();
+        }
     }
 
     @Override public void onBackPressed() {