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

Commit 41c19779 authored by Paul Crowley's avatar Paul Crowley Committed by Android (Google) Code Review
Browse files

Merge "Add a new flow for decryption checking." into lmp-mr1-dev

parents 99f191f5 529834da
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -4667,8 +4667,19 @@
    <string name="enter_pin">To start Android, enter your PIN</string>
    <!-- Informational text on the pattern entry screen prompting the user for their pattern -->
    <string name="enter_pattern">To start Android, draw your pattern</string>
    <!-- This is displayed when the password is entered incorrectly -->
    <string name="try_again">Try again.</string>

    <!-- Message shown when user enters wrong pattern -->
    <string name="cryptkeeper_wrong_pattern">Wrong Pattern</string>
    <!-- Message shown when user enters wrong password -->
    <string name="cryptkeeper_wrong_password">Wrong Password</string>
    <!-- Message shown when user enters wrong PIN -->
    <string name="cryptkeeper_wrong_pin">Wrong PIN</string>

    <!-- Shown when a password has been entered, and we're checking it -->
    <string name="checking_decryption">Checking\u2026</string>
    <!-- Shown when password is correct, and we're starting Android -->
    <string name="starting_android">Starting Android</string>


    <!-- the following are for Settings Storage screen -->
    <!-- Menu item/button 'delete' -->
+30 −9
Original line number Diff line number Diff line
@@ -61,8 +61,6 @@ import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.android.internal.statusbar.StatusBarIcon;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;
@@ -138,6 +136,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
    private static final int RIGHT_PATTERN_CLEAR_TIMEOUT_MS = 500;

    private Runnable mClearPatternRunnable = new Runnable() {
        @Override
        public void run() {
            mLockPatternView.clearPattern();
        }
@@ -162,6 +161,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
            }
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            final TextView status = (TextView) findViewById(R.id.status);
            status.setText(R.string.checking_decryption);
        }

        @Override
        protected Integer doInBackground(String... params) {
            final IMountService service = getMountService();
@@ -182,10 +188,11 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
                    mLockPatternView.removeCallbacks(mClearPatternRunnable);
                    mLockPatternView.postDelayed(mClearPatternRunnable, RIGHT_PATTERN_CLEAR_TIMEOUT_MS);
                }
                final TextView status = (TextView) findViewById(R.id.status);
                status.setText(R.string.starting_android);
                hide(R.id.passwordEntry);
                hide(R.id.switch_ime_button);
                hide(R.id.lockPattern);
                hide(R.id.status);
                hide(R.id.owner_info);
                hide(R.id.emergencyCallButton);
            } else if (failedAttempts == MAX_FAILED_ATTEMPTS) {
@@ -219,9 +226,24 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
                                                                        Integer.toString(remainingAttempts));
                        status.setText(warning);
                    } else {
                        status.setText(R.string.try_again);
                        int passwordType = StorageManager.CRYPT_TYPE_PASSWORD;
                        try {
                            final IMountService service = getMountService();
                            passwordType = service.getPasswordType();
                        } catch (Exception e) {
                            Log.e(TAG, "Error calling mount service " + e);
                        }

                        if (passwordType == StorageManager.CRYPT_TYPE_PIN) {
                            status.setText(R.string.cryptkeeper_wrong_pin);
                        } else if (passwordType == StorageManager.CRYPT_TYPE_PATTERN) {
                            status.setText(R.string.cryptkeeper_wrong_password);
                        } else {
                            status.setText(R.string.cryptkeeper_wrong_pin);
                        }
                    }


                    if (mLockPatternView != null) {
                        mLockPatternView.setDisplayMode(DisplayMode.Wrong);
                    }
@@ -434,7 +456,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
            encryptionProgressInit();
        } else if (mValidationComplete || isDebugView(FORCE_VIEW_PASSWORD)) {
            new AsyncTask<Void, Void, Void>() {
                int type = StorageManager.CRYPT_TYPE_PASSWORD;
                int passwordType = StorageManager.CRYPT_TYPE_PASSWORD;
                String owner_info;
                boolean pattern_visible;

@@ -442,7 +464,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
                public Void doInBackground(Void... v) {
                    try {
                        final IMountService service = getMountService();
                        type = service.getPasswordType();
                        passwordType = service.getPasswordType();
                        owner_info = service.getField(StorageManager.OWNER_INFO_KEY);
                        pattern_visible = !("0".equals(service.getField(StorageManager.PATTERN_VISIBLE_KEY)));
                    } catch (Exception e) {
@@ -454,10 +476,10 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList

                @Override
                public void onPostExecute(java.lang.Void v) {
                    if(type == StorageManager.CRYPT_TYPE_PIN) {
                    if(passwordType == StorageManager.CRYPT_TYPE_PIN) {
                        setContentView(R.layout.crypt_keeper_pin_entry);
                        mStatusString = R.string.enter_pin;
                    } else if (type == StorageManager.CRYPT_TYPE_PATTERN) {
                    } else if (passwordType == StorageManager.CRYPT_TYPE_PATTERN) {
                        setContentView(R.layout.crypt_keeper_pattern_entry);
                        setBackFunctionality(false);
                        mStatusString = R.string.enter_pattern;
@@ -851,7 +873,6 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
            mPasswordEntry.setEnabled(false);
            setBackFunctionality(false);

            Log.d(TAG, "Attempting to send command to decrypt");
            new DecryptTask().execute(password);

            return true;