summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2014-10-17 23:57:34 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-17 23:57:34 +0000
commit3221a342117bc3fd366e3f6520db0cb0672bb1f1 (patch)
treed180b73b771b01f480bcf5ccead096c85c57a2eb /src
parent1f39d6a6e78d5fd0595306d1ed38a8f7ac04e3fe (diff)
parentba1b33407d66289a2367caab3141a3555f1fdcf7 (diff)
downloadpackages_apps_Settings-3221a342117bc3fd366e3f6520db0cb0672bb1f1.tar.gz
packages_apps_Settings-3221a342117bc3fd366e3f6520db0cb0672bb1f1.tar.bz2
packages_apps_Settings-3221a342117bc3fd366e3f6520db0cb0672bb1f1.zip
am ba1b3340: am 602d559d: Merge "Several fixes to new EncryptionInterstitial dialog." into lmp-dev
* commit 'ba1b33407d66289a2367caab3141a3555f1fdcf7': Several fixes to new EncryptionInterstitial dialog.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/ChooseLockGeneric.java33
-rw-r--r--src/com/android/settings/ChooseLockPassword.java17
-rw-r--r--src/com/android/settings/ChooseLockPattern.java15
-rw-r--r--src/com/android/settings/EncryptionInterstitial.java44
-rw-r--r--src/com/android/settings/SecuritySettings.java7
-rw-r--r--src/com/android/settings/SettingsActivity.java16
6 files changed, 91 insertions, 41 deletions
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index 40fa69e6e..e3a993250 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -45,6 +45,7 @@ import com.android.internal.widget.LockPatternUtils;
import java.util.List;
public class ChooseLockGeneric extends SettingsActivity {
+ public static final String CONFIRM_CREDENTIALS = "confirm_credentials";
@Override
public Intent getIntent() {
@@ -75,7 +76,7 @@ public class ChooseLockGeneric extends SettingsActivity {
private static final int FALLBACK_REQUEST = 101;
private static final int ENABLE_ENCRYPTION_REQUEST = 102;
private static final String PASSWORD_CONFIRMED = "password_confirmed";
- private static final String CONFIRM_CREDENTIALS = "confirm_credentials";
+
private static final String WAITING_FOR_CONFIRMATION = "waiting_for_confirmation";
private static final String FINISH_PENDING = "finish_pending";
public static final String MINIMUM_QUALITY_KEY = "minimum_quality";
@@ -92,6 +93,8 @@ public class ChooseLockGeneric extends SettingsActivity {
private boolean mFinishPending = false;
private int mEncryptionRequestQuality;
private boolean mEncryptionRequestDisabled;
+ private boolean mRequirePassword;
+ private LockPatternUtils mLockPatternUtils;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -100,6 +103,7 @@ public class ChooseLockGeneric extends SettingsActivity {
mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
mKeyStore = KeyStore.getInstance();
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this.getActivity());
+ mLockPatternUtils = new LockPatternUtils(getActivity());
// Defaults to needing to confirm credentials
final boolean confirmCredentials = getActivity().getIntent()
@@ -183,9 +187,16 @@ public class ChooseLockGeneric extends SettingsActivity {
if (Process.myUserHandle().isOwner() && LockPatternUtils.isDeviceEncryptionEnabled()) {
mEncryptionRequestQuality = quality;
mEncryptionRequestDisabled = disabled;
- Intent intent = EncryptionInterstitial.createStartIntent(getActivity(), quality);
+ // If accessibility is enabled and the user hasn't seen this dialog before, set the
+ // default state to agree with that which is compatible with accessibility
+ // (password not required).
+ final boolean accEn = AccessibilityManager.getInstance(getActivity()).isEnabled();
+ final boolean required = mLockPatternUtils.isCredentialRequiredToDecrypt(!accEn);
+ Intent intent = EncryptionInterstitial.createStartIntent(
+ getActivity(), quality, required);
startActivityForResult(intent, ENABLE_ENCRYPTION_REQUEST);
} else {
+ mRequirePassword = false; // device encryption not enabled or not device owner.
updateUnlockMethodAndFinish(quality, disabled);
}
}
@@ -218,6 +229,8 @@ public class ChooseLockGeneric extends SettingsActivity {
finish();
} else if (requestCode == ENABLE_ENCRYPTION_REQUEST
&& resultCode == Activity.RESULT_OK) {
+ mRequirePassword = data.getBooleanExtra(
+ EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
updateUnlockMethodAndFinish(mEncryptionRequestQuality, mEncryptionRequestDisabled);
} else {
getActivity().setResult(Activity.RESULT_CANCELED);
@@ -412,13 +425,8 @@ public class ChooseLockGeneric extends SettingsActivity {
minLength = MIN_PASSWORD_LENGTH;
}
final int maxLength = mDPM.getPasswordMaximumLength(quality);
- Intent intent = new Intent().setClass(getActivity(), ChooseLockPassword.class);
- intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, quality);
- intent.putExtra(ChooseLockPassword.PASSWORD_MIN_KEY, minLength);
- intent.putExtra(ChooseLockPassword.PASSWORD_MAX_KEY, maxLength);
- intent.putExtra(CONFIRM_CREDENTIALS, false);
- intent.putExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK,
- isFallback);
+ Intent intent = ChooseLockPassword.createIntent(getActivity(), quality, isFallback,
+ minLength, maxLength, mRequirePassword, false /* confirm credentials */);
if (isFallback) {
startActivityForResult(intent, FALLBACK_REQUEST);
return;
@@ -428,11 +436,8 @@ public class ChooseLockGeneric extends SettingsActivity {
startActivity(intent);
}
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
- Intent intent = new Intent(getActivity(), ChooseLockPattern.class);
- intent.putExtra("key_lock_method", "pattern");
- intent.putExtra(CONFIRM_CREDENTIALS, false);
- intent.putExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK,
- isFallback);
+ Intent intent = ChooseLockPattern.createIntent(getActivity(),
+ isFallback, mRequirePassword, false /* confirm credentials */);
if (isFallback) {
startActivityForResult(intent, FALLBACK_REQUEST);
return;
diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/ChooseLockPassword.java
index 0a703cfb0..b72d5c591 100644
--- a/src/com/android/settings/ChooseLockPassword.java
+++ b/src/com/android/settings/ChooseLockPassword.java
@@ -25,6 +25,7 @@ import android.app.Activity;
import android.app.Fragment;
import android.app.admin.DevicePolicyManager;
import android.content.ContentResolver;
+import android.content.Context;
import android.content.Intent;
import android.inputmethodservice.KeyboardView;
import android.os.Bundle;
@@ -64,6 +65,19 @@ public class ChooseLockPassword extends SettingsActivity {
return modIntent;
}
+ public static Intent createIntent(Context context, int quality, final boolean isFallback,
+ int minLength, final int maxLength, boolean requirePasswordToDecrypt,
+ boolean confirmCredentials) {
+ Intent intent = new Intent().setClass(context, ChooseLockPassword.class);
+ intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, quality);
+ intent.putExtra(PASSWORD_MIN_KEY, minLength);
+ intent.putExtra(PASSWORD_MAX_KEY, maxLength);
+ intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials);
+ intent.putExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, isFallback);
+ intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePasswordToDecrypt);
+ return intent;
+ }
+
@Override
protected boolean isValidFragment(String fragmentName) {
if (ChooseLockPasswordFragment.class.getName().equals(fragmentName)) return true;
@@ -412,6 +426,9 @@ public class ChooseLockPassword extends SettingsActivity {
final boolean isFallback = getActivity().getIntent().getBooleanExtra(
LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
mLockPatternUtils.clearLock(isFallback);
+ final boolean required = getActivity().getIntent().getBooleanExtra(
+ EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
+ mLockPatternUtils.setCredentialRequiredToDecrypt(required);
mLockPatternUtils.saveLockPassword(pin, mRequestedQuality, isFallback);
getActivity().setResult(RESULT_FINISHED);
getActivity().finish();
diff --git a/src/com/android/settings/ChooseLockPattern.java b/src/com/android/settings/ChooseLockPattern.java
index 46bf94ca0..3d3ef1698 100644
--- a/src/com/android/settings/ChooseLockPattern.java
+++ b/src/com/android/settings/ChooseLockPattern.java
@@ -28,6 +28,7 @@ import static com.android.internal.widget.LockPatternView.DisplayMode;
import android.app.Activity;
import android.app.Fragment;
import android.content.ContentResolver;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
@@ -68,6 +69,16 @@ public class ChooseLockPattern extends SettingsActivity {
return modIntent;
}
+ public static Intent createIntent(Context context, final boolean isFallback,
+ boolean requirePassword, boolean confirmCredentials) {
+ Intent intent = new Intent(context, ChooseLockPattern.class);
+ intent.putExtra("key_lock_method", "pattern");
+ intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials);
+ intent.putExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, isFallback);
+ intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePassword);
+ return intent;
+ }
+
@Override
protected boolean isValidFragment(String fragmentName) {
if (ChooseLockPatternFragment.class.getName().equals(fragmentName)) return true;
@@ -528,6 +539,10 @@ public class ChooseLockPattern extends SettingsActivity {
final boolean isFallback = getActivity().getIntent()
.getBooleanExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
+
+ final boolean required = getActivity().getIntent().getBooleanExtra(
+ EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
+ utils.setCredentialRequiredToDecrypt(required);
utils.saveLockPattern(mChosenPattern, isFallback);
utils.setLockPatternEnabled(true);
diff --git a/src/com/android/settings/EncryptionInterstitial.java b/src/com/android/settings/EncryptionInterstitial.java
index 8a62001da..070805d42 100644
--- a/src/com/android/settings/EncryptionInterstitial.java
+++ b/src/com/android/settings/EncryptionInterstitial.java
@@ -24,8 +24,6 @@ import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
-import android.os.PersistableBundle;
-import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -35,6 +33,7 @@ import android.widget.TextView;
public class EncryptionInterstitial extends SettingsActivity {
private static final String EXTRA_PASSWORD_QUALITY = "extra_password_quality";
+ public static final String EXTRA_REQUIRE_PASSWORD = "extra_require_password";
@Override
public Intent getIntent() {
@@ -48,14 +47,16 @@ public class EncryptionInterstitial extends SettingsActivity {
return EncryptionInterstitialFragment.class.getName().equals(fragmentName);
}
- public static Intent createStartIntent(Context ctx, int quality) {
+ public static Intent createStartIntent(Context ctx, int quality,
+ boolean requirePasswordDefault) {
return new Intent(ctx, EncryptionInterstitial.class)
.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, true)
.putExtra(EXTRA_PREFS_SET_BACK_TEXT, (String) null)
.putExtra(EXTRA_PREFS_SET_NEXT_TEXT, ctx.getString(
R.string.encryption_continue_button))
.putExtra(EXTRA_PASSWORD_QUALITY, quality)
- .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.encryption_interstitial_header);
+ .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.encryption_interstitial_header)
+ .putExtra(EXTRA_REQUIRE_PASSWORD, requirePasswordDefault);
}
public static class EncryptionInterstitialFragment extends SettingsPreferenceFragment
@@ -64,6 +65,7 @@ public class EncryptionInterstitial extends SettingsActivity {
private RadioButton mRequirePasswordToDecryptButton;
private RadioButton mDontRequirePasswordToDecryptButton;
private TextView mEncryptionMessage;
+ private boolean mPasswordRequired;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -98,32 +100,36 @@ public class EncryptionInterstitial extends SettingsActivity {
disableId = R.string.encrypt_dont_require_password;
break;
}
+ mPasswordRequired = getActivity().getIntent().getBooleanExtra(
+ EXTRA_REQUIRE_PASSWORD, true);
+
mEncryptionMessage.setText(msgId);
+
mRequirePasswordToDecryptButton.setOnClickListener(this);
mRequirePasswordToDecryptButton.setText(enableId);
+ mRequirePasswordToDecryptButton.setChecked(mPasswordRequired);
+
mDontRequirePasswordToDecryptButton.setOnClickListener(this);
mDontRequirePasswordToDecryptButton.setText(disableId);
+ mDontRequirePasswordToDecryptButton.setChecked(!mPasswordRequired);
+
+ updateRequirePasswordIntent();
return view;
}
@Override
- public void onResume() {
- super.onResume();
- loadFromSettings();
- }
-
- private void loadFromSettings() {
- final boolean required = Settings.Global.getInt(getContentResolver(),
- Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, 1) == 1 ? true : false;
- mRequirePasswordToDecryptButton.setChecked(required);
- mDontRequirePasswordToDecryptButton.setChecked(!required);
+ public void onClick(View v) {
+ mPasswordRequired = (v == mRequirePasswordToDecryptButton);
+ updateRequirePasswordIntent();
}
- @Override
- public void onClick(View v) {
- final boolean required = (v == mRequirePasswordToDecryptButton);
- Settings.Global.putInt(getContentResolver(),
- Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, required ? 1 : 0);
+ // Updates the value we want to return.
+ private void updateRequirePasswordIntent() {
+ SettingsActivity sa = (SettingsActivity)getActivity();
+ Intent resultIntentData = sa.getResultIntentData();
+ resultIntentData = resultIntentData == null ? new Intent() : resultIntentData;
+ resultIntentData.putExtra(EXTRA_REQUIRE_PASSWORD, mPasswordRequired);
+ sa.setResultIntentData(resultIntentData);
}
}
}
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index b068c5164..65761639a 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -218,15 +218,12 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
if (mIsPrimary) {
- switch (mDPM.getStorageEncryptionStatus()) {
- case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE:
+ if (LockPatternUtils.isDeviceEncryptionEnabled()) {
// The device is currently encrypted.
addPreferencesFromResource(R.xml.security_settings_encrypted);
- break;
- case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE:
+ } else {
// This device supports encryption but isn't encrypted.
addPreferencesFromResource(R.xml.security_settings_unencrypted);
- break;
}
}
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 3ca85eabe..37fcc8719 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -368,6 +368,8 @@ public class SettingsActivity extends Activity
private boolean mNeedToRevertToInitialFragment = false;
private int mHomeActivitiesCount = 1;
+ private Intent mResultIntentData;
+
public SwitchBar getSwitchBar() {
return mSwitchBar;
}
@@ -597,21 +599,21 @@ public class SettingsActivity extends Activity
Button backButton = (Button)findViewById(R.id.back_button);
backButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
- setResult(RESULT_CANCELED);
+ setResult(RESULT_CANCELED, getResultIntentData());
finish();
}
});
Button skipButton = (Button)findViewById(R.id.skip_button);
skipButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
- setResult(RESULT_OK);
+ setResult(RESULT_OK, getResultIntentData());
finish();
}
});
mNextButton = (Button)findViewById(R.id.next_button);
mNextButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
- setResult(RESULT_OK);
+ setResult(RESULT_OK, getResultIntentData());
finish();
}
});
@@ -1345,4 +1347,12 @@ public class SettingsActivity extends Activity
mSearchMenuItem.collapseActionView();
}
}
+
+ public Intent getResultIntentData() {
+ return mResultIntentData;
+ }
+
+ public void setResultIntentData(Intent resultIntentData) {
+ mResultIntentData = resultIntentData;
+ }
}