Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68e2d6b3 authored by Yo Chiang's avatar Yo Chiang
Browse files

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
parent c5d02da0
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -37,6 +37,9 @@
    <string name="toast_dynsystem_discarded">Discarded dynamic system</string>
    <string name="toast_dynsystem_discarded">Discarded dynamic system</string>
    <!-- Toast when we fail to launch into Dynamic System [CHAR LIMIT=128] -->
    <!-- Toast when we fail to launch into Dynamic System [CHAR LIMIT=128] -->
    <string name="toast_failed_to_reboot_to_dynsystem">Can\u2019t restart or load dynamic system</string>
    <string name="toast_failed_to_reboot_to_dynsystem">Can\u2019t restart or load dynamic system</string>
    <!-- Toast when we fail to disable Dynamic System [CHAR LIMIT=128] -->
    <string name="toast_failed_to_disable_dynsystem">Failed to disable dynamic system</string>



    <!-- URL of Dynamic System Key Revocation List [DO NOT TRANSLATE] -->
    <!-- URL of Dynamic System Key Revocation List [DO NOT TRANSLATE] -->
    <string name="key_revocation_list_url" translatable="false">https://dl.google.com/developers/android/gsi/gsi-keyblacklist.json</string>
    <string name="key_revocation_list_url" translatable="false">https://dl.google.com/developers/android/gsi/gsi-keyblacklist.json</string>
+11 −2
Original line number Original line Diff line number Diff line
@@ -375,8 +375,17 @@ public class DynamicSystemInstallationService extends Service
            return;
            return;
        }
        }


        // Per current design, we don't have disable() API. AOT is disabled on next reboot.
        if (!mDynSystem.setEnable(/* enable = */ false, /* oneShot = */ false)) {
        // TODO: Use better status query when b/125079548 is done.
            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);
        PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);


        if (powerManager != null) {
        if (powerManager != null) {