aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuexi Ma <yuexima@google.com>2021-02-11 00:47:21 -0800
committerYuexi Ma <yuexima@google.com>2021-02-17 10:31:23 -0800
commita2b2ba7289958a0d3150c00725de07757a27895e (patch)
treeafeefc22d63920d710433c19ca64307315d5f540
parent274cc63042bae4135eae0935c4dc0c7d9b6a0f1b (diff)
downloadplatform_test_app_compat_csuite-a2b2ba7289958a0d3150c00725de07757a27895e.tar.gz
platform_test_app_compat_csuite-a2b2ba7289958a0d3150c00725de07757a27895e.tar.bz2
platform_test_app_compat_csuite-a2b2ba7289958a0d3150c00725de07757a27895e.zip
Check whether a system app is installed before trying to uninstall it
Previously the uninstaller attempts to uninstall a given app as a first step. While the uninstaller is designed to handle uninstalling non-existent apps, the log might cause confusion as the adb command would throw an error. It also triggers unnecessary error handling in the device's package manager. This CL adds a check and avoid attempting to uninstall a package that doesn't exist. Test: atest :presubmit Change-Id: Ie10c140d7ec4ef059b1d8a2c699600b4675d3698
-rw-r--r--harness/src/main/java/com/android/compatibility/targetprep/SystemAppRemovalPreparer.java7
1 files changed, 6 insertions, 1 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 d5438cc..8ab58d6 100644
--- a/harness/src/main/java/com/android/compatibility/targetprep/SystemAppRemovalPreparer.java
+++ b/harness/src/main/java/com/android/compatibility/targetprep/SystemAppRemovalPreparer.java
@@ -61,13 +61,18 @@ public final class SystemAppRemovalPreparer implements ITargetPreparer {
throws TargetSetupError, DeviceNotAvailableException {
checkNotNull(mPackageName);
+ if (!isPackageInstalled(mPackageName, device)) {
+ CLog.i("Package %s is not installed.", mPackageName);
+ return;
+ }
+
// Attempts to uninstall the package/updates from user partition.
// This method should be called before the other methods and requires
// the framework to be running.
removePackageUpdates(mPackageName, device);
if (!isPackageInstalled(mPackageName, device)) {
- CLog.i("Package %s is not installed.", mPackageName);
+ CLog.i("Package %s has been removed.", mPackageName);
return;
}