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

Commit 655f908a authored by Zac Iqbal's avatar Zac Iqbal Committed by Android (Google) Code Review
Browse files

Merge "Added an onDeviceUnlockLockout callback to TrustAgentService."

parents 0b0a6b63 327323d2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -38787,6 +38787,7 @@ package android.service.trust {
    method public final android.os.IBinder onBind(android.content.Intent);
    method public boolean onConfigure(java.util.List<android.os.PersistableBundle>);
    method public void onDeviceLocked();
    method public void onDeviceUnlockLockout(long);
    method public void onDeviceUnlocked();
    method public void onTrustTimeout();
    method public void onUnlockAttempt(boolean);
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.app.trust.ITrustListener;
 */
interface ITrustManager {
    void reportUnlockAttempt(boolean successful, int userId);
    void reportUnlockLockout(int timeoutMs, int userId);
    void reportEnabledTrustAgentsChanged(int userId);
    void registerTrustListener(in ITrustListener trustListener);
    void unregisterTrustListener(in ITrustListener trustListener);
+20 −0
Original line number Diff line number Diff line
@@ -80,6 +80,26 @@ public class TrustManager {
        }
    }

    /**
     * Reports that user {@param userId} has entered a temporary device lockout.
     *
     * This generally occurs when  the user has unsuccessfully tried to unlock the device too many
     * times. The user will then be unable to unlock the device until a set amount of time has
     * elapsed.
     *
     * @param timeout The amount of time that needs to elapse, in milliseconds, until the user may
     *    attempt to unlock the device again.
     *
     * Requires the {@link android.Manifest.permission#ACCESS_KEYGUARD_SECURE_STORAGE} permission.
     */
    public void reportUnlockLockout(int timeoutMs, int userId) {
        try {
            mService.reportUnlockLockout(timeoutMs, userId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Reports that the list of enabled trust agents changed for user {@param userId}.
     *
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.service.trust.ITrustAgentServiceCallback;
 */
interface ITrustAgentService {
    oneway void onUnlockAttempt(boolean successful);
    oneway void onUnlockLockout(int timeoutMs);
    oneway void onTrustTimeout();
    oneway void onDeviceLocked();
    oneway void onDeviceUnlocked();
+24 −0
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ public class TrustAgentService extends Service {
    private static final int MSG_TRUST_TIMEOUT = 3;
    private static final int MSG_DEVICE_LOCKED = 4;
    private static final int MSG_DEVICE_UNLOCKED = 5;
    private static final int MSG_UNLOCK_LOCKOUT = 6;

    /**
     * Class containing raw data for a given configuration request.
@@ -151,6 +152,9 @@ public class TrustAgentService extends Service {
                case MSG_UNLOCK_ATTEMPT:
                    onUnlockAttempt(msg.arg1 != 0);
                    break;
                case MSG_UNLOCK_LOCKOUT:
                    onDeviceUnlockLockout(msg.arg1);
                    break;
                case MSG_CONFIGURE:
                    ConfigurationData data = (ConfigurationData) msg.obj;
                    boolean result = onConfigure(data.options);
@@ -226,6 +230,21 @@ public class TrustAgentService extends Service {
    public void onDeviceUnlocked() {
    }

    /**
     * Called when the device enters a temporary unlock lockout.
     *
     * <p>This occurs when the user has consecutively failed to unlock the device too many times,
     * and must wait until a timeout has passed to perform another attempt. The user may then only
     * use strong authentication mechanisms (PIN, pattern or password) to unlock the device.
     * Calls to {@link #grantTrust(CharSequence, long, int)} will be ignored until the user has
     * unlocked the device and {@link #onDeviceUnlocked()} is called.
     *
     * @param timeoutMs The amount of time, in milliseconds, that needs to elapse before the user
     *    can attempt to unlock the device again.
     */
    public void onDeviceUnlockLockout(long timeoutMs) {
    }

    private void onError(String msg) {
        Slog.v(TAG, "Remote exception while " + msg);
    }
@@ -366,6 +385,11 @@ public class TrustAgentService extends Service {
            mHandler.obtainMessage(MSG_UNLOCK_ATTEMPT, successful ? 1 : 0, 0).sendToTarget();
        }

        @Override
        public void onUnlockLockout(int timeoutMs) {
            mHandler.obtainMessage(MSG_UNLOCK_LOCKOUT, timeoutMs, 0).sendToTarget();
        }

        @Override /* Binder API */
        public void onTrustTimeout() {
            mHandler.sendEmptyMessage(MSG_TRUST_TIMEOUT);
Loading