Don't hide approved NLSes in Settings am: ff255c6eda
am: 50df60c93c
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23563580 Change-Id: I840d7836ae899bcd40eafc772b96c9460c3f8a02 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -40,6 +40,7 @@ import android.widget.Toast;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.AppInfoBase;
|
||||
@@ -60,8 +61,8 @@ import java.util.List;
|
||||
@SearchIndexable
|
||||
public class NotificationAccessSettings extends EmptyTextSettings {
|
||||
private static final String TAG = "NotifAccessSettings";
|
||||
private static final String ALLOWED_KEY = "allowed";
|
||||
private static final String NOT_ALLOWED_KEY = "not_allowed";
|
||||
static final String ALLOWED_KEY = "allowed";
|
||||
static final String NOT_ALLOWED_KEY = "not_allowed";
|
||||
private static final int MAX_CN_LENGTH = 500;
|
||||
|
||||
private static final ManagedServiceSettings.Config CONFIG =
|
||||
@@ -77,9 +78,9 @@ public class NotificationAccessSettings extends EmptyTextSettings {
|
||||
.setEmptyText(R.string.no_notification_listeners)
|
||||
.build();
|
||||
|
||||
private NotificationManager mNm;
|
||||
@VisibleForTesting NotificationManager mNm;
|
||||
protected Context mContext;
|
||||
private PackageManager mPm;
|
||||
@VisibleForTesting PackageManager mPm;
|
||||
private DevicePolicyManager mDpm;
|
||||
private ServiceListing mServiceListing;
|
||||
private IconDrawableFactory mIconDrawableFactory;
|
||||
@@ -99,12 +100,6 @@ public class NotificationAccessSettings extends EmptyTextSettings {
|
||||
.setNoun(CONFIG.noun)
|
||||
.setSetting(CONFIG.setting)
|
||||
.setTag(CONFIG.tag)
|
||||
.setValidator(info -> {
|
||||
if (info.getComponentName().flattenToString().length() > MAX_CN_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.build();
|
||||
mServiceListing.addCallback(this::updateList);
|
||||
|
||||
@@ -135,7 +130,8 @@ public class NotificationAccessSettings extends EmptyTextSettings {
|
||||
mServiceListing.setListening(false);
|
||||
}
|
||||
|
||||
private void updateList(List<ServiceInfo> services) {
|
||||
@VisibleForTesting
|
||||
void updateList(List<ServiceInfo> services) {
|
||||
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
final int managedProfileId = Utils.getManagedProfileId(um, UserHandle.myUserId());
|
||||
|
||||
@@ -148,6 +144,11 @@ public class NotificationAccessSettings extends EmptyTextSettings {
|
||||
services.sort(new PackageItemInfo.DisplayNameComparator(mPm));
|
||||
for (ServiceInfo service : services) {
|
||||
final ComponentName cn = new ComponentName(service.packageName, service.name);
|
||||
boolean isAllowed = mNm.isNotificationListenerAccessGranted(cn);
|
||||
if (!isAllowed && cn.flattenToString().length() > MAX_CN_LENGTH) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CharSequence title = null;
|
||||
try {
|
||||
title = mPm.getApplicationInfoAsUser(
|
||||
@@ -192,7 +193,7 @@ public class NotificationAccessSettings extends EmptyTextSettings {
|
||||
return true;
|
||||
});
|
||||
pref.setKey(cn.flattenToString());
|
||||
if (mNm.isNotificationListenerAccessGranted(cn)) {
|
||||
if (isAllowed) {
|
||||
allowedCategory.addPreference(pref);
|
||||
} else {
|
||||
notAllowedCategory.addPreference(pref);
|
||||
|
@@ -143,6 +143,9 @@ public class NotificationBackend {
|
||||
|
||||
static public CharSequence getDeviceList(ICompanionDeviceManager cdm, LocalBluetoothManager lbm,
|
||||
String pkg, int userId) {
|
||||
if (cdm == null) {
|
||||
return "";
|
||||
}
|
||||
boolean multiple = false;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
Reference in New Issue
Block a user