Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33c3a30b authored by Matías Hernández's avatar Matías Hernández Committed by Android (Google) Code Review
Browse files

Merge "Create broadcast to be used by the (restored) DND slice" into main

parents 534b2135 5a950e86
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -292,6 +292,21 @@ public class NotificationManager {
    public static final String ACTION_AUTOMATIC_ZEN_RULE_STATUS_CHANGED =
            "android.app.action.AUTOMATIC_ZEN_RULE_STATUS_CHANGED";

    /**
     * Intent that is broadcast when the Zen configuration has changed. This includes any
     * modification to a {@code ZenRule}, including creation, modification, deletion, or activation
     * status change of {@link AutomaticZenRule} instances or the manual DND rule.
     *
     * <p>This broadcast is only sent to packages holding the
     * {@link android.Manifest.permission#MANAGE_NOTIFICATIONS} permission (which is only allowed
     * for system processes).
     *
     * @hide
     */
    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_ZEN_CONFIGURATION_CHANGED_INTERNAL =
            "android.app.action.ZEN_CONFIGURATION_CHANGED_INTERNAL";

    /**
     * Integer extra for {@link #ACTION_AUTOMATIC_ZEN_RULE_STATUS_CHANGED} containing the state of
     * the {@link AutomaticZenRule}.
+10 −0
Original line number Diff line number Diff line
@@ -90,6 +90,16 @@ flag {
  }
}

flag {
  name: "modes_ui_dnd_slice"
  namespace: "systemui"
  description: "Restores a (tweaked) DND slice in Settings; dependent on modes_ui"
  bug: "406238205"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
  name: "modes_cleanup_implicit"
  namespace: "systemui"
+2 −1
Original line number Diff line number Diff line
@@ -67,7 +67,8 @@ public class ZenMode implements Parcelable {

    private static final String TAG = "ZenMode";

    static final String MANUAL_DND_MODE_ID = ZenModeConfig.MANUAL_RULE_ID;
    public static final String MANUAL_DND_MODE_ID = ZenModeConfig.MANUAL_RULE_ID;

    static final String TEMP_NEW_MODE_ID = "temp_new_mode";

    private static final Comparator<Integer> PRIORITIZED_TYPE_COMPARATOR = new Comparator<>() {
+7 −0
Original line number Diff line number Diff line
@@ -2730,6 +2730,13 @@ public class NotificationManagerService extends SystemService {
            @Override
            public void onConfigChanged() {
                handleSavePolicyFile();
                if (android.app.Flags.modesUiDndSlice()) {
                    getContext().sendBroadcastAsUser(
                            new Intent(
                                    NotificationManager.ACTION_ZEN_CONFIGURATION_CHANGED_INTERNAL)
                                    .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT),
                            UserHandle.ALL, android.Manifest.permission.MANAGE_NOTIFICATIONS);
                }
            }
            @Override
+12 −0
Original line number Diff line number Diff line
@@ -11391,6 +11391,18 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        verify(mContext).sendBroadcastAsUser(eqIntent(expected), eq(UserHandle.of(mUserId)));
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_MODES_UI_DND_SLICE)
    public void onConfigChanged_sendsInternalZenChangedBroadcast() throws Exception {
        mService.mZenModeHelper.getCallbacks().forEach(c -> c.onConfigChanged());
        Intent expected = new Intent(NotificationManager.ACTION_ZEN_CONFIGURATION_CHANGED_INTERNAL)
                .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        verify(mContext).sendBroadcastAsUser(eqIntent(expected), eq(UserHandle.ALL),
                eq(android.Manifest.permission.MANAGE_NOTIFICATIONS));
    }
    private static Intent isIntentWithAction(String wantedAction) {
        return argThat(
                intent -> intent != null && wantedAction.equals(intent.getAction())