From fd5cba448308ddce72fbbd93c504b4183810a9c3 Mon Sep 17 00:00:00 2001 From: Janis Danisevskis Date: Tue, 23 Mar 2021 19:18:55 -0700 Subject: Keystore 2.0: Add onDeviceOffBody to AndroidKeyStoreMaintenance. Also have KeyStore.onDeviceOffBody call AndroidKeyStoreMaintenance.onDeviceOffBody. Test: N/A Bug: 171305684 Change-Id: I0b01764bfc4c5828d17ccfffb4f8dad5f3bcea6d --- .../java/android/security/AndroidKeyStoreMaintenance.java | 14 ++++++++++++++ keystore/java/android/security/KeyStore.java | 1 + 2 files changed, 15 insertions(+) diff --git a/keystore/java/android/security/AndroidKeyStoreMaintenance.java b/keystore/java/android/security/AndroidKeyStoreMaintenance.java index 35b1c169f283..72cea0cacd12 100644 --- a/keystore/java/android/security/AndroidKeyStoreMaintenance.java +++ b/keystore/java/android/security/AndroidKeyStoreMaintenance.java @@ -139,4 +139,18 @@ public class AndroidKeyStoreMaintenance { return SYSTEM_ERROR; } } + + /** + * Informs Keystore 2.0 that an off body event was detected. + */ + public static void onDeviceOffBody() { + if (!android.security.keystore2.AndroidKeyStoreProvider.isInstalled()) return; + try { + getService().onDeviceOffBody(); + } catch (Exception e) { + // TODO This fails open. This is not a regression with respect to keystore1 but it + // should get fixed. + Log.e(TAG, "Error while reporting device off body event.", e); + } + } } diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java index a08f390c9fd3..b05149ef75bc 100644 --- a/keystore/java/android/security/KeyStore.java +++ b/keystore/java/android/security/KeyStore.java @@ -1204,6 +1204,7 @@ public class KeyStore { * Notify keystore that the device went off-body. */ public void onDeviceOffBody() { + AndroidKeyStoreMaintenance.onDeviceOffBody(); try { mBinder.onDeviceOffBody(); } catch (RemoteException e) { -- cgit v1.2.3-59-g8ed1b