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

Commit 0d56dab9 authored by Sahil Sonar's avatar Sahil Sonar 💬
Browse files

Merge branch '8190-s-samsung-parental-control' into 'v2.4-s'

oemlock: Skip OEM unlock check for Samsung devices

See merge request e/os/android_frameworks_base!220
parents e3133d2a c64832d5
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.oemlock.V1_0.IOemLock;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.SystemProperties;
@@ -38,6 +39,8 @@ import com.android.server.pm.UserManagerInternal;
import com.android.server.pm.UserManagerInternal.UserRestrictionsListener;
import com.android.server.pm.UserRestrictionsUtils;

import java.util.Locale;

/**
 * Service for managing the OEM lock state of the device.
 *
@@ -92,6 +95,7 @@ public class OemLockService extends SystemService {
        @Override
        public void onUserRestrictionsChanged(int userId, Bundle newRestrictions,
                Bundle prevRestrictions) {
            if (isSamsungDevice()) return;
            // The admin can prevent OEM unlock with the DISALLOW_FACTORY_RESET user restriction
            if (UserRestrictionsUtils.restrictionsChanged(prevRestrictions, newRestrictions,
                     UserManager.DISALLOW_FACTORY_RESET)) {
@@ -266,6 +270,10 @@ public class OemLockService extends SystemService {
        }
    }

    private boolean isSamsungDevice() {
        return Build.MANUFACTURER.toLowerCase(Locale.US).contains("samsung");
    }

    private void enforceUserIsAdmin() {
        final int userId = UserHandle.getCallingUserId();
        final long token = Binder.clearCallingIdentity();