diff --git a/keystore/java/android/security/IKeyChainAliasCallback.aidl b/keystore/java/android/security/IKeyChainAliasCallback.aidl index 1ea952166009e..b9d37533de80d 100644 --- a/keystore/java/android/security/IKeyChainAliasCallback.aidl +++ b/keystore/java/android/security/IKeyChainAliasCallback.aidl @@ -20,7 +20,7 @@ package android.security; * * @hide */ -interface IKeyChainAliasCallback { +oneway interface IKeyChainAliasCallback { void alias(String alias); } diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 7b6b941688421..17e6bba5f1c73 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -4851,19 +4851,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { private void sendPrivateKeyAliasResponse(final String alias, final IBinder responseBinder) { final IKeyChainAliasCallback keyChainAliasResponse = IKeyChainAliasCallback.Stub.asInterface(responseBinder); - new AsyncTask() { - @Override - protected Void doInBackground(Void... unused) { - try { - keyChainAliasResponse.alias(alias); - } catch (Exception e) { - // Catch everything (not just RemoteException): caller could throw a - // RuntimeException back across processes. - Log.e(LOG_TAG, "error while responding to callback", e); - } - return null; - } - }.execute(); + // Send the response. It's OK to do this from the main thread because IKeyChainAliasCallback + // is oneway, which means it won't block if the recipient lives in another process. + try { + keyChainAliasResponse.alias(alias); + } catch (Exception e) { + // Caller could throw RuntimeException or RemoteException back across processes. Catch + // everything just to be sure. + Log.e(LOG_TAG, "error while responding to callback", e); + } } /**