Loading packages/ExtServices/src/android/ext/services/notification/AssistantSettings.java +4 −33 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.net.Uri; import android.os.Handler; import android.provider.DeviceConfig; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -128,17 +127,17 @@ final class AssistantSettings extends ContentObserver { } private void updateFromDeviceConfigFlags() { mGenerateReplies = DeviceConfigHelper.getBoolean( mGenerateReplies = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES, DEFAULT_GENERATE_REPLIES); mGenerateActions = DeviceConfigHelper.getBoolean( mGenerateActions = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS, DEFAULT_GENERATE_ACTIONS); mMaxMessagesToExtract = DeviceConfigHelper.getInteger( mMaxMessagesToExtract = DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_MAX_MESSAGES_TO_EXTRACT, DEFAULT_MAX_MESSAGES_TO_EXTRACT); mMaxSuggestions = DeviceConfigHelper.getInteger( mMaxSuggestions = DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_MAX_SUGGESTIONS, DEFAULT_MAX_SUGGESTIONS); mOnUpdateRunnable.run(); Loading Loading @@ -170,34 +169,6 @@ final class AssistantSettings extends ContentObserver { mOnUpdateRunnable.run(); } static class DeviceConfigHelper { static int getInteger(String key, int defaultValue) { String value = getValue(key); if (TextUtils.isEmpty(value)) { return defaultValue; } try { return Integer.parseInt(value); } catch (NumberFormatException ex) { return defaultValue; } } static boolean getBoolean(String key, boolean defaultValue) { String value = getValue(key); if (TextUtils.isEmpty(value)) { return defaultValue; } return Boolean.parseBoolean(value); } private static String getValue(String key) { return DeviceConfig.getProperty( DeviceConfig.NAMESPACE_SYSTEMUI, key); } } public interface Factory { AssistantSettings createAndRegister(Handler handler, ContentResolver resolver, int userId, Runnable onUpdateRunnable); Loading packages/ExtServices/tests/src/android/ext/services/notification/AssistantSettingsTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -120,7 +120,7 @@ public class AssistantSettingsTest { } @Test public void testGenerateRepliesEmptyFlag() { public void testGenerateRepliesNullFlag() { runWithShellPermissionIdentity(() -> setProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES, Loading @@ -136,12 +136,12 @@ public class AssistantSettingsTest { runWithShellPermissionIdentity(() -> setProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES, "", null, false /* makeDefault */)); mAssistantSettings.onDeviceConfigPropertyChanged( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES, ""); null); // Go back to the default value. assertTrue(mAssistantSettings.mGenerateReplies); Loading Loading @@ -178,7 +178,7 @@ public class AssistantSettingsTest { } @Test public void testGenerateActionsEmptyFlag() { public void testGenerateActionsNullFlag() { runWithShellPermissionIdentity(() -> setProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS, Loading @@ -194,12 +194,12 @@ public class AssistantSettingsTest { runWithShellPermissionIdentity(() -> setProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS, "", null, false /* makeDefault */)); mAssistantSettings.onDeviceConfigPropertyChanged( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS, ""); null); // Go back to the default value. assertTrue(mAssistantSettings.mGenerateActions); Loading Loading
packages/ExtServices/src/android/ext/services/notification/AssistantSettings.java +4 −33 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.net.Uri; import android.os.Handler; import android.provider.DeviceConfig; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -128,17 +127,17 @@ final class AssistantSettings extends ContentObserver { } private void updateFromDeviceConfigFlags() { mGenerateReplies = DeviceConfigHelper.getBoolean( mGenerateReplies = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES, DEFAULT_GENERATE_REPLIES); mGenerateActions = DeviceConfigHelper.getBoolean( mGenerateActions = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS, DEFAULT_GENERATE_ACTIONS); mMaxMessagesToExtract = DeviceConfigHelper.getInteger( mMaxMessagesToExtract = DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_MAX_MESSAGES_TO_EXTRACT, DEFAULT_MAX_MESSAGES_TO_EXTRACT); mMaxSuggestions = DeviceConfigHelper.getInteger( mMaxSuggestions = DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_MAX_SUGGESTIONS, DEFAULT_MAX_SUGGESTIONS); mOnUpdateRunnable.run(); Loading Loading @@ -170,34 +169,6 @@ final class AssistantSettings extends ContentObserver { mOnUpdateRunnable.run(); } static class DeviceConfigHelper { static int getInteger(String key, int defaultValue) { String value = getValue(key); if (TextUtils.isEmpty(value)) { return defaultValue; } try { return Integer.parseInt(value); } catch (NumberFormatException ex) { return defaultValue; } } static boolean getBoolean(String key, boolean defaultValue) { String value = getValue(key); if (TextUtils.isEmpty(value)) { return defaultValue; } return Boolean.parseBoolean(value); } private static String getValue(String key) { return DeviceConfig.getProperty( DeviceConfig.NAMESPACE_SYSTEMUI, key); } } public interface Factory { AssistantSettings createAndRegister(Handler handler, ContentResolver resolver, int userId, Runnable onUpdateRunnable); Loading
packages/ExtServices/tests/src/android/ext/services/notification/AssistantSettingsTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -120,7 +120,7 @@ public class AssistantSettingsTest { } @Test public void testGenerateRepliesEmptyFlag() { public void testGenerateRepliesNullFlag() { runWithShellPermissionIdentity(() -> setProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES, Loading @@ -136,12 +136,12 @@ public class AssistantSettingsTest { runWithShellPermissionIdentity(() -> setProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES, "", null, false /* makeDefault */)); mAssistantSettings.onDeviceConfigPropertyChanged( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES, ""); null); // Go back to the default value. assertTrue(mAssistantSettings.mGenerateReplies); Loading Loading @@ -178,7 +178,7 @@ public class AssistantSettingsTest { } @Test public void testGenerateActionsEmptyFlag() { public void testGenerateActionsNullFlag() { runWithShellPermissionIdentity(() -> setProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS, Loading @@ -194,12 +194,12 @@ public class AssistantSettingsTest { runWithShellPermissionIdentity(() -> setProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS, "", null, false /* makeDefault */)); mAssistantSettings.onDeviceConfigPropertyChanged( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS, ""); null); // Go back to the default value. assertTrue(mAssistantSettings.mGenerateActions); Loading