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

Commit cf0341ec authored by Geoffrey Pitsch's avatar Geoffrey Pitsch Committed by Android (Google) Code Review
Browse files

Merge "AccountManagerService send pkg uid when creating notification channel"

parents ab2bc07e 3560f847
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ interface INotificationManager

    void createNotificationChannelGroups(String pkg, in ParceledListSlice channelGroupList);
    void createNotificationChannels(String pkg, in ParceledListSlice channelsList);
    void createNotificationChannelsForPackage(String pkg, int uid, in ParceledListSlice channelsList);
    ParceledListSlice getNotificationChannelGroupsForPackage(String pkg, int uid, boolean includeDeleted);
    NotificationChannelGroup getNotificationChannelGroupForPackage(String groupId, String pkg, int uid);
    void updateNotificationChannelForPackage(String pkg, int uid, in NotificationChannel channel);
+0 −13
Original line number Diff line number Diff line
@@ -452,19 +452,6 @@ public class NotificationManager
        }
    }

    /**
     * @hide
     */
    public void createNotificationChannelsForPackage(String pkg,
            @NonNull List<NotificationChannel> channels) {
        INotificationManager service = getService();
        try {
            service.createNotificationChannels(pkg, new ParceledListSlice(channels));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns the notification channel settings for a given channel id.
     */
+18 −5
Original line number Diff line number Diff line
@@ -14,10 +14,13 @@

package com.android.internal.notification;

import android.app.INotificationManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.ParceledListSlice;
import android.os.RemoteException;
import android.provider.Settings;

import com.android.internal.R;
@@ -69,6 +72,8 @@ public class SystemNotificationChannels {
                context.getString(R.string.notification_channel_car_mode),
                NotificationManager.IMPORTANCE_LOW));

        channelsList.add(newAccountChannel(context));

        channelsList.add(new NotificationChannel(
                DEVELOPER,
                context.getString(R.string.notification_channel_developer),
@@ -121,15 +126,23 @@ public class SystemNotificationChannels {
                NotificationManager.IMPORTANCE_MIN));

        nm.createNotificationChannels(channelsList);
        createAccountChannelForPackage(context.getPackageName(), context);
    }

    public static void createAccountChannelForPackage(String pkg, Context context) {
        final NotificationManager nm = context.getSystemService(NotificationManager.class);
        nm.createNotificationChannelsForPackage(pkg, Arrays.asList(new NotificationChannel(
    public static void createAccountChannelForPackage(String pkg, int uid, Context context) {
        final INotificationManager iNotificationManager = NotificationManager.getService();
        try {
            iNotificationManager.createNotificationChannelsForPackage(pkg, uid,
                    new ParceledListSlice(Arrays.asList(newAccountChannel(context))));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    private static NotificationChannel newAccountChannel(Context context) {
        return new NotificationChannel(
                ACCOUNT,
                context.getString(R.string.notification_channel_account),
                NotificationManager.IMPORTANCE_LOW)));
                NotificationManager.IMPORTANCE_LOW);
    }

    private SystemNotificationChannels() {}
+1 −1
Original line number Diff line number Diff line
@@ -5677,7 +5677,7 @@ public class AccountManagerService
            synchronized (mUsers) {
                userAccounts = mUsers.get(userId);
            }
            SystemNotificationChannels.createAccountChannelForPackage(packageName, mContext);
            SystemNotificationChannels.createAccountChannelForPackage(packageName, uid, mContext);
            doNotification(userAccounts, account, null, intent, packageName, userId);
        }

+17 −5
Original line number Diff line number Diff line
@@ -1633,21 +1633,33 @@ public class NotificationManagerService extends SystemService {
            savePolicyFile();
        }

        @Override
        public void createNotificationChannels(String pkg,
                ParceledListSlice channelsList) throws RemoteException {
            checkCallerIsSystemOrSameApp(pkg);
        private void createNotificationChannelsImpl(String pkg, int uid,
                ParceledListSlice channelsList) {
            List<NotificationChannel> channels = channelsList.getList();
            final int channelsSize = channels.size();
            for (int i = 0; i < channelsSize; i++) {
                final NotificationChannel channel = channels.get(i);
                Preconditions.checkNotNull(channel, "channel in list is null");
                mRankingHelper.createNotificationChannel(pkg, Binder.getCallingUid(), channel,
                mRankingHelper.createNotificationChannel(pkg, uid, channel,
                        true /* fromTargetApp */);
            }
            savePolicyFile();
        }

        @Override
        public void createNotificationChannels(String pkg,
                ParceledListSlice channelsList) throws RemoteException {
            checkCallerIsSystemOrSameApp(pkg);
            createNotificationChannelsImpl(pkg, Binder.getCallingUid(), channelsList);
        }

        @Override
        public void createNotificationChannelsForPackage(String pkg, int uid,
                ParceledListSlice channelsList) throws RemoteException {
            checkCallerIsSystem();
            createNotificationChannelsImpl(pkg, uid, channelsList);
        }

        @Override
        public NotificationChannel getNotificationChannel(String pkg, String channelId) {
            checkCallerIsSystemOrSameApp(pkg);