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

Commit 365047df authored by Po-Chien Hsueh's avatar Po-Chien Hsueh Committed by android-build-merger
Browse files

Merge "Add KEY_ENABLE_WHEN_COMPLETED for testing" into qt-dev

am: f68b125a

Change-Id: Ic411420e85d94ed7aa113482acdfcc088f12fae9
parents 21da7375 f68b125a
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -70,6 +70,10 @@ public class DynamicSystemInstallationService extends Service

    private static final String TAG = "DynSystemInstallationService";


    // TODO (b/131866826): This is currently for test only. Will move this to System API.
    static final String KEY_ENABLE_WHEN_COMPLETED = "KEY_ENABLE_WHEN_COMPLETED";

    /*
     * Intent actions
     */
@@ -122,6 +126,9 @@ public class DynamicSystemInstallationService extends Service
    private long mInstalledSize;
    private boolean mJustCancelledByUser;

    // This is for testing only now
    private boolean mEnableWhenCompleted;

    private InstallationAsyncTask mInstallTask;


@@ -178,6 +185,11 @@ public class DynamicSystemInstallationService extends Service
    public void onResult(int result, Throwable detail) {
        if (result == RESULT_OK) {
            postStatus(STATUS_READY, CAUSE_INSTALL_COMPLETED, null);

            // For testing: enable DSU and restart the device when install completed
            if (mEnableWhenCompleted) {
                executeRebootToDynSystemCommand();
            }
            return;
        }

@@ -224,6 +236,7 @@ public class DynamicSystemInstallationService extends Service
        String url = intent.getDataString();
        mSystemSize = intent.getLongExtra(DynamicSystemClient.KEY_SYSTEM_SIZE, 0);
        mUserdataSize = intent.getLongExtra(DynamicSystemClient.KEY_USERDATA_SIZE, 0);
        mEnableWhenCompleted = intent.getBooleanExtra(KEY_ENABLE_WHEN_COMPLETED, false);

        mInstallTask = new InstallationAsyncTask(
                url, mSystemSize, mUserdataSize, this, mDynSystem, this);
@@ -275,7 +288,7 @@ public class DynamicSystemInstallationService extends Service
    private void executeRebootToDynSystemCommand() {
        boolean enabled = false;

        if (mInstallTask != null && mInstallTask.getStatus() == FINISHED) {
        if (mInstallTask != null && mInstallTask.getResult() == RESULT_OK) {
            enabled = mInstallTask.commit();
        } else if (isDynamicSystemInstalled()) {
            enabled = mDynSystem.setEnable(true);
+4 −0
Original line number Diff line number Diff line
@@ -92,6 +92,8 @@ public class VerificationActivity extends Activity {
        Uri url = callingIntent.getData();
        long systemSize = callingIntent.getLongExtra(KEY_SYSTEM_SIZE, 0);
        long userdataSize = callingIntent.getLongExtra(KEY_USERDATA_SIZE, 0);
        boolean enableWhenCompleted = callingIntent.getBooleanExtra(
                DynamicSystemInstallationService.KEY_ENABLE_WHEN_COMPLETED, false);

        sVerifiedUrl = url.toString();

@@ -101,6 +103,8 @@ public class VerificationActivity extends Activity {
        intent.setAction(DynamicSystemClient.ACTION_START_INSTALL);
        intent.putExtra(KEY_SYSTEM_SIZE, systemSize);
        intent.putExtra(KEY_USERDATA_SIZE, userdataSize);
        intent.putExtra(
                DynamicSystemInstallationService.KEY_ENABLE_WHEN_COMPLETED, enableWhenCompleted);

        Log.d(TAG, "Starting Installation Service");
        startServiceAsUser(intent, UserHandle.SYSTEM);