From 68e2d6b36049bdff1825ac86b36e8e46fc5ed0b1 Mon Sep 17 00:00:00 2001 From: Yo Chiang Date: Thu, 22 Oct 2020 19:02:45 +0800 Subject: [PATCH] Disable DSU in executeRebootToNormalCommand() executeRebootToNormalCommand() reboots the device only if DSU is successfully disabled, else show a toast describing the failure. Bug: 171380622 Test: 1. Install and boot into a DSU 2. adb shell gsi_tool enable 3. Press "Restart" in DSU notification 4. Observe the device reboots back to the original system Change-Id: I19b3d09a64282a28ca7b99b441ca93dea45fcce0 --- .../res/values/strings.xml | 3 +++ .../dynsystem/DynamicSystemInstallationService.java | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/DynamicSystemInstallationService/res/values/strings.xml b/packages/DynamicSystemInstallationService/res/values/strings.xml index 719fc73bd2251..bfeef0aa8c7b4 100644 --- a/packages/DynamicSystemInstallationService/res/values/strings.xml +++ b/packages/DynamicSystemInstallationService/res/values/strings.xml @@ -37,6 +37,9 @@ Discarded dynamic system Can\u2019t restart or load dynamic system + + Failed to disable dynamic system + https://dl.google.com/developers/android/gsi/gsi-keyblacklist.json diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java index f7f3cbb7d332e..256d2cd23dec6 100644 --- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java +++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java @@ -375,8 +375,17 @@ public class DynamicSystemInstallationService extends Service return; } - // Per current design, we don't have disable() API. AOT is disabled on next reboot. - // TODO: Use better status query when b/125079548 is done. + if (!mDynSystem.setEnable(/* enable = */ false, /* oneShot = */ false)) { + Log.e(TAG, "Failed to disable DynamicSystem."); + + // Dismiss status bar and show a toast. + sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); + Toast.makeText(this, + getString(R.string.toast_failed_to_disable_dynsystem), + Toast.LENGTH_LONG).show(); + return; + } + PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); if (powerManager != null) {