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

Commit 5ac69a23 authored by Justin Koh's avatar Justin Koh Committed by Android (Google) Code Review
Browse files

Merge "resolved conflicts for merge of bff6a514 to master"

parents 24fea55e 6a8096d7
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -1506,13 +1506,22 @@ public final class Settings {
        public static final String VOLUME_MASTER = "volume_master";

        /**
         * Whether the notifications should use the ring volume (value of 1) or a separate
         * notification volume (value of 0). In most cases, users will have this enabled so the
         * notification and ringer volumes will be the same. However, power users can disable this
         * and use the separate notification volume control.
         * Master volume mute (int 1 = mute, 0 = not muted).
         *
         * @hide
         */
        public static final String VOLUME_MASTER_MUTE = "volume_master_mute";

        /**
         * Whether the notifications should use the ring volume (value of 1) or
         * a separate notification volume (value of 0). In most cases, users
         * will have this enabled so the notification and ringer volumes will be
         * the same. However, power users can disable this and use the separate
         * notification volume control.
         * <p>
         * Note: This is a one-off setting that will be removed in the future when there is profile
         * support. For this reason, it is kept hidden from the public APIs.
         * Note: This is a one-off setting that will be removed in the future
         * when there is profile support. For this reason, it is kept hidden
         * from the public APIs.
         *
         * @hide
         * @deprecated
+18 −5
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ public class AudioService extends IAudioService.Stub {
    private static final int MSG_RCDISPLAY_CLEAR = 13;
    private static final int MSG_RCDISPLAY_UPDATE = 14;
    private static final int MSG_SET_ALL_VOLUMES = 15;
    private static final int MSG_PERSIST_MASTER_VOLUME_MUTE = 16;


    // flags for MSG_PERSIST_VOLUME indicating if current and/or last audible volume should be
@@ -501,6 +502,10 @@ public class AudioService extends IAudioService.Stub {
                System.MUTE_STREAMS_AFFECTED,
                ((1 << AudioSystem.STREAM_MUSIC)|(1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_SYSTEM)));

        boolean masterMute = System.getInt(cr, System.VOLUME_MASTER_MUTE, 0) == 1;
        AudioSystem.setMasterMute(masterMute);
        broadcastMasterMuteStatus(masterMute);

        // Each stream will read its own persisted settings

        // Broadcast the sticky intent
@@ -740,9 +745,14 @@ public class AudioService extends IAudioService.Stub {
    // UI update and Broadcast Intent
    private void sendMasterMuteUpdate(boolean muted, int flags) {
        mVolumePanel.postMasterMuteChanged(flags);
        broadcastMasterMuteStatus(muted);
    }

    private void broadcastMasterMuteStatus(boolean muted) {
        Intent intent = new Intent(AudioManager.MASTER_MUTE_CHANGED_ACTION);
        intent.putExtra(AudioManager.EXTRA_MASTER_VOLUME_MUTED, muted);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
                | Intent.FLAG_RECEIVER_REPLACE_PENDING);
        long origCallerIdentityToken = Binder.clearCallingIdentity();
        mContext.sendStickyBroadcast(intent);
        Binder.restoreCallingIdentity(origCallerIdentityToken);
@@ -820,6 +830,9 @@ public class AudioService extends IAudioService.Stub {
    public void setMasterMute(boolean state, IBinder cb) {
        if (state != AudioSystem.getMasterMute()) {
            AudioSystem.setMasterMute(state);
            // Post a persist master volume msg
            sendMsg(mAudioHandler, MSG_PERSIST_MASTER_VOLUME_MUTE, 0, SENDMSG_REPLACE, state ? 1
                    : 0, 0, null, PERSIST_DELAY);
            sendMasterMuteUpdate(state, AudioManager.FLAG_SHOW_UI);
        }
    }
@@ -2551,6 +2564,11 @@ public class AudioService extends IAudioService.Stub {
                            (float)msg.arg1 / (float)1000.0);
                    break;

                case MSG_PERSIST_MASTER_VOLUME_MUTE:
                    Settings.System.putInt(mContentResolver, Settings.System.VOLUME_MASTER_MUTE,
                            msg.arg1);
                    break;

                case MSG_PERSIST_RINGER_MODE:
                    // note that the value persisted is the current ringer mode, not the
                    // value of ringer mode as of the time the request was made to persist
@@ -3038,11 +3056,6 @@ public class AudioService extends IAudioService.Stub {
                    adapter.getProfileProxy(mContext, mBluetoothProfileServiceListener,
                                            BluetoothProfile.A2DP);
                }

                if (mUseMasterVolume) {
                    // Send sticky broadcast for initial master mute state
                    sendMasterMuteUpdate(false, 0);
                }
            } else if (action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
                if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
                    // a package is being removed, not replaced