summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SafetyCenter/TEST_MAPPING3
-rw-r--r--service/java/com/android/safetycenter/SafetyCenterService.java8
-rw-r--r--service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java26
-rw-r--r--tests/functional/safetycenter/safetycenteractivity/src/android/safetycenter/functional/ui/SafetyCenterActivityTest.kt6
-rw-r--r--tests/functional/safetycenter/singleuser/src/android/safetycenter/functional/ui/SafetyCenterSubpagesTest.kt6
5 files changed, 10 insertions, 39 deletions
diff --git a/SafetyCenter/TEST_MAPPING b/SafetyCenter/TEST_MAPPING
index 5bc6abbc7..a7e53d8a6 100644
--- a/SafetyCenter/TEST_MAPPING
+++ b/SafetyCenter/TEST_MAPPING
@@ -11,6 +11,9 @@
},
{
"path": "packages/modules/Permission/tests/functional/safetycenter/singleuser/"
+ },
+ {
+ "path": "packages/modules/Permission/tests/hostside/safetycenter/"
}
]
}
diff --git a/service/java/com/android/safetycenter/SafetyCenterService.java b/service/java/com/android/safetycenter/SafetyCenterService.java
index 52768950d..cac8bfc61 100644
--- a/service/java/com/android/safetycenter/SafetyCenterService.java
+++ b/service/java/com/android/safetycenter/SafetyCenterService.java
@@ -906,8 +906,14 @@ public final class SafetyCenterService extends SystemService {
@GuardedBy("mApiLock")
private void onApiDisabledLocked() {
+ // We're not clearing the Safety Center notification channels here. The reason for this
+ // is that the NotificationManager will post a runnable to cancel all associated
+ // notifications when clearing the channels. Given this happens asynchronously, this can
+ // leak between test cases and cause notifications that should be active to be cleared
+ // inadvertently. We're ok with the inconsistency because the channels are hidden
+ // somewhat deeply under Settings anyway, and we're unlikely to turn off Safety Center
+ // in production.
clearDataLocked();
- mNotificationChannels.clearAllChannelsForAllUsers(getContext());
mSafetyCenterListeners.clear();
mSafetyCenterBroadcastDispatcher.sendEnabledChanged();
}
diff --git a/service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java b/service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java
index 56476bd65..ccd2bfabc 100644
--- a/service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java
+++ b/service/java/com/android/safetycenter/notifications/SafetyCenterNotificationChannels.java
@@ -150,32 +150,6 @@ public final class SafetyCenterNotificationChannels {
}
}
- /** Clears all Safety Center {@link NotificationChannel}s, for all current users. */
- public void clearAllChannelsForAllUsers(Context context) {
- List<UserHandle> users = UserUtils.getUserHandles(context);
- for (int i = 0; i < users.size(); i++) {
- clearAllChannelsForUser(context, users.get(i));
- }
- }
-
- // This method is private and not public as it is assumed that clearing channels on user removal
- // is already handled by the NotificationManagerService.
- private void clearAllChannelsForUser(Context context, UserHandle user) {
- NotificationManager notificationManager = getNotificationManagerForUser(context, user);
- if (notificationManager == null) {
- return;
- }
-
- try {
- clearAllChannelsWithoutCallingIdentity(notificationManager);
- } catch (RuntimeException e) {
- Log.w(
- TAG,
- "Error clearing notification channels for user id: " + user.getIdentifier(),
- e);
- }
- }
-
@Nullable
private String getChannelIdForIssue(SafetySourceIssue issue) {
int issueSeverityLevel = issue.getSeverityLevel();
diff --git a/tests/functional/safetycenter/safetycenteractivity/src/android/safetycenter/functional/ui/SafetyCenterActivityTest.kt b/tests/functional/safetycenter/safetycenteractivity/src/android/safetycenter/functional/ui/SafetyCenterActivityTest.kt
index af9aaf74f..6656d0b98 100644
--- a/tests/functional/safetycenter/safetycenteractivity/src/android/safetycenter/functional/ui/SafetyCenterActivityTest.kt
+++ b/tests/functional/safetycenter/safetycenteractivity/src/android/safetycenter/functional/ui/SafetyCenterActivityTest.kt
@@ -21,8 +21,6 @@ import android.os.Build
import android.os.Build.VERSION_CODES.TIRAMISU
import android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE
import android.os.Bundle
-import android.platform.test.rule.ScreenRecordRule
-import android.platform.test.rule.ScreenRecordRule.ScreenRecord
import android.safetycenter.SafetyCenterManager.EXTRA_SAFETY_SOURCE_ID
import android.safetycenter.SafetyCenterManager.EXTRA_SAFETY_SOURCE_ISSUE_ID
import android.safetycenter.SafetySourceData.SEVERITY_LEVEL_CRITICAL_WARNING
@@ -98,7 +96,6 @@ class SafetyCenterActivityTest {
@get:Rule(order = 2) val safetyCenterTestRule = SafetyCenterTestRule(safetyCenterTestHelper)
@get:Rule(order = 3) val disableAnimationRule = DisableAnimationRule()
@get:Rule(order = 4) val freezeRotationRule = FreezeRotationRule()
- @get:Rule(order = 5) val screenRecordRule = ScreenRecordRule()
// It is necessary to couple RetryRule and Timeout to ensure that all the retries together are
// restricted with the test timeout
@@ -425,7 +422,6 @@ class SafetyCenterActivityTest {
}
@Test
- @ScreenRecord
fun entryListWithEntryGroup_clickingAClickableDisabledEntry_redirectsToDifferentScreen() {
safetyCenterTestHelper.setConfig(safetyCenterTestConfigs.multipleSourcesConfig)
safetyCenterTestHelper.setData(
@@ -481,7 +477,6 @@ class SafetyCenterActivityTest {
}
@Test
- @ScreenRecord
fun entryListWithSingleSource_clickingDefaultEntryImplicitIntent_redirectsToDifferentScreen() {
safetyCenterTestHelper.setConfig(safetyCenterTestConfigs.implicitIntentSingleSourceConfig)
@@ -924,7 +919,6 @@ class SafetyCenterActivityTest {
}
@Test
- @ScreenRecord
fun launchActivity_fromQuickSettings_issuesExpanded() {
safetyCenterTestHelper.setConfig(safetyCenterTestConfigs.multipleSourcesConfig)
safetyCenterTestHelper.setData(
diff --git a/tests/functional/safetycenter/singleuser/src/android/safetycenter/functional/ui/SafetyCenterSubpagesTest.kt b/tests/functional/safetycenter/singleuser/src/android/safetycenter/functional/ui/SafetyCenterSubpagesTest.kt
index a6230ab73..4a2267d05 100644
--- a/tests/functional/safetycenter/singleuser/src/android/safetycenter/functional/ui/SafetyCenterSubpagesTest.kt
+++ b/tests/functional/safetycenter/singleuser/src/android/safetycenter/functional/ui/SafetyCenterSubpagesTest.kt
@@ -19,8 +19,6 @@ package android.safetycenter.functional.ui
import android.content.Context
import android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE
import android.os.Bundle
-import android.platform.test.rule.ScreenRecordRule
-import android.platform.test.rule.ScreenRecordRule.ScreenRecord
import android.safetycenter.SafetyCenterManager.EXTRA_SAFETY_SOURCES_GROUP_ID
import android.safetycenter.SafetySourceData
import android.safetycenter.SafetySourceIssue
@@ -100,7 +98,6 @@ class SafetyCenterSubpagesTest {
@get:Rule(order = 2) val safetyCenterTestRule = SafetyCenterTestRule(safetyCenterTestHelper)
@get:Rule(order = 3) val disableAnimationRule = DisableAnimationRule()
@get:Rule(order = 4) val freezeRotationRule = FreezeRotationRule()
- @get:Rule(order = 5) val screenRecordRule = ScreenRecordRule()
// It is necessary to couple RetryRule and Timeout to ensure that all the retries together are
// restricted with the test timeout
@@ -314,7 +311,6 @@ class SafetyCenterSubpagesTest {
}
@Test
- @ScreenRecord
fun entryListWithSingleSource_clickingTheInfoIcon_redirectsToDifferentScreen() {
safetyCenterTestHelper.setConfig(safetyCenterTestConfigs.singleSourceConfig)
val sourceTestData = safetySourceTestData.informationWithIconAction
@@ -479,7 +475,6 @@ class SafetyCenterSubpagesTest {
}
@Test
- @ScreenRecord
fun issueCard_updateSafetySourceData_subpageDisplaysUpdatedIssue() {
val initialDataToDisplay = safetySourceTestData.informationWithIssueWithAttributionTitle
val updatedDataToDisplay = safetySourceTestData.criticalWithIssueWithAttributionTitle
@@ -912,7 +907,6 @@ class SafetyCenterSubpagesTest {
}
@Test
- @ScreenRecord
fun settingsSearch_openWithGenericIntentExtra_showsGenericSubpage() {
val config = safetyCenterTestConfigs.multipleSourcesConfig
safetyCenterTestHelper.setConfig(config)