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

Commit cae06274 authored by Rubin Xu's avatar Rubin Xu Committed by Android (Google) Code Review
Browse files

Merge "Canel all work notification when the profile is turned off"

parents 8766c398 7eadc1bf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -34411,6 +34411,7 @@ package android.service.notification {
    field public static final int REASON_PACKAGE_BANNED = 7; // 0x7
    field public static final int REASON_PACKAGE_CHANGED = 5; // 0x5
    field public static final int REASON_PACKAGE_SUSPENDED = 15; // 0xf
    field public static final int REASON_PROFILE_TURNED_OFF = 16; // 0x10
    field public static final int REASON_TOPIC_BANNED = 14; // 0xe
    field public static final int REASON_USER_STOPPED = 6; // 0x6
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService";
+1 −0
Original line number Diff line number Diff line
@@ -36591,6 +36591,7 @@ package android.service.notification {
    field public static final int REASON_PACKAGE_BANNED = 7; // 0x7
    field public static final int REASON_PACKAGE_CHANGED = 5; // 0x5
    field public static final int REASON_PACKAGE_SUSPENDED = 15; // 0xf
    field public static final int REASON_PROFILE_TURNED_OFF = 16; // 0x10
    field public static final int REASON_TOPIC_BANNED = 14; // 0xe
    field public static final int REASON_USER_STOPPED = 6; // 0x6
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService";
+1 −0
Original line number Diff line number Diff line
@@ -34426,6 +34426,7 @@ package android.service.notification {
    field public static final int REASON_PACKAGE_BANNED = 7; // 0x7
    field public static final int REASON_PACKAGE_CHANGED = 5; // 0x5
    field public static final int REASON_PACKAGE_SUSPENDED = 15; // 0xf
    field public static final int REASON_PROFILE_TURNED_OFF = 16; // 0x10
    field public static final int REASON_TOPIC_BANNED = 14; // 0xe
    field public static final int REASON_USER_STOPPED = 6; // 0x6
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService";
+3 −0
Original line number Diff line number Diff line
@@ -101,6 +101,9 @@ public abstract class NotificationAssistantService extends NotificationListenerS
    /** Notification was canceled by the device administrator suspending the package. */
    public static final int REASON_PACKAGE_SUSPENDED = 15;

    /** Notification was canceled by the owning managed profile being turned off. */
    public static final int REASON_PROFILE_TURNED_OFF = 16;

    public class Adjustment {
        int mImportance;
        CharSequence mExplanation;
+12 −1
Original line number Diff line number Diff line
@@ -30,15 +30,16 @@ import static android.service.notification.NotificationAssistantService.REASON_L
import static android.service.notification.NotificationAssistantService.REASON_PACKAGE_BANNED;
import static android.service.notification.NotificationAssistantService.REASON_PACKAGE_CHANGED;
import static android.service.notification.NotificationAssistantService.REASON_PACKAGE_SUSPENDED;
import static android.service.notification.NotificationAssistantService.REASON_PROFILE_TURNED_OFF;
import static android.service.notification.NotificationAssistantService.REASON_TOPIC_BANNED;
import static android.service.notification.NotificationAssistantService.REASON_USER_STOPPED;
import static android.service.notification.NotificationListenerService.HINT_HOST_DISABLE_EFFECTS;
import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_HIGH;
import static android.service.notification.NotificationListenerService.SUPPRESSED_EFFECT_LIGHTS;
import static android.service.notification.NotificationListenerService.SUPPRESSED_EFFECT_PEEK;
import static android.service.notification.NotificationListenerService.SUPPRESSED_EFFECT_SCREEN_ON;
import static android.service.notification.NotificationListenerService.TRIM_FULL;
import static android.service.notification.NotificationListenerService.TRIM_LIGHT;
import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_HIGH;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
import static org.xmlpull.v1.XmlPullParser.END_TAG;
import static org.xmlpull.v1.XmlPullParser.START_TAG;
@@ -118,6 +119,7 @@ import android.util.Xml;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.widget.Toast;

import com.android.internal.R;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.internal.util.FastXmlSerializer;
@@ -134,6 +136,7 @@ import com.android.server.vr.VrManagerInternal;
import com.android.server.vr.VrStateListener;

import libcore.io.IoUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -787,6 +790,13 @@ public class NotificationManagerService extends SystemService {
                    cancelAllNotificationsInt(MY_UID, MY_PID, null, 0, 0, true, userHandle,
                            REASON_USER_STOPPED, null, null);
                }
            } else if (action.equals(Intent.ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED)) {
                boolean inQuietMode = intent.getBooleanExtra(Intent.EXTRA_QUIET_MODE, false);
                int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
                if (inQuietMode && userHandle >= 0) {
                    cancelAllNotificationsInt(MY_UID, MY_PID, null, 0, 0, true, userHandle,
                            REASON_PROFILE_TURNED_OFF, null, null);
                }
            } else if (action.equals(Intent.ACTION_USER_PRESENT)) {
                // turn off LED when user passes through lock screen
                mNotificationLight.turnOff();
@@ -984,6 +994,7 @@ public class NotificationManagerService extends SystemService {
        filter.addAction(Intent.ACTION_USER_SWITCHED);
        filter.addAction(Intent.ACTION_USER_ADDED);
        filter.addAction(Intent.ACTION_USER_REMOVED);
        filter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED);
        getContext().registerReceiver(mIntentReceiver, filter);

        IntentFilter pkgFilter = new IntentFilter();