summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robin Lee <rgl@google.com> 2017-01-26 18:14:08 +0000
committer Robin Lee <rgl@google.com> 2017-01-26 18:20:45 +0000
commit2953f31b61fb8c8c1334ecbf7f65d0de05776f06 (patch)
treefd7e075115832ca1fbc6e86771317ae713b57116
parent6596c8ff4ee50e370a1e203d54a565626a7a06ef (diff)
Prompt to start user before choosing a new ringtone
Dead users can't hear, nor see, ringtones. Let's wake them up and give them a good shake first. Until then, show a nice friendly "work profile isn't available" message. Or depending on locale something confusing, egregious, and mismatched like "work profile isn't available" instead. Fix: 34735015 Bug: 34734809 Test: make RunSettingsRoboTests && make Settings && adb install -r $OUT/system/priv-app/Settings/Settings.apk && then reboot the device to see what happens Change-Id: I86e61a7f3f654d7f38f04c43227a31e2f288e18f
-rw-r--r--src/com/android/settings/DefaultRingtonePreference.java20
-rw-r--r--src/com/android/settings/notification/WorkSoundPreferenceController.java5
2 files changed, 11 insertions, 14 deletions
diff --git a/src/com/android/settings/DefaultRingtonePreference.java b/src/com/android/settings/DefaultRingtonePreference.java
index 6893a21801c..09f5af4999a 100644
--- a/src/com/android/settings/DefaultRingtonePreference.java
+++ b/src/com/android/settings/DefaultRingtonePreference.java
@@ -30,7 +30,7 @@ import android.util.Log;
public class DefaultRingtonePreference extends RingtonePreference {
private static final String TAG = "DefaultRingtonePreference";
- private int mUserId;
+ private int mUserId = UserHandle.USER_CURRENT;
protected Context mUserContext;
public DefaultRingtonePreference(Context context, AttributeSet attrs) {
@@ -40,21 +40,19 @@ public class DefaultRingtonePreference extends RingtonePreference {
public void setUserId(int userId) {
mUserId = userId;
- Context context = getContext();
- mUserContext = Utils.createPackageContextAsUser(context, mUserId);
+ mUserContext = Utils.createPackageContextAsUser(getContext(), mUserId);
}
@Override
public void performClick() {
- if (!Utils.startQuietModeDialogIfNecessary(getContext(), UserManager.get(getContext()),
- mUserId)) {
- super.performClick();
+ if (mUserId != UserHandle.USER_CURRENT) {
+ if (Utils.unlockWorkProfileIfNecessary(getContext(), mUserId) ||
+ Utils.startQuietModeDialogIfNecessary(getContext(),
+ UserManager.get(getContext()), mUserId)) {
+ return;
+ }
}
- }
-
- public void clearUserId(int userId) {
- mUserId = UserHandle.USER_CURRENT;
- mUserContext = getContext();
+ super.performClick();
}
@Override
diff --git a/src/com/android/settings/notification/WorkSoundPreferenceController.java b/src/com/android/settings/notification/WorkSoundPreferenceController.java
index cc671ad11cc..3053f2ac38a 100644
--- a/src/com/android/settings/notification/WorkSoundPreferenceController.java
+++ b/src/com/android/settings/notification/WorkSoundPreferenceController.java
@@ -157,9 +157,8 @@ public class WorkSoundPreferenceController extends PreferenceController implemen
}
private CharSequence updateRingtoneName(Context context, int type) {
- if (context == null) {
- Log.e(TAG, "Unable to update ringtone name, no context provided");
- return null;
+ if (context == null || !UserManager.get(context).isUserUnlocked(context.getUserId())) {
+ return context.getString(R.string.managed_profile_not_available_label);
}
Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, type);
return Ringtone.getTitle(context, ringtoneUri, false /* followSettingsUri */,