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

Commit 61bf3a9e authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Support for "recent conversations"

- Provide some extra information needed to display conversations
and to create their conversation specific channels
- Uncache unmodified recent conversations after 10 days

Test: atest
Bug: 171191376
Change-Id: I33ddc2485d560b7252b99af02ed796b667ec02e7
parent 617a0256
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ interface INotificationManager
    void updateNotificationChannelForPackage(String pkg, int uid, in NotificationChannel channel);
    NotificationChannel getNotificationChannel(String callingPkg, int userId, String pkg, String channelId);
    NotificationChannel getConversationNotificationChannel(String callingPkg, int userId, String pkg, String channelId, boolean returnParentIfNoConversationChannel, String conversationId);
    void createConversationNotificationChannelForPackage(String pkg, int uid, String triggeringKey, in NotificationChannel parentChannel, String conversationId);
    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);
+21 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.app.people;

import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
import android.content.pm.ShortcutInfo;
import android.os.Parcel;
import android.os.Parcelable;
@@ -30,7 +31,9 @@ import android.os.Parcelable;
public final class ConversationChannel implements Parcelable {

    private ShortcutInfo mShortcutInfo;
    private int mUid;
    private NotificationChannel mParentNotificationChannel;
    private NotificationChannelGroup mParentNotificationChannelGroup;
    private long mLastEventTimestamp;
    private boolean mHasActiveNotifications;

@@ -46,18 +49,24 @@ public final class ConversationChannel implements Parcelable {
        }
    };

    public ConversationChannel(ShortcutInfo shortcutInfo,
            NotificationChannel parentNotificationChannel, long lastEventTimestamp,
    public ConversationChannel(ShortcutInfo shortcutInfo, int uid,
            NotificationChannel parentNotificationChannel,
            NotificationChannelGroup parentNotificationChannelGroup, long lastEventTimestamp,
            boolean hasActiveNotifications) {
        mShortcutInfo = shortcutInfo;
        mUid = uid;
        mParentNotificationChannel = parentNotificationChannel;
        mParentNotificationChannelGroup = parentNotificationChannelGroup;
        mLastEventTimestamp = lastEventTimestamp;
        mHasActiveNotifications = hasActiveNotifications;
    }

    public ConversationChannel(Parcel in) {
        mShortcutInfo = in.readParcelable(ShortcutInfo.class.getClassLoader());
        mUid = in.readInt();
        mParentNotificationChannel = in.readParcelable(NotificationChannel.class.getClassLoader());
        mParentNotificationChannelGroup =
                in.readParcelable(NotificationChannelGroup.class.getClassLoader());
        mLastEventTimestamp = in.readLong();
        mHasActiveNotifications = in.readBoolean();
    }
@@ -70,7 +79,9 @@ public final class ConversationChannel implements Parcelable {
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(mShortcutInfo, flags);
        dest.writeInt(mUid);
        dest.writeParcelable(mParentNotificationChannel, flags);
        dest.writeParcelable(mParentNotificationChannelGroup, flags);
        dest.writeLong(mLastEventTimestamp);
        dest.writeBoolean(mHasActiveNotifications);
    }
@@ -79,10 +90,18 @@ public final class ConversationChannel implements Parcelable {
        return mShortcutInfo;
    }

    public int getUid() {
        return mUid;
    }

    public NotificationChannel getParentNotificationChannel() {
        return mParentNotificationChannel;
    }

    public NotificationChannelGroup getParentNotificationChannelGroup() {
        return mParentNotificationChannelGroup;
    }

    public long getLastEventTimestamp() {
        return mLastEventTimestamp;
    }
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ public class NotificationChannelHelper {
        try {
            channel.setName(getName(entry));
            notificationManager.createConversationNotificationChannelForPackage(
                    pkg, appUid, entry.getSbn().getKey(), channel,
                    pkg, appUid, channel,
                    conversationId);
            channel = notificationManager.getConversationNotificationChannel(
                    context.getOpPackageName(), UserHandle.getUserId(appUid), pkg,
+2 −2
Original line number Diff line number Diff line
@@ -995,7 +995,7 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
                mTestHandler, null, Optional.of(mBubbles));

        verify(mMockINotificationManager, times(1)).createConversationNotificationChannelForPackage(
                anyString(), anyInt(), anyString(), any(), eq(CONVERSATION_ID));
                anyString(), anyInt(), any(), eq(CONVERSATION_ID));
    }

    @Test
@@ -1020,7 +1020,7 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
                mTestHandler, null, Optional.of(mBubbles));

        verify(mMockINotificationManager, never()).createConversationNotificationChannelForPackage(
                anyString(), anyInt(), anyString(), any(), eq(CONVERSATION_ID));
                anyString(), anyInt(), any(), eq(CONVERSATION_ID));
    }

    @Test
+2 −0
Original line number Diff line number Diff line
@@ -18,11 +18,13 @@ package com.android.server.notification;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;

import java.util.Set;

public interface NotificationManagerInternal {
    NotificationChannel getNotificationChannel(String pkg, int uid, String channelId);
    NotificationChannelGroup getNotificationChannelGroup(String pkg, int uid, String channelId);
    void enqueueNotification(String pkg, String basePkg, int callingUid, int callingPid,
            String tag, int id, Notification notification, int userId);
    void cancelNotification(String pkg, String basePkg, int callingUid, int callingPid,
Loading