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

Commit 124aec35 authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge "Use effectiveUserId for credentials"

parents 167bcb1d b54bdfc1
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.hardware.biometrics.BiometricPrompt;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
@@ -162,6 +163,7 @@ public abstract class AuthBiometricView extends LinearLayout {
    private Bundle mBiometricPromptBundle;
    private boolean mRequireConfirmation;
    private int mUserId;
    private int mEffectiveUserId;
    @AuthDialog.DialogSize int mSize = AuthDialog.SIZE_UNKNOWN;

    private TextView mTitleView;
@@ -280,6 +282,10 @@ public abstract class AuthBiometricView extends LinearLayout {
        mUserId = userId;
    }

    public void setEffectiveUserId(int effectiveUserId) {
        mEffectiveUserId = effectiveUserId;
    }

    public void setRequireConfirmation(boolean requireConfirmation) {
        mRequireConfirmation = requireConfirmation;
    }
@@ -650,7 +656,8 @@ public abstract class AuthBiometricView extends LinearLayout {
        if (isDeviceCredentialAllowed()) {

            final @Utils.CredentialType int credentialType =
                    Utils.getCredentialType(mContext, mUserId);
                    Utils.getCredentialType(mContext, mEffectiveUserId);

            switch (credentialType) {
                case Utils.CREDENTIAL_PIN:
                    negativeText = getResources().getString(R.string.biometric_dialog_use_pin);
+20 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.UserManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -75,6 +76,7 @@ public class AuthContainerView extends LinearLayout
    @interface ContainerState {}

    final Config mConfig;
    final int mEffectiveUserId;
    private final Handler mHandler;
    private final Injector mInjector;
    private final IBinder mWindowToken = new Binder();
@@ -182,6 +184,14 @@ public class AuthContainerView extends LinearLayout
        int getAnimateCredentialStartDelayMs() {
            return AuthDialog.ANIMATE_CREDENTIAL_START_DELAY_MS;
        }

        UserManager getUserManager(Context context) {
            return UserManager.get(context);
        }

        int getCredentialType(Context context, int effectiveUserId) {
            return Utils.getCredentialType(context, effectiveUserId);
        }
    }

    @VisibleForTesting
@@ -230,6 +240,9 @@ public class AuthContainerView extends LinearLayout
        mConfig = config;
        mInjector = injector;

        mEffectiveUserId = mInjector.getUserManager(mContext)
                .getCredentialOwnerProfile(mConfig.mUserId);

        mHandler = new Handler(Looper.getMainLooper());
        mWindowManager = mContext.getSystemService(WindowManager.class);
        mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
@@ -268,7 +281,6 @@ public class AuthContainerView extends LinearLayout
        mBiometricScrollView = mInjector.getBiometricScrollView(mFrameLayout);
        mBackgroundView = mInjector.getBackgroundView(mFrameLayout);


        if (isManagedProfile) {
            final Drawable image = getResources().getDrawable(R.drawable.work_challenge_background,
                    mContext.getTheme());
@@ -307,6 +319,7 @@ public class AuthContainerView extends LinearLayout
        mBiometricView.setCallback(mBiometricCallback);
        mBiometricView.setBackgroundView(mBackgroundView);
        mBiometricView.setUserId(mConfig.mUserId);
        mBiometricView.setEffectiveUserId(mEffectiveUserId);
        mBiometricScrollView.addView(mBiometricView);
    }

@@ -318,7 +331,10 @@ public class AuthContainerView extends LinearLayout
     */
    private void addCredentialView(boolean animatePanel, boolean animateContents) {
        final LayoutInflater factory = LayoutInflater.from(mContext);
        final int credentialType = Utils.getCredentialType(mContext, mConfig.mUserId);

        final @Utils.CredentialType int credentialType = mInjector.getCredentialType(
                mContext, mEffectiveUserId);

        switch (credentialType) {
            case Utils.CREDENTIAL_PATTERN:
                mCredentialView = (AuthCredentialView) factory.inflate(
@@ -334,7 +350,8 @@ public class AuthContainerView extends LinearLayout
        }

        mCredentialView.setContainerView(this);
        mCredentialView.setUser(mConfig.mUserId);
        mCredentialView.setEffectiveUserId(mEffectiveUserId);
        mCredentialView.setCredentialType(credentialType);
        mCredentialView.setCallback(mCredentialCallback);
        mCredentialView.setBiometricPromptBundle(mConfig.mBiometricPromptBundle);
        mCredentialView.setPanelController(mPanelController, animatePanel);
+2 −2
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public class AuthCredentialPasswordView extends AuthCredentialView
            }

            mPendingLockCheck = LockPatternChecker.checkCredential(mLockPatternUtils,
                    password, mUserId, this::onCredentialChecked);
                    password, mEffectiveUserId, this::onCredentialChecked);
        }
    }

+3 −2
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ public class AuthCredentialPatternView extends AuthCredentialView {
                mPendingLockCheck = LockPatternChecker.checkCredential(
                        mLockPatternUtils,
                        credential,
                        mUserId,
                        mEffectiveUserId,
                        this::onPatternChecked);
            }
        }
@@ -99,7 +99,8 @@ public class AuthCredentialPatternView extends AuthCredentialView {
        super.onFinishInflate();
        mLockPatternView = findViewById(R.id.lockPattern);
        mLockPatternView.setOnPatternListener(new UnlockPatternListener());
        mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled(mUserId));
        mLockPatternView.setInStealthMode(
                !mLockPatternUtils.isVisiblePatternEnabled(mEffectiveUserId));
        mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled());
    }
}
+9 −6
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ public abstract class AuthCredentialView extends LinearLayout {
    protected AuthContainerView mContainerView;
    protected Callback mCallback;
    protected AsyncTask<?, ?, ?> mPendingLockCheck;
    protected int mUserId;
    protected int mEffectiveUserId;
    protected ErrorTimer mErrorTimer;

    interface Callback {
@@ -137,8 +137,12 @@ public abstract class AuthCredentialView extends LinearLayout {
        view.setText(string);
    }

    void setUser(int user) {
        mUserId = user;
    void setEffectiveUserId(int effectiveUserId) {
        mEffectiveUserId = effectiveUserId;
    }

    void setCredentialType(@Utils.CredentialType int credentialType) {
        mCredentialType = credentialType;
    }

    void setCallback(Callback callback) {
@@ -166,8 +170,6 @@ public abstract class AuthCredentialView extends LinearLayout {
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();

        mCredentialType = Utils.getCredentialType(mContext, mUserId);

        setText(mTitleView, mBiometricPromptBundle.getString(BiometricPrompt.KEY_TITLE));
        setTextOrHide(mSubtitleView,
                mBiometricPromptBundle.getString(BiometricPrompt.KEY_SUBTITLE));
@@ -230,7 +232,8 @@ public abstract class AuthCredentialView extends LinearLayout {
        } else {
            if (timeoutMs > 0) {
                mHandler.removeCallbacks(mClearErrorRunnable);
                long deadline = mLockPatternUtils.setLockoutAttemptDeadline(mUserId, timeoutMs);
                long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
                        mEffectiveUserId, timeoutMs);
                mErrorTimer = new ErrorTimer(mContext,
                        deadline - SystemClock.elapsedRealtime(),
                        LockPatternUtils.FAILED_ATTEMPT_COUNTDOWN_INTERVAL_MS,
Loading