diff options
Diffstat (limited to 'packages/DynamicSystemInstallationService/src')
2 files changed, 18 insertions, 1 deletions
diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java index 43d7d8fd0ac4..e731b45010a4 100644 --- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java +++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java @@ -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); diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/VerificationActivity.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/VerificationActivity.java index b1c09381823b..8a2948b04e3e 100644 --- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/VerificationActivity.java +++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/VerificationActivity.java @@ -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); |