Settings: don't try to allow NLSes with too-long component names am: f1af8c5292
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23726246 Change-Id: Iaf37229e9570c29792e801446e8db162ebb3dbda Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -181,7 +181,10 @@ public class NotificationAccessDetails extends AppInfoBase {
|
|||||||
|
|
||||||
public void updatePreference(SwitchPreference preference) {
|
public void updatePreference(SwitchPreference preference) {
|
||||||
final CharSequence label = mPackageInfo.applicationInfo.loadLabel(mPm);
|
final CharSequence label = mPackageInfo.applicationInfo.loadLabel(mPm);
|
||||||
|
final boolean isAllowedCn = mComponentName.flattenToShortString().length()
|
||||||
|
<= NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH;
|
||||||
preference.setChecked(isServiceEnabled(mComponentName));
|
preference.setChecked(isServiceEnabled(mComponentName));
|
||||||
|
preference.setEnabled(preference.isChecked() || isAllowedCn);
|
||||||
preference.setOnPreferenceChangeListener((p, newValue) -> {
|
preference.setOnPreferenceChangeListener((p, newValue) -> {
|
||||||
final boolean access = (Boolean) newValue;
|
final boolean access = (Boolean) newValue;
|
||||||
if (!access) {
|
if (!access) {
|
||||||
|
@@ -67,7 +67,9 @@ public class NotificationAccessConfirmationActivity extends Activity
|
|||||||
mUserId = getIntent().getIntExtra(EXTRA_USER_ID, UserHandle.USER_NULL);
|
mUserId = getIntent().getIntExtra(EXTRA_USER_ID, UserHandle.USER_NULL);
|
||||||
CharSequence mAppLabel;
|
CharSequence mAppLabel;
|
||||||
|
|
||||||
if (mComponentName == null || mComponentName.getPackageName() == null) {
|
if (mComponentName == null || mComponentName.getPackageName() == null
|
||||||
|
|| mComponentName.flattenToString().length()
|
||||||
|
> NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -58,8 +58,6 @@ import java.util.List;
|
|||||||
public class NotificationAccessSettings extends EmptyTextSettings {
|
public class NotificationAccessSettings extends EmptyTextSettings {
|
||||||
private static final String TAG = "NotifAccessSettings";
|
private static final String TAG = "NotifAccessSettings";
|
||||||
|
|
||||||
private static final int MAX_CN_LENGTH = 500;
|
|
||||||
|
|
||||||
private static final ManagedServiceSettings.Config CONFIG =
|
private static final ManagedServiceSettings.Config CONFIG =
|
||||||
new ManagedServiceSettings.Config.Builder()
|
new ManagedServiceSettings.Config.Builder()
|
||||||
.setTag(TAG)
|
.setTag(TAG)
|
||||||
@@ -135,7 +133,8 @@ public class NotificationAccessSettings extends EmptyTextSettings {
|
|||||||
for (ServiceInfo service : services) {
|
for (ServiceInfo service : services) {
|
||||||
final ComponentName cn = new ComponentName(service.packageName, service.name);
|
final ComponentName cn = new ComponentName(service.packageName, service.name);
|
||||||
boolean isAllowed = mNm.isNotificationListenerAccessGranted(cn);
|
boolean isAllowed = mNm.isNotificationListenerAccessGranted(cn);
|
||||||
if (!isAllowed && cn.flattenToString().length() > MAX_CN_LENGTH) {
|
if (!isAllowed && cn.flattenToString().length()
|
||||||
|
> NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user