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

Commit 24714576 authored by Yuri Lin's avatar Yuri Lin Committed by Automerger Merge Worker
Browse files

Merge "Add logging for zen mode events." into udc-dev am: 34bc8be6 am: 4f73c8e0

parents f10552bb 4f73c8e0
Loading
Loading
Loading
Loading
+103 −35
Original line number Diff line number Diff line
@@ -205,12 +205,24 @@ public class ZenModeDiff {
        private final ArrayMap<String, RuleDiff> mAutomaticRulesDiff = new ArrayMap<>();
        private RuleDiff mManualRuleDiff;

        // Helpers for string generation
        private static final String ALLOW_CALLS_FROM_FIELD = "allowCallsFrom";
        private static final String ALLOW_MESSAGES_FROM_FIELD = "allowMessagesFrom";
        private static final String ALLOW_CONVERSATIONS_FROM_FIELD = "allowConversationsFrom";
        // Field name constants
        public static final String FIELD_USER = "user";
        public static final String FIELD_ALLOW_ALARMS = "allowAlarms";
        public static final String FIELD_ALLOW_MEDIA = "allowMedia";
        public static final String FIELD_ALLOW_SYSTEM = "allowSystem";
        public static final String FIELD_ALLOW_CALLS = "allowCalls";
        public static final String FIELD_ALLOW_REMINDERS = "allowReminders";
        public static final String FIELD_ALLOW_EVENTS = "allowEvents";
        public static final String FIELD_ALLOW_REPEAT_CALLERS = "allowRepeatCallers";
        public static final String FIELD_ALLOW_MESSAGES = "allowMessages";
        public static final String FIELD_ALLOW_CONVERSATIONS = "allowConversations";
        public static final String FIELD_ALLOW_CALLS_FROM = "allowCallsFrom";
        public static final String FIELD_ALLOW_MESSAGES_FROM = "allowMessagesFrom";
        public static final String FIELD_ALLOW_CONVERSATIONS_FROM = "allowConversationsFrom";
        public static final String FIELD_SUPPRESSED_VISUAL_EFFECTS = "suppressedVisualEffects";
        public static final String FIELD_ARE_CHANNELS_BYPASSING_DND = "areChannelsBypassingDnd";
        private static final Set<String> PEOPLE_TYPE_FIELDS =
                Set.of(ALLOW_CALLS_FROM_FIELD, ALLOW_MESSAGES_FROM_FIELD);
                Set.of(FIELD_ALLOW_CALLS_FROM, FIELD_ALLOW_MESSAGES_FROM);

        /**
         * Create a diff that contains diffs between the "from" and "to" ZenModeConfigs.
@@ -232,57 +244,57 @@ public class ZenModeDiff {

            // Now we compare all the fields, knowing there's a diff and that neither is null
            if (from.user != to.user) {
                addField("user", new FieldDiff<>(from.user, to.user));
                addField(FIELD_USER, new FieldDiff<>(from.user, to.user));
            }
            if (from.allowAlarms != to.allowAlarms) {
                addField("allowAlarms", new FieldDiff<>(from.allowAlarms, to.allowAlarms));
                addField(FIELD_ALLOW_ALARMS, new FieldDiff<>(from.allowAlarms, to.allowAlarms));
            }
            if (from.allowMedia != to.allowMedia) {
                addField("allowMedia", new FieldDiff<>(from.allowMedia, to.allowMedia));
                addField(FIELD_ALLOW_MEDIA, new FieldDiff<>(from.allowMedia, to.allowMedia));
            }
            if (from.allowSystem != to.allowSystem) {
                addField("allowSystem", new FieldDiff<>(from.allowSystem, to.allowSystem));
                addField(FIELD_ALLOW_SYSTEM, new FieldDiff<>(from.allowSystem, to.allowSystem));
            }
            if (from.allowCalls != to.allowCalls) {
                addField("allowCalls", new FieldDiff<>(from.allowCalls, to.allowCalls));
                addField(FIELD_ALLOW_CALLS, new FieldDiff<>(from.allowCalls, to.allowCalls));
            }
            if (from.allowReminders != to.allowReminders) {
                addField("allowReminders",
                addField(FIELD_ALLOW_REMINDERS,
                        new FieldDiff<>(from.allowReminders, to.allowReminders));
            }
            if (from.allowEvents != to.allowEvents) {
                addField("allowEvents", new FieldDiff<>(from.allowEvents, to.allowEvents));
                addField(FIELD_ALLOW_EVENTS, new FieldDiff<>(from.allowEvents, to.allowEvents));
            }
            if (from.allowRepeatCallers != to.allowRepeatCallers) {
                addField("allowRepeatCallers",
                addField(FIELD_ALLOW_REPEAT_CALLERS,
                        new FieldDiff<>(from.allowRepeatCallers, to.allowRepeatCallers));
            }
            if (from.allowMessages != to.allowMessages) {
                addField("allowMessages",
                addField(FIELD_ALLOW_MESSAGES,
                        new FieldDiff<>(from.allowMessages, to.allowMessages));
            }
            if (from.allowConversations != to.allowConversations) {
                addField("allowConversations",
                addField(FIELD_ALLOW_CONVERSATIONS,
                        new FieldDiff<>(from.allowConversations, to.allowConversations));
            }
            if (from.allowCallsFrom != to.allowCallsFrom) {
                addField("allowCallsFrom",
                addField(FIELD_ALLOW_CALLS_FROM,
                        new FieldDiff<>(from.allowCallsFrom, to.allowCallsFrom));
            }
            if (from.allowMessagesFrom != to.allowMessagesFrom) {
                addField("allowMessagesFrom",
                addField(FIELD_ALLOW_MESSAGES_FROM,
                        new FieldDiff<>(from.allowMessagesFrom, to.allowMessagesFrom));
            }
            if (from.allowConversationsFrom != to.allowConversationsFrom) {
                addField("allowConversationsFrom",
                addField(FIELD_ALLOW_CONVERSATIONS_FROM,
                        new FieldDiff<>(from.allowConversationsFrom, to.allowConversationsFrom));
            }
            if (from.suppressedVisualEffects != to.suppressedVisualEffects) {
                addField("suppressedVisualEffects",
                addField(FIELD_SUPPRESSED_VISUAL_EFFECTS,
                        new FieldDiff<>(from.suppressedVisualEffects, to.suppressedVisualEffects));
            }
            if (from.areChannelsBypassingDnd != to.areChannelsBypassingDnd) {
                addField("areChannelsBypassingDnd",
                addField(FIELD_ARE_CHANNELS_BYPASSING_DND,
                        new FieldDiff<>(from.areChannelsBypassingDnd, to.areChannelsBypassingDnd));
            }

@@ -366,7 +378,7 @@ public class ZenModeDiff {
                    sb.append(ZenModeConfig.sourceToString((int) diff.from()));
                    sb.append("->");
                    sb.append(ZenModeConfig.sourceToString((int) diff.to()));
                } else if (key.equals(ALLOW_CONVERSATIONS_FROM_FIELD)) {
                } else if (key.equals(FIELD_ALLOW_CONVERSATIONS_FROM)) {
                    sb.append(key);
                    sb.append(":");
                    sb.append(ZenPolicy.conversationTypeToString((int) diff.from()));
@@ -428,6 +440,24 @@ public class ZenModeDiff {
     * Diff class representing a change between two ZenRules.
     */
    public static class RuleDiff extends BaseDiff {
        public static final String FIELD_ENABLED = "enabled";
        public static final String FIELD_SNOOZING = "snoozing";
        public static final String FIELD_NAME = "name";
        public static final String FIELD_ZEN_MODE = "zenMode";
        public static final String FIELD_CONDITION_ID = "conditionId";
        public static final String FIELD_CONDITION = "condition";
        public static final String FIELD_COMPONENT = "component";
        public static final String FIELD_CONFIGURATION_ACTIVITY = "configurationActivity";
        public static final String FIELD_ID = "id";
        public static final String FIELD_CREATION_TIME = "creationTime";
        public static final String FIELD_ENABLER = "enabler";
        public static final String FIELD_ZEN_POLICY = "zenPolicy";
        public static final String FIELD_MODIFIED = "modified";
        public static final String FIELD_PKG = "pkg";

        // Special field to track whether this rule became active or inactive
        FieldDiff<Boolean> mActiveDiff;

        /**
         * Create a RuleDiff representing the difference between two ZenRule objects.
         * @param from previous ZenRule
@@ -440,54 +470,64 @@ public class ZenModeDiff {
            if (from == null && to == null) {
                return;
            }

            // Even if added or removed, there may be a change in whether or not it was active.
            // This only applies to automatic rules.
            boolean fromActive = from != null ? from.isAutomaticActive() : false;
            boolean toActive = to != null ? to.isAutomaticActive() : false;
            if (fromActive != toActive) {
                mActiveDiff = new FieldDiff<>(fromActive, toActive);
            }

            // Return if the diff was added or removed
            if (hasExistenceChange()) {
                return;
            }

            if (from.enabled != to.enabled) {
                addField("enabled", new FieldDiff<>(from.enabled, to.enabled));
                addField(FIELD_ENABLED, new FieldDiff<>(from.enabled, to.enabled));
            }
            if (from.snoozing != to.snoozing) {
                addField("snoozing", new FieldDiff<>(from.snoozing, to.snoozing));
                addField(FIELD_SNOOZING, new FieldDiff<>(from.snoozing, to.snoozing));
            }
            if (!Objects.equals(from.name, to.name)) {
                addField("name", new FieldDiff<>(from.name, to.name));
                addField(FIELD_NAME, new FieldDiff<>(from.name, to.name));
            }
            if (from.zenMode != to.zenMode) {
                addField("zenMode", new FieldDiff<>(from.zenMode, to.zenMode));
                addField(FIELD_ZEN_MODE, new FieldDiff<>(from.zenMode, to.zenMode));
            }
            if (!Objects.equals(from.conditionId, to.conditionId)) {
                addField("conditionId", new FieldDiff<>(from.conditionId, to.conditionId));
                addField(FIELD_CONDITION_ID, new FieldDiff<>(from.conditionId,
                        to.conditionId));
            }
            if (!Objects.equals(from.condition, to.condition)) {
                addField("condition", new FieldDiff<>(from.condition, to.condition));
                addField(FIELD_CONDITION, new FieldDiff<>(from.condition, to.condition));
            }
            if (!Objects.equals(from.component, to.component)) {
                addField("component", new FieldDiff<>(from.component, to.component));
                addField(FIELD_COMPONENT, new FieldDiff<>(from.component, to.component));
            }
            if (!Objects.equals(from.configurationActivity, to.configurationActivity)) {
                addField("configurationActivity", new FieldDiff<>(
                addField(FIELD_CONFIGURATION_ACTIVITY, new FieldDiff<>(
                        from.configurationActivity, to.configurationActivity));
            }
            if (!Objects.equals(from.id, to.id)) {
                addField("id", new FieldDiff<>(from.id, to.id));
                addField(FIELD_ID, new FieldDiff<>(from.id, to.id));
            }
            if (from.creationTime != to.creationTime) {
                addField("creationTime",
                addField(FIELD_CREATION_TIME,
                        new FieldDiff<>(from.creationTime, to.creationTime));
            }
            if (!Objects.equals(from.enabler, to.enabler)) {
                addField("enabler", new FieldDiff<>(from.enabler, to.enabler));
                addField(FIELD_ENABLER, new FieldDiff<>(from.enabler, to.enabler));
            }
            if (!Objects.equals(from.zenPolicy, to.zenPolicy)) {
                addField("zenPolicy", new FieldDiff<>(from.zenPolicy, to.zenPolicy));
                addField(FIELD_ZEN_POLICY, new FieldDiff<>(from.zenPolicy, to.zenPolicy));
            }
            if (from.modified != to.modified) {
                addField("modified", new FieldDiff<>(from.modified, to.modified));
                addField(FIELD_MODIFIED, new FieldDiff<>(from.modified, to.modified));
            }
            if (!Objects.equals(from.pkg, to.pkg)) {
                addField("pkg", new FieldDiff<>(from.pkg, to.pkg));
                addField(FIELD_PKG, new FieldDiff<>(from.pkg, to.pkg));
            }
        }

@@ -536,7 +576,35 @@ public class ZenModeDiff {
                sb.append(diff);
            }

            if (becameActive()) {
                if (!first) {
                    sb.append(", ");
                }
                sb.append("(->active)");
            } else if (becameInactive()) {
                if (!first) {
                    sb.append(", ");
                }
                sb.append("(->inactive)");
            }

            return sb.append("}").toString();
        }

        /**
         * Returns whether this diff indicates that this (automatic) rule became active.
         */
        public boolean becameActive() {
            // if the "to" side is true, then it became active
            return mActiveDiff != null && mActiveDiff.to();
        }

        /**
         * Returns whether this diff indicates that this (automatic) rule became inactive.
         */
        public boolean becameInactive() {
            // if the "to" side is false, then it became inactive
            return mActiveDiff != null && !mActiveDiff.to();
        }
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -360,3 +360,11 @@ message DNDPolicyProto {

    optional ConversationType allow_conversations_from = 19;
}

// Enum identifying the type of rule that changed; values set to match ones used in the
// DNDStateChanged proto.
enum RuleType {
    RULE_TYPE_UNKNOWN = 0;
    RULE_TYPE_MANUAL = 1;
    RULE_TYPE_AUTOMATIC = 2;
}
+44 −19
Original line number Diff line number Diff line
@@ -1652,7 +1652,8 @@ public class NotificationManagerService extends SystemService {
            if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) {
                // update system notification channels
                SystemNotificationChannels.createAll(context);
                mZenModeHelper.updateDefaultZenRules();
                mZenModeHelper.updateDefaultZenRules(Binder.getCallingUid(),
                        isCallerIsSystemOrSystemUi());
                mPreferencesHelper.onLocaleChanged(context, ActivityManager.getCurrentUser());
            }
        }
@@ -2280,7 +2281,8 @@ public class NotificationManagerService extends SystemService {
        mRankingHandler = rankingHandler;
        mConditionProviders = conditionProviders;
        mZenModeHelper = new ZenModeHelper(getContext(), mHandler.getLooper(), mConditionProviders,
                new SysUiStatsEvent.BuilderFactory());
                new SysUiStatsEvent.BuilderFactory(), flagResolver,
                new ZenModeEventLogger(mPackageManagerClient));
        mZenModeHelper.addCallback(new ZenModeHelper.Callback() {
            @Override
            public void onConfigChanged() {
@@ -2862,7 +2864,8 @@ public class NotificationManagerService extends SystemService {
        final NotificationChannel preUpdate =
                mPreferencesHelper.getNotificationChannel(pkg, uid, channel.getId(), true);
        mPreferencesHelper.updateNotificationChannel(pkg, uid, channel, true);
        mPreferencesHelper.updateNotificationChannel(pkg, uid, channel, true,
                Binder.getCallingUid(), isCallerIsSystemOrSystemUi());
        if (mPreferencesHelper.onlyHasDefaultChannel(pkg, uid)) {
            mPermissionHelper.setNotificationPermission(pkg, UserHandle.getUserId(uid),
                    channel.getImportance() != IMPORTANCE_NONE, true);
@@ -2910,7 +2913,7 @@ public class NotificationManagerService extends SystemService {
        final NotificationChannelGroup preUpdate =
                mPreferencesHelper.getNotificationChannelGroup(group.getId(), pkg, uid);
        mPreferencesHelper.createNotificationChannelGroup(pkg, uid, group,
                fromApp);
                fromApp, Binder.getCallingUid(), isCallerIsSystemOrSystemUi());
        if (!fromApp) {
            maybeNotifyChannelGroupOwner(pkg, uid, preUpdate, group);
        }
@@ -3875,7 +3878,8 @@ public class NotificationManagerService extends SystemService {
                needsPolicyFileChange = mPreferencesHelper.createNotificationChannel(pkg, uid,
                        channel, true /* fromTargetApp */,
                        mConditionProviders.isPackageOrComponentAllowed(
                                pkg, UserHandle.getUserId(uid)));
                                pkg, UserHandle.getUserId(uid)), Binder.getCallingUid(),
                        isCallerIsSystemOrSystemUi());
                if (needsPolicyFileChange) {
                    mListeners.notifyNotificationChannelChanged(pkg,
                            UserHandle.getUserHandleForUid(uid),
@@ -4011,6 +4015,7 @@ public class NotificationManagerService extends SystemService {
        public void deleteNotificationChannel(String pkg, String channelId) {
            checkCallerIsSystemOrSameApp(pkg);
            final int callingUid = Binder.getCallingUid();
            final boolean isSystemOrSystemUi = isCallerIsSystemOrSystemUi();
            final int callingUser = UserHandle.getUserId(callingUid);
            if (NotificationChannel.DEFAULT_CHANNEL_ID.equals(channelId)) {
                throw new IllegalArgumentException("Cannot delete default channel");
@@ -4020,7 +4025,7 @@ public class NotificationManagerService extends SystemService {
            cancelAllNotificationsInt(MY_UID, MY_PID, pkg, channelId, 0, 0, true,
                    callingUser, REASON_CHANNEL_REMOVED, null);
            boolean previouslyExisted = mPreferencesHelper.deleteNotificationChannel(
                    pkg, callingUid, channelId);
                    pkg, callingUid, channelId, callingUid, isSystemOrSystemUi);
            if (previouslyExisted) {
                // Remove from both recent notification archive and notification history
                mArchive.removeChannelNotifications(pkg, callingUser, channelId);
@@ -4053,6 +4058,7 @@ public class NotificationManagerService extends SystemService {
            checkCallerIsSystemOrSameApp(pkg);
            final int callingUid = Binder.getCallingUid();
            final boolean isSystemOrSystemUi = isCallerIsSystemOrSystemUi();
            NotificationChannelGroup groupToDelete =
                    mPreferencesHelper.getNotificationChannelGroupWithChannels(
                            pkg, callingUid, groupId, false);
@@ -4066,7 +4072,8 @@ public class NotificationManagerService extends SystemService {
                    enforceDeletingChannelHasNoUserInitiatedJob(pkg, userId, channelId);
                }
                List<NotificationChannel> deletedChannels =
                        mPreferencesHelper.deleteNotificationChannelGroup(pkg, callingUid, groupId);
                        mPreferencesHelper.deleteNotificationChannelGroup(pkg, callingUid, groupId,
                                callingUid, isSystemOrSystemUi);
                for (int i = 0; i < deletedChannels.size(); i++) {
                    final NotificationChannel deletedChannel = deletedChannels.get(i);
                    cancelAllNotificationsInt(MY_UID, MY_PID, pkg, deletedChannel.getId(), 0, 0,
@@ -4964,11 +4971,14 @@ public class NotificationManagerService extends SystemService {
        @Override
        public void requestInterruptionFilterFromListener(INotificationListener token,
                int interruptionFilter) throws RemoteException {
            final int callingUid = Binder.getCallingUid();
            final boolean isSystemOrSystemUi = isCallerIsSystemOrSystemUi();
            final long identity = Binder.clearCallingIdentity();
            try {
                synchronized (mNotificationLock) {
                    final ManagedServiceInfo info = mListeners.checkServiceTokenLocked(token);
                    mZenModeHelper.requestFromListener(info.component, interruptionFilter);
                    mZenModeHelper.requestFromListener(info.component, interruptionFilter,
                            callingUid, isSystemOrSystemUi);
                    updateInterruptionFilterLocked();
                }
            } finally {
@@ -5008,9 +5018,12 @@ public class NotificationManagerService extends SystemService {
        @Override
        public void setZenMode(int mode, Uri conditionId, String reason) throws RemoteException {
            enforceSystemOrSystemUI("INotificationManager.setZenMode");
            final int callingUid = Binder.getCallingUid();
            final boolean isSystemOrSystemUi = isCallerIsSystemOrSystemUi();
            final long identity = Binder.clearCallingIdentity();
            try {
                mZenModeHelper.setManualZenMode(mode, conditionId, null, reason);
                mZenModeHelper.setManualZenMode(mode, conditionId, null, reason, callingUid,
                        isSystemOrSystemUi);
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
@@ -5057,7 +5070,8 @@ public class NotificationManagerService extends SystemService {
            }
            return mZenModeHelper.addAutomaticZenRule(rulePkg, automaticZenRule,
                    "addAutomaticZenRule");
                    "addAutomaticZenRule", Binder.getCallingUid(),
                    isCallerIsSystemOrSystemUi());
        }
        @Override
@@ -5074,7 +5088,8 @@ public class NotificationManagerService extends SystemService {
            enforcePolicyAccess(Binder.getCallingUid(), "updateAutomaticZenRule");
            return mZenModeHelper.updateAutomaticZenRule(id, automaticZenRule,
                    "updateAutomaticZenRule");
                    "updateAutomaticZenRule", Binder.getCallingUid(),
                    isCallerIsSystemOrSystemUi());
        }
        @Override
@@ -5083,7 +5098,8 @@ public class NotificationManagerService extends SystemService {
            // Verify that they can modify zen rules.
            enforcePolicyAccess(Binder.getCallingUid(), "removeAutomaticZenRule");
            return mZenModeHelper.removeAutomaticZenRule(id, "removeAutomaticZenRule");
            return mZenModeHelper.removeAutomaticZenRule(id, "removeAutomaticZenRule",
                    Binder.getCallingUid(), isCallerIsSystemOrSystemUi());
        }
        @Override
@@ -5092,7 +5108,8 @@ public class NotificationManagerService extends SystemService {
            enforceSystemOrSystemUI("removeAutomaticZenRules");
            return mZenModeHelper.removeAutomaticZenRules(packageName,
                    packageName + "|removeAutomaticZenRules");
                    packageName + "|removeAutomaticZenRules", Binder.getCallingUid(),
                    isCallerIsSystemOrSystemUi());
        }
        @Override
@@ -5110,7 +5127,8 @@ public class NotificationManagerService extends SystemService {
            enforcePolicyAccess(Binder.getCallingUid(), "setAutomaticZenRuleState");
            mZenModeHelper.setAutomaticZenRuleState(id, condition);
            mZenModeHelper.setAutomaticZenRuleState(id, condition, Binder.getCallingUid(),
                    isCallerIsSystemOrSystemUi());
        }
        @Override
@@ -5118,9 +5136,12 @@ public class NotificationManagerService extends SystemService {
            enforcePolicyAccess(pkg, "setInterruptionFilter");
            final int zen = NotificationManager.zenModeFromInterruptionFilter(filter, -1);
            if (zen == -1) throw new IllegalArgumentException("Invalid filter: " + filter);
            final int callingUid = Binder.getCallingUid();
            final boolean isSystemOrSystemUi = isCallerIsSystemOrSystemUi();
            final long identity = Binder.clearCallingIdentity();
            try {
                mZenModeHelper.setManualZenMode(zen, null, pkg, "setInterruptionFilter");
                mZenModeHelper.setManualZenMode(zen, null, pkg, "setInterruptionFilter",
                        callingUid, isSystemOrSystemUi);
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
@@ -5421,6 +5442,7 @@ public class NotificationManagerService extends SystemService {
        public void setNotificationPolicy(String pkg, Policy policy) {
            enforcePolicyAccess(pkg, "setNotificationPolicy");
            int callingUid = Binder.getCallingUid();
            boolean isSystemOrSystemUi = isCallerIsSystemOrSystemUi();
            final long identity = Binder.clearCallingIdentity();
            try {
                final ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo(pkg,
@@ -5460,7 +5482,7 @@ public class NotificationManagerService extends SystemService {
                        policy.priorityCallSenders, policy.priorityMessageSenders,
                        newVisualEffects, policy.priorityConversationSenders);
                ZenLog.traceSetNotificationPolicy(pkg, applicationInfo.targetSdkVersion, policy);
                mZenModeHelper.setNotificationPolicy(policy);
                mZenModeHelper.setNotificationPolicy(policy, callingUid, isSystemOrSystemUi);
            } catch (RemoteException e) {
            } finally {
                Binder.restoreCallingIdentity(identity);
@@ -6698,7 +6720,8 @@ public class NotificationManagerService extends SystemService {
                    channel.setUserVisibleTaskShown(true);
                }
                mPreferencesHelper.updateNotificationChannel(
                        pkg, notificationUid, channel, false);
                        pkg, notificationUid, channel, false, callingUid,
                        isCallerIsSystemOrSystemUi());
                r.updateNotificationChannel(channel);
            } else if (!channel.isUserVisibleTaskShown() && !TextUtils.isEmpty(channelId)
                    && !NotificationChannel.DEFAULT_CHANNEL_ID.equals(channelId)) {
@@ -6771,7 +6794,8 @@ public class NotificationManagerService extends SystemService {
        mHistoryManager.deleteConversations(pkg, uid, shortcuts);
        List<String> deletedChannelIds =
                mPreferencesHelper.deleteConversations(pkg, uid, shortcuts);
                mPreferencesHelper.deleteConversations(pkg, uid, shortcuts,
                        /* callingUid */ Process.SYSTEM_UID, /* is system */ true);
        for (String channelId : deletedChannelIds) {
            cancelAllNotificationsInt(MY_UID, MY_PID, pkg, channelId, 0, 0, true,
                    UserHandle.getUserId(uid), REASON_CHANNEL_REMOVED,
@@ -10000,7 +10024,8 @@ public class NotificationManagerService extends SystemService {
        return isUidSystemOrPhone(Binder.getCallingUid());
    }
    private boolean isCallerIsSystemOrSystemUi() {
    @VisibleForTesting
    protected boolean isCallerIsSystemOrSystemUi() {
        if (isCallerSystemOrPhone()) {
            return true;
        }
+23 −19

File changed.

Preview size limit exceeded, changes collapsed.

+7 −5
Original line number Diff line number Diff line
@@ -39,19 +39,21 @@ public interface RankingConfig {
    Collection<NotificationChannelGroup> getNotificationChannelGroups(String pkg,
            int uid);
    void createNotificationChannelGroup(String pkg, int uid, NotificationChannelGroup group,
            boolean fromTargetApp);
            boolean fromTargetApp, int callingUid, boolean isSystemOrSystemUi);
    ParceledListSlice<NotificationChannelGroup> getNotificationChannelGroups(String pkg,
            int uid, boolean includeDeleted, boolean includeNonGrouped, boolean includeEmpty);
    boolean createNotificationChannel(String pkg, int uid, NotificationChannel channel,
            boolean fromTargetApp, boolean hasDndAccess);
    void updateNotificationChannel(String pkg, int uid, NotificationChannel channel,
            boolean fromUser);
            boolean fromTargetApp, boolean hasDndAccess, int callingUid,
            boolean isSystemOrSystemUi);
    void updateNotificationChannel(String pkg, int uid, NotificationChannel updatedChannel,
            boolean fromUser, int callingUid, boolean fromSystemOrSystemUi);
    NotificationChannel getNotificationChannel(String pkg, int uid, String channelId,
            boolean includeDeleted);
    NotificationChannel getConversationNotificationChannel(String pkg, int uid, String channelId,
            String conversationId, boolean returnParentIfNoConversationChannel,
            boolean includeDeleted);
    boolean deleteNotificationChannel(String pkg, int uid, String channelId);
    boolean deleteNotificationChannel(String pkg, int uid, String channelId,
            int callingUid, boolean fromSystemOrSystemUi);
    void permanentlyDeleteNotificationChannel(String pkg, int uid, String channelId);
    void permanentlyDeleteNotificationChannels(String pkg, int uid);
    ParceledListSlice<NotificationChannel> getNotificationChannels(String pkg, int uid,
Loading