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

Commit 4afbe991 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Improved trust error messaging (1/2)"

parents 0f9f6713 c13723f2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -32,4 +32,5 @@ interface ITrustManager {
    void setDeviceLockedForUser(int userId, boolean locked);
    boolean isDeviceLocked(int userId);
    boolean isDeviceSecure(int userId);
    boolean isTrustUsuallyManaged(int userId);
}
+17 −6
Original line number Diff line number Diff line
@@ -16,21 +16,17 @@

package android.app.trust;

import com.android.internal.widget.LockPatternUtils;

import android.Manifest;
import android.annotation.IntDef;
import android.annotation.RequiresPermission;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.ArrayMap;
import android.util.Log;
import android.util.SparseIntArray;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * See {@link com.android.server.trust.TrustManagerService}
@@ -158,6 +154,21 @@ public class TrustManager {
        }
    }

    /**
     * @return whether {@userId} has enabled and configured trust agents. Ignores short-term
     * unavailability of trust due to {@link LockPatternUtils.StrongAuthTracker}.
     */
    @RequiresPermission(android.Manifest.permission.TRUST_LISTENER)
    public boolean isTrustUsuallyManaged(int userId) {
        try {
            return mService.isTrustUsuallyManaged(userId);
        } catch (RemoteException e) {
            return false;
        }
    }



    private void onError(Exception e) {
        Log.e(TAG, "Error while calling TrustManagerService", e);
    }
+25 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ public class LockPatternUtils {
    private static final String LOCK_SCREEN_DEVICE_OWNER_INFO = "lockscreen.device_owner_info";

    private static final String ENABLED_TRUST_AGENTS = "lockscreen.enabledtrustagents";
    private static final String IS_TRUST_USUALLY_MANAGED = "lockscreen.istrustusuallymanaged";

    private static final String SEPARATE_PROFILE_CHALLENGE_KEY = "lockscreen.profilechallenge";

@@ -149,6 +150,30 @@ public class LockPatternUtils {
    private ILockSettings mLockSettingsService;
    private UserManager mUserManager;

    /**
     * Use {@link TrustManager#isTrustUsuallyManaged(int)}.
     *
     * This returns the lazily-peristed value and should only be used by TrustManagerService.
     */
    public boolean isTrustUsuallyManaged(int userId) {
        if (!(mLockSettingsService instanceof ILockSettings.Stub)) {
            throw new IllegalStateException("May only be called by TrustManagerService. "
                    + "Use TrustManager.isTrustUsuallyManaged()");
        }
        try {
            return getLockSettings().getBoolean(IS_TRUST_USUALLY_MANAGED, false, userId);
        } catch (RemoteException e) {
            return false;
        }
    }

    public void setTrustUsuallyManaged(boolean managed, int userId) {
        try {
            getLockSettings().setBoolean(IS_TRUST_USUALLY_MANAGED, managed, userId);
        } catch (RemoteException e) {
            // System dead.
        }
    }

    public static final class RequestThrottledException extends Exception {
        private int mTimeoutMs;
+3 −1
Original line number Diff line number Diff line
@@ -117,8 +117,10 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
                return R.string.kg_prompt_reason_restart_password;
            case PROMPT_REASON_TIMEOUT:
                return R.string.kg_prompt_reason_timeout_password;
            default:
            case PROMPT_REASON_NONE:
                return 0;
            default:
                return R.string.kg_prompt_reason_timeout_password;
        }
    }

+4 −0
Original line number Diff line number Diff line
@@ -339,7 +339,11 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
                mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_timeout_pattern,
                        true /* important */);
                break;
            case PROMPT_REASON_NONE:
                break;
            default:
                mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_timeout_pattern,
                        true /* important */);
                break;
        }
    }
Loading