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

Commit cded3f16 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Additional functionality for the noti asst"

parents e08bef25 48a6ed99
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5676,6 +5676,7 @@ package android.app {
    method public java.lang.CharSequence getName();
    method public android.net.Uri getSound();
    method public long[] getVibrationPattern();
    method public boolean hasUserSetImportance();
    method public void setBypassDnd(boolean);
    method public void setDescription(java.lang.String);
    method public void setGroup(java.lang.String);
+3 −2
Original line number Diff line number Diff line
@@ -603,9 +603,10 @@ public final class NotificationChannel implements Parcelable {
    }

    /**
     * @hide
     * Returns whether the user has chosen the importance of this channel, either to affirm the
     * initial selection from the app, or changed it to be higher or lower.
     */
    public boolean isImportanceLocked() {
    public boolean hasUserSetImportance() {
        return (mUserLockedFields & USER_LOCKED_IMPORTANCE) != 0;
    }

+4 −2
Original line number Diff line number Diff line
@@ -737,7 +737,8 @@ public abstract class NotificationListenerService extends Service {
     * <p>This method will throw a security exception if you don't have access to notifications
     * for the given user.</p>
     * <p>The caller must have {@link CompanionDeviceManager#getAssociations() an associated
     * device} in order to use this method.
     * device} or be the {@link NotificationAssistantService notification assistant} in order to
     * use this method.
     *
     * @param pkg The package to retrieve channels for.
     */
@@ -760,7 +761,8 @@ public abstract class NotificationListenerService extends Service {
     * <p>This method will throw a security exception if you don't have access to notifications
     * for the given user.</p>
     * <p>The caller must have {@link CompanionDeviceManager#getAssociations() an associated
     * device} in order to use this method.
     * device} or be the {@link NotificationAssistantService notification assistant} in order to
     * use this method.
     *
     * @param pkg The package to retrieve channel groups for.
     */
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public class AgingHelper {

    public void onNotificationSeen(NotificationEntry entry) {
        // user has strong opinions about this notification. we can't down rank it, so don't bother.
        if (entry.getChannel().isImportanceLocked()) {
        if (entry.getChannel().hasUserSetImportance()) {
            return;
        }

+11 −6
Original line number Diff line number Diff line
@@ -3622,7 +3622,7 @@ public class NotificationManagerService extends SystemService {
                INotificationListener token, String pkg, UserHandle user,
                NotificationChannelGroup group) throws RemoteException {
            Preconditions.checkNotNull(user);
            verifyPrivilegedListener(token, user);
            verifyPrivilegedListener(token, user, false);
            createNotificationChannelGroup(
                    pkg, getUidForPackageAndUser(pkg, user), group, false, true);
            savePolicyFile();
@@ -3635,7 +3635,7 @@ public class NotificationManagerService extends SystemService {
            Preconditions.checkNotNull(pkg);
            Preconditions.checkNotNull(user);

            verifyPrivilegedListener(token, user);
            verifyPrivilegedListener(token, user, false);
            updateNotificationChannelInt(pkg, getUidForPackageAndUser(pkg, user), channel, true);
        }

@@ -3644,7 +3644,7 @@ public class NotificationManagerService extends SystemService {
                INotificationListener token, String pkg, UserHandle user) throws RemoteException {
            Preconditions.checkNotNull(pkg);
            Preconditions.checkNotNull(user);
            verifyPrivilegedListener(token, user);
            verifyPrivilegedListener(token, user, true);

            return mPreferencesHelper.getNotificationChannels(pkg, getUidForPackageAndUser(pkg, user),
                    false /* includeDeleted */);
@@ -3656,7 +3656,7 @@ public class NotificationManagerService extends SystemService {
                INotificationListener token, String pkg, UserHandle user) throws RemoteException {
            Preconditions.checkNotNull(pkg);
            Preconditions.checkNotNull(user);
            verifyPrivilegedListener(token, user);
            verifyPrivilegedListener(token, user, true);

            List<NotificationChannelGroup> groups = new ArrayList<>();
            groups.addAll(mPreferencesHelper.getNotificationChannelGroups(
@@ -3664,14 +3664,19 @@ public class NotificationManagerService extends SystemService {
            return new ParceledListSlice<>(groups);
        }

        private void verifyPrivilegedListener(INotificationListener token, UserHandle user) {
        private void verifyPrivilegedListener(INotificationListener token, UserHandle user,
                boolean assistantAllowed) {
            ManagedServiceInfo info;
            synchronized (mNotificationLock) {
                info = mListeners.checkServiceTokenLocked(token);
            }
            if (!hasCompanionDevice(info)) {
                synchronized (mNotificationLock) {
                    if (!assistantAllowed || !mAssistants.isServiceTokenValidLocked(info.service)) {
                        throw new SecurityException(info + " does not have access");
                    }
                }
            }
            if (!info.enabledAndUserMatches(user.getIdentifier())) {
                throw new SecurityException(info + " does not have access");
            }
Loading