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

Commit 977f3d34 authored by Roman Birg's avatar Roman Birg
Browse files

Settings: handle decrypting larger pattern sizes



Change-Id: Id24d46829063171fa87cabb23a7da378726d7548
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
(cherry picked from commit 47c4889a)
parent fb3bbcb1
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -36,6 +36,18 @@

    </LinearLayout>

    <LinearLayout
            android:id="@+id/pattern_sizes"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/crypt_keeper_pattern_margin"
            android:layout_marginEnd="@dimen/crypt_keeper_pattern_margin"
            android:orientation="horizontal">

        <include layout="@layout/crypt_keeper_pattern_sizes" />

    </LinearLayout>

    <include layout="@layout/crypt_keeper_emergency_button" />

</LinearLayout>
+73 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2015 The CyanogenMod Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">

    <Button
            android:id="@+id/lock_pattern_size_3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:textSize="14sp"
            android:fontFamily="sans-serif"
            android:text="@string/lock_pattern_size_3"
            android:textColor="@color/text_color_white"
            android:layout_weight="1"
            android:onClick="onPatternButtonClick"
            style="?android:attr/borderlessButtonStyle"/>

    <Button
            android:id="@+id/lock_pattern_size_4"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:textSize="14sp"
            android:fontFamily="sans-serif"
            android:text="@string/lock_pattern_size_4"
            android:textColor="@color/text_color_white"
            android:layout_weight="1"
            android:onClick="onPatternButtonClick"
            style="?android:attr/borderlessButtonStyle"/>

    <Button
            android:id="@+id/lock_pattern_size_5"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:textSize="14sp"
            android:fontFamily="sans-serif"
            android:text="@string/lock_pattern_size_5"
            android:textColor="@color/text_color_white"
            android:layout_weight="1"
            android:onClick="onPatternButtonClick"
            style="?android:attr/borderlessButtonStyle"/>

    <Button
            android:id="@+id/lock_pattern_size_6"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:textSize="14sp"
            android:fontFamily="sans-serif"
            android:text="@string/lock_pattern_size_6"
            android:textColor="@color/text_color_white"
            android:layout_weight="1"
            android:onClick="onPatternButtonClick"
            style="?android:attr/borderlessButtonStyle"/>


</merge >
+37 −3
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
@@ -199,6 +200,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
                hide(R.id.status);
                hide(R.id.owner_info);
                hide(R.id.emergencyCallButton);
                hide(R.id.pattern_sizes);
            } else if (failedAttempts == MAX_FAILED_ATTEMPTS) {
                // Factory reset the device.
                Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
@@ -651,6 +653,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
    /** Disable password input for a while to force the user to waste time between retries */
    private void cooldown() {
        final TextView status = (TextView) findViewById(R.id.status);
        final ViewGroup sizes = (ViewGroup) findViewById(R.id.status);

        if (mCooldown <= 0) {
            // Re-enable the password entry and back presses.
@@ -663,6 +666,9 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
            }
            if (mLockPatternView != null) {
                mLockPatternView.setEnabled(true);
                if (sizes != null) {
                    sizes.setEnabled(true);
                }
            }
            status.setText(mStatusString);
        } else {
@@ -672,6 +678,9 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
            }
            if (mLockPatternView != null) {
                mLockPatternView.setEnabled(false);
                if (sizes != null) {
                    sizes.setEnabled(false);
                }
            }

            CharSequence template = getText(R.string.crypt_keeper_cooldown);
@@ -716,8 +725,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
        public void onPatternDetected(List<LockPatternView.Cell> pattern) {
            mLockPatternView.setEnabled(false);
            if (pattern.size() >= MIN_LENGTH_BEFORE_REPORT) {
                new DecryptTask().execute(new LockPatternUtils(CryptKeeper.this)
                        .patternToString(pattern));
                new DecryptTask().execute(LockPatternUtils.patternToString(pattern,
                        mLockPatternView.getLockPatternSize()));
            } else {
                // Allow user to make as many of these as they want.
                fakeUnlockAttempt(mLockPatternView);
@@ -1017,4 +1026,29 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
    public void afterTextChanged(Editable s) {
        return;
    }

    public void onPatternButtonClick(View v) {
        byte size;
        switch (v.getId()) {
            default:
            case R.id.lock_pattern_size_3:
                size = 3;
                break;
            case R.id.lock_pattern_size_4:
                size = 4;
                break;
            case R.id.lock_pattern_size_5:
                size = 5;
                break;
            case R.id.lock_pattern_size_6:
                size = 6;
                break;
        }
        if (mLockPatternView != null) {
            setContentView(R.layout.crypt_keeper_pattern_entry);
            passwordEntryInit();
            mLockPatternView.setLockPatternSize(size);
            mLockPatternView.postInvalidate();
        }
    }
}