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

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

Merge "Delete deleteConversationNotificationChannels from...

Merge "Delete deleteConversationNotificationChannels from NotificationManagerService." into sc-dev am: e0d69283

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13997625

Change-Id: If930361aeceddfa8f535bea9627450170773a001
parents 8e769024 e0d69283
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -104,7 +104,6 @@ interface INotificationManager
    void createConversationNotificationChannelForPackage(String pkg, int uid, in NotificationChannel parentChannel, String conversationId);
    NotificationChannel getNotificationChannelForPackage(String pkg, int uid, String channelId, String conversationId, boolean includeDeleted);
    void deleteNotificationChannel(String pkg, String channelId);
    void deleteConversationNotificationChannels(String pkg, int uid, String conversationId);
    ParceledListSlice getNotificationChannels(String callingPkg, String targetPkg, int userId);
    ParceledListSlice getNotificationChannelsForPackage(String pkg, int uid, boolean includeDeleted);
    int getNumNotificationChannelsForPackage(String pkg, int uid, boolean includeDeleted);
+0 −28
Original line number Diff line number Diff line
@@ -3616,34 +3616,6 @@ public class NotificationManagerService extends SystemService {
            handleSavePolicyFile();
        }

        @Override
        public void deleteConversationNotificationChannels(String pkg, int uid,
                String conversationId) {
            checkCallerIsSystem();
            List<NotificationChannel> channels =
                    mPreferencesHelper.getNotificationChannelsByConversationId(
                            pkg, uid, conversationId);
            if (!channels.isEmpty()) {
                // Preflight for fg service notifications in these channels:  do nothing
                // unless they're all eligible
                final int appUserId = UserHandle.getUserId(uid);
                for (NotificationChannel nc : channels) {
                    final String channelId = nc.getId();
                    mAmi.stopForegroundServicesForChannel(pkg, appUserId, channelId);
                    cancelAllNotificationsInt(MY_UID, MY_PID, pkg, nc.getId(), 0, 0, true,
                            appUserId, REASON_CHANNEL_REMOVED, null);
                    mPreferencesHelper.deleteNotificationChannel(pkg, uid, channelId);
                    mListeners.notifyNotificationChannelChanged(pkg,
                            UserHandle.getUserHandleForUid(uid),
                            mPreferencesHelper.getNotificationChannel(
                                    pkg, uid, channelId, true),
                            NOTIFICATION_CHANNEL_OR_GROUP_DELETED);
                }
                handleSavePolicyFile();
            }
        }


        @Override
        public NotificationChannelGroup getNotificationChannelGroup(String pkg, String groupId) {
            checkCallerIsSystemOrSameApp(pkg);
+0 −45
Original line number Diff line number Diff line
@@ -6971,51 +6971,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        assertNotNull(friendChannel.getId());
    }

    @Test
    public void deleteConversationNotificationChannels() throws Exception {
        NotificationChannel messagesParent =
                new NotificationChannel("messages", "messages", IMPORTANCE_HIGH);
        Parcel msgParcel = Parcel.obtain();
        messagesParent.writeToParcel(msgParcel, 0);
        msgParcel.setDataPosition(0);

        NotificationChannel callsParent =
                new NotificationChannel("calls", "calls", IMPORTANCE_HIGH);
        Parcel callParcel = Parcel.obtain();
        callsParent.writeToParcel(callParcel, 0);
        callParcel.setDataPosition(0);

        mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(
                messagesParent, callsParent)));

        String conversationId = "friend";

        mBinderService.createConversationNotificationChannelForPackage(
                PKG, mUid, NotificationChannel.CREATOR.createFromParcel(msgParcel),
                conversationId);
        mBinderService.createConversationNotificationChannelForPackage(
                PKG, mUid, NotificationChannel.CREATOR.createFromParcel(callParcel),
                conversationId);

        NotificationChannel messagesChild = mBinderService.getConversationNotificationChannel(
                PKG, 0, PKG, messagesParent.getId(), false, conversationId);
        NotificationChannel callsChild = mBinderService.getConversationNotificationChannel(
                PKG, 0, PKG, callsParent.getId(), false, conversationId);

        assertEquals(messagesParent.getId(), messagesChild.getParentChannelId());
        assertEquals(conversationId, messagesChild.getConversationId());

        assertEquals(callsParent.getId(), callsChild.getParentChannelId());
        assertEquals(conversationId, callsChild.getConversationId());

        mBinderService.deleteConversationNotificationChannels(PKG, mUid, conversationId);

        assertNull(mBinderService.getConversationNotificationChannel(
                PKG, 0, PKG, messagesParent.getId(), false, conversationId));
        assertNull(mBinderService.getConversationNotificationChannel(
                PKG, 0, PKG, callsParent.getId(), false, conversationId));
    }

    @Test
    public void testCorrectCategory_systemOn_appCannotTurnOff() {
        int requested = 0;