Merge "Remove obsolete flag" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
83d16ecd9e
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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<Boolean>
|
||||
|
||||
/** 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<Boolean> = _isAvailable.asStateFlow()
|
||||
|
||||
val _showFooterDot = MutableStateFlow(false)
|
||||
override val showFooterDot: StateFlow<Boolean> = _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
|
||||
|
||||
@@ -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<Int>
|
||||
|
||||
@@ -52,32 +50,24 @@ constructor(
|
||||
fgsManagerController: FgsManagerController,
|
||||
) : ForegroundServicesRepository {
|
||||
override val foregroundServicesCount: Flow<Int> =
|
||||
fgsManagerController.isAvailable
|
||||
.flatMapLatest { isAvailable ->
|
||||
if (!isAvailable) {
|
||||
return@flatMapLatest flowOf(0)
|
||||
conflatedCallbackFlow<Int> {
|
||||
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<Boolean> =
|
||||
fgsManagerController.showFooterDot.flatMapLatest { showFooterDot ->
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -259,7 +259,6 @@ class FooterActionsViewModelTest : SysuiTestCase() {
|
||||
val securityController = FakeSecurityController()
|
||||
val fgsManagerController =
|
||||
FakeFgsManagerController(
|
||||
isAvailable = true,
|
||||
showFooterDot = false,
|
||||
numRunningPackages = 0,
|
||||
)
|
||||
|
||||
@@ -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<Boolean> = MutableStateFlow(isAvailable)
|
||||
|
||||
override var numRunningPackages = numRunningPackages
|
||||
set(value) {
|
||||
|
||||
@@ -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",
|
||||
@@ -7736,9 +7725,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);
|
||||
|
||||
@@ -1638,12 +1638,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";
|
||||
|
||||
@@ -1664,38 +1658,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())
|
||||
|
||||
Reference in New Issue
Block a user