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

Commit 78cea6e7 authored by Julia Reynolds's avatar Julia Reynolds Committed by Automerger Merge Worker
Browse files

Merge "Update logic about parent and convo channels" into sc-dev am: b87598c3

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

Change-Id: I1022456aabdd973fac8f9617f62ae95460c3cbf7
parents 61df1842 b87598c3
Loading
Loading
Loading
Loading
+28 −14
Original line number Diff line number Diff line
@@ -36,8 +36,8 @@ public final class ConversationChannel implements Parcelable {

    private ShortcutInfo mShortcutInfo;
    private int mUid;
    private NotificationChannel mParentNotificationChannel;
    private NotificationChannelGroup mParentNotificationChannelGroup;
    private NotificationChannel mNotificationChannel;
    private NotificationChannelGroup mNotificationChannelGroup;
    private long mLastEventTimestamp;
    private boolean mHasActiveNotifications;
    private boolean mHasBirthdayToday;
@@ -61,8 +61,8 @@ public final class ConversationChannel implements Parcelable {
            boolean hasActiveNotifications) {
        mShortcutInfo = shortcutInfo;
        mUid = uid;
        mParentNotificationChannel = parentNotificationChannel;
        mParentNotificationChannelGroup = parentNotificationChannelGroup;
        mNotificationChannel = parentNotificationChannel;
        mNotificationChannelGroup = parentNotificationChannelGroup;
        mLastEventTimestamp = lastEventTimestamp;
        mHasActiveNotifications = hasActiveNotifications;
    }
@@ -74,8 +74,8 @@ public final class ConversationChannel implements Parcelable {
            List<ConversationStatus> statuses) {
        mShortcutInfo = shortcutInfo;
        mUid = uid;
        mParentNotificationChannel = parentNotificationChannel;
        mParentNotificationChannelGroup = parentNotificationChannelGroup;
        mNotificationChannel = parentNotificationChannel;
        mNotificationChannelGroup = parentNotificationChannelGroup;
        mLastEventTimestamp = lastEventTimestamp;
        mHasActiveNotifications = hasActiveNotifications;
        mHasBirthdayToday = hasBirthdayToday;
@@ -85,8 +85,8 @@ public final class ConversationChannel implements Parcelable {
    public ConversationChannel(Parcel in) {
        mShortcutInfo = in.readParcelable(ShortcutInfo.class.getClassLoader());
        mUid = in.readInt();
        mParentNotificationChannel = in.readParcelable(NotificationChannel.class.getClassLoader());
        mParentNotificationChannelGroup =
        mNotificationChannel = in.readParcelable(NotificationChannel.class.getClassLoader());
        mNotificationChannelGroup =
                in.readParcelable(NotificationChannelGroup.class.getClassLoader());
        mLastEventTimestamp = in.readLong();
        mHasActiveNotifications = in.readBoolean();
@@ -104,8 +104,8 @@ public final class ConversationChannel implements Parcelable {
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(mShortcutInfo, flags);
        dest.writeInt(mUid);
        dest.writeParcelable(mParentNotificationChannel, flags);
        dest.writeParcelable(mParentNotificationChannelGroup, flags);
        dest.writeParcelable(mNotificationChannel, flags);
        dest.writeParcelable(mNotificationChannelGroup, flags);
        dest.writeLong(mLastEventTimestamp);
        dest.writeBoolean(mHasActiveNotifications);
        dest.writeBoolean(mHasBirthdayToday);
@@ -120,12 +120,12 @@ public final class ConversationChannel implements Parcelable {
        return mUid;
    }

    public NotificationChannel getParentNotificationChannel() {
        return mParentNotificationChannel;
    public NotificationChannel getNotificationChannel() {
        return mNotificationChannel;
    }

    public NotificationChannelGroup getParentNotificationChannelGroup() {
        return mParentNotificationChannelGroup;
    public NotificationChannelGroup getNotificationChannelGroup() {
        return mNotificationChannelGroup;
    }

    public long getLastEventTimestamp() {
@@ -149,4 +149,18 @@ public final class ConversationChannel implements Parcelable {
    public @Nullable List<ConversationStatus> getStatuses() {
        return mStatuses;
    }

    @Override
    public String toString() {
        return "ConversationChannel{" +
                "mShortcutInfo=" + mShortcutInfo +
                ", mUid=" + mUid +
                ", mNotificationChannel=" + mNotificationChannel +
                ", mNotificationChannelGroup=" + mNotificationChannelGroup +
                ", mLastEventTimestamp=" + mLastEventTimestamp +
                ", mHasActiveNotifications=" + mHasActiveNotifications +
                ", mHasBirthdayToday=" + mHasBirthdayToday +
                ", mStatuses=" + mStatuses +
                '}';
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -307,10 +307,10 @@ public class PeopleSpaceTile implements Parcelable {
            mContactUri = getContactUri(info);
            mStatuses = channel.getStatuses();
            mLastInteractionTimestamp = channel.getLastEventTimestamp();
            mIsImportantConversation = channel.getParentNotificationChannel() != null
                    && channel.getParentNotificationChannel().isImportantConversation();
            mCanBypassDnd = channel.getParentNotificationChannel() != null
                    && channel.getParentNotificationChannel().canBypassDnd();
            mIsImportantConversation = channel.getNotificationChannel() != null
                    && channel.getNotificationChannel().isImportantConversation();
            mCanBypassDnd = channel.getNotificationChannel() != null
                    && channel.getNotificationChannel().canBypassDnd();
            mNotificationPolicyState = SHOW_CONVERSATIONS;
        }

+1 −1
Original line number Diff line number Diff line
@@ -675,7 +675,7 @@ public class PeopleSpaceWidgetManager {
            updatedTile.setUserIcon(icon);
        }
        if (DEBUG) Log.d(TAG, "Statuses: " + conversation.getStatuses().toString());
        NotificationChannel channel = conversation.getParentNotificationChannel();
        NotificationChannel channel = conversation.getNotificationChannel();
        if (channel != null) {
            if (DEBUG) Log.d(TAG, "Important:" + channel.isImportantConversation());
            updatedTile.setIsImportantConversation(channel.isImportantConversation());
+28 −10
Original line number Diff line number Diff line
@@ -254,6 +254,18 @@ public class DataManager {
        return null;
    }

    ConversationInfo getConversationInfo(String packageName, int userId, String shortcutId) {
        UserData userData = getUnlockedUserData(userId);
        if (userData != null) {
            PackageData packageData = userData.getPackageData(packageName);
            // App may have been uninstalled.
            if (packageData != null) {
                return packageData.getConversationInfo(shortcutId);
            }
        }
        return null;
    }

    @Nullable
    private ConversationChannel getConversationChannel(String packageName, int userId,
            String shortcutId, ConversationInfo conversationInfo) {
@@ -277,7 +289,7 @@ public class DataManager {
        int uid = mPackageManagerInternal.getPackageUid(packageName, 0, userId);
        NotificationChannel parentChannel =
                mNotificationManagerInternal.getNotificationChannel(packageName, uid,
                        conversationInfo.getParentNotificationChannelId());
                        conversationInfo.getNotificationChannelId());
        NotificationChannelGroup parentChannelGroup = null;
        if (parentChannel != null) {
            parentChannelGroup =
@@ -302,7 +314,7 @@ public class DataManager {
                String shortcutId = conversationInfo.getShortcutId();
                ConversationChannel channel = getConversationChannel(packageData.getPackageName(),
                        packageData.getUserId(), shortcutId, conversationInfo);
                if (channel == null || channel.getParentNotificationChannel() == null) {
                if (channel == null || channel.getNotificationChannel() == null) {
                    return;
                }
                conversationChannels.add(channel);
@@ -791,8 +803,8 @@ public class DataManager {

    private boolean isCachedRecentConversation(ConversationInfo conversationInfo) {
        return conversationInfo.isShortcutCachedForNotification()
                && conversationInfo.getNotificationChannelId() == null
                && conversationInfo.getParentNotificationChannelId() != null
                && Objects.equals(conversationInfo.getNotificationChannelId(),
                conversationInfo.getParentNotificationChannelId())
                && conversationInfo.getLastEventTimestamp() > 0L;
    }

@@ -910,7 +922,7 @@ public class DataManager {
    }

    @VisibleForTesting
    NotificationListenerService getNotificationListenerServiceForTesting(@UserIdInt int userId) {
    NotificationListener getNotificationListenerServiceForTesting(@UserIdInt int userId) {
        return mNotificationListeners.get(userId);
    }

@@ -1132,7 +1144,7 @@ public class DataManager {
        }

        @Override
        public void onNotificationPosted(StatusBarNotification sbn) {
        public void onNotificationPosted(StatusBarNotification sbn, RankingMap map) {
            if (sbn.getUser().getIdentifier() != mUserId) {
                return;
            }
@@ -1145,16 +1157,22 @@ public class DataManager {
            });

            if (packageData != null) {
                Ranking rank = new Ranking();
                map.getRanking(sbn.getKey(), rank);
                ConversationInfo conversationInfo = packageData.getConversationInfo(shortcutId);
                if (conversationInfo == null) {
                    return;
                }
                if (DEBUG) Log.d(TAG, "Last event from notification: " + sbn.getPostTime());
                ConversationInfo updated = new ConversationInfo.Builder(conversationInfo)
                ConversationInfo.Builder updated = new ConversationInfo.Builder(conversationInfo)
                        .setLastEventTimestamp(sbn.getPostTime())
                        .setParentNotificationChannelId(sbn.getNotification().getChannelId())
                        .build();
                packageData.getConversationStore().addOrUpdate(updated);
                        .setNotificationChannelId(rank.getChannel().getId());
                if (!TextUtils.isEmpty(rank.getChannel().getParentChannelId())) {
                    updated.setParentNotificationChannelId(rank.getChannel().getParentChannelId());
                } else {
                    updated.setParentNotificationChannelId(sbn.getNotification().getChannelId());
                }
                packageData.getConversationStore().addOrUpdate(updated.build());

                EventHistoryImpl eventHistory = packageData.getEventStore().getOrCreateEventHistory(
                        EventStore.CATEGORY_SHORTCUT_BASED, shortcutId);
+149 −68

File changed.

Preview size limit exceeded, changes collapsed.