Update existing ECM settings to use new infrastructure

1. Update Notification Listener and A11y settings to call
   RestrictedLockUtilsInternal rather than checking appOp themselves

2. Rename ecm related methods to include Ecm rather than AppOp -
   implementation details are being moved to permissions module and may
   change.

Bug: 297372999
Test: Manually tested on device. Automaated tests to follow
Change-Id: Ie3e16b502993b21a7e34eab0d661f98814b3cfd5
This commit is contained in:
Hani Kazmi
2023-11-01 16:16:10 +00:00
parent 291e6043bf
commit ded1cd59c9
3 changed files with 52 additions and 2 deletions

View File

@@ -234,6 +234,32 @@ public class RestrictedPreferenceHelper {
// permittedServices null means all accessibility services are allowed.
boolean serviceAllowed = permittedServices == null || permittedServices.contains(
preference.getPackageName());
if (android.security.Flags.extendEcmToAllSettings()) {
preference.checkEcmRestrictionAndSetDisabled(
AppOpsManager.OPSTR_BIND_ACCESSIBILITY_SERVICE,
preference.getPackageName(), preference.getUid());
if (preference.isDisabledByEcm()) {
serviceAllowed = false;
}
if (serviceAllowed || serviceEnabled) {
preference.setEnabled(true);
} else {
// Disable accessibility service that are not permitted.
final RestrictedLockUtils.EnforcedAdmin admin =
RestrictedLockUtilsInternal.checkIfAccessibilityServiceDisallowed(
mContext, preference.getPackageName(), UserHandle.myUserId());
if (admin != null) {
preference.setDisabledByAdmin(admin);
} else if (!preference.isDisabledByEcm()) {
preference.setEnabled(false);
}
}
return;
}
boolean appOpsAllowed;
if (serviceAllowed) {
try {