Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2953f31b authored by Robin Lee's avatar Robin Lee
Browse files

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
parent 6596c8ff
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -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
+2 −3
Original line number Diff line number Diff line
@@ -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 */,