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

Commit 23a1a5f4 authored by Andrew Scull's avatar Andrew Scull
Browse files

Complete OemLockService API.

The API was missing a call to query the name of the HAL which is used to
identify the security protocol in use. The API also didn't conform to
the documentation in a few cases.

Bug: 120078865
Test: gts-tradefed run gts -m GtsOemLockServiceTestCases
Change-Id: Ib1ec06f99bbe21710d4d8f61252d6431ffab51a6
parent 6f4e2719
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5137,6 +5137,7 @@ package android.service.notification {
package android.service.oemlock {

  public class OemLockManager {
    method public java.lang.String getLockName();
    method public boolean isOemUnlockAllowedByCarrier();
    method public boolean isOemUnlockAllowedByUser();
    method public void setOemUnlockAllowedByCarrier(boolean, byte[]);
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ package android.service.oemlock;
 * @hide
 */
interface IOemLockService {
    String getLockName();

    void setOemUnlockAllowedByCarrier(boolean allowed, in byte[] signature);
    boolean isOemUnlockAllowedByCarrier();

+17 −0
Original line number Diff line number Diff line
@@ -43,6 +43,23 @@ public class OemLockManager {
        mService = service;
    }

    /**
     * Returns a vendor specific name for the OEM lock.
     *
     * This value is used to identify the security protocol used by locks.
     *
     * @return The name of the OEM lock or {@code null} if failed to get the name.
     */
    @RequiresPermission(android.Manifest.permission.MANAGE_CARRIER_OEM_UNLOCK_STATE)
    @Nullable
    public String getLockName() {
        try {
            return mService.getLockName();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Sets whether the carrier has allowed this device to be OEM unlocked.
     *
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.server.oemlock;
import android.annotation.Nullable;

abstract class OemLock {
    @Nullable
    abstract String getLockName();

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

+13 −0
Original line number Diff line number Diff line
@@ -112,6 +112,19 @@ public class OemLockService extends SystemService {
     * implementation being used on this device.
     */
    private final IBinder mService = new IOemLockService.Stub() {
        @Override
        @Nullable
        public String getLockName() {
            enforceManageCarrierOemUnlockPermission();

            final long token = Binder.clearCallingIdentity();
            try {
                return mOemLock.getLockName();
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        @Override
        public void setOemUnlockAllowedByCarrier(boolean allowed, @Nullable byte[] signature) {
            enforceManageCarrierOemUnlockPermission();
Loading