From 1d8f442aeefc4d51048390a36b86e3944e8e30d8 Mon Sep 17 00:00:00 2001 From: Chun-Wei Wang Date: Wed, 12 Jul 2023 08:03:30 +0000 Subject: Don't show notifications for locked slots Locked slots are used for customization. We expect the client apps to provide custom UI for notifications and entering/exiting DSU mode. (Cherry-picked from aosp/2655023) Bug: 277691885 Test: 1. adb shell am start-activity \ -n com.android.dynsystem/com.android.dynsystem.VerificationActivity \ -a android.os.image.action.START_INSTALL \ --el KEY_USERDATA_SIZE 2147483648 \ --ez KEY_ENABLE_WHEN_COMPLETED true \ --ez KEY_ONE_SHOT false \ --es KEY_DSU_SLOT foo.lock 2. check no dsu notification is shown after reboot Merged-In: I01de2fd2d5942dd4e5e462b46890ce1f10800768 Change-Id: I01de2fd2d5942dd4e5e462b46890ce1f10800768 --- .../dynsystem/DynamicSystemInstallationService.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java index e1eb36ac276c..25ac3c9d9074 100644 --- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java +++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java @@ -419,12 +419,20 @@ public class DynamicSystemInstallationService extends Service mDynSystem.remove(); } + private boolean isDsuSlotLocked() { + // Slot names ending with ".lock" are a customized installation. + // We expect the client app to provide custom UI to enter/exit DSU mode. + // We will ignore the ACTION_REBOOT_TO_NORMAL command and will not show + // notifications in this case. + return mDynSystem.getActiveDsuSlot().endsWith(".lock"); + } + private void executeRebootToNormalCommand() { if (!isInDynamicSystem()) { Log.e(TAG, "It's already running in normal system."); return; } - if (mDynSystem.getActiveDsuSlot().endsWith(".lock")) { + if (isDsuSlotLocked()) { Log.e(TAG, "Ignore the reboot intent for a locked DSU slot"); return; } @@ -449,13 +457,13 @@ public class DynamicSystemInstallationService extends Service private void executeNotifyIfInUseCommand() { switch (getStatus()) { case STATUS_IN_USE: - if (!mHideNotification) { + if (!mHideNotification && !isDsuSlotLocked()) { startForeground(NOTIFICATION_ID, buildNotification(STATUS_IN_USE, CAUSE_NOT_SPECIFIED)); } break; case STATUS_READY: - if (!mHideNotification) { + if (!mHideNotification && !isDsuSlotLocked()) { startForeground(NOTIFICATION_ID, buildNotification(STATUS_READY, CAUSE_NOT_SPECIFIED)); } -- cgit v1.2.3-59-g8ed1b