Merge "Handle NLS metadata when provided as strings" into sc-dev am: 333b68d059
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14470497 Change-Id: I5451f21c6519f20050e981ab868f233adeefb393
This commit is contained in:
@@ -16,6 +16,11 @@
|
||||
|
||||
package com.android.settings.applications.specialaccess.notificationaccess;
|
||||
|
||||
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ALERTING;
|
||||
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_CONVERSATIONS;
|
||||
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ONGOING;
|
||||
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_SILENT;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ServiceInfo;
|
||||
@@ -129,13 +134,24 @@ public abstract class TypeFilterPreferenceController extends BasePreferenceContr
|
||||
int types = 0;
|
||||
String[] typeStrings = typeList.split(XML_SEPARATOR);
|
||||
for (int i = 0; i < typeStrings.length; i++) {
|
||||
if (TextUtils.isEmpty(typeStrings[i])) {
|
||||
final String typeString = typeStrings[i];
|
||||
if (TextUtils.isEmpty(typeString)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
types |= Integer.parseInt(typeStrings[i]);
|
||||
} catch (NumberFormatException e) {
|
||||
// skip
|
||||
if (typeString.equalsIgnoreCase("ONGOING")) {
|
||||
types |= FLAG_FILTER_TYPE_ONGOING;
|
||||
} else if (typeString.equalsIgnoreCase("CONVERSATIONS")) {
|
||||
types |= FLAG_FILTER_TYPE_CONVERSATIONS;
|
||||
} else if (typeString.equalsIgnoreCase("SILENT")) {
|
||||
types |= FLAG_FILTER_TYPE_SILENT;
|
||||
} else if (typeString.equalsIgnoreCase("ALERTING")) {
|
||||
types |= FLAG_FILTER_TYPE_ALERTING;
|
||||
} else {
|
||||
try {
|
||||
types |= Integer.parseInt(typeString);
|
||||
} catch (NumberFormatException e) {
|
||||
// skip
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasFlag(types, getType())) {
|
||||
|
@@ -152,7 +152,7 @@ public class TypeFilterPreferenceControllerTest {
|
||||
public void updateState_enabled_metaData_disableFilter_notThisField() {
|
||||
mSi.metaData = new Bundle();
|
||||
mSi.metaData.putCharSequence(NotificationListenerService.META_DATA_DISABLED_FILTER_TYPES,
|
||||
"1,2");
|
||||
"1,alerting");
|
||||
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);
|
||||
when(mNm.getListenerFilter(mCn, 0)).thenReturn(new NotificationListenerFilter());
|
||||
CheckBoxPreference pref = new CheckBoxPreference(mContext);
|
||||
@@ -165,7 +165,7 @@ public class TypeFilterPreferenceControllerTest {
|
||||
public void updateState_enabled_metaData_disableFilter_thisField_stateIsChecked() {
|
||||
mSi.metaData = new Bundle();
|
||||
mSi.metaData.putCharSequence(NotificationListenerService.META_DATA_DISABLED_FILTER_TYPES,
|
||||
"1,2,32");
|
||||
"conversations,2,32");
|
||||
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);
|
||||
when(mNm.getListenerFilter(mCn, 0)).thenReturn(
|
||||
new NotificationListenerFilter(32, new ArraySet<>()));
|
||||
|
Reference in New Issue
Block a user