From 44bdc880c27fc16e55666989345b641d6dd959cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Wed, 27 Mar 2019 09:47:28 +0100 Subject: [PATCH] OMS: always update overlays.xml when overlay is removed The OverlayChangeListener in the overlay manger service is responsible for both writing /data/system/overlays.xml and starting the flow to notify affected processes. Because of this, the listener needs to know when an overlay is removed regardless of wheather the overlay is enabled or not, or overlays.xml will contain stale information. Unconditionally notify the OverlayChangeListener when an overlay is removed. Test: atest OverlayHostTests Bug: 129368140 Change-Id: I1f5aeb285154a5d90ff81161825a95d9325a479e --- .../server/om/hosttest/InstallOverlayTests.java | 14 ++++++++++++++ .../server/om/OverlayManagerServiceImpl.java | 5 +---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/tests/overlaytests/host/src/com/android/server/om/hosttest/InstallOverlayTests.java b/core/tests/overlaytests/host/src/com/android/server/om/hosttest/InstallOverlayTests.java index 99b6421d2bc79..267cb365748ea 100644 --- a/core/tests/overlaytests/host/src/com/android/server/om/hosttest/InstallOverlayTests.java +++ b/core/tests/overlaytests/host/src/com/android/server/om/hosttest/InstallOverlayTests.java @@ -163,6 +163,20 @@ public class InstallOverlayTests extends BaseHostJUnit4Test { assertTrue(overlayManagerContainsPackage(APP_OVERLAY_PACKAGE_NAME)); } + @Test + public void changesPersistedWhenUninstallingDisabledOverlay() throws Exception { + getDevice().enableAdbRoot(); + assertFalse(getDevice().executeShellCommand("cat /data/system/overlays.xml") + .contains(APP_OVERLAY_PACKAGE_NAME)); + installPackage("OverlayHostTests_AppOverlayV1.apk"); + assertTrue(getDevice().executeShellCommand("cat /data/system/overlays.xml") + .contains(APP_OVERLAY_PACKAGE_NAME)); + uninstallPackage(APP_OVERLAY_PACKAGE_NAME); + delay(); + assertFalse(getDevice().executeShellCommand("cat /data/system/overlays.xml") + .contains(APP_OVERLAY_PACKAGE_NAME)); + } + private void delay() { try { Thread.sleep(1000); diff --git a/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java b/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java index ec53e98ec5479..3a84b1e18e36d 100644 --- a/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java +++ b/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java @@ -452,10 +452,7 @@ final class OverlayManagerServiceImpl { final OverlayInfo overlayInfo = mSettings.getOverlayInfo(packageName, userId); if (mSettings.remove(packageName, userId)) { removeIdmapIfPossible(overlayInfo); - if (overlayInfo.isEnabled()) { - // Only trigger updates if the overlay was enabled. - mListener.onOverlaysChanged(overlayInfo.targetPackageName, userId); - } + mListener.onOverlaysChanged(overlayInfo.targetPackageName, userId); } } catch (OverlayManagerSettings.BadKeyException e) { Slog.e(TAG, "failed to remove overlay", e);