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

Commit 6deaa4c8 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Merge "Notification playback synchronized with audio focus"

parents 24e602a9 99489ccf
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -22085,6 +22085,7 @@ package android.media {
    method public int describeContents();
    method public android.media.AudioAttributes getAttributes();
    method public java.lang.String getClientId();
    method public int getClientUid();
    method public int getFlags();
    method public int getGainRequest();
    method public int getLossReceived();
@@ -24269,10 +24270,12 @@ package android.media {
  }
  public class PlayerProxy {
    method public void pause() throws java.lang.IllegalStateException;
    method public void setVolume(float) throws java.lang.IllegalStateException;
    method public void start() throws java.lang.IllegalStateException;
    method public void stop() throws java.lang.IllegalStateException;
    method public void pause();
    method public void setPan(float);
    method public void setStartDelayMs(int);
    method public void setVolume(float);
    method public void start();
    method public void stop();
  }
  public final class Rating implements android.os.Parcelable {
+15 −5
Original line number Diff line number Diff line
@@ -29,9 +29,10 @@ import java.util.Objects;
@SystemApi
public final class AudioFocusInfo implements Parcelable {

    private AudioAttributes mAttributes;
    private String mClientId;
    private String mPackageName;
    private final AudioAttributes mAttributes;
    private final int mClientUid;
    private final String mClientId;
    private final String mPackageName;
    private int mGainRequest;
    private int mLossReceived;
    private int mFlags;
@@ -47,9 +48,10 @@ public final class AudioFocusInfo implements Parcelable {
     * @param flags
     * @hide
     */
    public AudioFocusInfo(AudioAttributes aa, String clientId, String packageName,
    public AudioFocusInfo(AudioAttributes aa, int clientUid, String clientId, String packageName,
            int gainRequest, int lossReceived, int flags) {
        mAttributes = aa == null ? new AudioAttributes.Builder().build() : aa;
        mClientUid = clientUid;
        mClientId = clientId == null ? "" : clientId;
        mPackageName = packageName == null ? "" : packageName;
        mGainRequest = gainRequest;
@@ -65,6 +67,9 @@ public final class AudioFocusInfo implements Parcelable {
    @SystemApi
    public AudioAttributes getAttributes() { return mAttributes; }

    @SystemApi
    public int getClientUid() { return mClientUid; }

    @SystemApi
    public String getClientId() { return mClientId; }

@@ -111,6 +116,7 @@ public final class AudioFocusInfo implements Parcelable {
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        mAttributes.writeToParcel(dest, flags);
        dest.writeInt(mClientUid);
        dest.writeString(mClientId);
        dest.writeString(mPackageName);
        dest.writeInt(mGainRequest);
@@ -121,7 +127,7 @@ public final class AudioFocusInfo implements Parcelable {
    @SystemApi
    @Override
    public int hashCode() {
        return Objects.hash(mAttributes, mClientId, mPackageName, mGainRequest, mFlags);
        return Objects.hash(mAttributes, mClientUid, mClientId, mPackageName, mGainRequest, mFlags);
    }

    @SystemApi
@@ -137,6 +143,9 @@ public final class AudioFocusInfo implements Parcelable {
        if (!mAttributes.equals(other.mAttributes)) {
            return false;
        }
        if (mClientUid != other.mClientUid) {
            return false;
        }
        if (!mClientId.equals(other.mClientId)) {
            return false;
        }
@@ -161,6 +170,7 @@ public final class AudioFocusInfo implements Parcelable {
        public AudioFocusInfo createFromParcel(Parcel in) {
            return new AudioFocusInfo(
                    AudioAttributes.CREATOR.createFromParcel(in), //AudioAttributes aa
                    in.readInt(), // int clientUid
                    in.readString(), //String clientId
                    in.readString(), //String packageName
                    in.readInt(), //int gainRequest
+17 −0
Original line number Diff line number Diff line
@@ -2428,6 +2428,23 @@ public class AudioManager {
        }
    }

    /**
     * @hide
     * Return the volume ramping time for a sound to be played after the given focus request,
     *   and to play a sound of the given attributes
     * @param focusGain
     * @param attr
     * @return
     */
    public int getFocusRampTimeMs(int focusGain, AudioAttributes attr) {
        IAudioService service = getService();
        try {
            return service.getFocusRampTimeMs(focusGain, attr);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @hide
     * Used internally by telephony package to abandon audio focus, typically after a call or
+20 −0
Original line number Diff line number Diff line
@@ -1880,6 +1880,26 @@ public class AudioTrack extends PlayerBase
        if (mState != STATE_INITIALIZED) {
            throw new IllegalStateException("play() called on uninitialized AudioTrack.");
        }
        //FIXME use lambda to pass startImpl to superclass
        final int delay = getStartDelayMs();
        if (delay == 0) {
            startImpl();
        } else {
            new Thread() {
                public void run() {
                    try {
                        Thread.sleep(delay);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    baseSetStartDelayMs(0);
                    startImpl();
                }
            }.start();
        }
    }

    private void startImpl() {
        synchronized(mPlayStateLock) {
            baseStart();
            native_start();
+2 −0
Original line number Diff line number Diff line
@@ -194,5 +194,7 @@ interface IAudioService {

    void disableRingtoneSync();

    int getFocusRampTimeMs(in int focusGain, in AudioAttributes attr);

    // WARNING: read warning at top of file, it is recommended to add new methods at the end
}
Loading