* 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
<activity android:name=".CryptKeeper"
android:immersive="true"
android:launchMode="singleTop"
- android:theme="@android:style/Theme.Holo.NoActionBar"
+ android:theme="@style/CryptKeeperTheme"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter android:priority="10">
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
+ <activity android:name=".CryptKeeper$Blank"
+ android:immersive="true"
+ android:launchMode="singleTop"
+ android:theme="@style/CryptKeeperBlankTheme"
+ />
+
<!-- Pseudo-activity used to provide an intent-filter entry point to encryption settings -->
<activity android:name="Settings$CryptKeeperSettingsActivity"
android:theme="@android:style/Theme.Holo"
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source 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.
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_interpolator"
+>
+
+ <scale
+ android:fromXScale="1.0"
+ android:toXScale="0.0"
+ android:fromYScale="1.0"
+ android:toYScale="0.0"
+ android:pivotX="50%"
+ android:pivotY="50%"
+ android:fillAfter="false"
+ android:duration="500"
+ />
+
+</set>
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="horizontal"
+ android:orientation="vertical"
>
- <LinearLayout
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:layout_width="0dip"
- android:orientation="vertical"
- android:gravity="center_vertical"
- >
- <include layout="@layout/crypt_keeper_status" />
- </LinearLayout>
-
- <!-- right side: password -->
- <LinearLayout
- android:layout_width="0dip"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:layout_weight="1"
- android:gravity="center">
- <!-- Password entry field -->
- <EditText android:id="@+id/passwordEntry"
- android:layout_height="wrap_content"
- android:layout_width="450dip"
- android:singleLine="true"
- android:textStyle="normal"
- android:inputType="textPassword"
- android:gravity="center"
- android:layout_gravity="center"
- android:textSize="24sp"
- android:layout_marginTop="120dip"
- android:layout_marginBottom="5dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="#ffffffff"
- android:editable="false"
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1"
+ >
+ <!-- left side: status -->
+ <include layout="@layout/crypt_keeper_status"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="102dip"
+ android:layout_marginTop="20dip"
+ android:gravity="left"
+ android:paddingTop="50dip"
+ android:layout_centerVertical="true"
+ android:layout_alignParentLeft="true"
/>
- <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
- android:layout_width="450dip"
- android:layout_height="230dip"
- android:background="#00000000"
- android:keyBackground="@*android:drawable/btn_keyboard_key_fulltrans"
- android:visibility="visible"
- />
-
- </LinearLayout>
-
+ <!-- Password entry field -->
+ <EditText android:id="@+id/passwordEntry"
+ android:layout_height="wrap_content"
+ android:layout_width="450dip"
+ android:layout_marginRight="155dip"
+ android:layout_alignParentRight="true"
+ android:singleLine="true"
+ android:textStyle="normal"
+ android:inputType="textPassword"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:textSize="24sp"
+ android:layout_marginTop="120dip"
+ android:layout_marginBottom="5dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="#ffffffff"
+ android:editable="false"
+ />
+
+ </RelativeLayout>
+
+ <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#00000000"
+ android:keyBackground="@*android:drawable/btn_keyboard_key_fulltrans"
+ android:visibility="visible"
+ />
+
</LinearLayout>
\ No newline at end of file
*/
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical"
+ android:gravity="center_horizontal"
>
- <LinearLayout
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:orientation="vertical"
- android:gravity="center_vertical"
- >
- <include layout="@layout/crypt_keeper_status" />
- </LinearLayout>
-
- <!-- right side: password -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:gravity="center">
- <!-- Password entry field -->
- <EditText android:id="@+id/passwordEntry"
- android:layout_height="wrap_content"
- android:layout_width="450dip"
- android:singleLine="true"
- android:textStyle="normal"
- android:inputType="textPassword"
- android:gravity="center"
- android:layout_gravity="center"
- android:textSize="24sp"
- android:layout_marginTop="120dip"
- android:layout_marginBottom="5dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="#ffffffff"
- android:editable="false"
- />
+ <!-- left side: status -->
+ <include layout="@layout/crypt_keeper_status"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="134dip"
+ android:paddingTop="50dip"
+ android:layout_alignParentTop="true"
+ android:layout_gravity="center_horizontal"
+ android:layout_centerHorizontal="true"
+ />
- <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
- android:layout_width="450dip"
- android:layout_height="230dip"
- android:background="#00000000"
- android:keyBackground="@*android:drawable/btn_keyboard_key_fulltrans"
- android:visibility="visible"
- />
-
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
+ <!-- Password entry field -->
+ <EditText android:id="@+id/passwordEntry"
+ android:layout_above="@id/keyboard"
+ android:layout_height="wrap_content"
+ android:layout_width="450dip"
+ android:singleLine="true"
+ android:textStyle="normal"
+ android:inputType="textPassword"
+ android:gravity="center"
+ android:layout_gravity="center_horizontal"
+ android:layout_centerHorizontal="true"
+ android:textSize="24sp"
+ android:layout_marginTop="120dip"
+ android:layout_marginBottom="5dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="#ffffffff"
+ android:editable="false"
+ />
+
+ <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:background="#00000000"
+ android:keyBackground="@*android:drawable/btn_keyboard_key_fulltrans"
+ android:visibility="visible"
+ />
+
+</RelativeLayout>
\ No newline at end of file
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="140dip"
- android:layout_marginTop="20dip"
- android:gravity="left"
- >
+>
<com.android.internal.widget.DigitalClock android:id="@+id/time"
android:layout_width="wrap_content"
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
</style>
+
+ <style name="CryptKeeperTheme" parent="@android:style/Theme.Holo.NoActionBar">
+ <item name="android:windowAnimationStyle">@style/CryptKeeperAnimation</item>
+ </style>
+
+ <style name="CryptKeeperBlankTheme" parent="@android:style/Theme.Holo.NoActionBar">
+ <item name="android:background">#ff000000</item>
+ </style>
+
+ <style name="CryptKeeperAnimation">
+ <item name="android:windowExitAnimation">@anim/crypt_keeper_exit</item>
+ </style>
</resources>
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
}
};
- private int mFailedAttempts = 0;
private int mCooldown;
@Override
// 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();
IMountService service = getMountService();
try {
- service.decryptStorage(password);
-
- if (mFailedAttempts == 0) {
- // Success. Do something here within 2 seconds
-
- } else if (mFailedAttempts == MAX_FAILED_ATTEMPTS) {
+ int failedAttempts = service.decryptStorage(password);
+
+ 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);