Fix a no-op uninstall being treated as a failure
Treat a stageUninstall() doing nothing as a success, not a
failure. This prevents the system retrying the uninstall
later.
Unit tests run with:
make -j30 FrameworksServicesTests
adb install -r -g \
"out/target/product/marlin/data/app/FrameworksServicesTests/FrameworksServicesTests.apk"
adb shell am instrument -e package com.android.server.timezone -w \
com.android.frameworks.servicestests \
"com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner"
Test: See above
Test: Manual testing, adb dumpsys timezone
Test: PTS: run pts -m PtsTimeZoneTestCases
Bug: 65657176
Change-Id: Ifd205da90e848552711ac3f4207cd22ad2c2747b
diff --git a/services/core/java/com/android/server/timezone/RulesManagerService.java b/services/core/java/com/android/server/timezone/RulesManagerService.java
index 50f27ed..3ad4419 100644
--- a/services/core/java/com/android/server/timezone/RulesManagerService.java
+++ b/services/core/java/com/android/server/timezone/RulesManagerService.java
@@ -343,16 +343,20 @@
@Override
public void run() {
EventLogTags.writeTimezoneUninstallStarted(toStringOrNull(mCheckToken));
- boolean success = false;
+ boolean packageTrackerStatus = false;
try {
- success = mInstaller.stageUninstall();
- // Right now we just have success (0) / failure (1). All clients should be checking
- // against SUCCESS. More granular failures may be added in future.
- int resultCode = success ? Callback.SUCCESS
- : Callback.ERROR_UNKNOWN_FAILURE;
+ int uninstallResult = mInstaller.stageUninstall();
+ packageTrackerStatus = (uninstallResult == TimeZoneDistroInstaller.UNINSTALL_SUCCESS
+ || uninstallResult == TimeZoneDistroInstaller.UNINSTALL_NOTHING_INSTALLED);
+
+ // Right now we just have Callback.SUCCESS / Callback.ERROR_UNKNOWN_FAILURE for
+ // uninstall. All clients should be checking against SUCCESS. More granular failures
+ // may be added in future.
+ int callbackResultCode =
+ packageTrackerStatus ? Callback.SUCCESS : Callback.ERROR_UNKNOWN_FAILURE;
EventLogTags.writeTimezoneUninstallComplete(
- toStringOrNull(mCheckToken), resultCode);
- sendFinishedStatus(mCallback, resultCode);
+ toStringOrNull(mCheckToken), callbackResultCode);
+ sendFinishedStatus(mCallback, callbackResultCode);
} catch (Exception e) {
EventLogTags.writeTimezoneUninstallComplete(
toStringOrNull(mCheckToken), Callback.ERROR_UNKNOWN_FAILURE);
@@ -360,7 +364,7 @@
sendFinishedStatus(mCallback, Callback.ERROR_UNKNOWN_FAILURE);
} finally {
// Notify the package tracker that the operation is now complete.
- mPackageTracker.recordCheckResult(mCheckToken, success);
+ mPackageTracker.recordCheckResult(mCheckToken, packageTrackerStatus);
mOperationInProgress.set(false);
}