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

Commit a48d779d authored by John Spurlock's avatar John Spurlock
Browse files

Volume policy updates.

 - Make volume policy settable by the volume UI instead
   of hardcoded in AudioService.
 - Add status bar icon for silent mode.
 - Limit unmute-on-volume-adjust behavior to tvs.
 - Ensure all changes to device volume are sent through
   setIndex so no change events are missed.

Bug: 19260237
Change-Id: Iea070a7a6f90ff620e39629f2da3f33f87223d72
parent 80c24d4a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -3213,6 +3213,18 @@ public class AudioManager {
        }
    }

    /**
     * Only useful for volume controllers.
     * @hide
     */
    public void setVolumePolicy(VolumePolicy policy) {
        try {
            getService().setVolumePolicy(policy);
        } catch (RemoteException e) {
            Log.w(TAG, "Error calling setVolumePolicy", e);
        }
    }

    /**
     * Set Hdmi Cec system audio mode.
     *
+2 −2
Original line number Diff line number Diff line
@@ -46,10 +46,10 @@ public abstract class AudioManagerInternal {
    public interface RingerModeDelegate {
        /** Called when external ringer mode is evaluated, returns the new internal ringer mode */
        int onSetRingerModeExternal(int ringerModeOld, int ringerModeNew, String caller,
                int ringerModeInternal);
                int ringerModeInternal, VolumePolicy policy);

        /** Called when internal ringer mode is evaluated, returns the new external ringer mode */
        int onSetRingerModeInternal(int ringerModeOld, int ringerModeNew, String caller,
                int ringerModeExternal);
                int ringerModeExternal, VolumePolicy policy);
    }
}
+7 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.media.IRemoteVolumeObserver;
import android.media.IRingtonePlayer;
import android.media.IVolumeController;
import android.media.Rating;
import android.media.VolumePolicy;
import android.media.audiopolicy.AudioPolicyConfig;
import android.media.audiopolicy.IAudioPolicyCallback;
import android.net.Uri;
@@ -206,7 +207,10 @@ interface IAudioService {

    String registerAudioPolicy(in AudioPolicyConfig policyConfig,
            in IAudioPolicyCallback pcb, boolean hasFocusListener);

    oneway void unregisterAudioPolicyAsync(in IAudioPolicyCallback pcb);

    int setFocusPropertiesForPolicy(int duckingBehavior, in IAudioPolicyCallback pcb);

    void setVolumePolicy(in VolumePolicy policy);
}
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media;

parcelable VolumePolicy;
+68 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media;

import android.os.Parcel;
import android.os.Parcelable;

/** @hide */
public final class VolumePolicy implements Parcelable {
    public static final VolumePolicy DEFAULT = new VolumePolicy(false, false, true);

    public final boolean volumeDownToEnterSilent;
    public final boolean volumeUpToExitSilent;
    public final boolean doNotDisturbWhenSilent;

    public VolumePolicy(boolean volumeDownToEnterSilent, boolean volumeUpToExitSilent,
            boolean doNotDisturbWhenSilent) {
        this.volumeDownToEnterSilent = volumeDownToEnterSilent;
        this.volumeUpToExitSilent = volumeUpToExitSilent;
        this.doNotDisturbWhenSilent = doNotDisturbWhenSilent;
    }

    @Override
    public String toString() {
        return "VolumePolicy[volumeDownToEnterSilent=" + volumeDownToEnterSilent
                + ",volumeUpToExitSilent=" + volumeUpToExitSilent
                + ",doNotDisturbWhenSilent=" + doNotDisturbWhenSilent + "]";
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(volumeDownToEnterSilent ? 1 : 0);
        dest.writeInt(volumeUpToExitSilent ? 1 : 0);
        dest.writeInt(doNotDisturbWhenSilent ? 1 : 0);
    }

    public static final Parcelable.Creator<VolumePolicy> CREATOR
            = new Parcelable.Creator<VolumePolicy>() {
        @Override
        public VolumePolicy createFromParcel(Parcel p) {
            return new VolumePolicy(p.readInt() != 0, p.readInt() != 0, p.readInt() != 0);
        }

        @Override
        public VolumePolicy[] newArray(int size) {
            return new VolumePolicy[size];
        }
    };
}
 No newline at end of file
Loading