summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2020-02-26 11:17:39 -0500
committerJulia Reynolds <juliacr@google.com>2020-02-28 02:48:07 +0000
commit138111fca358f4e5354b772aaa90cfc2bc0e2548 (patch)
treeb646c51a513faf3f6db1103399b8e5459868ffde /core/java/android
parentccf72664db882caaf5588e5d67a766d9f1930b97 (diff)
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
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/service/notification/NotificationListenerService.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 6562572d0121..0cd96b8ea688 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -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);
}
@@ -1840,6 +1846,13 @@ public abstract class NotificationListenerService extends Service {
/**
* @hide
*/
+ public @Nullable ShortcutInfo getShortcutInfo() {
+ return mShortcutInfo;
+ }
+
+ /**
+ * @hide
+ */
@VisibleForTesting
public void populate(String key, int rank, boolean matchesInterruptionFilter,
int visibilityOverride, int suppressedVisualEffects, int importance,
@@ -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()));
}
}