diff --git a/api/current.txt b/api/current.txt index 2453b6722995e..970cf6d14303d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5974,6 +5974,7 @@ package android.app { method public long[] getVibrationPattern(); method public boolean hasUserSetImportance(); method public boolean hasUserSetSound(); + method public boolean isConversation(); method public boolean isDemoted(); method public boolean isImportantConversation(); method public void setAllowBubbles(boolean); diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index e68087f3ad555..accec30d037d4 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -4280,9 +4280,16 @@ message NotificationChannelModified { optional android.stats.sysui.NotificationImportance old_importance = 5; // New importance setting optional android.stats.sysui.NotificationImportance importance = 6; + // whether or not this channel represents a conversation + optional bool is_conversation = 7; + // Hash of app-assigned notification conversation id + optional int32 conversation_id_hash = 8; + // whether or not the user demoted this channel out of the conversation space + optional bool is_conversation_demoted = 9; + // whether this conversation is marked as being a priority + optional bool is_conversation_priority = 10; } - /** * Logs when a biometric acquire event occurs. * diff --git a/core/api/current.txt b/core/api/current.txt index 0516f6303960e..5215d58a35325 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -5974,6 +5974,7 @@ package android.app { method public long[] getVibrationPattern(); method public boolean hasUserSetImportance(); method public boolean hasUserSetSound(); + method public boolean isConversation(); method public boolean isDemoted(); method public boolean isImportantConversation(); method public void setAllowBubbles(boolean); diff --git a/core/java/android/app/NotificationChannel.java b/core/java/android/app/NotificationChannel.java index a06ffbdb43011..080aac9a9e6a9 100644 --- a/core/java/android/app/NotificationChannel.java +++ b/core/java/android/app/NotificationChannel.java @@ -628,13 +628,21 @@ public final class NotificationChannel implements Parcelable { return mBypassDnd; } + /** + * Whether or not this channel represents a conversation. + */ + public boolean isConversation() { + return !TextUtils.isEmpty(getConversationId()); + } + + /** * Whether or not notifications in this conversation are considered important. * *

Important conversations may get special visual treatment, and might be able to bypass DND. * - *

This is only valid for channels that represent conversations, that is, those with a valid - * {@link #getConversationId() conversation id}. + *

This is only valid for channels that represent conversations, that is, + * where {@link #isConversation()} is true. */ public boolean isImportantConversation() { return mImportantConvo; diff --git a/services/core/java/com/android/server/notification/NotificationChannelLogger.java b/services/core/java/com/android/server/notification/NotificationChannelLogger.java index 51faac76c447c..36eec26511c3a 100644 --- a/services/core/java/com/android/server/notification/NotificationChannelLogger.java +++ b/services/core/java/com/android/server/notification/NotificationChannelLogger.java @@ -214,6 +214,13 @@ public interface NotificationChannelLogger { return SmallHash.hash(channel.getId()); } + /** + * @return Small hash of the conversation ID, if present, or 0 otherwise. + */ + static int getConversationIdHash(@NonNull NotificationChannel channel) { + return SmallHash.hash(channel.getConversationId()); + } + /** * @return Small hash of the channel ID, if present, or 0 otherwise. */ diff --git a/services/core/java/com/android/server/notification/NotificationChannelLoggerImpl.java b/services/core/java/com/android/server/notification/NotificationChannelLoggerImpl.java index fd3dd568f6341..5a7bc48091bba 100644 --- a/services/core/java/com/android/server/notification/NotificationChannelLoggerImpl.java +++ b/services/core/java/com/android/server/notification/NotificationChannelLoggerImpl.java @@ -41,7 +41,12 @@ public class NotificationChannelLoggerImpl implements NotificationChannelLogger /* String package_name */ pkg, /* int32 channel_id_hash */ NotificationChannelLogger.getIdHash(channel), /* int old_importance*/ oldImportance, - /* int importance*/ newImportance); + /* int importance*/ newImportance, + /* bool is_conversation */ channel.isConversation(), + /* int32 conversation_id_hash */ + NotificationChannelLogger.getConversationIdHash(channel), + /* bool is_conversation_demoted */ channel.isDemoted(), + /* bool is_conversation_priority */ channel.isImportantConversation()); } @Override @@ -53,7 +58,11 @@ public class NotificationChannelLoggerImpl implements NotificationChannelLogger /* String package_name */ pkg, /* int32 channel_id_hash */ NotificationChannelLogger.getIdHash(channelGroup), /* int old_importance*/ NotificationChannelLogger.getImportance(wasBlocked), - /* int importance*/ NotificationChannelLogger.getImportance(channelGroup)); + /* int importance*/ NotificationChannelLogger.getImportance(channelGroup), + /* bool is_conversation */ false, + /* int32 conversation_id_hash */ 0, + /* bool is_conversation_demoted */ false, + /* bool is_conversation_priority */ false); } @Override