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

Commit 40db4bbb authored by Clara Bayarri's avatar Clara Bayarri
Browse files

Profile Challenge Fingerprint Support

Change-Id: Ic83c479f645776dd0678721bfb732b399f09c992
parent 1b4e746a
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -150,6 +150,23 @@ public final class ChooseLockSettingsHelper {
                false, false, true, challenge, Utils.getCredentialOwnerUserId(mActivity));
    }

    /**
     * If a pattern, password or PIN exists, prompt the user before allowing them to change it.
     * @param message optional message to display about the action about to be done
     * @param details optional detail message to display
     * @param challenge a challenge to be verified against the device credential.
     *                  This method can only be called internally.
     * @param userId The userId for whom the lock should be confirmed.
     * @return true if one exists and we launched an activity to confirm it
     * @see #onActivityResult(int, int, android.content.Intent)
     */
    public boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
            @Nullable CharSequence header, @Nullable CharSequence description,
            long challenge, int userId) {
        return launchConfirmationActivity(request, title, header, description,
                false, false, true, challenge, Utils.enforceSameOwner(mActivity, userId));
    }

    private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
            @Nullable CharSequence header, @Nullable CharSequence description,
            boolean returnCredentials, boolean external, boolean hasChallenge,
+11 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.app.ActivityManagerNative;
import android.app.ActivityOptions;
import android.app.IActivityManager;
import android.app.admin.DevicePolicyManager;
import android.app.trust.TrustManager;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
@@ -63,12 +64,16 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
    private boolean mAllowFpAuthentication;
    protected Button mCancelButton;
    protected ImageView mFingerprintIcon;
    protected int mEffectiveUserId;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mAllowFpAuthentication = getActivity().getIntent().getBooleanExtra(
                ALLOW_FP_AUTHENTICATION, false);
        // Only take this argument into account if it belongs to the current profile.
        Intent intent = getActivity().getIntent();
        mEffectiveUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
    }

    @Override
@@ -78,7 +83,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
        mFingerprintIcon = (ImageView) view.findViewById(R.id.fingerprintIcon);
        mFingerprintHelper = new FingerprintUiHelper(
                mFingerprintIcon,
                (TextView) view.findViewById(R.id.errorText), this);
                (TextView) view.findViewById(R.id.errorText), this, mEffectiveUserId);
        boolean showCancelButton = getActivity().getIntent().getBooleanExtra(
                SHOW_CANCEL_BUTTON, false);
        mCancelButton.setVisibility(showCancelButton ? View.VISIBLE : View.GONE);
@@ -132,7 +137,12 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
    public void onAuthenticated() {
        // Check whether we are still active.
        if (getActivity() != null && getActivity().isResumed()) {
            TrustManager trustManager =
                (TrustManager) getActivity().getSystemService(Context.TRUST_SERVICE);
            trustManager.setDeviceLockedForUser(mEffectiveUserId, false);
            authenticationSucceeded();
            authenticationSucceeded();
            checkForPendingIntent();
        }
    }

+6 −11
Original line number Diff line number Diff line
@@ -99,7 +99,6 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
        private AppearAnimationUtils mAppearAnimationUtils;
        private DisappearAnimationUtils mDisappearAnimationUtils;
        private boolean mBlockImm;
        private int mEffectiveUserId;

        // required constructor for fragments
        public ConfirmLockPasswordFragment() {
@@ -110,9 +109,6 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            mLockPatternUtils = new LockPatternUtils(getActivity());
            Intent intent = getActivity().getIntent();
            // Only take this argument into account if it belongs to the current profile.
            mEffectiveUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
        }

        @Override
@@ -183,14 +179,13 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
        private int getDefaultDetails() {
            boolean isProfile = Utils.isManagedProfile(
                    UserManager.get(getActivity()), mEffectiveUserId);
            if (mIsAlpha && !isProfile) {
                return R.string.lockpassword_confirm_your_password_generic;
            } else if (mIsAlpha && isProfile) {
                return R.string.lockpassword_confirm_your_password_generic_profile;
            } else if (!isProfile) {
                return R.string.lockpassword_confirm_your_pin_generic;
            }
            return R.string.lockpassword_confirm_your_pin_generic_profile;
            if (mIsAlpha) {
                return isProfile ? R.string.lockpassword_confirm_your_password_generic_profile
                        : R.string.lockpassword_confirm_your_password_generic;
            } else {
                return isProfile ? R.string.lockpassword_confirm_your_pin_generic_profile
                        : R.string.lockpassword_confirm_your_pin_generic;
            }
        }

        private int getErrorMessage() {
+0 −5
Original line number Diff line number Diff line
@@ -104,8 +104,6 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
        private AppearAnimationUtils mAppearAnimationUtils;
        private DisappearAnimationUtils mDisappearAnimationUtils;

        private int mEffectiveUserId;

        // required constructor for fragments
        public ConfirmLockPatternFragment() {

@@ -115,9 +113,6 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            mLockPatternUtils = new LockPatternUtils(getActivity());
            Intent intent = getActivity().getIntent();
            // Only take this argument into account if it belongs to the current profile.
            mEffectiveUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
        }

        @Override
+14 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.UserInfo;
import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
@@ -34,12 +36,15 @@ import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.util.Log;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;

import com.android.internal.logging.MetricsLogger;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.fingerprint.FingerprintEnrollIntroduction;
import com.android.settings.fingerprint.FingerprintSettings;

import java.util.Collections;
import java.util.HashSet;
@@ -218,6 +223,7 @@ public class ProfileChallengePreferenceFragment extends SettingsPreferenceFragme
        PreferenceGroup securityCategory = (PreferenceGroup)
                root.findPreference(KEY_SECURITY_CATEGORY);
        if (securityCategory != null) {
            maybeAddFingerprintPreference(securityCategory);
            if (mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileUserId)) {
                maybeAddUnificationPreference(securityCategory);
            } else {
@@ -241,6 +247,14 @@ public class ProfileChallengePreferenceFragment extends SettingsPreferenceFragme
        }
    }

    private void maybeAddFingerprintPreference(PreferenceGroup securityCategory) {
        Preference fingerprintPreference =
                FingerprintSettings.getFingerprintPreferenceForUser(getActivity(), mProfileUserId);
        if (fingerprintPreference != null) {
            securityCategory.addPreference(fingerprintPreference);
        }
    }

    private void removeNonWhitelistedItems(PreferenceGroup prefScreen) {
        int numPreferences = prefScreen.getPreferenceCount();
        int i = 0;
Loading