diff options
| author | Tianjie <xunchang@google.com> | 2021-02-11 13:23:49 -0800 |
|---|---|---|
| committer | Tianjie <xunchang@google.com> | 2021-02-18 15:26:33 -0800 |
| commit | 9dbd5e7457fda6d2f757657e52aa9e5c2186afff (patch) | |
| tree | 2c5bf273cacc1859d22c51a97686daa1539055ea /core/java | |
| parent | 30d9bfa03bbf2ad2f31e9aebb578c0158aacf463 (diff) | |
Throw an exception in RoR api on no-pin case
If the device doesn't have a pin, the current RoR preparation will
go through; but the lskf capture event won't happen. In order not
to confuse the caller, throw an exception instead in the no-pin
case.
Bug: 170664917
Test: remove pin, request RoR with adb shell
Change-Id: Ib04c629234b71e3f6cb36bdfe47759a715a69146
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/os/RecoverySystem.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java index 6713de83d394..246249e79604 100644 --- a/core/java/android/os/RecoverySystem.java +++ b/core/java/android/os/RecoverySystem.java @@ -26,6 +26,7 @@ import android.annotation.RequiresPermission; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemService; +import android.app.KeyguardManager; import android.app.PendingIntent; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; @@ -631,10 +632,15 @@ public class RecoverySystem { /** * Prepare to apply an unattended update by asking the user for their Lock Screen Knowledge * Factor (LSKF). If supplied, the {@code intentSender} will be called when the system is setup - * and ready to apply the OTA. This API is expected to handle requests from multiple clients - * simultaneously, e.g. from ota and mainline. + * and ready to apply the OTA. <p> * - * <p> The behavior of multi-client Resume on Reboot works as follows + * <p> If the device doesn't setup a lock screen, i.e. by checking + * {@link KeyguardManager#isKeyguardSecure()}, this API call will fail and throw an exception. + * Callers are expected to use {@link PowerManager#reboot(String)} directly without going + * through the RoR flow. <p> + * + * <p> This API is expected to handle requests from multiple clients simultaneously, e.g. + * from ota and mainline. The behavior of multi-client Resume on Reboot works as follows * <li> Each client should call this function to prepare for Resume on Reboot before calling * {@link #rebootAndApply(Context, String, boolean)} </li> * <li> One client cannot clear the Resume on Reboot preparation of another client. </li> @@ -658,6 +664,13 @@ public class RecoverySystem { if (updateToken == null) { throw new NullPointerException("updateToken == null"); } + + KeyguardManager keyguardManager = context.getSystemService(KeyguardManager.class); + if (keyguardManager == null || !keyguardManager.isDeviceSecure()) { + throw new IOException("Failed to request LSKF because the device doesn't have a" + + " lock screen. "); + } + RecoverySystem rs = (RecoverySystem) context.getSystemService(Context.RECOVERY_SERVICE); if (!rs.requestLskf(context.getPackageName(), intentSender)) { throw new IOException("preparation for update failed"); |
