From f1dbf55819e01f6cf1a99d38a292b15de1262a29 Mon Sep 17 00:00:00 2001 From: Jason parks Date: Mon, 24 Jan 2011 16:19:28 -0600 Subject: [PATCH] More UI tweaks. * Grab a full wakelock while encrypting. * Fix a bug with failed attempts. * Add a custom theme to animate the screen to black. * Fix the keyboard to be displayed properly in landscape and portrait. Change-Id: Icc2d813ce1780588eb3b16f5204c3c60cae5236f --- AndroidManifest.xml | 8 +- res/anim/crypt_keeper_exit.xml | 33 +++++++ .../crypt_keeper_password_entry.xml | 88 ++++++++++--------- .../crypt_keeper_password_entry.xml | 85 +++++++++--------- res/layout/crypt_keeper_status.xml | 5 +- res/values/styles.xml | 12 +++ src/com/android/settings/CryptKeeper.java | 23 +++-- 7 files changed, 154 insertions(+), 100 deletions(-) create mode 100644 res/anim/crypt_keeper_exit.xml diff --git a/AndroidManifest.xml b/AndroidManifest.xml index f822ff65236..809e92a24f5 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1071,7 +1071,7 @@ @@ -1080,6 +1080,12 @@ + + + + + + + + + + diff --git a/res/layout-xlarge-land/crypt_keeper_password_entry.xml b/res/layout-xlarge-land/crypt_keeper_password_entry.xml index 76d2278a604..ffbdf8946a5 100644 --- a/res/layout-xlarge-land/crypt_keeper_password_entry.xml +++ b/res/layout-xlarge-land/crypt_keeper_password_entry.xml @@ -20,51 +20,53 @@ - - - - - - - - + + - - - - + + + + + + + \ No newline at end of file diff --git a/res/layout-xlarge/crypt_keeper_password_entry.xml b/res/layout-xlarge/crypt_keeper_password_entry.xml index 4dce67adf66..b67eed0342b 100644 --- a/res/layout-xlarge/crypt_keeper_password_entry.xml +++ b/res/layout-xlarge/crypt_keeper_password_entry.xml @@ -17,52 +17,49 @@ */ --> - - - - - - - - - + + - - - - - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/res/layout/crypt_keeper_status.xml b/res/layout/crypt_keeper_status.xml index ba2584f5b61..d106c69455e 100644 --- a/res/layout/crypt_keeper_status.xml +++ b/res/layout/crypt_keeper_status.xml @@ -23,10 +23,7 @@ android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="140dip" - android:layout_marginTop="20dip" - android:gravity="left" - > +> true true + + + + + + diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java index 3917b76e6f8..5afc3f614e2 100644 --- a/src/com/android/settings/CryptKeeper.java +++ b/src/com/android/settings/CryptKeeper.java @@ -57,6 +57,9 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList private static final int COOL_DOWN_ATTEMPTS = 10; private static final int COOL_DOWN_INTERVAL = 30; // 30 seconds + // This activity is used to fade the screen to black after the password is entered. + public static class Blank extends Activity { + } private Handler mHandler = new Handler() { @Override @@ -103,7 +106,6 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList } }; - private int mFailedAttempts = 0; private int mCooldown; @Override @@ -143,7 +145,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList // is encrypted. PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); + PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG); wakeLock.acquire(); @@ -192,15 +194,20 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList IMountService service = getMountService(); try { - service.decryptStorage(password); + int failedAttempts = service.decryptStorage(password); - if (mFailedAttempts == 0) { - // Success. Do something here within 2 seconds - - } else if (mFailedAttempts == MAX_FAILED_ATTEMPTS) { + if (failedAttempts == 0) { + // The password was entered successfully. Start the Blank activity + // so this activity animates to black before the devices starts. Note + // It has 1 second to complete the animation or it will be frozen + // until the boot animation comes back up. + Intent intent = new Intent(this, Blank.class); + finish(); + startActivity(intent); + } else if (failedAttempts == MAX_FAILED_ATTEMPTS) { // Factory reset the device. sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR")); - } else if ((mFailedAttempts % COOL_DOWN_ATTEMPTS) == 0) { + } else if ((failedAttempts % COOL_DOWN_ATTEMPTS) == 0) { mCooldown = COOL_DOWN_INTERVAL; EditText passwordEntry = (EditText) findViewById(R.id.passwordEntry); passwordEntry.setEnabled(false);