Update Bridged app link when NLS access changes

Test: BridgedAppsLinkPreferenceControllerTest
Test: manual; turn an NLS on/off, verify correct disabled state for fields
Fixes: 240461761
Change-Id: Ib5a5365f7477c2a8d620ced2af96ace364b292e2
This commit is contained in:
Julia Reynolds
2022-08-15 13:41:44 -04:00
parent ec740c30d5
commit 2a61b3656b
3 changed files with 31 additions and 12 deletions

View File

@@ -18,10 +18,11 @@ import android.content.Context;
import android.os.Build;
import android.service.notification.NotificationListenerFilter;
import androidx.preference.Preference;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.notification.NotificationBackend;
public class BridgedAppsLinkPreferenceController extends BasePreferenceController {
private ComponentName mCn;
@@ -61,7 +62,6 @@ public class BridgedAppsLinkPreferenceController extends BasePreferenceControlle
if (mTargetSdk > Build.VERSION_CODES.S) {
return AVAILABLE;
}
mNlf = mNm.getListenerFilter(mCn, mUserId);
if (!mNlf.areAllTypesAllowed() || !mNlf.getDisallowedPackages().isEmpty()) {
return AVAILABLE;
@@ -69,4 +69,10 @@ public class BridgedAppsLinkPreferenceController extends BasePreferenceControlle
}
return DISABLED_DEPENDENT_SETTING;
}
@Override
public void updateState(Preference pref) {
pref.setEnabled(getAvailabilityStatus() == AVAILABLE);
super.updateState(pref);
}
}

View File

@@ -233,11 +233,7 @@ public class NotificationAccessDetails extends DashboardFragment {
apc.updateState(screen.findPreference(apc.getPreferenceKey()));
getPreferenceControllers().forEach(controllers -> {
controllers.forEach(controller -> {
if (controller instanceof TypeFilterPreferenceController) {
TypeFilterPreferenceController tfpc =
(TypeFilterPreferenceController) controller;
tfpc.updateState(screen.findPreference(tfpc.getPreferenceKey()));
}
controller.updateState(screen.findPreference(controller.getPreferenceKey()));
});
});
}
@@ -249,11 +245,7 @@ public class NotificationAccessDetails extends DashboardFragment {
apc.updateState(screen.findPreference(apc.getPreferenceKey()));
getPreferenceControllers().forEach(controllers -> {
controllers.forEach(controller -> {
if (controller instanceof TypeFilterPreferenceController) {
TypeFilterPreferenceController tfpc =
(TypeFilterPreferenceController) controller;
tfpc.updateState(screen.findPreference(tfpc.getPreferenceKey()));
}
controller.updateState(screen.findPreference(controller.getPreferenceKey()));
});
});
}