From b10e586f7c0a1f416b5241bc1bf7485cc5f9e3d8 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Thu, 30 Mar 2023 10:44:33 -0400 Subject: [PATCH] Remove obsolete flag Test: atest SystemUI Tests & UIServices Tests Test: ServicesTest (watch UI) & manually view UI when listening to music in the background Fixes: 275699193 Change-Id: Ic4a04d71bcf85f32d5a90f6b5929b77071fd4731 --- .../sysui/SystemUiDeviceConfigFlags.java | 5 --- .../systemui/qs/FgsManagerController.kt | 13 ------- .../ForegroundServicesRepository.kt | 28 +++++--------- .../systemui/qs/FgsManagerControllerTest.java | 2 - .../viewmodel/FooterActionsViewModelTest.kt | 1 - .../systemui/qs/FakeFgsManagerController.kt | 2 - .../NotificationManagerService.java | 14 ------- .../NotificationManagerServiceTest.java | 38 ------------------- 8 files changed, 9 insertions(+), 94 deletions(-) diff --git a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java index 0cb87fef09a16..7ad2a6898fb79 100644 --- a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java +++ b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java @@ -523,11 +523,6 @@ public final class SystemUiDeviceConfigFlags { */ public static final String DEFAULT_QR_CODE_SCANNER = "default_qr_code_scanner"; - /** - * (boolean) Whether the task manager entrypoint is enabled. - */ - public static final String TASK_MANAGER_ENABLED = "task_manager_enabled"; - /** * (boolean) Whether the task manager should show an attention grabbing dot when tasks changed. */ diff --git a/packages/SystemUI/src/com/android/systemui/qs/FgsManagerController.kt b/packages/SystemUI/src/com/android/systemui/qs/FgsManagerController.kt index 5355865de0933..0641eec154bbb 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/FgsManagerController.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/FgsManagerController.kt @@ -47,7 +47,6 @@ import androidx.annotation.VisibleForTesting import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.android.internal.config.sysui.SystemUiDeviceConfigFlags.TASK_MANAGER_ENABLED import com.android.internal.config.sysui.SystemUiDeviceConfigFlags.TASK_MANAGER_INFORM_JOB_SCHEDULER_OF_PENDING_APP_STOP import com.android.internal.config.sysui.SystemUiDeviceConfigFlags.TASK_MANAGER_SHOW_FOOTER_DOT import com.android.internal.config.sysui.SystemUiDeviceConfigFlags.TASK_MANAGER_SHOW_STOP_BUTTON_FOR_USER_ALLOWLISTED_APPS @@ -80,8 +79,6 @@ import kotlinx.coroutines.flow.asStateFlow /** A controller for the dealing with services running in the foreground. */ interface FgsManagerController { - /** Whether the TaskManager (and therefore this controller) is actually available. */ - val isAvailable: StateFlow /** The number of packages with a service running in the foreground. */ val numRunningPackages: Int @@ -155,7 +152,6 @@ class FgsManagerControllerImpl @Inject constructor( companion object { private const val INTERACTION_JANK_TAG = "active_background_apps" - private const val DEFAULT_TASK_MANAGER_ENABLED = true private const val DEFAULT_TASK_MANAGER_SHOW_FOOTER_DOT = false private const val DEFAULT_TASK_MANAGER_SHOW_STOP_BUTTON_FOR_USER_ALLOWLISTED_APPS = true private const val DEFAULT_TASK_MANAGER_SHOW_USER_VISIBLE_JOBS = true @@ -165,9 +161,6 @@ class FgsManagerControllerImpl @Inject constructor( override var newChangesSinceDialogWasDismissed = false private set - val _isAvailable = MutableStateFlow(false) - override val isAvailable: StateFlow = _isAvailable.asStateFlow() - val _showFooterDot = MutableStateFlow(false) override val showFooterDot: StateFlow = _showFooterDot.asStateFlow() @@ -264,7 +257,6 @@ class FgsManagerControllerImpl @Inject constructor( NAMESPACE_SYSTEMUI, backgroundExecutor ) { - _isAvailable.value = it.getBoolean(TASK_MANAGER_ENABLED, _isAvailable.value) _showFooterDot.value = it.getBoolean(TASK_MANAGER_SHOW_FOOTER_DOT, _showFooterDot.value) showStopBtnForUserAllowlistedApps = it.getBoolean( @@ -280,11 +272,6 @@ class FgsManagerControllerImpl @Inject constructor( TASK_MANAGER_SHOW_STOP_BUTTON_FOR_USER_ALLOWLISTED_APPS, informJobSchedulerOfPendingAppStop) } - - _isAvailable.value = deviceConfigProxy.getBoolean( - NAMESPACE_SYSTEMUI, - TASK_MANAGER_ENABLED, DEFAULT_TASK_MANAGER_ENABLED - ) _showFooterDot.value = deviceConfigProxy.getBoolean( NAMESPACE_SYSTEMUI, TASK_MANAGER_SHOW_FOOTER_DOT, DEFAULT_TASK_MANAGER_SHOW_FOOTER_DOT diff --git a/packages/SystemUI/src/com/android/systemui/qs/footer/data/repository/ForegroundServicesRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/footer/data/repository/ForegroundServicesRepository.kt index 37a9c40ffacfa..bd9d70c135729 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/footer/data/repository/ForegroundServicesRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/footer/data/repository/ForegroundServicesRepository.kt @@ -32,8 +32,6 @@ import kotlinx.coroutines.flow.merge interface ForegroundServicesRepository { /** * The number of packages with a service running in the foreground. - * - * Note that this will be equal to 0 if [FgsManagerController.isAvailable] is false. */ val foregroundServicesCount: Flow @@ -52,32 +50,24 @@ constructor( fgsManagerController: FgsManagerController, ) : ForegroundServicesRepository { override val foregroundServicesCount: Flow = - fgsManagerController.isAvailable - .flatMapLatest { isAvailable -> - if (!isAvailable) { - return@flatMapLatest flowOf(0) + conflatedCallbackFlow { + fun updateState(numberOfPackages: Int) { + trySendWithFailureLogging(numberOfPackages, TAG) } - conflatedCallbackFlow { - fun updateState(numberOfPackages: Int) { - trySendWithFailureLogging(numberOfPackages, TAG) - } - - val listener = + val listener = object : FgsManagerController.OnNumberOfPackagesChangedListener { override fun onNumberOfPackagesChanged(numberOfPackages: Int) { updateState(numberOfPackages) } } - fgsManagerController.addOnNumberOfPackagesChangedListener(listener) - updateState(fgsManagerController.numRunningPackages) - awaitClose { - fgsManagerController.removeOnNumberOfPackagesChangedListener(listener) - } + fgsManagerController.addOnNumberOfPackagesChangedListener(listener) + updateState(fgsManagerController.numRunningPackages) + awaitClose { + fgsManagerController.removeOnNumberOfPackagesChangedListener(listener) } - } - .distinctUntilChanged() + }.distinctUntilChanged() override val hasNewChanges: Flow = fgsManagerController.showFooterDot.flatMapLatest { showFooterDot -> diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/FgsManagerControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/FgsManagerControllerTest.java index 6f54f62cd70c5..f5a3becc70176 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/FgsManagerControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/FgsManagerControllerTest.java @@ -111,8 +111,6 @@ public class FgsManagerControllerTest extends SysuiTestCase { MockitoAnnotations.initMocks(this); mDeviceConfigProxyFake = new DeviceConfigProxyFake(); - mDeviceConfigProxyFake.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI, - SystemUiDeviceConfigFlags.TASK_MANAGER_ENABLED, "true", false); mSystemClock = new FakeSystemClock(); mMainExecutor = new FakeExecutor(mSystemClock); mBackgroundExecutor = new FakeExecutor(mSystemClock); diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt index 0b9fbd919715a..59f0d967596b7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt @@ -259,7 +259,6 @@ class FooterActionsViewModelTest : SysuiTestCase() { val securityController = FakeSecurityController() val fgsManagerController = FakeFgsManagerController( - isAvailable = true, showFooterDot = false, numRunningPackages = 0, ) diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/FakeFgsManagerController.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/FakeFgsManagerController.kt index ced7955100f77..9ff7dd590781b 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/FakeFgsManagerController.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/FakeFgsManagerController.kt @@ -23,11 +23,9 @@ import kotlinx.coroutines.flow.MutableStateFlow /** A fake [FgsManagerController] to be used in tests. */ class FakeFgsManagerController( - isAvailable: Boolean = true, showFooterDot: Boolean = false, numRunningPackages: Int = 0, ) : FgsManagerController { - override val isAvailable: MutableStateFlow = MutableStateFlow(isAvailable) override var numRunningPackages = numRunningPackages set(value) { diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index a4eb417be4e1f..97359f2d658a7 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -656,7 +656,6 @@ public class NotificationManagerService extends SystemService { private ConditionProviders mConditionProviders; private NotificationUsageStats mUsageStats; private boolean mLockScreenAllowSecureNotifications = true; - boolean mAllowFgsDismissal = false; boolean mSystemExemptFromDismissal = false; private static final int MY_UID = Process.myUid(); @@ -2581,19 +2580,9 @@ public class NotificationManagerService extends SystemService { for (String name : properties.getKeyset()) { if (SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE.equals(name)) { mAssistants.resetDefaultAssistantsIfNecessary(); - } else if (SystemUiDeviceConfigFlags.TASK_MANAGER_ENABLED.equals(name)) { - String value = properties.getString(name, null); - if ("true".equals(value)) { - mAllowFgsDismissal = true; - } else if ("false".equals(value)) { - mAllowFgsDismissal = false; - } } } }; - mAllowFgsDismissal = DeviceConfig.getBoolean( - DeviceConfig.NAMESPACE_SYSTEMUI, - SystemUiDeviceConfigFlags.TASK_MANAGER_ENABLED, true); mSystemExemptFromDismissal = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER, /* name= */ "application_exemptions", @@ -7728,9 +7717,6 @@ public class NotificationManagerService extends SystemService { // flags are set. if ((notification.flags & FLAG_FOREGROUND_SERVICE) != 0) { notification.flags |= FLAG_NO_CLEAR; - if (!mAllowFgsDismissal) { - notification.flags |= FLAG_ONGOING_EVENT; - } } mRankingHelper.extractSignals(r); diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index 9ca8d8444df94..e942422a978c8 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -1641,12 +1641,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { any(), anyString(), anyInt(), anyString(), anyInt())).thenReturn(SHOW_IMMEDIATELY); mContext.getTestablePermissions().setPermission( android.Manifest.permission.USE_COLORIZED_NOTIFICATIONS, PERMISSION_GRANTED); - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_SYSTEMUI, - SystemUiDeviceConfigFlags.TASK_MANAGER_ENABLED, - "true", - false); - Thread.sleep(300); final String tag = "testEnqueueNotificationWithTag_FgsAddsFlags_dismissalAllowed"; @@ -1667,38 +1661,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { FLAG_FOREGROUND_SERVICE | FLAG_CAN_COLORIZE | FLAG_NO_CLEAR); } - @Test - public void testEnqueueNotificationWithTag_FGSaddsFlags_dismissalNotAllowed() throws Exception { - when(mAmi.applyForegroundServiceNotification( - any(), anyString(), anyInt(), anyString(), anyInt())).thenReturn(SHOW_IMMEDIATELY); - mContext.getTestablePermissions().setPermission( - android.Manifest.permission.USE_COLORIZED_NOTIFICATIONS, PERMISSION_GRANTED); - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_SYSTEMUI, - SystemUiDeviceConfigFlags.TASK_MANAGER_ENABLED, - "false", - false); - Thread.sleep(300); - - final String tag = "testEnqueueNotificationWithTag_FGSaddsNoClear"; - - Notification n = new Notification.Builder(mContext, mTestNotificationChannel.getId()) - .setContentTitle("foo") - .setSmallIcon(android.R.drawable.sym_def_app_icon) - .setFlag(FLAG_FOREGROUND_SERVICE, true) - .build(); - StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 8, "tag", mUid, 0, - n, UserHandle.getUserHandleForUid(mUid), null, 0); - mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, - sbn.getId(), sbn.getNotification(), sbn.getUserId()); - waitForIdle(); - - StatusBarNotification[] notifs = - mBinderService.getActiveNotifications(PKG); - assertThat(notifs[0].getNotification().flags).isEqualTo( - FLAG_FOREGROUND_SERVICE | FLAG_CAN_COLORIZE | FLAG_NO_CLEAR | FLAG_ONGOING_EVENT); - } - @Test public void testEnqueueNotificationWithTag_nullAction_fixed() throws Exception { Notification n = new Notification.Builder(mContext, mTestNotificationChannel.getId())