Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1fdb5429 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

base: allow parental control to be activated with accounts

parent e9ab5665
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -439,6 +439,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    private static final String TAG_TRANSFER_OWNERSHIP_BUNDLE = "transfer-ownership-bundle";
    private static final String PARENTALCONTROL_PKG = "foundation.e.parentalcontrol";
    private static final int REQUEST_EXPIRE_PASSWORD = 5571;
    private static final int REQUEST_PROFILE_OFF_DEADLINE = 5572;
@@ -8442,6 +8444,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                + PackageManager.FEATURE_DEVICE_ADMIN + " feature.");
    }
    private boolean isParentalControl(ComponentName admin) {
        return admin != null && PARENTALCONTROL_PKG.equals(admin.getPackageName());
    }
    @Override
    public boolean setDeviceOwner(ComponentName admin, String ownerName, int userId,
            boolean setProfileOwnerOnCurrentUserIfNecessary) {
@@ -8459,7 +8465,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        if (!hasIncompatibleAccountsOrNonAdb) {
            synchronized (getLockObject()) {
                if (!isAdminTestOnlyLocked(admin, userId) && hasAccountsOnAnyUser()) {
                if (!isAdminTestOnlyLocked(admin, userId) && hasAccountsOnAnyUser() && !isParentalControl(admin)) {
                    Slogf.w(LOG_TAG,
                            "Non test-only owner can't be installed with existing accounts.");
                    return false;
@@ -15545,7 +15551,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            return true;
        }
        // Allow parental control with accounts
        if (owner != null && "foundation.e.parentalcontrol".equals(owner.getPackageName())) {
        if (isParentalControl(owner)) {
            return false;
        }
        wtfIfInLock();