2014-06-17 19:08:45 -07:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2014-09-12 22:16:17 -07:00
|
|
|
package android.telecom;
|
2014-06-17 19:08:45 -07:00
|
|
|
|
2014-09-12 22:16:17 -07:00
|
|
|
import com.android.internal.telecom.IConnectionService;
|
|
|
|
import com.android.internal.telecom.IVideoCallback;
|
|
|
|
import com.android.internal.telecom.IVideoProvider;
|
2014-08-07 19:46:01 -07:00
|
|
|
|
2015-05-27 17:21:45 -07:00
|
|
|
import android.annotation.Nullable;
|
2015-05-13 14:14:54 -07:00
|
|
|
import android.annotation.SystemApi;
|
2015-06-04 11:08:54 -07:00
|
|
|
import android.hardware.camera2.CameraManager;
|
2014-06-17 19:08:45 -07:00
|
|
|
import android.net.Uri;
|
2015-05-27 17:21:45 -07:00
|
|
|
import android.os.Bundle;
|
2015-04-23 15:47:06 -07:00
|
|
|
import android.os.Handler;
|
2014-08-20 09:36:40 -07:00
|
|
|
import android.os.IBinder;
|
2014-06-17 19:08:45 -07:00
|
|
|
import android.os.RemoteException;
|
2014-08-20 09:36:40 -07:00
|
|
|
import android.view.Surface;
|
2014-06-17 19:08:45 -07:00
|
|
|
|
2014-07-28 18:15:48 -07:00
|
|
|
import java.util.ArrayList;
|
2014-08-14 17:43:13 -07:00
|
|
|
import java.util.Collections;
|
2014-07-30 10:07:40 -07:00
|
|
|
import java.util.List;
|
2014-06-17 19:08:45 -07:00
|
|
|
import java.util.Set;
|
2014-08-14 17:43:13 -07:00
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
2014-06-17 19:08:45 -07:00
|
|
|
|
|
|
|
/**
|
2014-08-07 19:46:01 -07:00
|
|
|
* A connection provided to a {@link ConnectionService} by another {@code ConnectionService}
|
|
|
|
* running in a different process.
|
|
|
|
*
|
|
|
|
* @see ConnectionService#createRemoteOutgoingConnection(PhoneAccountHandle, ConnectionRequest)
|
|
|
|
* @see ConnectionService#createRemoteIncomingConnection(PhoneAccountHandle, ConnectionRequest)
|
2014-06-17 19:08:45 -07:00
|
|
|
*/
|
|
|
|
public final class RemoteConnection {
|
2014-07-30 10:07:40 -07:00
|
|
|
|
2015-06-25 16:41:48 -07:00
|
|
|
/**
|
|
|
|
* Callback base class for {@link RemoteConnection}.
|
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public static abstract class Callback {
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
|
|
|
* Invoked when the state of this {@code RemoteConnection} has changed. See
|
|
|
|
* {@link #getState()}.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param state The new state of the {@code RemoteConnection}.
|
|
|
|
*/
|
2014-07-20 22:06:28 -07:00
|
|
|
public void onStateChanged(RemoteConnection connection, int state) {}
|
2014-07-30 10:07:40 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked when this {@code RemoteConnection} is disconnected.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
2014-09-11 17:33:16 -07:00
|
|
|
* @param disconnectCause The ({@see DisconnectCause}) associated with this failed
|
|
|
|
* connection.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
|
|
|
public void onDisconnected(
|
|
|
|
RemoteConnection connection,
|
2014-09-11 17:33:16 -07:00
|
|
|
DisconnectCause disconnectCause) {}
|
2014-07-30 10:07:40 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked when this {@code RemoteConnection} is requesting ringback. See
|
2014-09-08 15:34:24 -07:00
|
|
|
* {@link #isRingbackRequested()}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param ringback Whether the {@code RemoteConnection} is requesting ringback.
|
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public void onRingbackRequested(RemoteConnection connection, boolean ringback) {}
|
2014-07-30 10:07:40 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates that the call capabilities of this {@code RemoteConnection} have changed.
|
2014-11-12 13:41:16 -08:00
|
|
|
* See {@link #getConnectionCapabilities()}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
2014-11-12 13:41:16 -08:00
|
|
|
* @param connectionCapabilities The new capabilities of the {@code RemoteConnection}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-11-12 13:41:16 -08:00
|
|
|
public void onConnectionCapabilitiesChanged(
|
|
|
|
RemoteConnection connection,
|
|
|
|
int connectionCapabilities) {}
|
2014-07-30 10:07:40 -07:00
|
|
|
|
2016-03-22 09:02:47 -07:00
|
|
|
/**
|
|
|
|
* Indicates that the call properties of this {@code RemoteConnection} have changed.
|
|
|
|
* See {@link #getConnectionProperties()}.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param connectionProperties The new properties of the {@code RemoteConnection}.
|
2016-04-15 11:28:44 -07:00
|
|
|
* @hide
|
2016-03-22 09:02:47 -07:00
|
|
|
*/
|
|
|
|
public void onConnectionPropertiesChanged(
|
|
|
|
RemoteConnection connection,
|
|
|
|
int connectionProperties) {}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
|
|
|
* Invoked when the post-dial sequence in the outgoing {@code Connection} has reached a
|
|
|
|
* pause character. This causes the post-dial signals to stop pending user confirmation. An
|
|
|
|
* implementation should present this choice to the user and invoke
|
2014-08-07 19:46:01 -07:00
|
|
|
* {@link RemoteConnection#postDialContinue(boolean)} when the user makes the choice.
|
2014-07-30 10:07:40 -07:00
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param remainingPostDialSequence The post-dial characters that remain to be sent.
|
|
|
|
*/
|
|
|
|
public void onPostDialWait(RemoteConnection connection, String remainingPostDialSequence) {}
|
|
|
|
|
2014-12-15 16:12:50 -08:00
|
|
|
/**
|
|
|
|
* Invoked when the post-dial sequence in the outgoing {@code Connection} has processed
|
|
|
|
* a character.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param nextChar The character being processed.
|
|
|
|
*/
|
|
|
|
public void onPostDialChar(RemoteConnection connection, char nextChar) {}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
|
|
|
* Indicates that the VOIP audio status of this {@code RemoteConnection} has changed.
|
2014-09-08 15:34:24 -07:00
|
|
|
* See {@link #isVoipAudioMode()}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param isVoip Whether the new audio state of the {@code RemoteConnection} is VOIP.
|
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public void onVoipAudioChanged(RemoteConnection connection, boolean isVoip) {}
|
2014-07-30 10:07:40 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates that the status hints of this {@code RemoteConnection} have changed. See
|
|
|
|
* {@link #getStatusHints()} ()}.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param statusHints The new status hints of the {@code RemoteConnection}.
|
|
|
|
*/
|
2014-07-20 22:06:28 -07:00
|
|
|
public void onStatusHintsChanged(RemoteConnection connection, StatusHints statusHints) {}
|
2014-07-30 10:07:40 -07:00
|
|
|
|
|
|
|
/**
|
2014-09-08 15:34:24 -07:00
|
|
|
* Indicates that the address (e.g., phone number) of this {@code RemoteConnection} has
|
|
|
|
* changed. See {@link #getAddress()} and {@link #getAddressPresentation()}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
2014-09-08 15:34:24 -07:00
|
|
|
* @param address The new address of the {@code RemoteConnection}.
|
|
|
|
* @param presentation The presentation requirements for the address.
|
2014-09-12 22:16:17 -07:00
|
|
|
* See {@link TelecomManager} for valid values.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public void onAddressChanged(RemoteConnection connection, Uri address, int presentation) {}
|
2014-07-30 10:07:40 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates that the caller display name of this {@code RemoteConnection} has changed.
|
|
|
|
* See {@link #getCallerDisplayName()} and {@link #getCallerDisplayNamePresentation()}.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param callerDisplayName The new caller display name of the {@code RemoteConnection}.
|
2014-09-08 14:17:59 -07:00
|
|
|
* @param presentation The presentation requirements for the handle.
|
2014-09-12 22:16:17 -07:00
|
|
|
* See {@link TelecomManager} for valid values.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-07-20 22:06:28 -07:00
|
|
|
public void onCallerDisplayNameChanged(
|
|
|
|
RemoteConnection connection, String callerDisplayName, int presentation) {}
|
2014-07-30 10:07:40 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates that the video state of this {@code RemoteConnection} has changed.
|
|
|
|
* See {@link #getVideoState()}.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param videoState The new video state of the {@code RemoteConnection}.
|
|
|
|
*/
|
2014-07-20 22:06:28 -07:00
|
|
|
public void onVideoStateChanged(RemoteConnection connection, int videoState) {}
|
2014-07-30 10:07:40 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates that this {@code RemoteConnection} has been destroyed. No further requests
|
|
|
|
* should be made to the {@code RemoteConnection}, and references to it should be cleared.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
*/
|
2014-07-20 22:06:28 -07:00
|
|
|
public void onDestroyed(RemoteConnection connection) {}
|
2014-08-23 20:34:57 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates that the {@code RemoteConnection}s with which this {@code RemoteConnection}
|
|
|
|
* may be asked to create a conference has changed.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param conferenceableConnections The {@code RemoteConnection}s with which this
|
|
|
|
* {@code RemoteConnection} may be asked to create a conference.
|
|
|
|
*/
|
2014-07-28 18:15:48 -07:00
|
|
|
public void onConferenceableConnectionsChanged(
|
2014-08-23 20:34:57 -07:00
|
|
|
RemoteConnection connection,
|
|
|
|
List<RemoteConnection> conferenceableConnections) {}
|
|
|
|
|
2014-08-20 09:36:40 -07:00
|
|
|
/**
|
|
|
|
* Indicates that the {@code VideoProvider} associated with this {@code RemoteConnection}
|
|
|
|
* has changed.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param videoProvider The new {@code VideoProvider} associated with this
|
|
|
|
* {@code RemoteConnection}.
|
|
|
|
*/
|
|
|
|
public void onVideoProviderChanged(
|
|
|
|
RemoteConnection connection, VideoProvider videoProvider) {}
|
|
|
|
|
2014-08-23 20:34:57 -07:00
|
|
|
/**
|
|
|
|
* Indicates that the {@code RemoteConference} that this {@code RemoteConnection} is a part
|
|
|
|
* of has changed.
|
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param conference The {@code RemoteConference} of which this {@code RemoteConnection} is
|
|
|
|
* a part, which may be {@code null}.
|
|
|
|
*/
|
|
|
|
public void onConferenceChanged(
|
|
|
|
RemoteConnection connection,
|
|
|
|
RemoteConference conference) {}
|
2015-05-27 17:21:45 -07:00
|
|
|
|
|
|
|
/**
|
2015-06-25 16:41:48 -07:00
|
|
|
* Handles changes to the {@code RemoteConnection} extras.
|
2015-05-27 17:21:45 -07:00
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param extras The extras containing other information associated with the connection.
|
|
|
|
*/
|
|
|
|
public void onExtrasChanged(RemoteConnection connection, @Nullable Bundle extras) {}
|
2016-02-16 14:36:20 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles a connection event propagated to this {@link RemoteConnection}.
|
2016-03-14 15:18:07 -07:00
|
|
|
* <p>
|
|
|
|
* Connection events originate from {@link Connection#sendConnectionEvent(String, Bundle)}.
|
2016-02-16 14:36:20 -08:00
|
|
|
*
|
|
|
|
* @param connection The {@code RemoteConnection} invoking this method.
|
|
|
|
* @param event The connection event.
|
2016-03-14 15:18:07 -07:00
|
|
|
* @param extras Extras associated with the event.
|
2016-04-15 11:28:44 -07:00
|
|
|
* @hide
|
2016-02-16 14:36:20 -08:00
|
|
|
*/
|
2016-03-14 15:18:07 -07:00
|
|
|
public void onConnectionEvent(RemoteConnection connection, String event, Bundle extras) {}
|
2014-07-20 22:06:28 -07:00
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* {@link RemoteConnection.VideoProvider} associated with a {@link RemoteConnection}. Used to
|
|
|
|
* receive video related events and control the video associated with a
|
|
|
|
* {@link RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @see Connection.VideoProvider
|
|
|
|
*/
|
2014-08-20 09:36:40 -07:00
|
|
|
public static class VideoProvider {
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Callback class used by the {@link RemoteConnection.VideoProvider} to relay events from
|
|
|
|
* the {@link Connection.VideoProvider}.
|
|
|
|
*/
|
2015-05-29 10:05:46 -07:00
|
|
|
public abstract static class Callback {
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Reports a session modification request received from the
|
|
|
|
* {@link Connection.VideoProvider} associated with a {@link RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @param videoProvider The {@link RemoteConnection.VideoProvider} invoking this method.
|
|
|
|
* @param videoProfile The requested video call profile.
|
|
|
|
* @see InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)
|
|
|
|
* @see Connection.VideoProvider#receiveSessionModifyRequest(VideoProfile)
|
|
|
|
*/
|
2015-05-29 10:05:46 -07:00
|
|
|
public void onSessionModifyRequestReceived(
|
2014-08-20 09:36:40 -07:00
|
|
|
VideoProvider videoProvider,
|
|
|
|
VideoProfile videoProfile) {}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Reports a session modification response received from the
|
|
|
|
* {@link Connection.VideoProvider} associated with a {@link RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @param videoProvider The {@link RemoteConnection.VideoProvider} invoking this method.
|
|
|
|
* @param status Status of the session modify request.
|
|
|
|
* @param requestedProfile The original request which was sent to the peer device.
|
|
|
|
* @param responseProfile The actual profile changes made by the peer device.
|
|
|
|
* @see InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int,
|
|
|
|
* VideoProfile, VideoProfile)
|
|
|
|
* @see Connection.VideoProvider#receiveSessionModifyResponse(int, VideoProfile,
|
|
|
|
* VideoProfile)
|
|
|
|
*/
|
2015-05-29 10:05:46 -07:00
|
|
|
public void onSessionModifyResponseReceived(
|
2014-08-20 09:36:40 -07:00
|
|
|
VideoProvider videoProvider,
|
|
|
|
int status,
|
|
|
|
VideoProfile requestedProfile,
|
|
|
|
VideoProfile responseProfile) {}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Reports a call session event received from the {@link Connection.VideoProvider}
|
|
|
|
* associated with a {@link RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @param videoProvider The {@link RemoteConnection.VideoProvider} invoking this method.
|
|
|
|
* @param event The event.
|
|
|
|
* @see InCallService.VideoCall.Callback#onCallSessionEvent(int)
|
|
|
|
* @see Connection.VideoProvider#handleCallSessionEvent(int)
|
|
|
|
*/
|
2015-05-29 10:05:46 -07:00
|
|
|
public void onCallSessionEvent(VideoProvider videoProvider, int event) {}
|
2014-08-20 09:36:40 -07:00
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Reports a change in the peer video dimensions received from the
|
|
|
|
* {@link Connection.VideoProvider} associated with a {@link RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @param videoProvider The {@link RemoteConnection.VideoProvider} invoking this method.
|
|
|
|
* @param width The updated peer video width.
|
|
|
|
* @param height The updated peer video height.
|
|
|
|
* @see InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)
|
|
|
|
* @see Connection.VideoProvider#changePeerDimensions(int, int)
|
|
|
|
*/
|
|
|
|
public void onPeerDimensionsChanged(VideoProvider videoProvider, int width,
|
|
|
|
int height) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reports a change in the data usage (in bytes) received from the
|
|
|
|
* {@link Connection.VideoProvider} associated with a {@link RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @param videoProvider The {@link RemoteConnection.VideoProvider} invoking this method.
|
|
|
|
* @param dataUsage The updated data usage (in bytes).
|
|
|
|
* @see InCallService.VideoCall.Callback#onCallDataUsageChanged(long)
|
|
|
|
* @see Connection.VideoProvider#setCallDataUsage(long)
|
|
|
|
*/
|
2015-03-24 16:42:31 -07:00
|
|
|
public void onCallDataUsageChanged(VideoProvider videoProvider, long dataUsage) {}
|
2014-08-20 09:36:40 -07:00
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Reports a change in the capabilities of the current camera, received from the
|
|
|
|
* {@link Connection.VideoProvider} associated with a {@link RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @param videoProvider The {@link RemoteConnection.VideoProvider} invoking this method.
|
|
|
|
* @param cameraCapabilities The changed camera capabilities.
|
|
|
|
* @see InCallService.VideoCall.Callback#onCameraCapabilitiesChanged(
|
|
|
|
* VideoProfile.CameraCapabilities)
|
|
|
|
* @see Connection.VideoProvider#changeCameraCapabilities(
|
|
|
|
* VideoProfile.CameraCapabilities)
|
|
|
|
*/
|
2014-08-20 09:36:40 -07:00
|
|
|
public void onCameraCapabilitiesChanged(
|
|
|
|
VideoProvider videoProvider,
|
2015-05-12 13:31:25 -07:00
|
|
|
VideoProfile.CameraCapabilities cameraCapabilities) {}
|
2015-03-24 16:42:31 -07:00
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Reports a change in the video quality received from the
|
|
|
|
* {@link Connection.VideoProvider} associated with a {@link RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @param videoProvider The {@link RemoteConnection.VideoProvider} invoking this method.
|
|
|
|
* @param videoQuality The updated peer video quality.
|
|
|
|
* @see InCallService.VideoCall.Callback#onVideoQualityChanged(int)
|
|
|
|
* @see Connection.VideoProvider#changeVideoQuality(int)
|
|
|
|
*/
|
2015-03-24 16:42:31 -07:00
|
|
|
public void onVideoQualityChanged(VideoProvider videoProvider, int videoQuality) {}
|
2014-08-20 09:36:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private final IVideoCallback mVideoCallbackDelegate = new IVideoCallback() {
|
|
|
|
@Override
|
|
|
|
public void receiveSessionModifyRequest(VideoProfile videoProfile) {
|
2015-05-29 10:05:46 -07:00
|
|
|
for (Callback l : mCallbacks) {
|
|
|
|
l.onSessionModifyRequestReceived(VideoProvider.this, videoProfile);
|
2014-08-20 09:36:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void receiveSessionModifyResponse(int status, VideoProfile requestedProfile,
|
|
|
|
VideoProfile responseProfile) {
|
2015-05-29 10:05:46 -07:00
|
|
|
for (Callback l : mCallbacks) {
|
|
|
|
l.onSessionModifyResponseReceived(
|
2014-08-20 09:36:40 -07:00
|
|
|
VideoProvider.this,
|
|
|
|
status,
|
|
|
|
requestedProfile,
|
|
|
|
responseProfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handleCallSessionEvent(int event) {
|
2015-05-29 10:05:46 -07:00
|
|
|
for (Callback l : mCallbacks) {
|
|
|
|
l.onCallSessionEvent(VideoProvider.this, event);
|
2014-08-20 09:36:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void changePeerDimensions(int width, int height) {
|
2015-05-29 10:05:46 -07:00
|
|
|
for (Callback l : mCallbacks) {
|
2014-08-20 09:36:40 -07:00
|
|
|
l.onPeerDimensionsChanged(VideoProvider.this, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-03-24 16:42:31 -07:00
|
|
|
public void changeCallDataUsage(long dataUsage) {
|
2015-05-29 10:05:46 -07:00
|
|
|
for (Callback l : mCallbacks) {
|
2014-08-20 09:36:40 -07:00
|
|
|
l.onCallDataUsageChanged(VideoProvider.this, dataUsage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-05-12 13:31:25 -07:00
|
|
|
public void changeCameraCapabilities(
|
|
|
|
VideoProfile.CameraCapabilities cameraCapabilities) {
|
2015-05-29 10:05:46 -07:00
|
|
|
for (Callback l : mCallbacks) {
|
2014-08-20 09:36:40 -07:00
|
|
|
l.onCameraCapabilitiesChanged(VideoProvider.this, cameraCapabilities);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-24 16:42:31 -07:00
|
|
|
@Override
|
|
|
|
public void changeVideoQuality(int videoQuality) {
|
2015-05-29 10:05:46 -07:00
|
|
|
for (Callback l : mCallbacks) {
|
2015-03-24 16:42:31 -07:00
|
|
|
l.onVideoQualityChanged(VideoProvider.this, videoQuality);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-20 09:36:40 -07:00
|
|
|
@Override
|
|
|
|
public IBinder asBinder() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
private final VideoCallbackServant mVideoCallbackServant =
|
|
|
|
new VideoCallbackServant(mVideoCallbackDelegate);
|
|
|
|
|
|
|
|
private final IVideoProvider mVideoProviderBinder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
|
|
|
|
* load factor before resizing, 1 means we only expect a single thread to
|
|
|
|
* access the map so make only a single shard
|
|
|
|
*/
|
2015-05-29 10:05:46 -07:00
|
|
|
private final Set<Callback> mCallbacks = Collections.newSetFromMap(
|
|
|
|
new ConcurrentHashMap<Callback, Boolean>(8, 0.9f, 1));
|
2014-08-20 09:36:40 -07:00
|
|
|
|
2015-05-29 10:05:46 -07:00
|
|
|
VideoProvider(IVideoProvider videoProviderBinder) {
|
2014-08-20 09:36:40 -07:00
|
|
|
mVideoProviderBinder = videoProviderBinder;
|
|
|
|
try {
|
2015-04-15 14:23:42 -07:00
|
|
|
mVideoProviderBinder.addVideoCallback(mVideoCallbackServant.getStub().asBinder());
|
2014-08-20 09:36:40 -07:00
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Registers a callback to receive commands and state changes for video calls.
|
|
|
|
*
|
|
|
|
* @param l The video call callback.
|
|
|
|
*/
|
2015-05-29 10:05:46 -07:00
|
|
|
public void registerCallback(Callback l) {
|
|
|
|
mCallbacks.add(l);
|
2014-08-20 09:36:40 -07:00
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Clears the video call callback set via {@link #registerCallback}.
|
|
|
|
*
|
|
|
|
* @param l The video call callback to clear.
|
|
|
|
*/
|
2015-05-29 10:05:46 -07:00
|
|
|
public void unregisterCallback(Callback l) {
|
|
|
|
mCallbacks.remove(l);
|
2014-08-20 09:36:40 -07:00
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Sets the camera to be used for the outgoing video for the
|
|
|
|
* {@link RemoteConnection.VideoProvider}.
|
|
|
|
*
|
|
|
|
* @param cameraId The id of the camera (use ids as reported by
|
|
|
|
* {@link CameraManager#getCameraIdList()}).
|
|
|
|
* @see Connection.VideoProvider#onSetCamera(String)
|
|
|
|
*/
|
2014-08-20 09:36:40 -07:00
|
|
|
public void setCamera(String cameraId) {
|
|
|
|
try {
|
|
|
|
mVideoProviderBinder.setCamera(cameraId);
|
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Sets the surface to be used for displaying a preview of what the user's camera is
|
|
|
|
* currently capturing for the {@link RemoteConnection.VideoProvider}.
|
|
|
|
*
|
|
|
|
* @param surface The {@link Surface}.
|
|
|
|
* @see Connection.VideoProvider#onSetPreviewSurface(Surface)
|
|
|
|
*/
|
2014-08-20 09:36:40 -07:00
|
|
|
public void setPreviewSurface(Surface surface) {
|
|
|
|
try {
|
|
|
|
mVideoProviderBinder.setPreviewSurface(surface);
|
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Sets the surface to be used for displaying the video received from the remote device for
|
|
|
|
* the {@link RemoteConnection.VideoProvider}.
|
|
|
|
*
|
|
|
|
* @param surface The {@link Surface}.
|
|
|
|
* @see Connection.VideoProvider#onSetDisplaySurface(Surface)
|
|
|
|
*/
|
2014-08-20 09:36:40 -07:00
|
|
|
public void setDisplaySurface(Surface surface) {
|
|
|
|
try {
|
|
|
|
mVideoProviderBinder.setDisplaySurface(surface);
|
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Sets the device orientation, in degrees, for the {@link RemoteConnection.VideoProvider}.
|
|
|
|
* Assumes that a standard portrait orientation of the device is 0 degrees.
|
|
|
|
*
|
|
|
|
* @param rotation The device orientation, in degrees.
|
|
|
|
* @see Connection.VideoProvider#onSetDeviceOrientation(int)
|
|
|
|
*/
|
2014-08-20 09:36:40 -07:00
|
|
|
public void setDeviceOrientation(int rotation) {
|
|
|
|
try {
|
|
|
|
mVideoProviderBinder.setDeviceOrientation(rotation);
|
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Sets camera zoom ratio for the {@link RemoteConnection.VideoProvider}.
|
|
|
|
*
|
|
|
|
* @param value The camera zoom ratio.
|
|
|
|
* @see Connection.VideoProvider#onSetZoom(float)
|
|
|
|
*/
|
2014-08-20 09:36:40 -07:00
|
|
|
public void setZoom(float value) {
|
|
|
|
try {
|
|
|
|
mVideoProviderBinder.setZoom(value);
|
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Issues a request to modify the properties of the current video session for the
|
|
|
|
* {@link RemoteConnection.VideoProvider}.
|
|
|
|
*
|
|
|
|
* @param fromProfile The video profile prior to the request.
|
|
|
|
* @param toProfile The video profile with the requested changes made.
|
|
|
|
* @see Connection.VideoProvider#onSendSessionModifyRequest(VideoProfile, VideoProfile)
|
|
|
|
*/
|
2015-05-06 08:52:27 -07:00
|
|
|
public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) {
|
2014-08-20 09:36:40 -07:00
|
|
|
try {
|
2015-05-06 08:52:27 -07:00
|
|
|
mVideoProviderBinder.sendSessionModifyRequest(fromProfile, toProfile);
|
2014-08-20 09:36:40 -07:00
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Provides a response to a request to change the current call video session
|
|
|
|
* properties for the {@link RemoteConnection.VideoProvider}.
|
|
|
|
*
|
|
|
|
* @param responseProfile The response call video properties.
|
|
|
|
* @see Connection.VideoProvider#onSendSessionModifyResponse(VideoProfile)
|
|
|
|
*/
|
2014-08-20 09:36:40 -07:00
|
|
|
public void sendSessionModifyResponse(VideoProfile responseProfile) {
|
|
|
|
try {
|
|
|
|
mVideoProviderBinder.sendSessionModifyResponse(responseProfile);
|
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Issues a request to retrieve the capabilities of the current camera for the
|
|
|
|
* {@link RemoteConnection.VideoProvider}.
|
|
|
|
*
|
|
|
|
* @see Connection.VideoProvider#onRequestCameraCapabilities()
|
|
|
|
*/
|
2014-08-20 09:36:40 -07:00
|
|
|
public void requestCameraCapabilities() {
|
|
|
|
try {
|
|
|
|
mVideoProviderBinder.requestCameraCapabilities();
|
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Issues a request to retrieve the data usage (in bytes) of the video portion of the
|
|
|
|
* {@link RemoteConnection} for the {@link RemoteConnection.VideoProvider}.
|
|
|
|
*
|
|
|
|
* @see Connection.VideoProvider#onRequestConnectionDataUsage()
|
|
|
|
*/
|
2014-08-20 09:36:40 -07:00
|
|
|
public void requestCallDataUsage() {
|
|
|
|
try {
|
|
|
|
mVideoProviderBinder.requestCallDataUsage();
|
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 11:08:54 -07:00
|
|
|
/**
|
|
|
|
* Sets the {@link Uri} of an image to be displayed to the peer device when the video signal
|
|
|
|
* is paused, for the {@link RemoteConnection.VideoProvider}.
|
|
|
|
*
|
|
|
|
* @see Connection.VideoProvider#onSetPauseImage(Uri)
|
|
|
|
*/
|
2015-05-12 16:18:03 -07:00
|
|
|
public void setPauseImage(Uri uri) {
|
2014-08-20 09:36:40 -07:00
|
|
|
try {
|
|
|
|
mVideoProviderBinder.setPauseImage(uri);
|
|
|
|
} catch (RemoteException e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-20 22:06:28 -07:00
|
|
|
private IConnectionService mConnectionService;
|
2014-06-17 19:08:45 -07:00
|
|
|
private final String mConnectionId;
|
2014-08-15 09:23:07 -07:00
|
|
|
/**
|
|
|
|
* ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
|
|
|
|
* load factor before resizing, 1 means we only expect a single thread to
|
|
|
|
* access the map so make only a single shard
|
|
|
|
*/
|
2015-04-23 15:47:06 -07:00
|
|
|
private final Set<CallbackRecord> mCallbackRecords = Collections.newSetFromMap(
|
|
|
|
new ConcurrentHashMap<CallbackRecord, Boolean>(8, 0.9f, 1));
|
2014-08-23 20:34:57 -07:00
|
|
|
private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>();
|
|
|
|
private final List<RemoteConnection> mUnmodifiableconferenceableConnections =
|
|
|
|
Collections.unmodifiableList(mConferenceableConnections);
|
2014-06-17 19:08:45 -07:00
|
|
|
|
2014-08-07 19:46:01 -07:00
|
|
|
private int mState = Connection.STATE_NEW;
|
2014-09-11 17:33:16 -07:00
|
|
|
private DisconnectCause mDisconnectCause;
|
2014-09-08 15:34:24 -07:00
|
|
|
private boolean mRingbackRequested;
|
2014-06-17 19:08:45 -07:00
|
|
|
private boolean mConnected;
|
2014-11-12 13:41:16 -08:00
|
|
|
private int mConnectionCapabilities;
|
2016-03-22 09:02:47 -07:00
|
|
|
private int mConnectionProperties;
|
2014-07-17 07:50:22 -07:00
|
|
|
private int mVideoState;
|
2014-08-20 09:36:40 -07:00
|
|
|
private VideoProvider mVideoProvider;
|
2014-09-08 15:34:24 -07:00
|
|
|
private boolean mIsVoipAudioMode;
|
2014-07-08 21:48:22 -07:00
|
|
|
private StatusHints mStatusHints;
|
2014-09-08 15:34:24 -07:00
|
|
|
private Uri mAddress;
|
|
|
|
private int mAddressPresentation;
|
2014-07-11 14:50:13 -07:00
|
|
|
private String mCallerDisplayName;
|
|
|
|
private int mCallerDisplayNamePresentation;
|
2014-08-23 20:34:57 -07:00
|
|
|
private RemoteConference mConference;
|
2015-05-27 17:21:45 -07:00
|
|
|
private Bundle mExtras;
|
2014-06-17 19:08:45 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
2014-08-07 19:46:01 -07:00
|
|
|
RemoteConnection(
|
|
|
|
String id,
|
|
|
|
IConnectionService connectionService,
|
|
|
|
ConnectionRequest request) {
|
|
|
|
mConnectionId = id;
|
2014-07-04 17:21:07 -07:00
|
|
|
mConnectionService = connectionService;
|
2014-06-17 19:08:45 -07:00
|
|
|
mConnected = true;
|
2014-08-07 19:46:01 -07:00
|
|
|
mState = Connection.STATE_INITIALIZING;
|
2014-07-20 22:06:28 -07:00
|
|
|
}
|
|
|
|
|
2014-10-30 14:27:48 -07:00
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
RemoteConnection(String callId, IConnectionService connectionService,
|
|
|
|
ParcelableConnection connection) {
|
|
|
|
mConnectionId = callId;
|
|
|
|
mConnectionService = connectionService;
|
|
|
|
mConnected = true;
|
|
|
|
mState = connection.getState();
|
|
|
|
mDisconnectCause = connection.getDisconnectCause();
|
|
|
|
mRingbackRequested = connection.isRingbackRequested();
|
2014-11-12 13:41:16 -08:00
|
|
|
mConnectionCapabilities = connection.getConnectionCapabilities();
|
2016-03-22 09:02:47 -07:00
|
|
|
mConnectionProperties = connection.getConnectionProperties();
|
2014-10-30 14:27:48 -07:00
|
|
|
mVideoState = connection.getVideoState();
|
|
|
|
mVideoProvider = new RemoteConnection.VideoProvider(connection.getVideoProvider());
|
|
|
|
mIsVoipAudioMode = connection.getIsVoipAudioMode();
|
|
|
|
mStatusHints = connection.getStatusHints();
|
|
|
|
mAddress = connection.getHandle();
|
|
|
|
mAddressPresentation = connection.getHandlePresentation();
|
|
|
|
mCallerDisplayName = connection.getCallerDisplayName();
|
|
|
|
mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
|
|
|
|
mConference = null;
|
|
|
|
}
|
|
|
|
|
2014-07-20 22:06:28 -07:00
|
|
|
/**
|
|
|
|
* Create a RemoteConnection which is used for failed connections. Note that using it for any
|
|
|
|
* "real" purpose will almost certainly fail. Callers should note the failure and act
|
|
|
|
* accordingly (moving on to another RemoteConnection, for example)
|
|
|
|
*
|
2014-09-11 17:33:16 -07:00
|
|
|
* @param disconnectCause The reason for the failed connection.
|
|
|
|
* @hide
|
2014-07-20 22:06:28 -07:00
|
|
|
*/
|
2014-09-11 17:33:16 -07:00
|
|
|
RemoteConnection(DisconnectCause disconnectCause) {
|
2014-10-30 14:27:48 -07:00
|
|
|
mConnectionId = "NULL";
|
2014-07-20 22:06:28 -07:00
|
|
|
mConnected = false;
|
2014-08-18 09:23:25 -07:00
|
|
|
mState = Connection.STATE_DISCONNECTED;
|
2014-09-11 17:33:16 -07:00
|
|
|
mDisconnectCause = disconnectCause;
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-09-08 15:34:24 -07:00
|
|
|
* Adds a callback to this {@code RemoteConnection}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*
|
2014-09-08 15:34:24 -07:00
|
|
|
* @param callback A {@code Callback}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public void registerCallback(Callback callback) {
|
2015-04-23 15:47:06 -07:00
|
|
|
registerCallback(callback, new Handler());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a callback to this {@code RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @param callback A {@code Callback}.
|
|
|
|
* @param handler A {@code Handler} which command and status changes will be delivered to.
|
|
|
|
*/
|
|
|
|
public void registerCallback(Callback callback, Handler handler) {
|
|
|
|
unregisterCallback(callback);
|
|
|
|
if (callback != null && handler != null) {
|
|
|
|
mCallbackRecords.add(new CallbackRecord(callback, handler));
|
|
|
|
}
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-09-08 15:34:24 -07:00
|
|
|
* Removes a callback from this {@code RemoteConnection}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*
|
2014-09-08 15:34:24 -07:00
|
|
|
* @param callback A {@code Callback}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public void unregisterCallback(Callback callback) {
|
|
|
|
if (callback != null) {
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
if (record.getCallback() == callback) {
|
|
|
|
mCallbackRecords.remove(record);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-08-15 09:23:07 -07:00
|
|
|
}
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
|
|
|
* Obtains the state of this {@code RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @return A state value, chosen from the {@code STATE_*} constants.
|
|
|
|
*/
|
2014-07-01 17:25:37 -07:00
|
|
|
public int getState() {
|
|
|
|
return mState;
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Obtains the reason why this {@code RemoteConnection} may have been disconnected.
|
|
|
|
*
|
2014-08-07 19:46:01 -07:00
|
|
|
* @return For a {@link Connection#STATE_DISCONNECTED} {@code RemoteConnection}, the
|
2014-11-12 13:41:16 -08:00
|
|
|
* disconnect cause expressed as a code chosen from among those declared in
|
|
|
|
* {@link DisconnectCause}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-09-11 17:33:16 -07:00
|
|
|
public DisconnectCause getDisconnectCause() {
|
|
|
|
return mDisconnectCause;
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Obtains the capabilities of this {@code RemoteConnection}.
|
|
|
|
*
|
2014-07-30 10:07:40 -07:00
|
|
|
* @return A bitmask of the capabilities of the {@code RemoteConnection}, as defined in
|
2014-11-12 13:41:16 -08:00
|
|
|
* the {@code CAPABILITY_*} constants in class {@link Connection}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-11-12 13:41:16 -08:00
|
|
|
public int getConnectionCapabilities() {
|
|
|
|
return mConnectionCapabilities;
|
2014-07-09 21:03:20 -07:00
|
|
|
}
|
|
|
|
|
2016-03-22 09:02:47 -07:00
|
|
|
/**
|
|
|
|
* Obtains the properties of this {@code RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @return A bitmask of the properties of the {@code RemoteConnection}, as defined in the
|
|
|
|
* {@code PROPERTY_*} constants in class {@link Connection}.
|
2016-04-15 11:28:44 -07:00
|
|
|
* @hide
|
2016-03-22 09:02:47 -07:00
|
|
|
*/
|
|
|
|
public int getConnectionProperties() {
|
|
|
|
return mConnectionProperties;
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Determines if the audio mode of this {@code RemoteConnection} is VOIP.
|
|
|
|
*
|
2014-07-30 10:07:40 -07:00
|
|
|
* @return {@code true} if the {@code RemoteConnection}'s current audio mode is VOIP.
|
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public boolean isVoipAudioMode() {
|
|
|
|
return mIsVoipAudioMode;
|
2014-07-07 22:49:44 -07:00
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Obtains status hints pertaining to this {@code RemoteConnection}.
|
|
|
|
*
|
2014-08-07 19:46:01 -07:00
|
|
|
* @return The current {@link StatusHints} of this {@code RemoteConnection},
|
2014-11-12 13:41:16 -08:00
|
|
|
* or {@code null} if none have been set.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-07-08 21:48:22 -07:00
|
|
|
public StatusHints getStatusHints() {
|
|
|
|
return mStatusHints;
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Obtains the address of this {@code RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @return The address (e.g., phone number) to which the {@code RemoteConnection}
|
|
|
|
* is currently connected.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public Uri getAddress() {
|
|
|
|
return mAddress;
|
2014-07-11 14:50:13 -07:00
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Obtains the presentation requirements for the address of this {@code RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @return The presentation requirements for the address. See
|
|
|
|
* {@link TelecomManager} for valid values.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public int getAddressPresentation() {
|
|
|
|
return mAddressPresentation;
|
2014-07-11 14:50:13 -07:00
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Obtains the display name for this {@code RemoteConnection}'s caller.
|
|
|
|
*
|
2014-07-30 10:07:40 -07:00
|
|
|
* @return The display name for the caller.
|
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public CharSequence getCallerDisplayName() {
|
2014-07-11 14:50:13 -07:00
|
|
|
return mCallerDisplayName;
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Obtains the presentation requirements for this {@code RemoteConnection}'s
|
|
|
|
* caller's display name.
|
|
|
|
*
|
2014-07-30 10:07:40 -07:00
|
|
|
* @return The presentation requirements for the caller display name. See
|
2014-11-12 13:41:16 -08:00
|
|
|
* {@link TelecomManager} for valid values.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-07-11 14:50:13 -07:00
|
|
|
public int getCallerDisplayNamePresentation() {
|
|
|
|
return mCallerDisplayNamePresentation;
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Obtains the video state of this {@code RemoteConnection}.
|
|
|
|
*
|
2015-06-03 10:09:59 -07:00
|
|
|
* @return The video state of the {@code RemoteConnection}. See {@link VideoProfile}.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-07-17 07:50:22 -07:00
|
|
|
public int getVideoState() {
|
|
|
|
return mVideoState;
|
|
|
|
}
|
|
|
|
|
2015-03-24 16:42:31 -07:00
|
|
|
/**
|
|
|
|
* Obtains the video provider of this {@code RemoteConnection}.
|
2014-08-20 09:36:40 -07:00
|
|
|
* @return The video provider associated with this {@code RemoteConnection}.
|
|
|
|
*/
|
|
|
|
public final VideoProvider getVideoProvider() {
|
|
|
|
return mVideoProvider;
|
|
|
|
}
|
|
|
|
|
2015-05-27 17:21:45 -07:00
|
|
|
/**
|
|
|
|
* Obtain the extras associated with this {@code RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @return The extras for this connection.
|
|
|
|
*/
|
|
|
|
public final Bundle getExtras() {
|
|
|
|
return mExtras;
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-11-12 13:41:16 -08:00
|
|
|
* Determines whether this {@code RemoteConnection} is requesting ringback.
|
|
|
|
*
|
2014-07-30 10:07:40 -07:00
|
|
|
* @return Whether the {@code RemoteConnection} is requesting that the framework play a
|
2014-11-12 13:41:16 -08:00
|
|
|
* ringback tone on its behalf.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-09-08 15:34:24 -07:00
|
|
|
public boolean isRingbackRequested() {
|
2015-06-02 15:08:26 -07:00
|
|
|
return mRingbackRequested;
|
2014-07-30 10:07:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instructs this {@code RemoteConnection} to abort.
|
|
|
|
*/
|
2014-06-30 15:15:23 -07:00
|
|
|
public void abort() {
|
|
|
|
try {
|
|
|
|
if (mConnected) {
|
2014-07-04 17:21:07 -07:00
|
|
|
mConnectionService.abort(mConnectionId);
|
2014-06-30 15:15:23 -07:00
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-29 14:51:48 -07:00
|
|
|
/**
|
|
|
|
* Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.
|
|
|
|
*/
|
|
|
|
public void answer() {
|
|
|
|
try {
|
|
|
|
if (mConnected) {
|
|
|
|
mConnectionService.answer(mConnectionId);
|
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-08-07 19:46:01 -07:00
|
|
|
* Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to answer.
|
2014-07-30 10:07:40 -07:00
|
|
|
* @param videoState The video state in which to answer the call.
|
2014-08-29 14:51:48 -07:00
|
|
|
* @hide
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-07-16 10:11:42 -07:00
|
|
|
public void answer(int videoState) {
|
2014-06-17 19:08:45 -07:00
|
|
|
try {
|
|
|
|
if (mConnected) {
|
2014-08-29 14:51:48 -07:00
|
|
|
mConnectionService.answerVideo(mConnectionId, videoState);
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-08-07 19:46:01 -07:00
|
|
|
* Instructs this {@link Connection#STATE_RINGING} {@code RemoteConnection} to reject.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-06-17 19:08:45 -07:00
|
|
|
public void reject() {
|
|
|
|
try {
|
|
|
|
if (mConnected) {
|
2014-07-04 17:21:07 -07:00
|
|
|
mConnectionService.reject(mConnectionId);
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
|
|
|
* Instructs this {@code RemoteConnection} to go on hold.
|
|
|
|
*/
|
2014-06-17 19:08:45 -07:00
|
|
|
public void hold() {
|
|
|
|
try {
|
|
|
|
if (mConnected) {
|
2014-07-04 17:21:07 -07:00
|
|
|
mConnectionService.hold(mConnectionId);
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
2014-08-07 19:46:01 -07:00
|
|
|
* Instructs this {@link Connection#STATE_HOLDING} call to release from hold.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2014-06-17 19:08:45 -07:00
|
|
|
public void unhold() {
|
|
|
|
try {
|
|
|
|
if (mConnected) {
|
2014-07-04 17:21:07 -07:00
|
|
|
mConnectionService.unhold(mConnectionId);
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
|
|
|
* Instructs this {@code RemoteConnection} to disconnect.
|
|
|
|
*/
|
2014-06-17 19:08:45 -07:00
|
|
|
public void disconnect() {
|
|
|
|
try {
|
|
|
|
if (mConnected) {
|
2014-07-04 17:21:07 -07:00
|
|
|
mConnectionService.disconnect(mConnectionId);
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
|
|
|
* Instructs this {@code RemoteConnection} to play a dual-tone multi-frequency signaling
|
|
|
|
* (DTMF) tone.
|
|
|
|
*
|
|
|
|
* Any other currently playing DTMF tone in the specified call is immediately stopped.
|
|
|
|
*
|
|
|
|
* @param digit A character representing the DTMF digit for which to play the tone. This
|
|
|
|
* value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}.
|
|
|
|
*/
|
|
|
|
public void playDtmfTone(char digit) {
|
2014-06-17 19:08:45 -07:00
|
|
|
try {
|
|
|
|
if (mConnected) {
|
2014-07-04 17:21:07 -07:00
|
|
|
mConnectionService.playDtmfTone(mConnectionId, digit);
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
|
|
|
* Instructs this {@code RemoteConnection} to stop any dual-tone multi-frequency signaling
|
|
|
|
* (DTMF) tone currently playing.
|
|
|
|
*
|
|
|
|
* DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is
|
|
|
|
* currently playing, this method will do nothing.
|
|
|
|
*/
|
|
|
|
public void stopDtmfTone() {
|
2014-06-17 19:08:45 -07:00
|
|
|
try {
|
|
|
|
if (mConnected) {
|
2014-07-04 17:21:07 -07:00
|
|
|
mConnectionService.stopDtmfTone(mConnectionId);
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
|
|
|
* Instructs this {@code RemoteConnection} to continue playing a post-dial DTMF string.
|
|
|
|
*
|
|
|
|
* A post-dial DTMF string is a string of digits following the first instance of either
|
2014-09-12 22:16:17 -07:00
|
|
|
* {@link TelecomManager#DTMF_CHARACTER_WAIT} or {@link TelecomManager#DTMF_CHARACTER_PAUSE}.
|
2014-07-30 10:07:40 -07:00
|
|
|
* These digits are immediately sent as DTMF tones to the recipient as soon as the
|
|
|
|
* connection is made.
|
|
|
|
*
|
2014-09-12 22:16:17 -07:00
|
|
|
* If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, this
|
2014-07-30 10:07:40 -07:00
|
|
|
* {@code RemoteConnection} will temporarily pause playing the tones for a pre-defined period
|
|
|
|
* of time.
|
|
|
|
*
|
2014-09-12 22:16:17 -07:00
|
|
|
* If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this
|
2014-12-15 16:12:50 -08:00
|
|
|
* {@code RemoteConnection} will pause playing the tones and notify callbacks via
|
2014-09-08 15:34:24 -07:00
|
|
|
* {@link Callback#onPostDialWait(RemoteConnection, String)}. At this point, the in-call app
|
2014-07-30 10:07:40 -07:00
|
|
|
* should display to the user an indication of this state and an affordance to continue
|
|
|
|
* the postdial sequence. When the user decides to continue the postdial sequence, the in-call
|
|
|
|
* app should invoke the {@link #postDialContinue(boolean)} method.
|
|
|
|
*
|
|
|
|
* @param proceed Whether or not to continue with the post-dial sequence.
|
|
|
|
*/
|
2014-06-17 19:08:45 -07:00
|
|
|
public void postDialContinue(boolean proceed) {
|
|
|
|
try {
|
|
|
|
if (mConnected) {
|
2014-07-04 17:21:07 -07:00
|
|
|
mConnectionService.onPostDialContinue(mConnectionId, proceed);
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-14 15:18:07 -07:00
|
|
|
/**
|
|
|
|
* Instructs this {@link RemoteConnection} to pull itself to the local device.
|
|
|
|
* <p>
|
|
|
|
* See {@link Call#pullExternalCall()} for more information.
|
2016-04-15 11:28:44 -07:00
|
|
|
* @hide
|
2016-03-14 15:18:07 -07:00
|
|
|
*/
|
|
|
|
public void pullExternalCall() {
|
|
|
|
try {
|
|
|
|
if (mConnected) {
|
|
|
|
mConnectionService.pullExternalCall(mConnectionId);
|
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
/**
|
|
|
|
* Set the audio state of this {@code RemoteConnection}.
|
|
|
|
*
|
|
|
|
* @param state The audio state of this {@code RemoteConnection}.
|
2015-05-13 14:14:54 -07:00
|
|
|
* @hide
|
|
|
|
* @deprecated Use {@link #setCallAudioState(CallAudioState) instead.
|
2014-07-30 10:07:40 -07:00
|
|
|
*/
|
2015-05-13 14:14:54 -07:00
|
|
|
@SystemApi
|
|
|
|
@Deprecated
|
2014-08-07 19:46:01 -07:00
|
|
|
public void setAudioState(AudioState state) {
|
2015-05-13 14:14:54 -07:00
|
|
|
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) {
|
2014-06-30 15:15:23 -07:00
|
|
|
try {
|
|
|
|
if (mConnected) {
|
2015-05-13 14:14:54 -07:00
|
|
|
mConnectionService.onCallAudioStateChanged(mConnectionId, state);
|
2014-06-30 15:15:23 -07:00
|
|
|
}
|
|
|
|
} catch (RemoteException ignored) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-23 20:34:57 -07:00
|
|
|
/**
|
|
|
|
* Obtain the {@code RemoteConnection}s with which this {@code RemoteConnection} may be
|
|
|
|
* successfully asked to create a conference with.
|
|
|
|
*
|
|
|
|
* @return The {@code RemoteConnection}s with which this {@code RemoteConnection} may be
|
|
|
|
* merged into a {@link RemoteConference}.
|
|
|
|
*/
|
|
|
|
public List<RemoteConnection> getConferenceableConnections() {
|
|
|
|
return mUnmodifiableconferenceableConnections;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain the {@code RemoteConference} that this {@code RemoteConnection} may be a part
|
|
|
|
* of, or {@code null} if there is no such {@code RemoteConference}.
|
|
|
|
*
|
|
|
|
* @return A {@code RemoteConference} or {@code null};
|
|
|
|
*/
|
|
|
|
public RemoteConference getConference() {
|
|
|
|
return mConference;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** {@hide} */
|
|
|
|
String getId() {
|
|
|
|
return mConnectionId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** {@hide} */
|
|
|
|
IConnectionService getConnectionService() {
|
|
|
|
return mConnectionService;
|
|
|
|
}
|
|
|
|
|
2014-06-17 19:08:45 -07:00
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
2015-04-23 15:47:06 -07:00
|
|
|
void setState(final int state) {
|
2014-06-17 19:08:45 -07:00
|
|
|
if (mState != state) {
|
|
|
|
mState = state;
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record: mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onStateChanged(connection, state);
|
|
|
|
}
|
|
|
|
});
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
2015-04-23 15:47:06 -07:00
|
|
|
void setDisconnected(final DisconnectCause disconnectCause) {
|
2014-08-07 19:46:01 -07:00
|
|
|
if (mState != Connection.STATE_DISCONNECTED) {
|
|
|
|
mState = Connection.STATE_DISCONNECTED;
|
2014-09-11 17:33:16 -07:00
|
|
|
mDisconnectCause = disconnectCause;
|
2014-06-17 19:08:45 -07:00
|
|
|
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onDisconnected(connection, disconnectCause);
|
|
|
|
}
|
|
|
|
});
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
2015-04-23 15:47:06 -07:00
|
|
|
void setRingbackRequested(final boolean ringback) {
|
2014-09-08 15:34:24 -07:00
|
|
|
if (mRingbackRequested != ringback) {
|
|
|
|
mRingbackRequested = ringback;
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onRingbackRequested(connection, ringback);
|
|
|
|
}
|
|
|
|
});
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-09 21:03:20 -07:00
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
2015-04-23 15:47:06 -07:00
|
|
|
void setConnectionCapabilities(final int connectionCapabilities) {
|
2014-11-12 13:41:16 -08:00
|
|
|
mConnectionCapabilities = connectionCapabilities;
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onConnectionCapabilitiesChanged(connection, connectionCapabilities);
|
|
|
|
}
|
|
|
|
});
|
2014-07-09 21:03:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-22 09:02:47 -07:00
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
void setConnectionProperties(final int connectionProperties) {
|
|
|
|
mConnectionProperties = connectionProperties;
|
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onConnectionPropertiesChanged(connection, connectionProperties);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-17 19:08:45 -07:00
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
void setDestroyed() {
|
2015-04-23 15:47:06 -07:00
|
|
|
if (!mCallbackRecords.isEmpty()) {
|
2014-09-08 15:34:24 -07:00
|
|
|
// Make sure that the callbacks are notified that the call is destroyed first.
|
2014-08-07 19:46:01 -07:00
|
|
|
if (mState != Connection.STATE_DISCONNECTED) {
|
2014-09-11 17:33:16 -07:00
|
|
|
setDisconnected(
|
|
|
|
new DisconnectCause(DisconnectCause.ERROR, "Connection destroyed."));
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onDestroyed(connection);
|
|
|
|
}
|
|
|
|
});
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
2015-04-23 15:47:06 -07:00
|
|
|
mCallbackRecords.clear();
|
2014-06-17 19:08:45 -07:00
|
|
|
|
|
|
|
mConnected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
2015-04-23 15:47:06 -07:00
|
|
|
void setPostDialWait(final String remainingDigits) {
|
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onPostDialWait(connection, remainingDigits);
|
|
|
|
}
|
|
|
|
});
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
2014-07-17 07:50:22 -07:00
|
|
|
}
|
|
|
|
|
2014-12-15 16:12:50 -08:00
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
2015-04-23 15:47:06 -07:00
|
|
|
void onPostDialChar(final char nextChar) {
|
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2015-05-14 17:39:41 -07:00
|
|
|
callback.onPostDialChar(connection, nextChar);
|
2015-04-23 15:47:06 -07:00
|
|
|
}
|
|
|
|
});
|
2014-12-15 16:12:50 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-17 07:50:22 -07:00
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
2015-04-23 15:47:06 -07:00
|
|
|
void setVideoState(final int videoState) {
|
2014-07-17 07:50:22 -07:00
|
|
|
mVideoState = videoState;
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onVideoStateChanged(connection, videoState);
|
|
|
|
}
|
|
|
|
});
|
2014-07-17 07:50:22 -07:00
|
|
|
}
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
|
2014-08-20 09:36:40 -07:00
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
2015-04-23 15:47:06 -07:00
|
|
|
void setVideoProvider(final VideoProvider videoProvider) {
|
2014-08-20 09:36:40 -07:00
|
|
|
mVideoProvider = videoProvider;
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onVideoProviderChanged(connection, videoProvider);
|
|
|
|
}
|
|
|
|
});
|
2014-08-20 09:36:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-07 22:49:44 -07:00
|
|
|
/** @hide */
|
2015-04-23 15:47:06 -07:00
|
|
|
void setIsVoipAudioMode(final boolean isVoip) {
|
2014-09-08 15:34:24 -07:00
|
|
|
mIsVoipAudioMode = isVoip;
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onVoipAudioChanged(connection, isVoip);
|
|
|
|
}
|
|
|
|
});
|
2014-07-07 22:49:44 -07:00
|
|
|
}
|
|
|
|
}
|
2014-07-08 21:48:22 -07:00
|
|
|
|
|
|
|
/** @hide */
|
2015-04-23 15:47:06 -07:00
|
|
|
void setStatusHints(final StatusHints statusHints) {
|
2014-07-08 21:48:22 -07:00
|
|
|
mStatusHints = statusHints;
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onStatusHintsChanged(connection, statusHints);
|
|
|
|
}
|
|
|
|
});
|
2014-07-11 14:50:13 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @hide */
|
2015-04-23 15:47:06 -07:00
|
|
|
void setAddress(final Uri address, final int presentation) {
|
2014-09-08 15:34:24 -07:00
|
|
|
mAddress = address;
|
|
|
|
mAddressPresentation = presentation;
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onAddressChanged(connection, address, presentation);
|
|
|
|
}
|
|
|
|
});
|
2014-07-11 14:50:13 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @hide */
|
2015-04-23 15:47:06 -07:00
|
|
|
void setCallerDisplayName(final String callerDisplayName, final int presentation) {
|
2014-07-11 14:50:13 -07:00
|
|
|
mCallerDisplayName = callerDisplayName;
|
|
|
|
mCallerDisplayNamePresentation = presentation;
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onCallerDisplayNameChanged(
|
|
|
|
connection, callerDisplayName, presentation);
|
|
|
|
}
|
|
|
|
});
|
2014-07-08 21:48:22 -07:00
|
|
|
}
|
|
|
|
}
|
2014-07-18 14:49:18 -07:00
|
|
|
|
2014-07-28 18:15:48 -07:00
|
|
|
/** @hide */
|
2015-04-23 15:47:06 -07:00
|
|
|
void setConferenceableConnections(final List<RemoteConnection> conferenceableConnections) {
|
2014-07-28 18:15:48 -07:00
|
|
|
mConferenceableConnections.clear();
|
|
|
|
mConferenceableConnections.addAll(conferenceableConnections);
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onConferenceableConnectionsChanged(
|
|
|
|
connection, mUnmodifiableconferenceableConnections);
|
|
|
|
}
|
|
|
|
});
|
2014-08-23 20:34:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @hide */
|
2015-04-23 15:47:06 -07:00
|
|
|
void setConference(final RemoteConference conference) {
|
2014-08-23 20:34:57 -07:00
|
|
|
if (mConference != conference) {
|
|
|
|
mConference = conference;
|
2015-04-23 15:47:06 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
callback.onConferenceChanged(connection, conference);
|
|
|
|
}
|
|
|
|
});
|
2014-08-23 20:34:57 -07:00
|
|
|
}
|
2014-07-28 18:15:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-27 17:21:45 -07:00
|
|
|
/** @hide */
|
Expand call/connection extras API.
Currently, connection extras are propagated up to Telecom as an
entire bundle. This is not ideal, as any time a change is made to
the extras, the bundle needs to be fetched, changed, and then re-set on
the connection, where it is parceled to Telecom as a whole.
Using how extras on an Intent as inspiration, this CL adds separate
putExtras, putExtra, and removeExtra methods to allow manipulation of
the extras bundle without operating on it in its entirety.
This Cl also adds support for Calls modifying the extras bundle, with
changes propagated back down to ConnectionServices.
Bug: 27458894
Change-Id: I152340a3bca2dc03f170b06b172a6823410fb961
2016-03-23 16:06:34 -07:00
|
|
|
void putExtras(final Bundle extras) {
|
|
|
|
if (mExtras == null) {
|
|
|
|
mExtras = new Bundle();
|
|
|
|
}
|
|
|
|
mExtras.putAll(extras);
|
|
|
|
|
|
|
|
notifyExtrasChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @hide */
|
|
|
|
void removeExtras(List<String> keys) {
|
|
|
|
if (mExtras == null || keys == null || keys.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (String key : keys) {
|
|
|
|
mExtras.remove(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
notifyExtrasChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void notifyExtrasChanged() {
|
2015-05-27 17:21:45 -07:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
Expand call/connection extras API.
Currently, connection extras are propagated up to Telecom as an
entire bundle. This is not ideal, as any time a change is made to
the extras, the bundle needs to be fetched, changed, and then re-set on
the connection, where it is parceled to Telecom as a whole.
Using how extras on an Intent as inspiration, this CL adds separate
putExtras, putExtra, and removeExtra methods to allow manipulation of
the extras bundle without operating on it in its entirety.
This Cl also adds support for Calls modifying the extras bundle, with
changes propagated back down to ConnectionServices.
Bug: 27458894
Change-Id: I152340a3bca2dc03f170b06b172a6823410fb961
2016-03-23 16:06:34 -07:00
|
|
|
callback.onExtrasChanged(connection, mExtras);
|
2015-05-27 17:21:45 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-16 14:36:20 -08:00
|
|
|
/** @hide */
|
2016-03-14 15:18:07 -07:00
|
|
|
void onConnectionEvent(final String event, final Bundle extras) {
|
2016-02-16 14:36:20 -08:00
|
|
|
for (CallbackRecord record : mCallbackRecords) {
|
|
|
|
final RemoteConnection connection = this;
|
|
|
|
final Callback callback = record.getCallback();
|
|
|
|
record.getHandler().post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2016-03-14 15:18:07 -07:00
|
|
|
callback.onConnectionEvent(connection, event, extras);
|
2016-02-16 14:36:20 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-20 22:06:28 -07:00
|
|
|
/**
|
2014-08-18 09:23:25 -07:00
|
|
|
* Create a RemoteConnection represents a failure, and which will be in
|
|
|
|
* {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost
|
|
|
|
* certainly result in bad things happening. Do not do this.
|
2014-07-20 22:06:28 -07:00
|
|
|
*
|
|
|
|
* @return a failed {@link RemoteConnection}
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
2014-09-11 17:33:16 -07:00
|
|
|
public static RemoteConnection failure(DisconnectCause disconnectCause) {
|
|
|
|
return new RemoteConnection(disconnectCause);
|
2014-07-20 22:06:28 -07:00
|
|
|
}
|
2015-04-23 15:47:06 -07:00
|
|
|
|
|
|
|
private static final class CallbackRecord extends Callback {
|
|
|
|
private final Callback mCallback;
|
|
|
|
private final Handler mHandler;
|
|
|
|
|
|
|
|
public CallbackRecord(Callback callback, Handler handler) {
|
|
|
|
mCallback = callback;
|
|
|
|
mHandler = handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Callback getCallback() {
|
|
|
|
return mCallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Handler getHandler() {
|
|
|
|
return mHandler;
|
|
|
|
}
|
|
|
|
}
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|