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

Commit 138111fc authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Show snoozed conversations in conversation header

- And allow them to be unsnoozed with a tap.
- Also use the conversation's shortcut icon and name if available.
- And ignore the setting to turn off the strips since it now requires
explicit user action to make the strip visible

Note 1: unsnoozing a notification causes it to make sound again - we
probably want to change that for manually unsnoozed things
Note 2: the entries in the header don't yet persist across a reboot

Test: atest, manual
Bug: 149486431
Change-Id: Id661c25a49bc982e39deab977eb912f51eaf6757
parent ccf72664
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.service.notification;
import android.annotation.CurrentTimeMillisLong;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -37,6 +38,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ParceledListSlice;
import android.content.pm.ShortcutInfo;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
@@ -53,6 +55,7 @@ import android.os.ServiceManager;
import android.os.UserHandle;
import android.util.ArrayMap;
import android.util.Log;
import android.util.Slog;
import android.widget.RemoteViews;

import com.android.internal.annotations.GuardedBy;
@@ -1566,6 +1569,7 @@ public abstract class NotificationListenerService extends Service {
        private boolean mCanBubble;
        private boolean mVisuallyInterruptive;
        private boolean mIsConversation;
        private ShortcutInfo mShortcutInfo;

        private static final int PARCEL_VERSION = 2;

@@ -1599,6 +1603,7 @@ public abstract class NotificationListenerService extends Service {
            out.writeBoolean(mCanBubble);
            out.writeBoolean(mVisuallyInterruptive);
            out.writeBoolean(mIsConversation);
            out.writeParcelable(mShortcutInfo, flags);
        }

        /** @hide */
@@ -1620,7 +1625,7 @@ public abstract class NotificationListenerService extends Service {
            mImportance = in.readInt();
            mImportanceExplanation = in.readCharSequence(); // may be null
            mOverrideGroupKey = in.readString(); // may be null
            mChannel = (NotificationChannel) in.readParcelable(cl); // may be null
            mChannel = in.readParcelable(cl); // may be null
            mOverridePeople = in.createStringArrayList();
            mSnoozeCriteria = in.createTypedArrayList(SnoozeCriterion.CREATOR);
            mShowBadge = in.readBoolean();
@@ -1633,6 +1638,7 @@ public abstract class NotificationListenerService extends Service {
            mCanBubble = in.readBoolean();
            mVisuallyInterruptive = in.readBoolean();
            mIsConversation = in.readBoolean();
            mShortcutInfo = in.readParcelable(cl);
        }


@@ -1837,6 +1843,13 @@ public abstract class NotificationListenerService extends Service {
            return mIsConversation;
        }

        /**
         * @hide
         */
        public @Nullable ShortcutInfo getShortcutInfo() {
            return mShortcutInfo;
        }

        /**
         * @hide
         */
@@ -1849,7 +1862,7 @@ public abstract class NotificationListenerService extends Service {
                int userSentiment, boolean hidden, long lastAudiblyAlertedMs,
                boolean noisy, ArrayList<Notification.Action> smartActions,
                ArrayList<CharSequence> smartReplies, boolean canBubble,
                boolean visuallyInterruptive, boolean isConversation) {
                boolean visuallyInterruptive, boolean isConversation, ShortcutInfo shortcutInfo) {
            mKey = key;
            mRank = rank;
            mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW;
@@ -1872,6 +1885,7 @@ public abstract class NotificationListenerService extends Service {
            mCanBubble = canBubble;
            mVisuallyInterruptive = visuallyInterruptive;
            mIsConversation = isConversation;
            mShortcutInfo = shortcutInfo;
        }

        /**
@@ -1898,7 +1912,8 @@ public abstract class NotificationListenerService extends Service {
                    other.mSmartReplies,
                    other.mCanBubble,
                    other.mVisuallyInterruptive,
                    other.mIsConversation);
                    other.mIsConversation,
                    other.mShortcutInfo);
        }

        /**
@@ -1952,7 +1967,10 @@ public abstract class NotificationListenerService extends Service {
                    && Objects.equals(mSmartReplies, other.mSmartReplies)
                    && Objects.equals(mCanBubble, other.mCanBubble)
                    && Objects.equals(mVisuallyInterruptive, other.mVisuallyInterruptive)
                    && Objects.equals(mIsConversation, other.mIsConversation);
                    && Objects.equals(mIsConversation, other.mIsConversation)
                    // Shortcutinfo doesn't have equals either; use id
                    &&  Objects.equals((mShortcutInfo == null ? 0 : mShortcutInfo.getId()),
                    (other.mShortcutInfo == null ? 0 : other.mShortcutInfo.getId()));
        }
    }

+3 −3
Original line number Diff line number Diff line
@@ -68,14 +68,14 @@ public interface NotificationPersonExtractorPlugin extends Plugin {
        public final String key;
        public final CharSequence name;
        public final Drawable avatar;
        public final PendingIntent clickIntent;
        public final Runnable clickRunnable;

        public PersonData(String key, CharSequence name, Drawable avatar,
                PendingIntent clickIntent) {
                Runnable clickRunnable) {
            this.key = key;
            this.name = name;
            this.avatar = avatar;
            this.clickIntent = clickIntent;
            this.clickRunnable = clickRunnable;
        }
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -71,7 +71,8 @@ public class ForegroundServiceNotificationListener {
            public void onEntryRemoved(
                    NotificationEntry entry,
                    NotificationVisibility visibility,
                    boolean removedByUser) {
                    boolean removedByUser,
                    int reason) {
                removeNotification(entry.getSbn());
            }
        });
+2 −1
Original line number Diff line number Diff line
@@ -425,7 +425,8 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
                    public void onEntryRemoved(
                            NotificationEntry entry,
                            @android.annotation.Nullable NotificationVisibility visibility,
                            boolean removedByUser) {
                            boolean removedByUser,
                            int reason) {
                        BubbleController.this.onEntryRemoved(entry);
                    }

+14 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import android.app.trust.TrustManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.IPackageManager;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.hardware.SensorPrivacyManager;
import android.media.AudioManager;
@@ -167,6 +169,12 @@ public class SystemServicesModule {
        return LatencyTracker.getInstance(context);
    }

    @Singleton
    @Provides
    static LauncherApps provideLauncherApps(Context context) {
        return context.getSystemService(LauncherApps.class);
    }

    @SuppressLint("MissingPermission")
    @Singleton
    @Provides
@@ -182,6 +190,12 @@ public class SystemServicesModule {
        return context.getSystemService(NotificationManager.class);
    }

    @Singleton
    @Provides
    static PackageManager providePackageManager(Context context) {
        return context.getPackageManager();
    }

    @Singleton
    @Provides
    static PackageManagerWrapper providePackageManagerWrapper() {
Loading