Loading services/core/java/com/android/server/notification/PreferencesHelper.java +4 −4 Original line number Diff line number Diff line Loading @@ -559,7 +559,7 @@ public class PreferencesHelper implements RankingConfig { if (r.uid == UNKNOWN_UID) { if (Flags.persistIncompleteRestoreData()) { r.userId = userId; r.userIdWhenUidUnknown = userId; } mRestoredWithoutUids.put(unrestoredPackageKey(pkg, userId), r); } else { Loading Loading @@ -756,7 +756,7 @@ public class PreferencesHelper implements RankingConfig { if (Flags.persistIncompleteRestoreData() && r.uid == UNKNOWN_UID) { out.attributeLong(null, ATT_CREATION_TIME, r.creationTime); out.attributeInt(null, ATT_USERID, r.userId); out.attributeInt(null, ATT_USERID, r.userIdWhenUidUnknown); } if (!forBackup) { Loading Loading @@ -1959,7 +1959,7 @@ public class PreferencesHelper implements RankingConfig { ArrayList<ZenBypassingApp> bypassing = new ArrayList<>(); synchronized (mLock) { for (PackagePreferences p : mPackagePreferences.values()) { if (p.userId != userId) { if (UserHandle.getUserId(p.uid) != userId) { continue; } int totalChannelCount = p.channels.size(); Loading Loading @@ -3189,7 +3189,7 @@ public class PreferencesHelper implements RankingConfig { // Until we enable the UI, we should return false. boolean canHavePromotedNotifs = android.app.Flags.uiRichOngoing(); @UserIdInt int userId; @UserIdInt int userIdWhenUidUnknown; Delegate delegate = null; ArrayMap<String, NotificationChannel> channels = new ArrayMap<>(); Loading services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +32 −5 Original line number Diff line number Diff line Loading @@ -66,7 +66,6 @@ import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.No import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES__FSI_STATE__DENIED; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES__FSI_STATE__GRANTED; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES__FSI_STATE__NOT_REQUESTED; import static com.android.server.notification.Flags.FLAG_ALL_NOTIFS_NEED_TTL; import static com.android.server.notification.Flags.FLAG_NOTIFICATION_VERIFY_CHANNEL_SOUND_URI; import static com.android.server.notification.Flags.FLAG_PERSIST_INCOMPLETE_RESTORE_DATA; import static com.android.server.notification.NotificationChannelLogger.NotificationChannelEvent.NOTIFICATION_CHANNEL_UPDATED_BY_USER; Loading Loading @@ -155,7 +154,6 @@ import android.util.proto.ProtoOutputStream; import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags; import com.android.internal.config.sysui.TestableFlagResolver; Loading @@ -167,9 +165,6 @@ import com.android.os.AtomsProto.PackageNotificationPreferences; import com.android.server.UiServiceTestCase; import com.android.server.notification.PermissionHelper.PackagePermission; import platform.test.runner.parameterized.ParameterizedAndroidJunit4; import platform.test.runner.parameterized.Parameters; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.protobuf.InvalidProtocolBufferException; Loading Loading @@ -204,6 +199,9 @@ import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ThreadLocalRandom; import platform.test.runner.parameterized.ParameterizedAndroidJunit4; import platform.test.runner.parameterized.Parameters; @SmallTest @RunWith(ParameterizedAndroidJunit4.class) @EnableFlags(FLAG_PERSIST_INCOMPLETE_RESTORE_DATA) Loading Loading @@ -2639,6 +2637,35 @@ public class PreferencesHelperTest extends UiServiceTestCase { assertThat(mHelper.getPackagesBypassingDnd(UserHandle.getUserId(UID_N_MR1))).isEmpty(); } @Test public void getPackagesBypassingDnd_multipleUsers() { int uidUser1 = UserHandle.getUid(1, UID_P); NotificationChannel channelUser1Bypass = new NotificationChannel("id11", "name1", NotificationManager.IMPORTANCE_MAX); channelUser1Bypass.setBypassDnd(true); NotificationChannel channelUser1NoBypass = new NotificationChannel("id12", "name2", NotificationManager.IMPORTANCE_MAX); channelUser1NoBypass.setBypassDnd(false); int uidUser2 = UserHandle.getUid(2, UID_P); NotificationChannel channelUser2Bypass = new NotificationChannel("id21", "name1", NotificationManager.IMPORTANCE_MAX); channelUser2Bypass.setBypassDnd(true); mHelper.createNotificationChannel(PKG_P, uidUser1, channelUser1Bypass, true, /* hasDndAccess= */ true, uidUser1, false); mHelper.createNotificationChannel(PKG_P, uidUser1, channelUser1NoBypass, true, /* hasDndAccess= */ true, uidUser1, false); mHelper.createNotificationChannel(PKG_P, uidUser2, channelUser2Bypass, true, /* hasDndAccess= */ true, uidUser2, false); assertThat(mHelper.getPackagesBypassingDnd(0)).isEmpty(); assertThat(mHelper.getPackagesBypassingDnd(1)) .containsExactly(new ZenBypassingApp(PKG_P, false)); assertThat(mHelper.getPackagesBypassingDnd(2)) .containsExactly(new ZenBypassingApp(PKG_P, true)); } @Test public void getPackagesBypassingDnd_oneChannelBypassing_groupBlocked() { int uid = UID_N_MR1; Loading Loading
services/core/java/com/android/server/notification/PreferencesHelper.java +4 −4 Original line number Diff line number Diff line Loading @@ -559,7 +559,7 @@ public class PreferencesHelper implements RankingConfig { if (r.uid == UNKNOWN_UID) { if (Flags.persistIncompleteRestoreData()) { r.userId = userId; r.userIdWhenUidUnknown = userId; } mRestoredWithoutUids.put(unrestoredPackageKey(pkg, userId), r); } else { Loading Loading @@ -756,7 +756,7 @@ public class PreferencesHelper implements RankingConfig { if (Flags.persistIncompleteRestoreData() && r.uid == UNKNOWN_UID) { out.attributeLong(null, ATT_CREATION_TIME, r.creationTime); out.attributeInt(null, ATT_USERID, r.userId); out.attributeInt(null, ATT_USERID, r.userIdWhenUidUnknown); } if (!forBackup) { Loading Loading @@ -1959,7 +1959,7 @@ public class PreferencesHelper implements RankingConfig { ArrayList<ZenBypassingApp> bypassing = new ArrayList<>(); synchronized (mLock) { for (PackagePreferences p : mPackagePreferences.values()) { if (p.userId != userId) { if (UserHandle.getUserId(p.uid) != userId) { continue; } int totalChannelCount = p.channels.size(); Loading Loading @@ -3189,7 +3189,7 @@ public class PreferencesHelper implements RankingConfig { // Until we enable the UI, we should return false. boolean canHavePromotedNotifs = android.app.Flags.uiRichOngoing(); @UserIdInt int userId; @UserIdInt int userIdWhenUidUnknown; Delegate delegate = null; ArrayMap<String, NotificationChannel> channels = new ArrayMap<>(); Loading
services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +32 −5 Original line number Diff line number Diff line Loading @@ -66,7 +66,6 @@ import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.No import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES__FSI_STATE__DENIED; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES__FSI_STATE__GRANTED; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES__FSI_STATE__NOT_REQUESTED; import static com.android.server.notification.Flags.FLAG_ALL_NOTIFS_NEED_TTL; import static com.android.server.notification.Flags.FLAG_NOTIFICATION_VERIFY_CHANNEL_SOUND_URI; import static com.android.server.notification.Flags.FLAG_PERSIST_INCOMPLETE_RESTORE_DATA; import static com.android.server.notification.NotificationChannelLogger.NotificationChannelEvent.NOTIFICATION_CHANNEL_UPDATED_BY_USER; Loading Loading @@ -155,7 +154,6 @@ import android.util.proto.ProtoOutputStream; import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags; import com.android.internal.config.sysui.TestableFlagResolver; Loading @@ -167,9 +165,6 @@ import com.android.os.AtomsProto.PackageNotificationPreferences; import com.android.server.UiServiceTestCase; import com.android.server.notification.PermissionHelper.PackagePermission; import platform.test.runner.parameterized.ParameterizedAndroidJunit4; import platform.test.runner.parameterized.Parameters; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.protobuf.InvalidProtocolBufferException; Loading Loading @@ -204,6 +199,9 @@ import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ThreadLocalRandom; import platform.test.runner.parameterized.ParameterizedAndroidJunit4; import platform.test.runner.parameterized.Parameters; @SmallTest @RunWith(ParameterizedAndroidJunit4.class) @EnableFlags(FLAG_PERSIST_INCOMPLETE_RESTORE_DATA) Loading Loading @@ -2639,6 +2637,35 @@ public class PreferencesHelperTest extends UiServiceTestCase { assertThat(mHelper.getPackagesBypassingDnd(UserHandle.getUserId(UID_N_MR1))).isEmpty(); } @Test public void getPackagesBypassingDnd_multipleUsers() { int uidUser1 = UserHandle.getUid(1, UID_P); NotificationChannel channelUser1Bypass = new NotificationChannel("id11", "name1", NotificationManager.IMPORTANCE_MAX); channelUser1Bypass.setBypassDnd(true); NotificationChannel channelUser1NoBypass = new NotificationChannel("id12", "name2", NotificationManager.IMPORTANCE_MAX); channelUser1NoBypass.setBypassDnd(false); int uidUser2 = UserHandle.getUid(2, UID_P); NotificationChannel channelUser2Bypass = new NotificationChannel("id21", "name1", NotificationManager.IMPORTANCE_MAX); channelUser2Bypass.setBypassDnd(true); mHelper.createNotificationChannel(PKG_P, uidUser1, channelUser1Bypass, true, /* hasDndAccess= */ true, uidUser1, false); mHelper.createNotificationChannel(PKG_P, uidUser1, channelUser1NoBypass, true, /* hasDndAccess= */ true, uidUser1, false); mHelper.createNotificationChannel(PKG_P, uidUser2, channelUser2Bypass, true, /* hasDndAccess= */ true, uidUser2, false); assertThat(mHelper.getPackagesBypassingDnd(0)).isEmpty(); assertThat(mHelper.getPackagesBypassingDnd(1)) .containsExactly(new ZenBypassingApp(PKG_P, false)); assertThat(mHelper.getPackagesBypassingDnd(2)) .containsExactly(new ZenBypassingApp(PKG_P, true)); } @Test public void getPackagesBypassingDnd_oneChannelBypassing_groupBlocked() { int uid = UID_N_MR1; Loading