diff options
| author | Yuexi Ma <yuexima@google.com> | 2021-03-02 19:55:54 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-03-02 19:55:54 +0000 |
| commit | 03843acaf24579efcc80d8e928dd9b9c7d671574 (patch) | |
| tree | 22f01979b7edafdc955526b96b30bd12f9a39d2a | |
| parent | 89ec18bc4d4ba0a9394932d49ad0084da4c5c09e (diff) | |
| parent | 274cc63042bae4135eae0935c4dc0c7d9b6a0f1b (diff) | |
| download | platform_test_app_compat_csuite-03843acaf24579efcc80d8e928dd9b9c7d671574.tar.gz platform_test_app_compat_csuite-03843acaf24579efcc80d8e928dd9b9c7d671574.tar.bz2 platform_test_app_compat_csuite-03843acaf24579efcc80d8e928dd9b9c7d671574.zip | |
Ensure the framework is turned back on in uninstaller am: 274cc63042
Original change: https://android-review.googlesource.com/c/platform/test/app_compat/csuite/+/1584223
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I79f736be19b1a6cb6d264ecc226f39e661242058
| -rw-r--r-- | harness/src/main/java/com/android/compatibility/targetprep/SystemAppRemovalPreparer.java | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/harness/src/main/java/com/android/compatibility/targetprep/SystemAppRemovalPreparer.java b/harness/src/main/java/com/android/compatibility/targetprep/SystemAppRemovalPreparer.java index 7639e9f..d5438cc 100644 --- a/harness/src/main/java/com/android/compatibility/targetprep/SystemAppRemovalPreparer.java +++ b/harness/src/main/java/com/android/compatibility/targetprep/SystemAppRemovalPreparer.java @@ -83,18 +83,30 @@ public final class SystemAppRemovalPreparer implements ITargetPreparer { runWithWritableFilesystem( device, - () -> { - stopFramework(device); - removePackageInstallDirectory(packageInstallDirectory, device); - removePackageData(mPackageName, device); - startFramework(device); - }); + () -> + runWithFrameworkOff( + device, + () -> { + removePackageInstallDirectory(packageInstallDirectory, device); + removePackageData(mPackageName, device); + })); } private interface PreparerTask { void run() throws TargetSetupError, DeviceNotAvailableException; } + private static void runWithFrameworkOff(ITestDevice device, PreparerTask action) + throws TargetSetupError, DeviceNotAvailableException { + stopFramework(device); + + try { + action.run(); + } finally { + startFramework(device); + } + } + private static void runWithWritableFilesystem(ITestDevice device, PreparerTask action) throws TargetSetupError, DeviceNotAvailableException { runAsRoot( @@ -209,7 +221,9 @@ public final class SystemAppRemovalPreparer implements ITargetPreparer { // only uninstalls the latest update. To remove all update packages we can // call uninstall repeatedly until the command fails. for (int i = 0; i < MAX_NUMBER_OF_UPDATES; i++) { - if (device.uninstallPackage(packageName) != null) { + String errMsg = device.uninstallPackage(packageName); + if (errMsg != null) { + CLog.d("Completed removing updates as the uninstall command returned: %s", errMsg); return; } CLog.i("Removed an update package for %s", packageName); |
