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

Commit 54639924 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add implementation alternatives for OemLockManager."

parents 650bdcf4 5d7027db
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -27,4 +27,8 @@ interface IOemLockService {

    void setOemUnlockAllowedByUser(boolean allowed);
    boolean isOemUnlockAllowedByUser();

    boolean canUserAllowOemUnlock();
    boolean isOemUnlockAllowed();
    boolean isDeviceOemUnlocked();
}
+46 −1
Original line number Diff line number Diff line
@@ -82,7 +82,8 @@ public class OemLockManager {
     *
     * All actors involved must agree for OEM unlock to be possible.
     *
     * @param unlocked Whether the device should be made OEM unlocked.
     * @param allowed Whether the device should be allowed to be unlocked.
     * @throws SecurityException if the user is not allowed to unlock the device.
     *
     * @see #isOemUnlockAllowedByUser()
     */
@@ -107,4 +108,48 @@ public class OemLockManager {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns whether all parties other than the user allow OEM unlock meaning the user can
     * directly control whether or not the device can be OEM unlocked.
     *
     * If this is true, {@link #isOemUnlockAllowedByUser} is the same as {@link #isOemUnlockAllowed}
     *
     * @return Whether the user can directly control whether the device can be OEM unlocked.
     *
     * @hide
     */
    public boolean canUserAllowOemUnlock() {
        try {
            return mService.canUserAllowOemUnlock();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @return Whether the bootloader is able to OEM unlock the device.
     *
     * @hide
     */
    public boolean isOemUnlockAllowed() {
        try {
            return mService.isOemUnlockAllowed();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @return Whether the device has been OEM unlocked by the bootloader.
     *
     * @hide
     */
    public boolean isDeviceOemUnlocked() {
        try {
            return mService.isOemUnlockAllowed();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -229,6 +229,7 @@ applications that come with the platform
        <permission name="android.permission.MANAGE_FINGERPRINT"/>
        <permission name="android.permission.MANAGE_USB"/>
        <permission name="android.permission.MANAGE_USERS"/>
        <permission name="android.permission.MANAGE_USER_OEM_UNLOCK_STATE" />
        <permission name="android.permission.MASTER_CLEAR"/>
        <permission name="android.permission.MODIFY_PHONE_STATE"/>
        <permission name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
    android.hidl.base-V1.0-java-static \
    android.hardware.weaver-V1.0-java-static \
    android.hardware.biometrics.fingerprint-V2.1-java-static \
    android.hardware.oemlock-V1.0-java-static \
    android.hardware.vibrator-V1.0-java-constants \

ifneq ($(INCREMENTAL_BUILDS),)
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.oemlock;

import android.annotation.Nullable;

abstract class OemLock {
    abstract void setOemUnlockAllowedByCarrier(boolean allowed, @Nullable byte[] signature);
    abstract boolean isOemUnlockAllowedByCarrier();

    abstract void setOemUnlockAllowedByDevice(boolean allowedByDevice);
    abstract boolean isOemUnlockAllowedByDevice();
}
Loading