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

Commit 52017a50 authored by AnilKumar Chimata's avatar AnilKumar Chimata Committed by Łukasz Patron
Browse files

frameworks: base: Port password retention feature

Port password retention feature for HW FDE.

This patch also include these changes:
   - Fix clearing of retained password
   - keyguard: Fix password doesnot sanitize after verification
   - LockSettings: fix the get password issue during boot up
   - frameworks/base: Fix pattern update issue

Change-Id: I2def56b14c10229b72feccd1c97b281cad65f282
parent bbde56e8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -53,4 +53,6 @@ interface ILockSettings {
    boolean setLockCredentialWithToken(String credential, int type, long tokenHandle,
            in byte[] token, int requestedQuality, int userId);
    void unlockUserWithToken(long tokenHandle, in byte[] token, int userId);
    void sanitizePassword();
    String getPassword();
}
+11 −0
Original line number Diff line number Diff line
@@ -703,6 +703,17 @@ public class LockPatternUtils {
        }
    }

    /**
     * Clears stored password.
     */
    public void sanitizePassword() {
        try {
            getLockSettings().sanitizePassword();
        } catch (RemoteException e) {
            Log.e(TAG, "Couldn't sanitize password", e);
        }
    }

    private void updateCryptoUserInfo(int userId) {
        if (userId != UserHandle.USER_SYSTEM) {
            return;
+1 −0
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
            boolean isValidPassword) {
        boolean dismissKeyguard = KeyguardUpdateMonitor.getCurrentUser() == userId;
        if (matched) {
            mLockPatternUtils.sanitizePassword();
            mCallback.reportUnlockAttempt(userId, true, 0);
            if (dismissKeyguard) {
                mDismissing = true;
+1 −0
Original line number Diff line number Diff line
@@ -307,6 +307,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
                boolean isValidPattern) {
            boolean dismissKeyguard = KeyguardUpdateMonitor.getCurrentUser() == userId;
            if (matched) {
                mLockPatternUtils.sanitizePassword();
                mCallback.reportUnlockAttempt(userId, true, 0);
                if (dismissKeyguard) {
                    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
+16 −1
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.HexDump;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.internal.widget.ILockSettings;
import com.android.internal.widget.LockPatternUtils;
import com.android.server.NativeDaemonConnector.Command;
import com.android.server.NativeDaemonConnector.SensitiveArg;
@@ -2700,9 +2701,23 @@ class StorageManagerService extends IStorageManager.Stub
            Slog.i(TAG, "changing encryption password...");
        }

        ILockSettings lockSettings = ILockSettings.Stub.asInterface(
                ServiceManager.getService("lock_settings"));
        String currentPassword = "default_password";
        try {
            currentPassword = lockSettings.getPassword();
        } catch (RemoteException e) {
            Slog.e(TAG, "Couldn't get password", e);
        }

        try {
            NativeDaemonEvent event = mCryptConnector.execute("cryptfs", "changepw", CRYPTO_TYPES[type],
                        new SensitiveArg(password));
                        new SensitiveArg(currentPassword), new SensitiveArg(password));
            try {
                lockSettings.sanitizePassword();
            } catch (RemoteException e) {
                Slog.e(TAG, "Couldn't sanitize password", e);
            }
            return Integer.parseInt(event.getMessage());
        } catch (NativeDaemonConnectorException e) {
            // Encryption failed
Loading