summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-05-19 06:51:54 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-05-19 06:51:54 +0000
commit1d867453cacf01eb855e95e56fc7d424565e100f (patch)
tree49edce5d55dc94ca0b5ab4f1f4cd3f0c2859cc20
parent54f0b9e24cdd9ec9a059de03671ed7693177c9f2 (diff)
parent07cb6a4b23524ba7822a3e4da3bef5af89d1511b (diff)
Merge "add conversation flags to channel atom" into rvc-dev
-rw-r--r--cmds/statsd/src/atoms.proto6
-rw-r--r--services/core/java/com/android/server/notification/PreferencesHelper.java3
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java27
3 files changed, 36 insertions, 0 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 98441204532f..8ba52ef06c44 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -6032,6 +6032,12 @@ message PackageNotificationChannelPreferences {
optional int32 user_locked_fields = 6;
// Indicates if the channel was deleted by the app.
optional bool is_deleted = 7;
+ // Indicates if the channel was marked as a conversation by the app.
+ optional bool is_conversation = 8;
+ // Indicates if the channel is a conversation that was demoted by the user.
+ optional bool is_demoted_conversation = 9;
+ // Indicates if the channel is a conversation that was marked as important by the user.
+ optional bool is_important_conversation = 10;
}
/**
diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java
index 38c65f11a717..9d56d817440b 100644
--- a/services/core/java/com/android/server/notification/PreferencesHelper.java
+++ b/services/core/java/com/android/server/notification/PreferencesHelper.java
@@ -1936,6 +1936,9 @@ public class PreferencesHelper implements RankingConfig {
event.writeInt(channel.getImportance());
event.writeInt(channel.getUserLockedFields());
event.writeBoolean(channel.isDeleted());
+ event.writeBoolean(channel.getConversationId() != null);
+ event.writeBoolean(channel.isDemoted());
+ event.writeBoolean(channel.isImportantConversation());
events.add(event.build());
}
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
index f4e5d569512a..078c21e04512 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
@@ -81,6 +81,7 @@ import android.testing.TestableContentResolver;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Pair;
+import android.util.StatsEvent;
import android.util.Xml;
import androidx.test.InstrumentationRegistry;
@@ -89,6 +90,7 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.internal.util.FastXmlSerializer;
import com.android.server.UiServiceTestCase;
+
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Before;
@@ -2996,6 +2998,31 @@ public class PreferencesHelperTest extends UiServiceTestCase {
PKG_O, UID_O, parent.getId(), conversationId, false, false), conversationId);
}
+
+ @Test
+ public void testPullConversationNotificationChannel() {
+ String conversationId = "friend";
+
+ NotificationChannel parent =
+ new NotificationChannel("parent", "messages", IMPORTANCE_DEFAULT);
+ mHelper.createNotificationChannel(PKG_O, UID_O, parent, true, false);
+
+ String channelId = String.format(
+ CONVERSATION_CHANNEL_ID_FORMAT, parent.getId(), conversationId);
+ NotificationChannel friend = new NotificationChannel(channelId,
+ "messages", IMPORTANCE_DEFAULT);
+ friend.setConversationId(parent.getId(), conversationId);
+ mHelper.createNotificationChannel(PKG_O, UID_O, friend, true, false);
+ ArrayList<StatsEvent> events = new ArrayList<>();
+ mHelper.pullPackageChannelPreferencesStats(events);
+ boolean found = false;
+ for (StatsEvent event : events) {
+ // TODO(b/153195691): inspect the content once it is possible to do so
+ found = true;
+ }
+ assertTrue("conversation was not in the pull", found);
+ }
+
@Test
public void testGetNotificationChannel_conversationProvidedByNotCustomizedYet() {
String conversationId = "friend";