Merge "Update existing ECM settings to use new infrastructure" into main
This commit is contained in:
@@ -234,6 +234,32 @@ public class RestrictedPreferenceHelper {
|
|||||||
// permittedServices null means all accessibility services are allowed.
|
// permittedServices null means all accessibility services are allowed.
|
||||||
boolean serviceAllowed = permittedServices == null || permittedServices.contains(
|
boolean serviceAllowed = permittedServices == null || permittedServices.contains(
|
||||||
preference.getPackageName());
|
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;
|
boolean appOpsAllowed;
|
||||||
if (serviceAllowed) {
|
if (serviceAllowed) {
|
||||||
try {
|
try {
|
||||||
|
@@ -41,6 +41,8 @@ public class ApprovalPreferenceController extends BasePreferenceController {
|
|||||||
private PreferenceFragmentCompat mParent;
|
private PreferenceFragmentCompat mParent;
|
||||||
private NotificationManager mNm;
|
private NotificationManager mNm;
|
||||||
private PackageManager mPm;
|
private PackageManager mPm;
|
||||||
|
// The appOp representing this preference
|
||||||
|
private String mAppOpStr;
|
||||||
|
|
||||||
public ApprovalPreferenceController(Context context, String key) {
|
public ApprovalPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
@@ -71,6 +73,14 @@ public class ApprovalPreferenceController extends BasePreferenceController {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the associated appOp for the Setting
|
||||||
|
*/
|
||||||
|
public ApprovalPreferenceController setAppOpStr(String appOpStr) {
|
||||||
|
mAppOpStr = appOpStr;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return AVAILABLE;
|
return AVAILABLE;
|
||||||
@@ -107,8 +117,20 @@ public class ApprovalPreferenceController extends BasePreferenceController {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
preference.updateState(
|
|
||||||
mCn.getPackageName(), mPkgInfo.applicationInfo.uid, isAllowedCn, isEnabled);
|
if (android.security.Flags.extendEcmToAllSettings()) {
|
||||||
|
if (!isAllowedCn && !isEnabled) {
|
||||||
|
preference.setEnabled(false);
|
||||||
|
} else if (isEnabled) {
|
||||||
|
preference.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
preference.checkEcmRestrictionAndSetDisabled(mAppOpStr,
|
||||||
|
mCn.getPackageName(), mPkgInfo.applicationInfo.uid);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
preference.updateState(
|
||||||
|
mCn.getPackageName(), mPkgInfo.applicationInfo.uid, isAllowedCn, isEnabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable(final ComponentName cn) {
|
public void disable(final ComponentName cn) {
|
||||||
|
@@ -21,6 +21,7 @@ import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
|||||||
import static com.android.settings.applications.AppInfoBase.ARG_PACKAGE_NAME;
|
import static com.android.settings.applications.AppInfoBase.ARG_PACKAGE_NAME;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.app.AppOpsManager;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.companion.ICompanionDeviceManager;
|
import android.companion.ICompanionDeviceManager;
|
||||||
@@ -102,6 +103,7 @@ public class NotificationAccessDetails extends DashboardFragment {
|
|||||||
.setCn(mComponentName)
|
.setCn(mComponentName)
|
||||||
.setNm(context.getSystemService(NotificationManager.class))
|
.setNm(context.getSystemService(NotificationManager.class))
|
||||||
.setPm(mPm)
|
.setPm(mPm)
|
||||||
|
.setAppOpStr(AppOpsManager.OPSTR_ACCESS_NOTIFICATIONS)
|
||||||
.setParent(this);
|
.setParent(this);
|
||||||
use(HeaderPreferenceController.class)
|
use(HeaderPreferenceController.class)
|
||||||
.setFragment(this)
|
.setFragment(this)
|
||||||
|
Reference in New Issue
Block a user