diff options
author | Po-Chien Hsueh <pchsueh@google.com> | 2019-05-07 17:23:44 +0800 |
---|---|---|
committer | Po-Chien Hsueh <pchsueh@google.com> | 2019-05-15 02:46:19 +0000 |
commit | dfd69d770ca4f13cd5bf1ed6de944630a028fe71 (patch) | |
tree | c8cdc91d063df7d8dde73b6a22edecc51648631f /packages/DynamicSystemInstallationService | |
parent | 92f755e33926f62c7120df6618b0071d5a794ae3 (diff) |
Add KEY_ENABLE_WHEN_COMPLETED for testing
Per design, we ask user's confirmation before enabling DSU when
install completed. To simplify the process of testing, this CL adds
a paramenter (intent key) "KEY_ENABLE_WHEN_COMPLETED". If the key is
set, the installation service will not ask user before enabling DSU.
Bug: 131866826
Test: adb shell am start-activity -n com.android.dynsystem/com.android.dynsystem.VerificationActivity
-a android.os.image.action.START_INSTALL
-d file:///storage/emulated/0/Download/system.raw.gz
--el KEY_SYSTEM_SIZE 893841408
--el KEY_USERDATA_SIZE 8589934592
--ez KEY_ENABLE_WHEN_COMPLETED true
Change-Id: Id38c4c0525199594f6bd6704b5a575d4a42b7b61
Diffstat (limited to 'packages/DynamicSystemInstallationService')
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); |