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

Commit 91508ea2 authored by Po-Chien Hsueh's avatar Po-Chien Hsueh
Browse files

Use setEnable() when there is an installed image

We can now use setEnable() to tell GsiService that we would like
run in DynamicSystem on the next restart, if there is a system
image installed.

Bug: 124613126
Test: Tap the button and setEnabe() is invoked.
Change-Id: I74312af0c87548981ecb4e1ac9a1f3814304a4d5
parent 72324e4e
Loading
Loading
Loading
Loading
+16 −12
Original line number Original line Diff line number Diff line
@@ -257,7 +257,7 @@ public class DynamicSystemInstallationService extends Service
            return;
            return;
        }
        }


        if (getStatus() != STATUS_READY) {
        if (!isDynamicSystemInstalled() && (getStatus() != STATUS_READY)) {
            Log.e(TAG, "Trying to discard AOT while there is no complete installation");
            Log.e(TAG, "Trying to discard AOT while there is no complete installation");
            return;
            return;
        }
        }
@@ -273,13 +273,25 @@ public class DynamicSystemInstallationService extends Service
    }
    }


    private void executeRebootToDynSystemCommand() {
    private void executeRebootToDynSystemCommand() {
        if (mInstallTask == null || mInstallTask.getStatus() != FINISHED) {
        boolean enabled = false;

        if (mInstallTask != null && mInstallTask.getStatus() == FINISHED) {
            enabled = mInstallTask.commit();
        } else if (isDynamicSystemInstalled()) {
            enabled = mDynSystem.setEnable(true);
        } else {
            Log.e(TAG, "Trying to reboot to AOT while there is no complete installation");
            Log.e(TAG, "Trying to reboot to AOT while there is no complete installation");
            return;
            return;
        }
        }


        if (!mInstallTask.commit()) {
        if (enabled) {
            Log.e(TAG, "Failed to commit installation because of native runtime error.");
            PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);

            if (powerManager != null) {
                powerManager.reboot("dynsystem");
            }
        } else {
            Log.e(TAG, "Failed to enable DynamicSystem because of native runtime error.");
            mNM.cancel(NOTIFICATION_ID);
            mNM.cancel(NOTIFICATION_ID);


            Toast.makeText(this,
            Toast.makeText(this,
@@ -287,14 +299,6 @@ public class DynamicSystemInstallationService extends Service
                    Toast.LENGTH_LONG).show();
                    Toast.LENGTH_LONG).show();


            mDynSystem.remove();
            mDynSystem.remove();

            return;
        }

        PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);

        if (powerManager != null) {
            powerManager.reboot("dynsystem");
        }
        }
    }
    }