diff options
| author | Kenny Root <kroot@google.com> | 2020-03-26 09:48:35 -0700 |
|---|---|---|
| committer | Kenny Root <kroot@google.com> | 2020-03-26 12:23:11 -0700 |
| commit | 625bcd2eeb9e41ef68f190abbe3f7c26b58fa380 (patch) | |
| tree | 1f8e92d57e54e3dcb1577f659ab836512334baad /core/java/android/os/RecoverySystem.java | |
| parent | 4f9ab82c08ccafa758057843677cb7638e3eae38 (diff) | |
Resume-on-Reboot: change SystemApi calls slightly
In response to feedback, remove boolean returns and rely on exceptions
to provide detail descriptions.
Test: make # using a test app that calls the API using old signature
Test: atest FrameworksServicesTests:RecoverySystemServiceTest
Bug: 150205125
Change-Id: I95930078df9c88194f21b38ff7d96b425db47d56
Diffstat (limited to 'core/java/android/os/RecoverySystem.java')
| -rw-r--r-- | core/java/android/os/RecoverySystem.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java index d60820ef0f57..8cdcd49cb2cc 100644 --- a/core/java/android/os/RecoverySystem.java +++ b/core/java/android/os/RecoverySystem.java @@ -665,15 +665,17 @@ public class RecoverySystem { * the preparation for unattended update is reset. * * @param context the Context to use. - * @throws IOException if there were any errors setting up unattended update + * @throws IOException if there were any errors clearing the unattended update state * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.RECOVERY) - public static boolean clearPrepareForUnattendedUpdate(@NonNull Context context) + public static void clearPrepareForUnattendedUpdate(@NonNull Context context) throws IOException { RecoverySystem rs = (RecoverySystem) context.getSystemService(Context.RECOVERY_SERVICE); - return rs.clearLskf(); + if (!rs.clearLskf()) { + throw new IOException("could not reset unattended update state"); + } } /** @@ -684,21 +686,22 @@ public class RecoverySystem { * @param context the Context to use. * @param updateToken the token used to call {@link #prepareForUnattendedUpdate} before * @param reason the reboot reason to give to the {@link PowerManager} - * @throws IOException if there were any errors setting up unattended update - * @return false if the reboot couldn't proceed because the device wasn't ready for an + * @throws IOException if the reboot couldn't proceed because the device wasn't ready for an * unattended reboot or if the {@code updateToken} did not match the previously * given token * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.RECOVERY) - public static boolean rebootAndApply(@NonNull Context context, @NonNull String updateToken, + public static void rebootAndApply(@NonNull Context context, @NonNull String updateToken, @NonNull String reason) throws IOException { if (updateToken == null) { throw new NullPointerException("updateToken == null"); } RecoverySystem rs = (RecoverySystem) context.getSystemService(Context.RECOVERY_SERVICE); - return rs.rebootWithLskf(updateToken, reason); + if (!rs.rebootWithLskf(updateToken, reason)) { + throw new IOException("system not prepared to apply update"); + } } /** |
