diff options
Diffstat (limited to 'telecomm')
17 files changed, 468 insertions, 268 deletions
diff --git a/telecomm/java/android/telecom/AudioState.java b/telecomm/java/android/telecom/AudioState.java index 465c5f4..33013ac 100644 --- a/telecomm/java/android/telecom/AudioState.java +++ b/telecomm/java/android/telecom/AudioState.java @@ -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) { diff --git a/telecomm/java/android/telecom/CallAudioState.aidl b/telecomm/java/android/telecom/CallAudioState.aidl new file mode 100644 index 0000000..90dbbe5 --- /dev/null +++ b/telecomm/java/android/telecom/CallAudioState.aidl @@ -0,0 +1,22 @@ +/* + * 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; diff --git a/telecomm/java/android/telecom/CallAudioState.java b/telecomm/java/android/telecom/CallAudioState.java new file mode 100644 index 0000000..2b16722 --- /dev/null +++ b/telecomm/java/android/telecom/CallAudioState.java @@ -0,0 +1,209 @@ +/* + * 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); + } +} diff --git a/telecomm/java/android/telecom/Conference.java b/telecomm/java/android/telecom/Conference.java index 6fa94b9..dfbb67a 100644 --- a/telecomm/java/android/telecom/Conference.java +++ b/telecomm/java/android/telecom/Conference.java @@ -30,7 +30,7 @@ import java.util.concurrent.CopyOnWriteArraySet; /** * Represents a conference call which can contain any number of {@link Connection} objects. */ -public abstract class Conference implements Conferenceable { +public abstract class Conference extends Conferenceable { /** * Used to indicate that the conference connection time is not specified. If not specified, @@ -63,7 +63,7 @@ public abstract class Conference implements Conferenceable { Collections.unmodifiableList(mConferenceableConnections); private PhoneAccountHandle mPhoneAccount; - private AudioState mAudioState; + private CallAudioState mCallAudioState; private int mState = Connection.STATE_NEW; private DisconnectCause mDisconnectCause; private int mConnectionCapabilities; @@ -173,9 +173,22 @@ public abstract class Conference implements Conferenceable { * @return The audio state of the conference, describing how its audio is currently * being routed by the system. This is {@code null} if this Conference * does not directly know about its audio state. + * @deprecated Use {@link #getCallAudioState()} instead. + * @hide */ + @Deprecated + @SystemApi public final AudioState getAudioState() { - return mAudioState; + return new AudioState(mCallAudioState); + } + + /** + * @return The audio state of the conference, describing how its audio is currently + * being routed by the system. This is {@code null} if this Conference + * does not directly know about its audio state. + */ + public final CallAudioState getCallAudioState() { + return mCallAudioState; } /** @@ -249,10 +262,21 @@ public abstract class Conference implements Conferenceable { * Notifies this conference that the {@link #getAudioState()} property has a new value. * * @param state The new call audio state. + * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead. + * @hide */ + @SystemApi + @Deprecated public void onAudioStateChanged(AudioState state) {} /** + * Notifies this conference that the {@link #getCallAudioState()} property has a new value. + * + * @param state The new call audio state. + */ + public void onCallAudioStateChanged(CallAudioState state) {} + + /** * Notifies this conference that a connection has been added to it. * * @param connection The newly added connection. @@ -515,10 +539,11 @@ public abstract class Conference implements Conferenceable { * @param state The new audio state. * @hide */ - final void setAudioState(AudioState state) { - Log.d(this, "setAudioState %s", state); - mAudioState = state; - onAudioStateChanged(state); + final void setCallAudioState(CallAudioState state) { + Log.d(this, "setCallAudioState %s", state); + mCallAudioState = state; + onAudioStateChanged(getAudioState()); + onCallAudioStateChanged(state); } private void setState(int newState) { diff --git a/telecomm/java/android/telecom/Conferenceable.java b/telecomm/java/android/telecom/Conferenceable.java index 5c4cbc5..bb6f2b8 100644 --- a/telecomm/java/android/telecom/Conferenceable.java +++ b/telecomm/java/android/telecom/Conferenceable.java @@ -21,6 +21,6 @@ package android.telecom; * call with. The {@link ConnectionService} implementation will only recognize * {@link Conferenceable}s which are {@link Connection}s or {@link Conference}s. */ -public interface Conferenceable { - +public abstract class Conferenceable { + Conferenceable() {} } diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index 2ee5d25..fba4e6a 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -20,6 +20,7 @@ import com.android.internal.os.SomeArgs; import com.android.internal.telecom.IVideoCallback; import com.android.internal.telecom.IVideoProvider; +import android.annotation.SystemApi; import android.net.Uri; import android.os.Handler; import android.os.IBinder; @@ -46,7 +47,7 @@ import java.util.concurrent.ConcurrentHashMap; * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no * longer used and associated resources may be recovered. */ -public abstract class Connection implements Conferenceable { +public abstract class Connection extends Conferenceable { public static final int STATE_INITIALIZING = 0; @@ -817,7 +818,7 @@ public abstract class Connection implements Conferenceable { Collections.unmodifiableList(mConferenceables); private int mState = STATE_NEW; - private AudioState mAudioState; + private CallAudioState mCallAudioState; private Uri mAddress; private int mAddressPresentation; private String mCallerDisplayName; @@ -892,9 +893,22 @@ public abstract class Connection implements Conferenceable { * @return The audio state of the connection, describing how its audio is currently * being routed by the system. This is {@code null} if this Connection * does not directly know about its audio state. + * @deprecated Use {@link #getCallAudioState()} instead. + * @hide */ + @SystemApi + @Deprecated public final AudioState getAudioState() { - return mAudioState; + return new AudioState(mCallAudioState); + } + + /** + * @return The audio state of the connection, describing how its audio is currently + * being routed by the system. This is {@code null} if this Connection + * does not directly know about its audio state. + */ + public final CallAudioState getCallAudioState() { + return mCallAudioState; } /** @@ -968,11 +982,12 @@ public abstract class Connection implements Conferenceable { * @param state The new audio state. * @hide */ - final void setAudioState(AudioState state) { + final void setCallAudioState(CallAudioState state) { checkImmutable(); Log.d(this, "setAudioState %s", state); - mAudioState = state; - onAudioStateChanged(state); + mCallAudioState = state; + onAudioStateChanged(getAudioState()); + onCallAudioStateChanged(state); } /** @@ -1359,10 +1374,21 @@ public abstract class Connection implements Conferenceable { * Notifies this Connection that the {@link #getAudioState()} property has a new value. * * @param state The new connection audio state. + * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead. + * @hide */ + @SystemApi + @Deprecated public void onAudioStateChanged(AudioState state) {} /** + * Notifies this Connection that the {@link #getCallAudioState()} property has a new value. + * + * @param state The new connection audio state. + */ + public void onCallAudioStateChanged(CallAudioState state) {} + + /** * Notifies this Connection of an internal state change. This method is called after the * state is changed. * diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java index 13eb016..199100b 100644 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -50,7 +50,7 @@ import java.util.concurrent.ConcurrentHashMap; * <pre> * <service android:name="com.example.package.MyConnectionService" * android:label="@string/some_label_for_my_connection_service" - * android:permission="android.permission.BIND_CONNECTION_SERVICE"> + * android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"> * <intent-filter> * <action android:name="android.telecom.ConnectionService" /> * </intent-filter> @@ -90,7 +90,7 @@ public abstract class ConnectionService extends Service { private static final int MSG_DISCONNECT = 6; private static final int MSG_HOLD = 7; private static final int MSG_UNHOLD = 8; - private static final int MSG_ON_AUDIO_STATE_CHANGED = 9; + private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 9; private static final int MSG_PLAY_DTMF_TONE = 10; private static final int MSG_STOP_DTMF_TONE = 11; private static final int MSG_CONFERENCE = 12; @@ -180,11 +180,11 @@ public abstract class ConnectionService extends Service { } @Override - public void onAudioStateChanged(String callId, AudioState audioState) { + public void onCallAudioStateChanged(String callId, CallAudioState callAudioState) { SomeArgs args = SomeArgs.obtain(); args.arg1 = callId; - args.arg2 = audioState; - mHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, args).sendToTarget(); + args.arg2 = callAudioState; + mHandler.obtainMessage(MSG_ON_CALL_AUDIO_STATE_CHANGED, args).sendToTarget(); } @Override @@ -304,12 +304,12 @@ public abstract class ConnectionService extends Service { case MSG_UNHOLD: unhold((String) msg.obj); break; - case MSG_ON_AUDIO_STATE_CHANGED: { + case MSG_ON_CALL_AUDIO_STATE_CHANGED: { SomeArgs args = (SomeArgs) msg.obj; try { String callId = (String) args.arg1; - AudioState audioState = (AudioState) args.arg2; - onAudioStateChanged(callId, audioState); + CallAudioState audioState = (CallAudioState) args.arg2; + onCallAudioStateChanged(callId, new CallAudioState(audioState)); } finally { args.recycle(); } @@ -688,12 +688,14 @@ public abstract class ConnectionService extends Service { } } - private void onAudioStateChanged(String callId, AudioState audioState) { - Log.d(this, "onAudioStateChanged %s %s", callId, audioState); + private void onCallAudioStateChanged(String callId, CallAudioState callAudioState) { + Log.d(this, "onAudioStateChanged %s %s", callId, callAudioState); if (mConnectionById.containsKey(callId)) { - findConnectionForAction(callId, "onAudioStateChanged").setAudioState(audioState); + findConnectionForAction(callId, "onCallAudioStateChanged").setCallAudioState( + callAudioState); } else { - findConferenceForAction(callId, "onAudioStateChanged").setAudioState(audioState); + findConferenceForAction(callId, "onCallAudioStateChanged").setCallAudioState( + callAudioState); } } diff --git a/telecomm/java/android/telecom/IConferenceable.java b/telecomm/java/android/telecom/IConferenceable.java deleted file mode 100644 index a664baa..0000000 --- a/telecomm/java/android/telecom/IConferenceable.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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; - -/** - * Interface used to identify entities with which another entity can participate in a conference - * call with. The {@link ConnectionService} implementation will only recognize - * {@link Conferenceable}s which are {@link Connection}s or {@link Conference}s. - * <p> - * @deprecated use {@link Conferenceable} instead. - * @hide - */ -public interface IConferenceable extends Conferenceable { -} diff --git a/telecomm/java/android/telecom/InCallAdapter.java b/telecomm/java/android/telecom/InCallAdapter.java index 62b8dea..0cf7212 100644 --- a/telecomm/java/android/telecom/InCallAdapter.java +++ b/telecomm/java/android/telecom/InCallAdapter.java @@ -119,7 +119,7 @@ public final class InCallAdapter { } /** - * Sets the audio route (speaker, bluetooth, etc...). See {@link AudioState}. + * Sets the audio route (speaker, bluetooth, etc...). See {@link CallAudioState}. * * @param route The audio route to use. */ diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java index 182a7f5..e37cff7 100644 --- a/telecomm/java/android/telecom/InCallService.java +++ b/telecomm/java/android/telecom/InCallService.java @@ -52,7 +52,7 @@ public abstract class InCallService extends Service { private static final int MSG_ADD_CALL = 2; private static final int MSG_UPDATE_CALL = 3; private static final int MSG_SET_POST_DIAL_WAIT = 4; - private static final int MSG_ON_AUDIO_STATE_CHANGED = 5; + private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 5; private static final int MSG_BRING_TO_FOREGROUND = 6; private static final int MSG_ON_CAN_ADD_CALL_CHANGED = 7; @@ -87,8 +87,8 @@ public abstract class InCallService extends Service { } break; } - case MSG_ON_AUDIO_STATE_CHANGED: - mPhone.internalAudioStateChanged((AudioState) msg.obj); + case MSG_ON_CALL_AUDIO_STATE_CHANGED: + mPhone.internalCallAudioStateChanged((CallAudioState) msg.obj); break; case MSG_BRING_TO_FOREGROUND: mPhone.internalBringToForeground(msg.arg1 == 1); @@ -133,8 +133,8 @@ public abstract class InCallService extends Service { } @Override - public void onAudioStateChanged(AudioState audioState) { - mHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, audioState).sendToTarget(); + public void onCallAudioStateChanged(CallAudioState callAudioState) { + mHandler.obtainMessage(MSG_ON_CALL_AUDIO_STATE_CHANGED, callAudioState).sendToTarget(); } @Override @@ -156,6 +156,10 @@ public abstract class InCallService extends Service { InCallService.this.onAudioStateChanged(audioState); } + public void onCallAudioStateChanged(Phone phone, CallAudioState callAudioState) { + InCallService.this.onCallAudioStateChanged(callAudioState); + }; + /** ${inheritDoc} */ @Override public void onBringToForeground(Phone phone, boolean showDialpad) { @@ -248,14 +252,27 @@ public abstract class InCallService extends Service { * * @return An object encapsulating the audio state. Returns null if the service is not * fully initialized. + * @deprecated Use {@link #getCallAudioState()} instead. + * @hide */ + @Deprecated public final AudioState getAudioState() { return mPhone == null ? null : mPhone.getAudioState(); } /** + * Obtains the current phone call audio state. + * + * @return An object encapsulating the audio state. Returns null if the service is not + * fully initialized. + */ + public final CallAudioState getCallAudioState() { + return mPhone == null ? null : mPhone.getCallAudioState(); + } + + /** * Sets the microphone mute state. When this request is honored, there will be change to - * the {@link #getAudioState()}. + * the {@link #getCallAudioState()}. * * @param state {@code true} if the microphone should be muted; {@code false} otherwise. */ @@ -267,7 +284,7 @@ public abstract class InCallService extends Service { /** * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will - * be change to the {@link #getAudioState()}. + * be change to the {@link #getCallAudioState()}. * * @param route The audio route to use. */ @@ -311,11 +328,22 @@ public abstract class InCallService extends Service { * Called when the audio state changes. * * @param audioState The new {@link AudioState}. + * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState) instead}. + * @hide */ + @Deprecated public void onAudioStateChanged(AudioState audioState) { } /** + * Called when the audio state changes. + * + * @param audioState The new {@link CallAudioState}. + */ + public void onCallAudioStateChanged(CallAudioState audioState) { + } + + /** * Called to bring the in-call screen to the foreground. The in-call experience should * respond immediately by coming to the foreground to inform the user of the state of * ongoing {@code Call}s. diff --git a/telecomm/java/android/telecom/Phone.java b/telecomm/java/android/telecom/Phone.java index 4cdfd2e..8eb091b 100644 --- a/telecomm/java/android/telecom/Phone.java +++ b/telecomm/java/android/telecom/Phone.java @@ -41,10 +41,21 @@ public final class Phone { * * @param phone The {@code Phone} calling this method. * @param audioState The new {@link AudioState}. + * + * @deprecated Use {@link #onCallAudioStateChanged(Phone, CallAudioState)} instead. */ + @Deprecated public void onAudioStateChanged(Phone phone, AudioState audioState) { } /** + * Called when the audio state changes. + * + * @param phone The {@code Phone} calling this method. + * @param callAudioState The new {@link CallAudioState}. + */ + public void onCallAudioStateChanged(Phone phone, CallAudioState callAudioState) { } + + /** * Called to bring the in-call screen to the foreground. The in-call experience should * respond immediately by coming to the foreground to inform the user of the state of * ongoing {@code Call}s. @@ -100,7 +111,7 @@ public final class Phone { private final InCallAdapter mInCallAdapter; - private AudioState mAudioState; + private CallAudioState mCallAudioState; private final List<Listener> mListeners = new CopyOnWriteArrayList<>(); @@ -145,10 +156,10 @@ public final class Phone { } } - final void internalAudioStateChanged(AudioState audioState) { - if (!Objects.equals(mAudioState, audioState)) { - mAudioState = audioState; - fireAudioStateChanged(audioState); + final void internalCallAudioStateChanged(CallAudioState callAudioState) { + if (!Objects.equals(mCallAudioState, callAudioState)) { + mCallAudioState = callAudioState; + fireCallAudioStateChanged(callAudioState); } } @@ -271,9 +282,20 @@ public final class Phone { * Obtains the current phone call audio state of the {@code Phone}. * * @return An object encapsulating the audio state. + * @deprecated Use {@link #getCallAudioState()} instead. */ + @Deprecated public final AudioState getAudioState() { - return mAudioState; + return new AudioState(mCallAudioState); + } + + /** + * Obtains the current phone call audio state of the {@code Phone}. + * + * @return An object encapsulating the audio state. + */ + public final CallAudioState getCallAudioState() { + return mCallAudioState; } private void fireCallAdded(Call call) { @@ -288,9 +310,10 @@ public final class Phone { } } - private void fireAudioStateChanged(AudioState audioState) { + private void fireCallAudioStateChanged(CallAudioState audioState) { for (Listener listener : mListeners) { - listener.onAudioStateChanged(this, audioState); + listener.onCallAudioStateChanged(this, audioState); + listener.onAudioStateChanged(this, new AudioState(audioState)); } } diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java index 86475b1..f05a1ef 100644 --- a/telecomm/java/android/telecom/PhoneAccount.java +++ b/telecomm/java/android/telecom/PhoneAccount.java @@ -26,6 +26,7 @@ import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.Icon; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; @@ -127,6 +128,7 @@ public final class PhoneAccount implements Parcelable { /** * Indicating no icon tint is set. + * @hide */ public static final int NO_ICON_TINT = 0; @@ -144,14 +146,11 @@ public final class PhoneAccount implements Parcelable { private final Uri mAddress; private final Uri mSubscriptionAddress; private final int mCapabilities; - private final int mIconResId; - private final String mIconPackageName; - private final Bitmap mIconBitmap; - private final int mIconTint; private final int mHighlightColor; private final CharSequence mLabel; private final CharSequence mShortDescription; private final List<String> mSupportedUriSchemes; + private final Icon mIcon; /** * Helper class for creating a {@link PhoneAccount}. @@ -161,14 +160,11 @@ public final class PhoneAccount implements Parcelable { private Uri mAddress; private Uri mSubscriptionAddress; private int mCapabilities; - private int mIconResId; - private String mIconPackageName; - private Bitmap mIconBitmap; - private int mIconTint = NO_ICON_TINT; private int mHighlightColor = NO_HIGHLIGHT_COLOR; private CharSequence mLabel; private CharSequence mShortDescription; private List<String> mSupportedUriSchemes = new ArrayList<String>(); + private Icon mIcon; /** * Creates a builder with the specified {@link PhoneAccountHandle} and label. @@ -189,14 +185,11 @@ public final class PhoneAccount implements Parcelable { mAddress = phoneAccount.getAddress(); mSubscriptionAddress = phoneAccount.getSubscriptionAddress(); mCapabilities = phoneAccount.getCapabilities(); - mIconResId = phoneAccount.getIconResId(); - mIconPackageName = phoneAccount.getIconPackageName(); - mIconBitmap = phoneAccount.getIconBitmap(); - mIconTint = phoneAccount.getIconTint(); mHighlightColor = phoneAccount.getHighlightColor(); mLabel = phoneAccount.getLabel(); mShortDescription = phoneAccount.getShortDescription(); mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes()); + mIcon = phoneAccount.getIcon(); } /** @@ -233,65 +226,12 @@ public final class PhoneAccount implements Parcelable { } /** - * Sets the icon. See {@link PhoneAccount#createIconDrawable}. - * - * @param packageContext The package from which to load an icon. - * @param iconResId The resource in {@code iconPackageName} representing the icon. - * @return The builder. - */ - public Builder setIcon(Context packageContext, int iconResId) { - return setIcon(packageContext.getPackageName(), iconResId); - } - - /** - * Sets the icon. See {@link PhoneAccount#createIconDrawable}. - * - * @param iconPackageName The package from which to load an icon. - * @param iconResId The resource in {@code iconPackageName} representing the icon. - * @return The builder. - */ - public Builder setIcon(String iconPackageName, int iconResId) { - return setIcon(iconPackageName, iconResId, NO_ICON_TINT); - } - - /** - * Sets the icon. See {@link PhoneAccount#createIconDrawable}. + * Sets the icon. See {@link PhoneAccount#getIcon}. * - * @param packageContext The package from which to load an icon. - * @param iconResId The resource in {@code iconPackageName} representing the icon. - * @param iconTint A color with which to tint this icon. - * @return The builder. + * @param icon The icon to set. */ - public Builder setIcon(Context packageContext, int iconResId, int iconTint) { - return setIcon(packageContext.getPackageName(), iconResId, iconTint); - } - - /** - * Sets the icon. See {@link PhoneAccount#createIconDrawable}. - * - * @param iconPackageName The package from which to load an icon. - * @param iconResId The resource in {@code iconPackageName} representing the icon. - * @param iconTint A color with which to tint this icon. - * @return The builder. - */ - public Builder setIcon(String iconPackageName, int iconResId, int iconTint) { - this.mIconPackageName = iconPackageName; - this.mIconResId = iconResId; - this.mIconTint = iconTint; - return this; - } - - /** - * Sets the icon. See {@link PhoneAccount#createIconDrawable}. - * - * @param iconBitmap The icon bitmap. - * @return The builder. - */ - public Builder setIcon(Bitmap iconBitmap) { - this.mIconBitmap = iconBitmap; - this.mIconPackageName = null; - this.mIconResId = NO_RESOURCE_ID; - this.mIconTint = NO_ICON_TINT; + public Builder setIcon(Icon icon) { + mIcon = icon; return this; } @@ -363,10 +303,7 @@ public final class PhoneAccount implements Parcelable { mAddress, mSubscriptionAddress, mCapabilities, - mIconResId, - mIconPackageName, - mIconBitmap, - mIconTint, + mIcon, mHighlightColor, mLabel, mShortDescription, @@ -379,10 +316,7 @@ public final class PhoneAccount implements Parcelable { Uri address, Uri subscriptionAddress, int capabilities, - int iconResId, - String iconPackageName, - Bitmap iconBitmap, - int iconTint, + Icon icon, int highlightColor, CharSequence label, CharSequence shortDescription, @@ -391,10 +325,7 @@ public final class PhoneAccount implements Parcelable { mAddress = address; mSubscriptionAddress = subscriptionAddress; mCapabilities = capabilities; - mIconResId = iconResId; - mIconPackageName = iconPackageName; - mIconBitmap = iconBitmap; - mIconTint = iconTint; + mIcon = icon; mHighlightColor = highlightColor; mLabel = label; mShortDescription = shortDescription; @@ -497,6 +428,15 @@ public final class PhoneAccount implements Parcelable { } /** + * The icon to represent this {@code PhoneAccount}. + * + * @return The icon. + */ + public Icon getIcon() { + return mIcon; + } + + /** * Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI * scheme. * @@ -518,59 +458,6 @@ public final class PhoneAccount implements Parcelable { } /** - * The icon resource ID for the icon of this {@code PhoneAccount}. - * <p> - * Creators of a {@code PhoneAccount} who possess the icon in static resources should prefer - * this method of indicating the icon rather than using {@link #getIconBitmap()}, since it - * leads to less resource usage. - * <p> - * Clients wishing to display a {@code PhoneAccount} should use {@link #createIconDrawable(Context)}. - * - * @return A resource ID. - */ - public int getIconResId() { - return mIconResId; - } - - /** - * The package name from which to load the icon of this {@code PhoneAccount}. - * <p> - * If this property is {@code null}, the resource {@link #getIconResId()} will be loaded from - * the package in the {@link ComponentName} of the {@link #getAccountHandle()}. - * <p> - * Clients wishing to display a {@code PhoneAccount} should use {@link #createIconDrawable(Context)}. - * - * @return A package name. - */ - public String getIconPackageName() { - return mIconPackageName; - } - - /** - * A tint to apply to the icon of this {@code PhoneAccount}. - * - * @return A hexadecimal color value. - */ - public int getIconTint() { - return mIconTint; - } - - /** - * A literal icon bitmap to represent this {@code PhoneAccount} in a user interface. - * <p> - * If this property is specified, it is to be considered the preferred icon. Otherwise, the - * resource specified by {@link #getIconResId()} should be used. - * <p> - * Clients wishing to display a {@code PhoneAccount} should use - * {@link #createIconDrawable(Context)}. - * - * @return A bitmap. - */ - public Bitmap getIconBitmap() { - return mIconBitmap; - } - - /** * A highlight color to use in displaying information about this {@code PhoneAccount}. * * @return A hexadecimal color value. @@ -579,41 +466,6 @@ public final class PhoneAccount implements Parcelable { return mHighlightColor; } - /** - * Builds and returns an icon {@code Drawable} to represent this {@code PhoneAccount} in a user - * interface. Uses the properties {@link #getIconResId()}, {@link #getIconPackageName()}, and - * {@link #getIconBitmap()} as necessary. - * - * @param context A {@code Context} to use for loading {@code Drawable}s. - * - * @return An icon for this {@code PhoneAccount}. - */ - public Drawable createIconDrawable(Context context) { - if (mIconBitmap != null) { - return new BitmapDrawable(context.getResources(), mIconBitmap); - } - - if (mIconResId != 0) { - try { - Context packageContext = context.createPackageContext(mIconPackageName, 0); - try { - Drawable iconDrawable = packageContext.getDrawable(mIconResId); - if (mIconTint != NO_ICON_TINT) { - iconDrawable.setTint(mIconTint); - } - return iconDrawable; - } catch (NotFoundException | MissingResourceException e) { - Log.e(this, e, "Cannot find icon %d in package %s", - mIconResId, mIconPackageName); - } - } catch (PackageManager.NameNotFoundException e) { - Log.w(this, "Cannot find package %s", mIconPackageName); - } - } - - return new ColorDrawable(Color.TRANSPARENT); - } - // // Parcelable implementation // @@ -644,19 +496,16 @@ public final class PhoneAccount implements Parcelable { mSubscriptionAddress.writeToParcel(out, flags); } out.writeInt(mCapabilities); - out.writeInt(mIconResId); - out.writeString(mIconPackageName); - if (mIconBitmap == null) { - out.writeInt(0); - } else { - out.writeInt(1); - mIconBitmap.writeToParcel(out, flags); - } - out.writeInt(mIconTint); out.writeInt(mHighlightColor); out.writeCharSequence(mLabel); out.writeCharSequence(mShortDescription); out.writeStringList(mSupportedUriSchemes); + if (mIcon == null) { + out.writeInt(0); + } else { + out.writeInt(1); + mIcon.writeToParcel(out, flags); + } } public static final Creator<PhoneAccount> CREATOR @@ -689,18 +538,15 @@ public final class PhoneAccount implements Parcelable { mSubscriptionAddress = null; } mCapabilities = in.readInt(); - mIconResId = in.readInt(); - mIconPackageName = in.readString(); - if (in.readInt() > 0) { - mIconBitmap = Bitmap.CREATOR.createFromParcel(in); - } else { - mIconBitmap = null; - } - mIconTint = in.readInt(); mHighlightColor = in.readInt(); mLabel = in.readCharSequence(); mShortDescription = in.readCharSequence(); mSupportedUriSchemes = Collections.unmodifiableList(in.createStringArrayList()); + if (in.readInt() > 0) { + mIcon = Icon.CREATOR.createFromParcel(in); + } else { + mIcon = null; + } } @Override diff --git a/telecomm/java/android/telecom/RemoteConference.java b/telecomm/java/android/telecom/RemoteConference.java index b59584b..095a88f 100644 --- a/telecomm/java/android/telecom/RemoteConference.java +++ b/telecomm/java/android/telecom/RemoteConference.java @@ -18,6 +18,7 @@ package android.telecom; import com.android.internal.telecom.IConnectionService; +import android.annotation.SystemApi; import android.os.Handler; import android.os.RemoteException; @@ -355,14 +356,27 @@ public final class RemoteConference { * can include audio routing (Bluetooth, Speaker, etc) and muting state. * * @see android.telecom.AudioState + * @deprecated Use {@link #setCallAudioState(CallAudioState)} instead. + * @hide */ + @SystemApi + @Deprecated public void setAudioState(AudioState state) { + setCallAudioState(new CallAudioState(state)); + } + + /** + * Request to change the conference's audio routing to the specified state. The specified state + * can include audio routing (Bluetooth, Speaker, etc) and muting state. + */ + public void setCallAudioState(CallAudioState state) { try { - mConnectionService.onAudioStateChanged(mId, state); + mConnectionService.onCallAudioStateChanged(mId, state); } catch (RemoteException e) { } } + /** * Returns a list of independent connections that can me merged with this conference. * diff --git a/telecomm/java/android/telecom/RemoteConnection.java b/telecomm/java/android/telecom/RemoteConnection.java index 19bb3f1..08485a3 100644 --- a/telecomm/java/android/telecom/RemoteConnection.java +++ b/telecomm/java/android/telecom/RemoteConnection.java @@ -20,6 +20,7 @@ import com.android.internal.telecom.IConnectionService; import com.android.internal.telecom.IVideoCallback; import com.android.internal.telecom.IVideoProvider; +import android.annotation.SystemApi; import android.net.Uri; import android.os.Handler; import android.os.IBinder; @@ -776,11 +777,24 @@ public final class RemoteConnection { * Set the audio state of this {@code RemoteConnection}. * * @param state The audio state of this {@code RemoteConnection}. + * @hide + * @deprecated Use {@link #setCallAudioState(CallAudioState) instead. */ + @SystemApi + @Deprecated public void setAudioState(AudioState state) { + setCallAudioState(new CallAudioState(state)); + } + + /** + * Set the audio state of this {@code RemoteConnection}. + * + * @param state The audio state of this {@code RemoteConnection}. + */ + public void setCallAudioState(CallAudioState state) { try { if (mConnected) { - mConnectionService.onAudioStateChanged(mConnectionId, state); + mConnectionService.onCallAudioStateChanged(mConnectionId, state); } } catch (RemoteException ignored) { } diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index b2c036c..c8ed2b0 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -333,16 +333,24 @@ public class TelecomManager { * displayed to the user. */ - /** Property is displayed normally. */ + /** + * Indicates that the address or number of a call is allowed to be displayed for caller ID. + */ public static final int PRESENTATION_ALLOWED = 1; - /** Property was blocked. */ + /** + * Indicates that the address or number of a call is blocked by the other party. + */ public static final int PRESENTATION_RESTRICTED = 2; - /** Presentation was not specified or is unknown. */ + /** + * Indicates that the address or number of a call is not specified or known by the carrier. + */ public static final int PRESENTATION_UNKNOWN = 3; - /** Property should be displayed as a pay phone. */ + /** + * Indicates that the address or number of a call belongs to a pay phone. + */ public static final int PRESENTATION_PAYPHONE = 4; private static final String TAG = "TelecomManager"; diff --git a/telecomm/java/com/android/internal/telecom/IConnectionService.aidl b/telecomm/java/com/android/internal/telecom/IConnectionService.aidl index 339a982..c2e8530 100644 --- a/telecomm/java/com/android/internal/telecom/IConnectionService.aidl +++ b/telecomm/java/com/android/internal/telecom/IConnectionService.aidl @@ -17,7 +17,7 @@ package com.android.internal.telecom; import android.os.Bundle; -import android.telecom.AudioState; +import android.telecom.CallAudioState; import android.telecom.ConnectionRequest; import android.telecom.PhoneAccountHandle; @@ -56,7 +56,7 @@ oneway interface IConnectionService { void unhold(String callId); - void onAudioStateChanged(String activeCallId, in AudioState audioState); + void onCallAudioStateChanged(String activeCallId, in CallAudioState callAudioState); void playDtmfTone(String callId, char digit); diff --git a/telecomm/java/com/android/internal/telecom/IInCallService.aidl b/telecomm/java/com/android/internal/telecom/IInCallService.aidl index d26f6cb..ded47d5 100644 --- a/telecomm/java/com/android/internal/telecom/IInCallService.aidl +++ b/telecomm/java/com/android/internal/telecom/IInCallService.aidl @@ -17,7 +17,7 @@ package com.android.internal.telecom; import android.app.PendingIntent; -import android.telecom.AudioState; +import android.telecom.CallAudioState; import android.telecom.ParcelableCall; import com.android.internal.telecom.IInCallAdapter; @@ -40,7 +40,7 @@ oneway interface IInCallService { void setPostDialWait(String callId, String remaining); - void onAudioStateChanged(in AudioState audioState); + void onCallAudioStateChanged(in CallAudioState callAudioState); void bringToForeground(boolean showDialpad); |