summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2014-10-17 18:53:32 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-17 18:53:32 +0000
commitb363c26e2f3255ad891d0fd466c9bbd2794a734d (patch)
tree54f443480fd23ca5e05bd84f66903118dc0d79bd
parent2106c79bc28324aa2bb3658b19c58551ddc1cc14 (diff)
parent431e246032d58b8aae72d348107f0d2aaa9efbac (diff)
downloadpackages_apps_Settings-b363c26e2f3255ad891d0fd466c9bbd2794a734d.zip
packages_apps_Settings-b363c26e2f3255ad891d0fd466c9bbd2794a734d.tar.gz
packages_apps_Settings-b363c26e2f3255ad891d0fd466c9bbd2794a734d.tar.bz2
am 431e2460: am 3ea423ae: User to confirm credentials if an accessibility service changes encryption.
* commit '431e246032d58b8aae72d348107f0d2aaa9efbac': User to confirm credentials if an accessibility service changes encryption.
-rw-r--r--res/layout-sw600dp-land/confirm_lock_password.xml2
-rw-r--r--res/layout-sw600dp/confirm_lock_password.xml3
-rw-r--r--res/layout/confirm_lock_password.xml3
-rw-r--r--res/values/strings.xml15
-rw-r--r--src/com/android/settings/ChooseLockSettingsHelper.java8
-rw-r--r--src/com/android/settings/ConfirmDeviceCredentialActivity.java9
-rw-r--r--src/com/android/settings/ConfirmLockPassword.java14
-rw-r--r--src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java64
8 files changed, 103 insertions, 15 deletions
diff --git a/res/layout-sw600dp-land/confirm_lock_password.xml b/res/layout-sw600dp-land/confirm_lock_password.xml
index e3cc20c..cbaad7a 100644
--- a/res/layout-sw600dp-land/confirm_lock_password.xml
+++ b/res/layout-sw600dp-land/confirm_lock_password.xml
@@ -41,7 +41,7 @@
android:layout_marginBottom="10dip"
android:gravity="start"
android:ellipsize="marquee"
- android:textAppearance="?android:attr/textAppearanceLarge"
+ android:textAppearance="?android:attr/textAppearanceMedium"
/>
<!-- Password entry field -->
diff --git a/res/layout-sw600dp/confirm_lock_password.xml b/res/layout-sw600dp/confirm_lock_password.xml
index 9e236d5..12b6ab2 100644
--- a/res/layout-sw600dp/confirm_lock_password.xml
+++ b/res/layout-sw600dp/confirm_lock_password.xml
@@ -30,8 +30,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
- android:lines="2"
- android:textAppearance="?android:attr/textAppearanceLarge"/>
+ android:textAppearance="?android:attr/textAppearanceMedium"/>
<!-- spacer above text entry field -->
<View
diff --git a/res/layout/confirm_lock_password.xml b/res/layout/confirm_lock_password.xml
index 0ea4c52..c9a0bbe 100644
--- a/res/layout/confirm_lock_password.xml
+++ b/res/layout/confirm_lock_password.xml
@@ -30,8 +30,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
- android:lines="2"
- android:textAppearance="?android:attr/textAppearanceLarge"/>
+ android:textAppearance="?android:attr/textAppearanceMedium"/>
<!-- Password entry field -->
<EditText android:id="@+id/password_entry"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5192ff6..4fea1d5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3675,6 +3675,21 @@
<string name="secure_lock_encryption_warning">Because you\'ve turned on an accessibility service,
your device won’t use your screen lock to enhance data encryption.</string>
+ <!-- Message to the user to enter his pattern before enabling an accessibility service. [CHAR LIMIT=NONE] -->
+ <string name="enable_service_pattern_reason">Turning on <xliff:g id="service"
+ example="TalkBack">%1$s</xliff:g> reduces data protection.
+ </string>
+
+ <!-- Message to the user to enter his PIN before enabling an accessibility service. [CHAR LIMIT=NONE] -->
+ <string name="enable_service_pin_reason">Turning on <xliff:g id="service"
+ example="TalkBack">%1$s</xliff:g> reduces data protection.
+ </string>
+
+ <!-- Message to the user to enter his password before enabling an accessibility service. [CHAR LIMIT=NONE] -->
+ <string name="enable_service_password_reason">Turning on <xliff:g id="service"
+ example="TalkBack">%1$s</xliff:g> reduces data protection.
+ </string>
+
<!-- Title for the capability of an accessibility service to receive events and keys. -->
<string name="capability_title_receiveAccessibilityEvents">Observe your actions</string>
<!-- Description for the capability of an accessibility service to receive events and keys. -->
diff --git a/src/com/android/settings/ChooseLockSettingsHelper.java b/src/com/android/settings/ChooseLockSettingsHelper.java
index 5aa511a..3086a7a 100644
--- a/src/com/android/settings/ChooseLockSettingsHelper.java
+++ b/src/com/android/settings/ChooseLockSettingsHelper.java
@@ -79,7 +79,7 @@ public final class ChooseLockSettingsHelper {
case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
// TODO: update UI layout for ConfirmPassword to show message and details
- launched = confirmPassword(request, returnCredentials);
+ launched = confirmPassword(request, message, returnCredentials);
break;
}
return launched;
@@ -116,13 +116,17 @@ public final class ChooseLockSettingsHelper {
/**
* Launch screen to confirm the existing lock password.
+ * @param message shown in header of ConfirmLockPassword if not null
* @param returnCredentials if true, put credentials into intent.
* @see #onActivityResult(int, int, android.content.Intent)
* @return true if we launched an activity to confirm password
*/
- private boolean confirmPassword(int request, boolean returnCredentials) {
+ private boolean confirmPassword(int request, CharSequence message,
+ boolean returnCredentials) {
if (!mLockPatternUtils.isLockPasswordEnabled()) return false;
final Intent intent = new Intent();
+ // supply header text in the intent
+ intent.putExtra(ConfirmLockPattern.HEADER_TEXT, message);
intent.setClassName("com.android.settings",
returnCredentials
? ConfirmLockPassword.InternalActivity.class.getName()
diff --git a/src/com/android/settings/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/ConfirmDeviceCredentialActivity.java
index 6b2bfd2..beb2d97 100644
--- a/src/com/android/settings/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/ConfirmDeviceCredentialActivity.java
@@ -30,6 +30,15 @@ import android.util.Log;
public class ConfirmDeviceCredentialActivity extends Activity {
public static final String TAG = ConfirmDeviceCredentialActivity.class.getSimpleName();
+ public static Intent createIntent(CharSequence title, CharSequence details) {
+ Intent intent = new Intent();
+ intent.setClassName("com.android.settings",
+ ConfirmDeviceCredentialActivity.class.getName());
+ intent.putExtra(KeyguardManager.EXTRA_TITLE, title);
+ intent.putExtra(KeyguardManager.EXTRA_DESCRIPTION, details);
+ return intent;
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/src/com/android/settings/ConfirmLockPassword.java b/src/com/android/settings/ConfirmLockPassword.java
index a89d718..c74e861 100644
--- a/src/com/android/settings/ConfirmLockPassword.java
+++ b/src/com/android/settings/ConfirmLockPassword.java
@@ -16,6 +16,7 @@
package com.android.settings;
+import android.text.TextUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.PasswordEntryKeyboardHelper;
import com.android.internal.widget.PasswordEntryKeyboardView;
@@ -44,6 +45,9 @@ import android.widget.TextView.OnEditorActionListener;
public class ConfirmLockPassword extends SettingsActivity {
+ public static final String PACKAGE = "com.android.settings";
+ public static final String HEADER_TEXT = PACKAGE + ".ConfirmLockPattern.header";
+
public static class InternalActivity extends ConfirmLockPassword {
}
@@ -122,7 +126,15 @@ public class ConfirmLockPassword extends SettingsActivity {
mIsAlpha = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == storedQuality
|| DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == storedQuality
|| DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == storedQuality;
- mHeaderText.setText(getDefaultHeader());
+
+ Intent intent = getActivity().getIntent();
+ if (intent != null) {
+ CharSequence headerMessage = intent.getCharSequenceExtra(HEADER_TEXT);
+ if (TextUtils.isEmpty(headerMessage)) {
+ headerMessage = getString(getDefaultHeader());
+ }
+ mHeaderText.setText(headerMessage);
+ }
final Activity activity = getActivity();
mKeyboardHelper = new PasswordEntryKeyboardHelper(activity,
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 51b5ca9..b10cefd 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -17,8 +17,10 @@
package com.android.settings.accessibility;
import android.accessibilityservice.AccessibilityServiceInfo;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
+import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
@@ -37,6 +39,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.ConfirmDeviceCredentialActivity;
import com.android.settings.R;
import com.android.settings.widget.ToggleSwitch;
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
@@ -52,6 +55,10 @@ public class ToggleAccessibilityServicePreferenceFragment
private static final int DIALOG_ID_ENABLE_WARNING = 1;
private static final int DIALOG_ID_DISABLE_WARNING = 2;
+ public static final int ACTIVITY_REQUEST_CONFIRM_CREDENTIAL = 1;
+
+ private LockPatternUtils mLockPatternUtils;
+
private final SettingsContentObserver mSettingsContentObserver =
new SettingsContentObserver(new Handler()) {
@Override
@@ -65,6 +72,12 @@ public class ToggleAccessibilityServicePreferenceFragment
private int mShownDialogId;
@Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mLockPatternUtils = new LockPatternUtils(getActivity());
+ }
+
+ @Override
public void onResume() {
mSettingsContentObserver.register(getContentResolver());
updateSwitchBarToggleSwitch();
@@ -276,26 +289,63 @@ public class ToggleAccessibilityServicePreferenceFragment
}
@Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == ACTIVITY_REQUEST_CONFIRM_CREDENTIAL) {
+ if (resultCode == Activity.RESULT_OK) {
+ handleConfirmServiceEnabled(true);
+ } else {
+ handleConfirmServiceEnabled(false);
+ }
+ }
+ }
+
+ @Override
public void onClick(DialogInterface dialog, int which) {
final boolean checked;
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
- checked = (mShownDialogId == DIALOG_ID_ENABLE_WARNING);
- mSwitchBar.setCheckedInternal(checked);
- getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, checked);
- onPreferenceToggled(mPreferenceKey, checked);
+ if (mShownDialogId == DIALOG_ID_ENABLE_WARNING) {
+ if (LockPatternUtils.isDeviceEncrypted()) {
+ String title = createConfirmCredentialReasonMessage();
+ Intent intent = ConfirmDeviceCredentialActivity.createIntent(title, null);
+ startActivityForResult(intent, ACTIVITY_REQUEST_CONFIRM_CREDENTIAL);
+ } else {
+ handleConfirmServiceEnabled(true);
+ }
+ } else {
+ handleConfirmServiceEnabled(false);
+ }
break;
case DialogInterface.BUTTON_NEGATIVE:
checked = (mShownDialogId == DIALOG_ID_DISABLE_WARNING);
- mSwitchBar.setCheckedInternal(checked);
- getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, checked);
- onPreferenceToggled(mPreferenceKey, checked);
+ handleConfirmServiceEnabled(checked);
break;
default:
throw new IllegalArgumentException();
}
}
+ private void handleConfirmServiceEnabled(boolean confirmed) {
+ mSwitchBar.setCheckedInternal(confirmed);
+ getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, confirmed);
+ onPreferenceToggled(mPreferenceKey, confirmed);
+ }
+
+ private String createConfirmCredentialReasonMessage() {
+ int resId = R.string.enable_service_password_reason;
+ switch (mLockPatternUtils.getKeyguardStoredPasswordQuality()) {
+ case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: {
+ resId = R.string.enable_service_pattern_reason;
+ } break;
+ case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX: {
+ resId = R.string.enable_service_pin_reason;
+ } break;
+ }
+ return getString(resId, getAccessibilityServiceInfo().getResolveInfo()
+ .loadLabel(getPackageManager()));
+ }
+
@Override
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();