Merge "Honor hide pattern on crypto screen" into lmp-dev

This commit is contained in:
Paul Lawrence
2014-08-25 21:59:26 +00:00
committed by Android (Google) Code Review
2 changed files with 37 additions and 0 deletions

View File

@@ -133,6 +133,9 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
// how long we wait to clear a wrong pattern
private static final int WRONG_PATTERN_CLEAR_TIMEOUT_MS = 1500;
// how long we wait to clear a right pattern
private static final int RIGHT_PATTERN_CLEAR_TIMEOUT_MS = 500;
private Runnable mClearPatternRunnable = new Runnable() {
public void run() {
mLockPatternView.clearPattern();
@@ -167,6 +170,10 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
if (failedAttempts == 0) {
// The password was entered successfully. Simply do nothing
// and wait for the service restart to switch to surfacefligner
if (mLockPatternView != null) {
mLockPatternView.removeCallbacks(mClearPatternRunnable);
mLockPatternView.postDelayed(mClearPatternRunnable, RIGHT_PATTERN_CLEAR_TIMEOUT_MS);
}
} else if (failedAttempts == MAX_FAILED_ATTEMPTS) {
// Factory reset the device.
sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
@@ -409,6 +416,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
new AsyncTask<Void, Void, Void>() {
int type = StorageManager.CRYPT_TYPE_PASSWORD;
String owner_info;
boolean pattern_visible;
@Override
public Void doInBackground(Void... v) {
@@ -416,6 +424,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
final IMountService service = getMountService();
type = service.getPasswordType();
owner_info = service.getField("OwnerInfo");
pattern_visible = !("0".equals(service.getField("PatternVisible")));
} catch (Exception e) {
Log.e(TAG, "Error calling mount service " + e);
}
@@ -445,6 +454,10 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
passwordEntryInit();
if (mLockPatternView != null) {
mLockPatternView.setInStealthMode(!pattern_visible);
}
if (mCooldown > 0) {
setBackFunctionality(false);
cooldown(); // in case we are cooling down and coming back from emergency dialler

View File

@@ -25,6 +25,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.storage.IMountService;
import android.util.Log;
import android.view.LayoutInflater;
@@ -32,6 +33,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.android.internal.widget.LockPatternUtils;
public class CryptKeeperConfirm extends Fragment {
public static class Blank extends Activity {
@@ -90,6 +93,27 @@ public class CryptKeeperConfirm extends Fragment {
return;
}
/* WARNING - nasty hack!
Settings for the lock screen are not available to the crypto
screen (CryptKeeper) at boot. We duplicate the ones that
CryptKeeper needs to the crypto key/value store when they are
modified (see LockPatternUtils).
However, prior to encryption, the crypto key/value store is not
persisted across reboots, thus modified settings are lost to
CryptKeeper.
In order to make sure CryptKeeper had the correct settings after
first encrypting, we thus need to rewrite them, which ensures the
crypto key/value store is up to date. On encryption, this store
is then persisted, and the settings will be there on future
reboots.
*/
LockPatternUtils utils = new LockPatternUtils(getActivity());
utils.setVisiblePatternEnabled(utils.isVisiblePatternEnabled());
if (utils.isOwnerInfoEnabled()) {
utils.setOwnerInfo(utils.getOwnerInfo(UserHandle.USER_OWNER),
UserHandle.USER_OWNER);
}
Intent intent = new Intent(getActivity(), Blank.class);
intent.putExtras(getArguments());