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

Commit e01f9355 authored by Yorke Lee's avatar Yorke Lee Committed by Android (Google) Code Review
Browse files

Merge "Rename AudioState to CallAudioState" into mnc-dev

parents 7853e137 4af5935c
Loading
Loading
Loading
Loading
+24 −25
Original line number Diff line number Diff line
@@ -29940,23 +29940,6 @@ package android.system {
package android.telecom {
  public final class AudioState implements android.os.Parcelable {
    ctor public AudioState(boolean, int, int);
    ctor public AudioState(android.telecom.AudioState);
    method public static java.lang.String audioRouteToString(int);
    method public int describeContents();
    method public int getRoute();
    method public int getSupportedRouteMask();
    method public boolean isMuted();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.telecom.AudioState> CREATOR;
    field public static final int ROUTE_BLUETOOTH = 2; // 0x2
    field public static final int ROUTE_EARPIECE = 1; // 0x1
    field public static final int ROUTE_SPEAKER = 8; // 0x8
    field public static final int ROUTE_WIRED_HEADSET = 4; // 0x4
    field public static final int ROUTE_WIRED_OR_EARPIECE = 5; // 0x5
  }
  public final class Call {
    method public void answer(int);
    method public void conference(android.telecom.Call);
@@ -30050,11 +30033,27 @@ package android.telecom {
    field public static final int PROPERTY_WIFI = 8; // 0x8
  }
  public final class CallAudioState implements android.os.Parcelable {
    ctor public CallAudioState(boolean, int, int);
    method public static java.lang.String audioRouteToString(int);
    method public int describeContents();
    method public int getRoute();
    method public int getSupportedRouteMask();
    method public boolean isMuted();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.telecom.CallAudioState> CREATOR;
    field public static final int ROUTE_BLUETOOTH = 2; // 0x2
    field public static final int ROUTE_EARPIECE = 1; // 0x1
    field public static final int ROUTE_SPEAKER = 8; // 0x8
    field public static final int ROUTE_WIRED_HEADSET = 4; // 0x4
    field public static final int ROUTE_WIRED_OR_EARPIECE = 5; // 0x5
  }
  public abstract class Conference implements android.telecom.Conferenceable {
    ctor public Conference(android.telecom.PhoneAccountHandle);
    method public final boolean addConnection(android.telecom.Connection);
    method public final void destroy();
    method public final android.telecom.AudioState getAudioState();
    method public final android.telecom.CallAudioState getCallAudioState();
    method public final java.util.List<android.telecom.Connection> getConferenceableConnections();
    method public final int getConnectionCapabilities();
    method public final long getConnectionTime();
@@ -30065,7 +30064,7 @@ package android.telecom {
    method public final android.telecom.StatusHints getStatusHints();
    method public android.telecom.Connection.VideoProvider getVideoProvider();
    method public int getVideoState();
    method public void onAudioStateChanged(android.telecom.AudioState);
    method public void onCallAudioStateChanged(android.telecom.CallAudioState);
    method public void onConnectionAdded(android.telecom.Connection);
    method public void onDisconnect();
    method public void onHold();
@@ -30101,7 +30100,7 @@ package android.telecom {
    method public final android.net.Uri getAddress();
    method public final int getAddressPresentation();
    method public final boolean getAudioModeIsVoip();
    method public final android.telecom.AudioState getAudioState();
    method public final android.telecom.CallAudioState getCallAudioState();
    method public final java.lang.String getCallerDisplayName();
    method public final int getCallerDisplayNamePresentation();
    method public final android.telecom.Conference getConference();
@@ -30115,7 +30114,7 @@ package android.telecom {
    method public void onAbort();
    method public void onAnswer(int);
    method public void onAnswer();
    method public void onAudioStateChanged(android.telecom.AudioState);
    method public void onCallAudioStateChanged(android.telecom.CallAudioState);
    method public void onDisconnect();
    method public void onHold();
    method public void onPlayDtmfTone(char);
@@ -30273,12 +30272,12 @@ package android.telecom {
  public abstract class InCallService extends android.app.Service {
    ctor public InCallService();
    method public final boolean canAddCall();
    method public final android.telecom.AudioState getAudioState();
    method public final android.telecom.CallAudioState getCallAudioState();
    method public final java.util.List<android.telecom.Call> getCalls();
    method public void onAudioStateChanged(android.telecom.AudioState);
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onBringToForeground(boolean);
    method public void onCallAdded(android.telecom.Call);
    method public void onCallAudioStateChanged(android.telecom.CallAudioState);
    method public void onCallRemoved(android.telecom.Call);
    method public void onCanAddCallChanged(boolean);
    method public final void setAudioRoute(int);
@@ -30390,7 +30389,7 @@ package android.telecom {
    method public final void registerCallback(android.telecom.RemoteConference.Callback);
    method public final void registerCallback(android.telecom.RemoteConference.Callback, android.os.Handler);
    method public void separate(android.telecom.RemoteConnection);
    method public void setAudioState(android.telecom.AudioState);
    method public void setCallAudioState(android.telecom.CallAudioState);
    method public void stopDtmfTone();
    method public void swap();
    method public void unhold();
@@ -30430,7 +30429,7 @@ package android.telecom {
    method public void registerCallback(android.telecom.RemoteConnection.Callback);
    method public void registerCallback(android.telecom.RemoteConnection.Callback, android.os.Handler);
    method public void reject();
    method public void setAudioState(android.telecom.AudioState);
    method public void setCallAudioState(android.telecom.CallAudioState);
    method public void stopDtmfTone();
    method public void unhold();
    method public void unregisterCallback(android.telecom.RemoteConnection.Callback);
+36 −11
Original line number Diff line number Diff line
@@ -32066,9 +32066,10 @@ package android.system {
package android.telecom {
  public final class AudioState implements android.os.Parcelable {
  public deprecated class AudioState implements android.os.Parcelable {
    ctor public AudioState(boolean, int, int);
    ctor public AudioState(android.telecom.AudioState);
    ctor public AudioState(android.telecom.CallAudioState);
    method public static java.lang.String audioRouteToString(int);
    method public int describeContents();
    method public int getRoute();
@@ -32183,11 +32184,28 @@ package android.telecom {
    ctor public Call.Listener();
  }
  public final class CallAudioState implements android.os.Parcelable {
    ctor public CallAudioState(boolean, int, int);
    method public static java.lang.String audioRouteToString(int);
    method public int describeContents();
    method public int getRoute();
    method public int getSupportedRouteMask();
    method public boolean isMuted();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.telecom.CallAudioState> CREATOR;
    field public static final int ROUTE_BLUETOOTH = 2; // 0x2
    field public static final int ROUTE_EARPIECE = 1; // 0x1
    field public static final int ROUTE_SPEAKER = 8; // 0x8
    field public static final int ROUTE_WIRED_HEADSET = 4; // 0x4
    field public static final int ROUTE_WIRED_OR_EARPIECE = 5; // 0x5
  }
  public abstract class Conference implements android.telecom.Conferenceable {
    ctor public Conference(android.telecom.PhoneAccountHandle);
    method public final boolean addConnection(android.telecom.Connection);
    method public final void destroy();
    method public final android.telecom.AudioState getAudioState();
    method public final deprecated android.telecom.AudioState getAudioState();
    method public final android.telecom.CallAudioState getCallAudioState();
    method public final java.util.List<android.telecom.Connection> getConferenceableConnections();
    method public final deprecated long getConnectTimeMillis();
    method public final int getConnectionCapabilities();
@@ -32200,7 +32218,8 @@ package android.telecom {
    method public final android.telecom.StatusHints getStatusHints();
    method public android.telecom.Connection.VideoProvider getVideoProvider();
    method public int getVideoState();
    method public void onAudioStateChanged(android.telecom.AudioState);
    method public deprecated void onAudioStateChanged(android.telecom.AudioState);
    method public void onCallAudioStateChanged(android.telecom.CallAudioState);
    method public void onConnectionAdded(android.telecom.Connection);
    method public void onDisconnect();
    method public void onHold();
@@ -32237,7 +32256,8 @@ package android.telecom {
    method public final android.net.Uri getAddress();
    method public final int getAddressPresentation();
    method public final boolean getAudioModeIsVoip();
    method public final android.telecom.AudioState getAudioState();
    method public final deprecated android.telecom.AudioState getAudioState();
    method public final android.telecom.CallAudioState getCallAudioState();
    method public final java.lang.String getCallerDisplayName();
    method public final int getCallerDisplayNamePresentation();
    method public final android.telecom.Conference getConference();
@@ -32251,7 +32271,8 @@ package android.telecom {
    method public void onAbort();
    method public void onAnswer(int);
    method public void onAnswer();
    method public void onAudioStateChanged(android.telecom.AudioState);
    method public deprecated void onAudioStateChanged(android.telecom.AudioState);
    method public void onCallAudioStateChanged(android.telecom.CallAudioState);
    method public void onDisconnect();
    method public void onHold();
    method public void onPlayDtmfTone(char);
@@ -32409,13 +32430,13 @@ package android.telecom {
  public abstract class InCallService extends android.app.Service {
    ctor public InCallService();
    method public final boolean canAddCall();
    method public final android.telecom.AudioState getAudioState();
    method public final android.telecom.CallAudioState getCallAudioState();
    method public final java.util.List<android.telecom.Call> getCalls();
    method public deprecated android.telecom.Phone getPhone();
    method public void onAudioStateChanged(android.telecom.AudioState);
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onBringToForeground(boolean);
    method public void onCallAdded(android.telecom.Call);
    method public void onCallAudioStateChanged(android.telecom.CallAudioState);
    method public void onCallRemoved(android.telecom.Call);
    method public void onCanAddCallChanged(boolean);
    method public deprecated void onPhoneCreated(android.telecom.Phone);
@@ -32456,7 +32477,8 @@ package android.telecom {
  public final deprecated class Phone {
    method public final void addListener(android.telecom.Phone.Listener);
    method public final boolean canAddCall();
    method public final android.telecom.AudioState getAudioState();
    method public final deprecated android.telecom.AudioState getAudioState();
    method public final android.telecom.CallAudioState getCallAudioState();
    method public final java.util.List<android.telecom.Call> getCalls();
    method public final void removeListener(android.telecom.Phone.Listener);
    method public final void setAudioRoute(int);
@@ -32465,9 +32487,10 @@ package android.telecom {
  public static abstract class Phone.Listener {
    ctor public Phone.Listener();
    method public void onAudioStateChanged(android.telecom.Phone, android.telecom.AudioState);
    method public deprecated void onAudioStateChanged(android.telecom.Phone, android.telecom.AudioState);
    method public void onBringToForeground(android.telecom.Phone, boolean);
    method public void onCallAdded(android.telecom.Phone, android.telecom.Call);
    method public void onCallAudioStateChanged(android.telecom.Phone, android.telecom.CallAudioState);
    method public void onCallRemoved(android.telecom.Phone, android.telecom.Call);
    method public void onCanAddCallChanged(android.telecom.Phone, boolean);
  }
@@ -32549,7 +32572,8 @@ package android.telecom {
    method public final void registerCallback(android.telecom.RemoteConference.Callback);
    method public final void registerCallback(android.telecom.RemoteConference.Callback, android.os.Handler);
    method public void separate(android.telecom.RemoteConnection);
    method public void setAudioState(android.telecom.AudioState);
    method public deprecated void setAudioState(android.telecom.AudioState);
    method public void setCallAudioState(android.telecom.CallAudioState);
    method public void stopDtmfTone();
    method public void swap();
    method public void unhold();
@@ -32589,7 +32613,8 @@ package android.telecom {
    method public void registerCallback(android.telecom.RemoteConnection.Callback);
    method public void registerCallback(android.telecom.RemoteConnection.Callback, android.os.Handler);
    method public void reject();
    method public void setAudioState(android.telecom.AudioState);
    method public deprecated void setAudioState(android.telecom.AudioState);
    method public void setCallAudioState(android.telecom.CallAudioState);
    method public void stopDtmfTone();
    method public void unhold();
    method public void unregisterCallback(android.telecom.RemoteConnection.Callback);
+12 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.telecom;

import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

@@ -24,8 +25,12 @@ import java.util.Locale;
/**
 *  Encapsulates the telecom audio state, including the current audio routing, supported audio
 *  routing and mute.
 *  @deprecated - use {@link CallAudioState} instead.
 *  @hide
 */
public final class AudioState implements Parcelable {
@Deprecated
@SystemApi
public class AudioState implements Parcelable {
    /** Direct the audio stream through the device's earpiece. */
    public static final int ROUTE_EARPIECE      = 0x00000001;

@@ -64,6 +69,12 @@ public final class AudioState implements Parcelable {
        supportedRouteMask = state.getSupportedRouteMask();
    }

    public AudioState(CallAudioState state) {
        isMuted = state.isMuted();
        route = state.getRoute();
        supportedRouteMask = state.getSupportedRouteMask();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright 2014, 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.telecom;

/**
 * {@hide}
 */
parcelable CallAudioState;
+209 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.telecom;

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

import java.util.Locale;

/**
 *  Encapsulates the telecom audio state, including the current audio routing, supported audio
 *  routing and mute.
 */
public final class CallAudioState implements Parcelable {
    /** Direct the audio stream through the device's earpiece. */
    public static final int ROUTE_EARPIECE      = 0x00000001;

    /** Direct the audio stream through Bluetooth. */
    public static final int ROUTE_BLUETOOTH     = 0x00000002;

    /** Direct the audio stream through a wired headset. */
    public static final int ROUTE_WIRED_HEADSET = 0x00000004;

    /** Direct the audio stream through the device's speakerphone. */
    public static final int ROUTE_SPEAKER       = 0x00000008;

    /**
     * Direct the audio stream through the device's earpiece or wired headset if one is
     * connected.
     */
    public static final int ROUTE_WIRED_OR_EARPIECE = ROUTE_EARPIECE | ROUTE_WIRED_HEADSET;

    /** Bit mask of all possible audio routes. */
    private static final int ROUTE_ALL = ROUTE_EARPIECE | ROUTE_BLUETOOTH | ROUTE_WIRED_HEADSET |
            ROUTE_SPEAKER;

    private final boolean isMuted;
    private final int route;
    private final int supportedRouteMask;

    /**
     * Constructor for a {@link CallAudioState} object.
     *
     * @param muted {@code true} if the call is muted, {@code false} otherwise.
     * @param route The current audio route being used.
     * Allowed values:
     * {@link #ROUTE_EARPIECE}
     * {@link #ROUTE_BLUETOOTH}
     * {@link #ROUTE_WIRED_HEADSET}
     * {@link #ROUTE_SPEAKER}
     * @param supportedRouteMask Bit mask of all routes supported by this call. This should be a
     * bitwise combination of the following values:
     * {@link #ROUTE_EARPIECE}
     * {@link #ROUTE_BLUETOOTH}
     * {@link #ROUTE_WIRED_HEADSET}
     * {@link #ROUTE_SPEAKER}
     */
    public CallAudioState(boolean muted, int route, int supportedRouteMask) {
        this.isMuted = muted;
        this.route = route;
        this.supportedRouteMask = supportedRouteMask;
    }

    /** @hide */
    public CallAudioState(CallAudioState state) {
        isMuted = state.isMuted();
        route = state.getRoute();
        supportedRouteMask = state.getSupportedRouteMask();
    }

    /** @hide */
    @SuppressWarnings("deprecation")
    public CallAudioState(AudioState state) {
        isMuted = state.isMuted();
        route = state.getRoute();
        supportedRouteMask = state.getSupportedRouteMask();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof CallAudioState)) {
            return false;
        }
        CallAudioState state = (CallAudioState) obj;
        return isMuted() == state.isMuted() && getRoute() == state.getRoute() &&
                getSupportedRouteMask() == state.getSupportedRouteMask();
    }

    @Override
    public String toString() {
        return String.format(Locale.US,
                "[AudioState isMuted: %b, route: %s, supportedRouteMask: %s]",
                isMuted,
                audioRouteToString(route),
                audioRouteToString(supportedRouteMask));
    }

    /**
     * @return {@code true} if the call is muted, {@code false} otherwise.
     */
    public boolean isMuted() {
        return isMuted;
    }

    /**
     * @return The current audio route being used.
     */
    public int getRoute() {
        return route;
    }

    /**
     * @return Bit mask of all routes supported by this call.
     */
    public int getSupportedRouteMask() {
        return supportedRouteMask;
    }

    /**
     * Converts the provided audio route into a human readable string representation.
     *
     * @param route to convert into a string.
     *
     * @return String representation of the provided audio route.
     */
    public static String audioRouteToString(int route) {
        if (route == 0 || (route & ~ROUTE_ALL) != 0x0) {
            return "UNKNOWN";
        }

        StringBuffer buffer = new StringBuffer();
        if ((route & ROUTE_EARPIECE) == ROUTE_EARPIECE) {
            listAppend(buffer, "EARPIECE");
        }
        if ((route & ROUTE_BLUETOOTH) == ROUTE_BLUETOOTH) {
            listAppend(buffer, "BLUETOOTH");
        }
        if ((route & ROUTE_WIRED_HEADSET) == ROUTE_WIRED_HEADSET) {
            listAppend(buffer, "WIRED_HEADSET");
        }
        if ((route & ROUTE_SPEAKER) == ROUTE_SPEAKER) {
            listAppend(buffer, "SPEAKER");
        }

        return buffer.toString();
    }

    /**
     * Responsible for creating AudioState objects for deserialized Parcels.
     */
    public static final Parcelable.Creator<CallAudioState> CREATOR =
            new Parcelable.Creator<CallAudioState> () {

        @Override
        public CallAudioState createFromParcel(Parcel source) {
            boolean isMuted = source.readByte() == 0 ? false : true;
            int route = source.readInt();
            int supportedRouteMask = source.readInt();
            return new CallAudioState(isMuted, route, supportedRouteMask);
        }

        @Override
        public CallAudioState[] newArray(int size) {
            return new CallAudioState[size];
        }
    };

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

    /**
     * Writes AudioState object into a serializeable Parcel.
     */
    @Override
    public void writeToParcel(Parcel destination, int flags) {
        destination.writeByte((byte) (isMuted ? 1 : 0));
        destination.writeInt(route);
        destination.writeInt(supportedRouteMask);
    }

    private static void listAppend(StringBuffer buffer, String str) {
        if (buffer.length() > 0) {
            buffer.append(", ");
        }
        buffer.append(str);
    }
}
Loading