summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robin Lee <rgl@google.com> 2017-02-10 15:32:49 +0000
committer Robin Lee <rgl@google.com> 2017-02-10 15:34:53 +0000
commitcccf3244b6f3e93856b1b51e70044ec565ab7b12 (patch)
treee10721a9961463fe89ea4d7c1d5b0027e32a2473
parentaa6e4b5b93c6c3f23b2d72e7cff9d9e7683746f4 (diff)
Prompt credentials for installing/deleting sounds
Actually we probably want to confirm credentials in all locked cases not just when starting the user -- fewer corners to special case. Fix: 34734809 Test: manual. set a work profile lock, screen off/on, open sound settings, try to set a work ringtone. first attempt should prompt for credentials, second attempt should not until next screen-off. Change-Id: I1fea94f3b0d1b768b22741b887d9891f5e318549
-rw-r--r--src/com/android/settings/DefaultRingtonePreference.java2
-rw-r--r--src/com/android/settings/Utils.java13
2 files changed, 13 insertions, 2 deletions
diff --git a/src/com/android/settings/DefaultRingtonePreference.java b/src/com/android/settings/DefaultRingtonePreference.java
index 09f5af4999a..823c970f63a 100644
--- a/src/com/android/settings/DefaultRingtonePreference.java
+++ b/src/com/android/settings/DefaultRingtonePreference.java
@@ -46,7 +46,7 @@ public class DefaultRingtonePreference extends RingtonePreference {
@Override
public void performClick() {
if (mUserId != UserHandle.USER_CURRENT) {
- if (Utils.unlockWorkProfileIfNecessary(getContext(), mUserId) ||
+ if (Utils.confirmWorkProfileCredentialsIfNecessary(getContext(), mUserId) ||
Utils.startQuietModeDialogIfNecessary(getContext(),
UserManager.get(getContext()), mUserId)) {
return;
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 803b8e548a5..b1c3ab36175 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -1161,6 +1161,18 @@ public final class Utils extends com.android.settingslib.Utils {
if (!(new LockPatternUtils(context)).isSecure(userId)) {
return false;
}
+ return confirmWorkProfileCredentials(context, userId);
+ }
+
+ public static boolean confirmWorkProfileCredentialsIfNecessary(Context context, int userId) {
+ KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
+ if (!km.isDeviceLocked(userId)) {
+ return false;
+ }
+ return confirmWorkProfileCredentials(context, userId);
+ }
+
+ private static boolean confirmWorkProfileCredentials(Context context, int userId) {
final KeyguardManager km = (KeyguardManager) context.getSystemService(
Context.KEYGUARD_SERVICE);
final Intent unlockIntent = km.createConfirmDeviceCredentialIntent(null, null, userId);
@@ -1170,7 +1182,6 @@ public final class Utils extends com.android.settingslib.Utils {
} else {
return false;
}
-
}
public static CharSequence getApplicationLabel(Context context, String packageName) {