Merge "Update the notification_assistant DeviceConfig namespace."
diff --git a/api/system-current.txt b/api/system-current.txt
index 8255a3d..e204048 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -5784,7 +5784,6 @@
field public static final String NAMESPACE_GAME_DRIVER = "game_driver";
field public static final String NAMESPACE_INPUT_NATIVE_BOOT = "input_native_boot";
field public static final String NAMESPACE_NETD_NATIVE = "netd_native";
- field public static final String NAMESPACE_NOTIFICATION_ASSISTANT = "notification_assistant";
}
public static interface DeviceConfig.ActivityManager {
@@ -5821,6 +5820,12 @@
field public static final String PROPERTY_ATTENTION_SETTINGS = "attention_settings";
}
+ public static interface DeviceConfig.NotificationAssistant {
+ field public static final String GENERATE_ACTIONS = "generate_actions";
+ field public static final String GENERATE_REPLIES = "generate_replies";
+ field public static final String NAMESPACE = "notification_assistant";
+ }
+
public static interface DeviceConfig.OnPropertyChangedListener {
method public void onPropertyChanged(String, String, String);
}
diff --git a/core/java/android/provider/DeviceConfig.java b/core/java/android/provider/DeviceConfig.java
index bc7129d..b6653b5 100644
--- a/core/java/android/provider/DeviceConfig.java
+++ b/core/java/android/provider/DeviceConfig.java
@@ -135,7 +135,17 @@
* @hide
*/
@SystemApi
- public static final String NAMESPACE_NOTIFICATION_ASSISTANT = "notification_assistant";
+ public interface NotificationAssistant {
+ String NAMESPACE = "notification_assistant";
+ /**
+ * Whether the Notification Assistant should generate replies for notifications.
+ */
+ String GENERATE_REPLIES = "generate_replies";
+ /**
+ * Whether the Notification Assistant should generate contextual actions for notifications.
+ */
+ String GENERATE_ACTIONS = "generate_actions";
+ }
/**
* Namespace for attention-based features provided by on-device machine intelligence.
diff --git a/packages/ExtServices/src/android/ext/services/notification/AssistantSettings.java b/packages/ExtServices/src/android/ext/services/notification/AssistantSettings.java
index 406b44d..d99c356 100644
--- a/packages/ExtServices/src/android/ext/services/notification/AssistantSettings.java
+++ b/packages/ExtServices/src/android/ext/services/notification/AssistantSettings.java
@@ -46,24 +46,6 @@
private static final Uri NOTIFICATION_NEW_INTERRUPTION_MODEL_URI =
Settings.Secure.getUriFor(Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL);
- /**
- * Flag determining whether the Notification Assistant should generate replies for
- * notifications.
- * <p>
- * This flag belongs to the namespace: {@link DeviceConfig#NAMESPACE_NOTIFICATION_ASSISTANT}.
- */
- @VisibleForTesting
- static final String KEY_GENERATE_REPLIES = "notification_assistant_generate_replies";
-
- /**
- * Flag determining whether the Notification Assistant should generate contextual actions in
- * notifications.
- * <p>
- * This flag belongs to the namespace: {@link DeviceConfig#NAMESPACE_NOTIFICATION_ASSISTANT}.
- */
- @VisibleForTesting
- static final String KEY_GENERATE_ACTIONS = "notification_assistant_generate_actions";
-
private final KeyValueListParser mParser = new KeyValueListParser(',');
private final ContentResolver mResolver;
private final int mUserId;
@@ -118,7 +100,7 @@
private void registerDeviceConfigs() {
DeviceConfig.addOnPropertyChangedListener(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
+ DeviceConfig.NotificationAssistant.NAMESPACE,
this::postToHandler,
this::onDeviceConfigPropertyChanged);
@@ -132,7 +114,7 @@
@VisibleForTesting
void onDeviceConfigPropertyChanged(String namespace, String name, String value) {
- if (!DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT.equals(namespace)) {
+ if (!DeviceConfig.NotificationAssistant.NAMESPACE.equals(namespace)) {
Log.e(LOG_TAG, "Received update from DeviceConfig for unrelated namespace: "
+ namespace + " " + name + "=" + value);
return;
@@ -143,8 +125,8 @@
private void updateFromDeviceConfigFlags() {
String generateRepliesFlag = DeviceConfig.getProperty(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
- KEY_GENERATE_REPLIES);
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_REPLIES);
if (TextUtils.isEmpty(generateRepliesFlag)) {
mGenerateReplies = DEFAULT_GENERATE_REPLIES;
} else {
@@ -154,8 +136,8 @@
}
String generateActionsFlag = DeviceConfig.getProperty(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
- KEY_GENERATE_ACTIONS);
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_ACTIONS);
if (TextUtils.isEmpty(generateActionsFlag)) {
mGenerateActions = DEFAULT_GENERATE_ACTIONS;
} else {
diff --git a/packages/ExtServices/tests/src/android/ext/services/notification/AssistantSettingsTest.java b/packages/ExtServices/tests/src/android/ext/services/notification/AssistantSettingsTest.java
index 51b723d..597051a 100644
--- a/packages/ExtServices/tests/src/android/ext/services/notification/AssistantSettingsTest.java
+++ b/packages/ExtServices/tests/src/android/ext/services/notification/AssistantSettingsTest.java
@@ -71,9 +71,14 @@
@Test
public void testGenerateRepliesDisabled() {
+ DeviceConfig.setProperty(
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_REPLIES,
+ "false",
+ false /* makeDefault */);
mAssistantSettings.onDeviceConfigPropertyChanged(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
- AssistantSettings.KEY_GENERATE_REPLIES,
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_REPLIES,
"false");
assertFalse(mAssistantSettings.mGenerateReplies);
@@ -81,9 +86,14 @@
@Test
public void testGenerateRepliesEnabled() {
+ DeviceConfig.setProperty(
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_REPLIES,
+ "true",
+ false /* makeDefault */);
mAssistantSettings.onDeviceConfigPropertyChanged(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
- AssistantSettings.KEY_GENERATE_REPLIES,
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_REPLIES,
"true");
assertTrue(mAssistantSettings.mGenerateReplies);
@@ -91,16 +101,26 @@
@Test
public void testGenerateRepliesEmptyFlag() {
+ DeviceConfig.setProperty(
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_REPLIES,
+ "false",
+ false /* makeDefault */);
mAssistantSettings.onDeviceConfigPropertyChanged(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
- AssistantSettings.KEY_GENERATE_REPLIES,
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_REPLIES,
"false");
assertFalse(mAssistantSettings.mGenerateReplies);
+ DeviceConfig.setProperty(
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_REPLIES,
+ "",
+ false /* makeDefault */);
mAssistantSettings.onDeviceConfigPropertyChanged(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
- AssistantSettings.KEY_GENERATE_REPLIES,
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_REPLIES,
"");
// Go back to the default value.
@@ -109,9 +129,14 @@
@Test
public void testGenerateActionsDisabled() {
+ DeviceConfig.setProperty(
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_ACTIONS,
+ "false",
+ false /* makeDefault */);
mAssistantSettings.onDeviceConfigPropertyChanged(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
- AssistantSettings.KEY_GENERATE_ACTIONS,
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_ACTIONS,
"false");
assertFalse(mAssistantSettings.mGenerateActions);
@@ -119,9 +144,14 @@
@Test
public void testGenerateActionsEnabled() {
+ DeviceConfig.setProperty(
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_ACTIONS,
+ "true",
+ false /* makeDefault */);
mAssistantSettings.onDeviceConfigPropertyChanged(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
- AssistantSettings.KEY_GENERATE_ACTIONS,
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_ACTIONS,
"true");
assertTrue(mAssistantSettings.mGenerateActions);
@@ -129,16 +159,26 @@
@Test
public void testGenerateActionsEmptyFlag() {
+ DeviceConfig.setProperty(
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_ACTIONS,
+ "false",
+ false /* makeDefault */);
mAssistantSettings.onDeviceConfigPropertyChanged(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
- AssistantSettings.KEY_GENERATE_ACTIONS,
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_ACTIONS,
"false");
assertFalse(mAssistantSettings.mGenerateActions);
+ DeviceConfig.setProperty(
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_ACTIONS,
+ "",
+ false /* makeDefault */);
mAssistantSettings.onDeviceConfigPropertyChanged(
- DeviceConfig.NAMESPACE_NOTIFICATION_ASSISTANT,
- AssistantSettings.KEY_GENERATE_ACTIONS,
+ DeviceConfig.NotificationAssistant.NAMESPACE,
+ DeviceConfig.NotificationAssistant.GENERATE_ACTIONS,
"");
// Go back to the default value.