Wired remaining SpecialAppAccess for ECM.

This change enables the remaining settings for ECM, and adds tests for
both this and previous ECM changes.

Bug: 297372999
Test: Tested on device
Test: atest SpaPrivilegedLibTests
Test: atest com.android.settings.applications.specialaccess.notificationaccess
Test: atest com.android.settings.datausage
Test: atest PremiumSmsAccessTest
Test: atest RestrictedPreferenceHelperTest
Change-Id: I73d39d765dba0c1a75111c37b29ccf1c85d2cdd8
This commit is contained in:
Hani Kazmi
2023-11-10 16:19:51 +00:00
parent 73b273d781
commit 96ab2b9e25
11 changed files with 343 additions and 14 deletions

View File

@@ -72,10 +72,18 @@ public class RestrictedAppPreference extends AppPreference {
@Override
public void setEnabled(boolean enabled) {
if (isDisabledByAdmin() && enabled) {
return;
boolean changed = false;
if (enabled && isDisabledByAdmin()) {
mHelper.setDisabledByAdmin(null);
changed = true;
}
if (enabled && isDisabledByEcm()) {
mHelper.setDisabledByEcm(null);
changed = true;
}
if (!changed) {
super.setEnabled(enabled);
}
super.setEnabled(enabled);
}
public void setDisabledByAdmin(RestrictedLockUtils.EnforcedAdmin admin) {
@@ -88,6 +96,10 @@ public class RestrictedAppPreference extends AppPreference {
return mHelper.isDisabledByAdmin();
}
public boolean isDisabledByEcm() {
return mHelper.isDisabledByEcm();
}
public void useAdminDisabledSummary(boolean useSummary) {
mHelper.useAdminDisabledSummary(useSummary);
}
@@ -112,4 +124,15 @@ public class RestrictedAppPreference extends AppPreference {
public void checkRestrictionAndSetDisabled(String userRestriction, int userId) {
mHelper.checkRestrictionAndSetDisabled(userRestriction, userId);
}
/**
* Checks if the given setting is subject to Enhanced Confirmation Mode restrictions for this
* package. Marks the preference as disabled if so.
* @param restriction The key identifying the setting
* @param packageName the package to check the restriction for
* @param uid the uid of the package
*/
public void checkEcmRestrictionAndSetDisabled(String restriction, String packageName, int uid) {
mHelper.checkEcmRestrictionAndSetDisabled(restriction, packageName, uid);
}
}