2014-05-16 10:22:16 -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-05-16 10:22:16 -07:00
|
|
|
|
2014-07-20 17:47:12 -07:00
|
|
|
import android.annotation.SdkConstant;
|
2014-07-04 17:21:07 -07:00
|
|
|
import android.app.Service;
|
2014-06-17 19:08:45 -07:00
|
|
|
import android.content.ComponentName;
|
2014-07-20 17:47:12 -07:00
|
|
|
import android.content.Intent;
|
2014-05-16 10:22:16 -07:00
|
|
|
import android.net.Uri;
|
2015-05-27 17:21:45 -07:00
|
|
|
import android.os.Bundle;
|
2014-06-17 19:08:45 -07:00
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.IBinder;
|
|
|
|
import android.os.Looper;
|
2014-07-04 17:21:07 -07:00
|
|
|
import android.os.Message;
|
2016-10-24 16:40:49 -07:00
|
|
|
import android.telecom.Logging.Session;
|
2014-07-25 09:41:56 -07:00
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
import com.android.internal.os.SomeArgs;
|
2014-09-12 22:16:17 -07:00
|
|
|
import com.android.internal.telecom.IConnectionService;
|
|
|
|
import com.android.internal.telecom.IConnectionServiceAdapter;
|
|
|
|
import com.android.internal.telecom.RemoteServiceCallback;
|
2014-06-17 19:08:45 -07:00
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
import java.util.ArrayList;
|
2014-06-04 20:20:58 -07:00
|
|
|
import java.util.Collection;
|
2014-07-28 18:15:48 -07:00
|
|
|
import java.util.Collections;
|
2014-06-17 19:08:45 -07:00
|
|
|
import java.util.List;
|
2014-05-16 10:22:16 -07:00
|
|
|
import java.util.Map;
|
2014-08-07 18:35:18 -07:00
|
|
|
import java.util.UUID;
|
2014-09-18 14:07:52 -07:00
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
2014-05-16 10:22:16 -07:00
|
|
|
|
|
|
|
/**
|
2017-01-09 09:43:12 -08:00
|
|
|
* An abstract service that should be implemented by any apps which either:
|
|
|
|
* <ol>
|
|
|
|
* <li>Can make phone calls (VoIP or otherwise) and want those calls to be integrated into the
|
|
|
|
* built-in phone app. Referred to as a <b>system managed</b> {@link ConnectionService}.</li>
|
|
|
|
* <li>Are a standalone calling app and don't want their calls to be integrated into the
|
|
|
|
* built-in phone app. Referred to as a <b>self managed</b> {@link ConnectionService}.</li>
|
|
|
|
* </ol>
|
|
|
|
* Once implemented, the {@link ConnectionService} needs to take the following steps so that Telecom
|
|
|
|
* will bind to it:
|
2014-10-29 13:49:58 -07:00
|
|
|
* <p>
|
|
|
|
* 1. <i>Registration in AndroidManifest.xml</i>
|
|
|
|
* <br/>
|
|
|
|
* <pre>
|
|
|
|
* <service android:name="com.example.package.MyConnectionService"
|
|
|
|
* android:label="@string/some_label_for_my_connection_service"
|
2015-05-13 15:59:29 -07:00
|
|
|
* android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
|
2014-10-29 13:49:58 -07:00
|
|
|
* <intent-filter>
|
|
|
|
* <action android:name="android.telecom.ConnectionService" />
|
|
|
|
* </intent-filter>
|
|
|
|
* </service>
|
|
|
|
* </pre>
|
|
|
|
* <p>
|
|
|
|
* 2. <i> Registration of {@link PhoneAccount} with {@link TelecomManager}.</i>
|
|
|
|
* <br/>
|
|
|
|
* See {@link PhoneAccount} and {@link TelecomManager#registerPhoneAccount} for more information.
|
|
|
|
* <p>
|
2017-01-09 09:43:12 -08:00
|
|
|
* System managed {@link ConnectionService}s must be enabled by the user in the phone app settings
|
|
|
|
* before Telecom will bind to them. Self-manged {@link ConnectionService}s must be granted the
|
|
|
|
* appropriate permission before Telecom will bind to them.
|
|
|
|
* <p>
|
|
|
|
* Once registered and enabled by the user in the phone app settings or granted permission, telecom
|
|
|
|
* will bind to a {@link ConnectionService} implementation when it wants that
|
|
|
|
* {@link ConnectionService} to place a call or the service has indicated that is has an incoming
|
|
|
|
* call through {@link TelecomManager#addNewIncomingCall}. The {@link ConnectionService} can then
|
|
|
|
* expect a call to {@link #onCreateIncomingConnection} or {@link #onCreateOutgoingConnection}
|
|
|
|
* wherein it should provide a new instance of a {@link Connection} object. It is through this
|
|
|
|
* {@link Connection} object that telecom receives state updates and the {@link ConnectionService}
|
2014-10-29 13:49:58 -07:00
|
|
|
* receives call-commands such as answer, reject, hold and disconnect.
|
|
|
|
* <p>
|
2017-01-09 09:43:12 -08:00
|
|
|
* When there are no more live calls, telecom will unbind from the {@link ConnectionService}.
|
2014-05-16 10:22:16 -07:00
|
|
|
*/
|
2014-07-04 17:21:07 -07:00
|
|
|
public abstract class ConnectionService extends Service {
|
2014-07-20 17:47:12 -07:00
|
|
|
/**
|
|
|
|
* The {@link Intent} that must be declared as handled by the service.
|
|
|
|
*/
|
2014-08-07 19:46:01 -07:00
|
|
|
@SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
|
2014-09-12 22:16:17 -07:00
|
|
|
public static final String SERVICE_INTERFACE = "android.telecom.ConnectionService";
|
2014-07-20 17:47:12 -07:00
|
|
|
|
2014-05-16 10:22:16 -07:00
|
|
|
// Flag controlling whether PII is emitted into the logs
|
2014-05-20 22:32:12 -07:00
|
|
|
private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
|
2014-05-16 10:22:16 -07:00
|
|
|
|
2016-10-24 16:40:49 -07:00
|
|
|
// Session Definitions
|
|
|
|
private static final String SESSION_HANDLER = "H.";
|
|
|
|
private static final String SESSION_ADD_CS_ADAPTER = "CS.aCSA";
|
|
|
|
private static final String SESSION_REMOVE_CS_ADAPTER = "CS.rCSA";
|
|
|
|
private static final String SESSION_CREATE_CONN = "CS.crCo";
|
|
|
|
private static final String SESSION_ABORT = "CS.ab";
|
|
|
|
private static final String SESSION_ANSWER = "CS.an";
|
|
|
|
private static final String SESSION_ANSWER_VIDEO = "CS.anV";
|
|
|
|
private static final String SESSION_REJECT = "CS.r";
|
|
|
|
private static final String SESSION_REJECT_MESSAGE = "CS.rWM";
|
|
|
|
private static final String SESSION_SILENCE = "CS.s";
|
|
|
|
private static final String SESSION_DISCONNECT = "CS.d";
|
|
|
|
private static final String SESSION_HOLD = "CS.h";
|
|
|
|
private static final String SESSION_UNHOLD = "CS.u";
|
|
|
|
private static final String SESSION_CALL_AUDIO_SC = "CS.cASC";
|
|
|
|
private static final String SESSION_PLAY_DTMF = "CS.pDT";
|
|
|
|
private static final String SESSION_STOP_DTMF = "CS.sDT";
|
|
|
|
private static final String SESSION_CONFERENCE = "CS.c";
|
|
|
|
private static final String SESSION_SPLIT_CONFERENCE = "CS.sFC";
|
|
|
|
private static final String SESSION_MERGE_CONFERENCE = "CS.mC";
|
|
|
|
private static final String SESSION_SWAP_CONFERENCE = "CS.sC";
|
|
|
|
private static final String SESSION_POST_DIAL_CONT = "CS.oPDC";
|
|
|
|
private static final String SESSION_PULL_EXTERNAL_CALL = "CS.pEC";
|
|
|
|
private static final String SESSION_SEND_CALL_EVENT = "CS.sCE";
|
|
|
|
private static final String SESSION_EXTRAS_CHANGED = "CS.oEC";
|
|
|
|
|
2014-08-08 17:06:11 -07:00
|
|
|
private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1;
|
2014-07-14 16:29:44 -07:00
|
|
|
private static final int MSG_CREATE_CONNECTION = 2;
|
2014-07-04 17:21:07 -07:00
|
|
|
private static final int MSG_ABORT = 3;
|
2014-07-14 16:29:44 -07:00
|
|
|
private static final int MSG_ANSWER = 4;
|
|
|
|
private static final int MSG_REJECT = 5;
|
|
|
|
private static final int MSG_DISCONNECT = 6;
|
|
|
|
private static final int MSG_HOLD = 7;
|
|
|
|
private static final int MSG_UNHOLD = 8;
|
2015-05-13 14:14:54 -07:00
|
|
|
private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 9;
|
2014-07-14 16:29:44 -07:00
|
|
|
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;
|
|
|
|
private static final int MSG_SPLIT_FROM_CONFERENCE = 13;
|
2014-08-07 19:46:01 -07:00
|
|
|
private static final int MSG_ON_POST_DIAL_CONTINUE = 14;
|
|
|
|
private static final int MSG_REMOVE_CONNECTION_SERVICE_ADAPTER = 16;
|
2014-08-29 14:51:48 -07:00
|
|
|
private static final int MSG_ANSWER_VIDEO = 17;
|
2014-09-04 17:39:22 -07:00
|
|
|
private static final int MSG_MERGE_CONFERENCE = 18;
|
|
|
|
private static final int MSG_SWAP_CONFERENCE = 19;
|
2015-08-28 16:38:02 -07:00
|
|
|
private static final int MSG_REJECT_WITH_MESSAGE = 20;
|
2015-11-17 15:13:29 -08:00
|
|
|
private static final int MSG_SILENCE = 21;
|
2016-03-14 15:18:07 -07:00
|
|
|
private static final int MSG_PULL_EXTERNAL_CALL = 22;
|
|
|
|
private static final int MSG_SEND_CALL_EVENT = 23;
|
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
|
|
|
private static final int MSG_ON_EXTRAS_CHANGED = 24;
|
2014-07-28 18:15:48 -07:00
|
|
|
|
2014-08-20 10:07:19 -07:00
|
|
|
private static Connection sNullConnection;
|
|
|
|
|
2014-09-18 14:07:52 -07:00
|
|
|
private final Map<String, Connection> mConnectionById = new ConcurrentHashMap<>();
|
|
|
|
private final Map<Connection, String> mIdByConnection = new ConcurrentHashMap<>();
|
|
|
|
private final Map<String, Conference> mConferenceById = new ConcurrentHashMap<>();
|
|
|
|
private final Map<Conference, String> mIdByConference = new ConcurrentHashMap<>();
|
2014-08-23 20:34:57 -07:00
|
|
|
private final RemoteConnectionManager mRemoteConnectionManager =
|
|
|
|
new RemoteConnectionManager(this);
|
2014-07-30 10:07:40 -07:00
|
|
|
private final List<Runnable> mPreInitializationConnectionRequests = new ArrayList<>();
|
2014-07-04 17:21:07 -07:00
|
|
|
private final ConnectionServiceAdapter mAdapter = new ConnectionServiceAdapter();
|
2014-05-16 10:22:16 -07:00
|
|
|
|
2014-08-07 18:35:18 -07:00
|
|
|
private boolean mAreAccountsInitialized = false;
|
2014-08-21 14:28:11 -07:00
|
|
|
private Conference sNullConference;
|
2015-09-01 10:59:48 -07:00
|
|
|
private Object mIdSyncRoot = new Object();
|
|
|
|
private int mId = 0;
|
2014-08-07 18:35:18 -07:00
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private final IBinder mBinder = new IConnectionService.Stub() {
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void addConnectionServiceAdapter(IConnectionServiceAdapter adapter,
|
|
|
|
Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_ADD_CS_ADAPTER);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = adapter;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_ADD_CONNECTION_SERVICE_ADAPTER, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-08-08 17:06:11 -07:00
|
|
|
}
|
|
|
|
|
2016-10-24 16:40:49 -07:00
|
|
|
public void removeConnectionServiceAdapter(IConnectionServiceAdapter adapter,
|
|
|
|
Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_REMOVE_CS_ADAPTER);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = adapter;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_REMOVE_CONNECTION_SERVICE_ADAPTER, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-07-25 15:14:01 -07:00
|
|
|
public void createConnection(
|
|
|
|
PhoneAccountHandle connectionManagerPhoneAccount,
|
2014-08-07 19:46:01 -07:00
|
|
|
String id,
|
2014-07-25 15:14:01 -07:00
|
|
|
ConnectionRequest request,
|
2014-10-02 09:38:39 -07:00
|
|
|
boolean isIncoming,
|
2016-10-24 16:40:49 -07:00
|
|
|
boolean isUnknown,
|
|
|
|
Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_CREATE_CONN);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = connectionManagerPhoneAccount;
|
|
|
|
args.arg2 = id;
|
|
|
|
args.arg3 = request;
|
|
|
|
args.arg4 = Log.createSubsession();
|
|
|
|
args.argi1 = isIncoming ? 1 : 0;
|
|
|
|
args.argi2 = isUnknown ? 1 : 0;
|
|
|
|
mHandler.obtainMessage(MSG_CREATE_CONNECTION, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void abort(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_ABORT);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_ABORT, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void answerVideo(String callId, int videoState, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_ANSWER_VIDEO);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
args.argi1 = videoState;
|
|
|
|
mHandler.obtainMessage(MSG_ANSWER_VIDEO, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-08-29 14:51:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void answer(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_ANSWER);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_ANSWER, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void reject(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_REJECT);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_REJECT, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
2015-08-28 16:38:02 -07:00
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void rejectWithMessage(String callId, String message, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_REJECT_MESSAGE);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = message;
|
|
|
|
args.arg3 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_REJECT_WITH_MESSAGE, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2015-08-28 16:38:02 -07:00
|
|
|
}
|
|
|
|
|
2015-11-17 15:13:29 -08:00
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void silence(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_SILENCE);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_SILENCE, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2015-11-17 15:13:29 -08:00
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void disconnect(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_DISCONNECT);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_DISCONNECT, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void hold(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_HOLD);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_HOLD, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void unhold(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_UNHOLD);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_UNHOLD, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void onCallAudioStateChanged(String callId, CallAudioState callAudioState,
|
|
|
|
Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_CALL_AUDIO_SC);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = callAudioState;
|
|
|
|
args.arg3 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_ON_CALL_AUDIO_STATE_CHANGED, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void playDtmfTone(String callId, char digit, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_PLAY_DTMF);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = digit;
|
|
|
|
args.arg2 = callId;
|
|
|
|
args.arg3 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_PLAY_DTMF_TONE, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void stopDtmfTone(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_STOP_DTMF);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_STOP_DTMF_TONE, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void conference(String callId1, String callId2, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_CONFERENCE);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId1;
|
|
|
|
args.arg2 = callId2;
|
|
|
|
args.arg3 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_CONFERENCE, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void splitFromConference(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_SPLIT_CONFERENCE);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_SPLIT_FROM_CONFERENCE, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
|
2014-09-04 17:39:22 -07:00
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void mergeConference(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_MERGE_CONFERENCE);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_MERGE_CONFERENCE, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-09-04 17:39:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void swapConference(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_SWAP_CONFERENCE);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_SWAP_CONFERENCE, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-09-04 17:39:22 -07:00
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void onPostDialContinue(String callId, boolean proceed, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_POST_DIAL_CONT);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
args.argi1 = proceed ? 1 : 0;
|
|
|
|
mHandler.obtainMessage(MSG_ON_POST_DIAL_CONTINUE, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
2016-03-14 15:18:07 -07:00
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void pullExternalCall(String callId, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_PULL_EXTERNAL_CALL);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_PULL_EXTERNAL_CALL, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2016-03-14 15:18:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void sendCallEvent(String callId, String event, Bundle extras,
|
|
|
|
Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_SEND_CALL_EVENT);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = event;
|
|
|
|
args.arg3 = extras;
|
|
|
|
args.arg4 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_SEND_CALL_EVENT, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2016-03-14 15:18:07 -07:00
|
|
|
}
|
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
|
|
|
|
|
|
|
@Override
|
2016-10-24 16:40:49 -07:00
|
|
|
public void onExtrasChanged(String callId, Bundle extras, Session.Info sessionInfo) {
|
|
|
|
Log.startSession(sessionInfo, SESSION_EXTRAS_CHANGED);
|
|
|
|
try {
|
|
|
|
SomeArgs args = SomeArgs.obtain();
|
|
|
|
args.arg1 = callId;
|
|
|
|
args.arg2 = extras;
|
|
|
|
args.arg3 = Log.createSubsession();
|
|
|
|
mHandler.obtainMessage(MSG_ON_EXTRAS_CHANGED, args).sendToTarget();
|
|
|
|
} finally {
|
|
|
|
Log.endSession();
|
|
|
|
}
|
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
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
|
|
|
|
@Override
|
|
|
|
public void handleMessage(Message msg) {
|
|
|
|
switch (msg.what) {
|
2016-10-24 16:40:49 -07:00
|
|
|
case MSG_ADD_CONNECTION_SERVICE_ADAPTER: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
|
|
|
IConnectionServiceAdapter adapter = (IConnectionServiceAdapter) args.arg1;
|
|
|
|
Log.continueSession((Session) args.arg2,
|
|
|
|
SESSION_HANDLER + SESSION_ADD_CS_ADAPTER);
|
|
|
|
mAdapter.addAdapter(adapter);
|
|
|
|
onAdapterAttached();
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
|
|
|
case MSG_REMOVE_CONNECTION_SERVICE_ADAPTER: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
|
|
|
Log.continueSession((Session) args.arg2,
|
|
|
|
SESSION_HANDLER + SESSION_REMOVE_CS_ADAPTER);
|
|
|
|
mAdapter.removeAdapter((IConnectionServiceAdapter) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-08-08 17:06:11 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
2014-07-25 15:14:01 -07:00
|
|
|
case MSG_CREATE_CONNECTION: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.continueSession((Session) args.arg4, SESSION_HANDLER + SESSION_CREATE_CONN);
|
2014-07-25 15:14:01 -07:00
|
|
|
try {
|
2014-07-30 10:07:40 -07:00
|
|
|
final PhoneAccountHandle connectionManagerPhoneAccount =
|
2014-07-25 15:14:01 -07:00
|
|
|
(PhoneAccountHandle) args.arg1;
|
2014-08-07 19:46:01 -07:00
|
|
|
final String id = (String) args.arg2;
|
|
|
|
final ConnectionRequest request = (ConnectionRequest) args.arg3;
|
2014-07-30 10:07:40 -07:00
|
|
|
final boolean isIncoming = args.argi1 == 1;
|
2014-10-02 09:38:39 -07:00
|
|
|
final boolean isUnknown = args.argi2 == 1;
|
2014-07-30 10:07:40 -07:00
|
|
|
if (!mAreAccountsInitialized) {
|
2014-08-07 19:46:01 -07:00
|
|
|
Log.d(this, "Enqueueing pre-init request %s", id);
|
2016-11-01 14:11:38 -07:00
|
|
|
mPreInitializationConnectionRequests.add(
|
|
|
|
new android.telecom.Logging.Runnable(
|
|
|
|
SESSION_HANDLER + SESSION_CREATE_CONN + ".pICR",
|
|
|
|
null /*lock*/) {
|
2014-07-30 10:07:40 -07:00
|
|
|
@Override
|
2016-11-01 14:11:38 -07:00
|
|
|
public void loggedRun() {
|
2014-07-30 10:07:40 -07:00
|
|
|
createConnection(
|
|
|
|
connectionManagerPhoneAccount,
|
2014-08-07 19:46:01 -07:00
|
|
|
id,
|
2014-07-30 10:07:40 -07:00
|
|
|
request,
|
2014-10-02 09:38:39 -07:00
|
|
|
isIncoming,
|
|
|
|
isUnknown);
|
2014-07-30 10:07:40 -07:00
|
|
|
}
|
2016-11-01 14:11:38 -07:00
|
|
|
}.prepare());
|
2014-07-30 10:07:40 -07:00
|
|
|
} else {
|
2014-08-07 19:46:01 -07:00
|
|
|
createConnection(
|
|
|
|
connectionManagerPhoneAccount,
|
|
|
|
id,
|
|
|
|
request,
|
2014-10-02 09:38:39 -07:00
|
|
|
isIncoming,
|
|
|
|
isUnknown);
|
2014-07-30 10:07:40 -07:00
|
|
|
}
|
2014-07-25 15:14:01 -07:00
|
|
|
} finally {
|
|
|
|
args.recycle();
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.endSession();
|
2014-07-25 15:14:01 -07:00
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2014-07-25 15:14:01 -07:00
|
|
|
}
|
2016-10-24 16:40:49 -07:00
|
|
|
case MSG_ABORT: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_ABORT);
|
|
|
|
try {
|
|
|
|
abort((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
|
|
|
case MSG_ANSWER: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_ANSWER);
|
|
|
|
try {
|
|
|
|
answer((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-08-29 14:51:48 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
2014-08-29 14:51:48 -07:00
|
|
|
case MSG_ANSWER_VIDEO: {
|
2014-07-16 10:11:42 -07:00
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.continueSession((Session) args.arg2,
|
|
|
|
SESSION_HANDLER + SESSION_ANSWER_VIDEO);
|
2014-07-16 10:11:42 -07:00
|
|
|
try {
|
|
|
|
String callId = (String) args.arg1;
|
2014-07-20 22:06:28 -07:00
|
|
|
int videoState = args.argi1;
|
2014-08-29 14:51:48 -07:00
|
|
|
answerVideo(callId, videoState);
|
2014-07-16 10:11:42 -07:00
|
|
|
} finally {
|
|
|
|
args.recycle();
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.endSession();
|
2014-07-16 10:11:42 -07:00
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2014-07-16 10:11:42 -07:00
|
|
|
}
|
2016-10-24 16:40:49 -07:00
|
|
|
case MSG_REJECT: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_REJECT);
|
|
|
|
try {
|
|
|
|
reject((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
2015-08-28 16:38:02 -07:00
|
|
|
case MSG_REJECT_WITH_MESSAGE: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.continueSession((Session) args.arg3,
|
|
|
|
SESSION_HANDLER + SESSION_REJECT_MESSAGE);
|
2015-08-28 16:38:02 -07:00
|
|
|
try {
|
|
|
|
reject((String) args.arg1, (String) args.arg2);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.endSession();
|
2015-08-28 16:38:02 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-10-24 16:40:49 -07:00
|
|
|
case MSG_DISCONNECT: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_DISCONNECT);
|
|
|
|
try {
|
|
|
|
disconnect((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
|
|
|
case MSG_SILENCE: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_SILENCE);
|
|
|
|
try {
|
|
|
|
silence((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2015-11-17 15:13:29 -08:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
|
|
|
case MSG_HOLD: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_REJECT);
|
|
|
|
try {
|
|
|
|
hold((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
|
|
|
case MSG_UNHOLD: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_UNHOLD);
|
|
|
|
try {
|
|
|
|
unhold((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
2015-05-13 14:14:54 -07:00
|
|
|
case MSG_ON_CALL_AUDIO_STATE_CHANGED: {
|
2014-07-04 17:21:07 -07:00
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.continueSession((Session) args.arg3,
|
|
|
|
SESSION_HANDLER + SESSION_CALL_AUDIO_SC);
|
2014-07-04 17:21:07 -07:00
|
|
|
try {
|
|
|
|
String callId = (String) args.arg1;
|
2015-05-13 14:14:54 -07:00
|
|
|
CallAudioState audioState = (CallAudioState) args.arg2;
|
|
|
|
onCallAudioStateChanged(callId, new CallAudioState(audioState));
|
2014-07-04 17:21:07 -07:00
|
|
|
} finally {
|
|
|
|
args.recycle();
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.endSession();
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-10-24 16:40:49 -07:00
|
|
|
case MSG_PLAY_DTMF_TONE: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
|
|
|
Log.continueSession((Session) args.arg3,
|
|
|
|
SESSION_HANDLER + SESSION_PLAY_DTMF);
|
|
|
|
playDtmfTone((String) args.arg2, (char) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
|
|
|
case MSG_STOP_DTMF_TONE: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
|
|
|
Log.continueSession((Session) args.arg2,
|
|
|
|
SESSION_HANDLER + SESSION_STOP_DTMF);
|
|
|
|
stopDtmfTone((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
case MSG_CONFERENCE: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.continueSession((Session) args.arg3,
|
|
|
|
SESSION_HANDLER + SESSION_CONFERENCE);
|
2014-08-07 18:35:18 -07:00
|
|
|
String callId1 = (String) args.arg1;
|
|
|
|
String callId2 = (String) args.arg2;
|
|
|
|
conference(callId1, callId2);
|
2014-07-04 17:21:07 -07:00
|
|
|
} finally {
|
|
|
|
args.recycle();
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.endSession();
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-10-24 16:40:49 -07:00
|
|
|
case MSG_SPLIT_FROM_CONFERENCE: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
|
|
|
Log.continueSession((Session) args.arg2,
|
|
|
|
SESSION_HANDLER + SESSION_SPLIT_CONFERENCE);
|
|
|
|
splitFromConference((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
|
|
|
case MSG_MERGE_CONFERENCE: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
|
|
|
Log.continueSession((Session) args.arg2,
|
|
|
|
SESSION_HANDLER + SESSION_MERGE_CONFERENCE);
|
|
|
|
mergeConference((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-09-04 17:39:22 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
|
|
|
case MSG_SWAP_CONFERENCE: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
|
|
|
Log.continueSession((Session) args.arg2,
|
|
|
|
SESSION_HANDLER + SESSION_SWAP_CONFERENCE);
|
|
|
|
swapConference((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2014-09-04 17:39:22 -07:00
|
|
|
break;
|
2016-10-24 16:40:49 -07:00
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
case MSG_ON_POST_DIAL_CONTINUE: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.continueSession((Session) args.arg2,
|
|
|
|
SESSION_HANDLER + SESSION_POST_DIAL_CONT);
|
2014-07-04 17:21:07 -07:00
|
|
|
String callId = (String) args.arg1;
|
|
|
|
boolean proceed = (args.argi1 == 1);
|
|
|
|
onPostDialContinue(callId, proceed);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.endSession();
|
2014-07-04 17:21:07 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-03-14 15:18:07 -07:00
|
|
|
case MSG_PULL_EXTERNAL_CALL: {
|
2016-10-24 16:40:49 -07:00
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
|
|
|
Log.continueSession((Session) args.arg2,
|
|
|
|
SESSION_HANDLER + SESSION_PULL_EXTERNAL_CALL);
|
|
|
|
pullExternalCall((String) args.arg1);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
|
|
|
Log.endSession();
|
|
|
|
}
|
2016-03-14 15:18:07 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MSG_SEND_CALL_EVENT: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.continueSession((Session) args.arg4,
|
|
|
|
SESSION_HANDLER + SESSION_SEND_CALL_EVENT);
|
2016-03-14 15:18:07 -07:00
|
|
|
String callId = (String) args.arg1;
|
|
|
|
String event = (String) args.arg2;
|
|
|
|
Bundle extras = (Bundle) args.arg3;
|
|
|
|
sendCallEvent(callId, event, extras);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.endSession();
|
2016-03-14 15:18:07 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
case MSG_ON_EXTRAS_CHANGED: {
|
|
|
|
SomeArgs args = (SomeArgs) msg.obj;
|
|
|
|
try {
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.continueSession((Session) args.arg3,
|
|
|
|
SESSION_HANDLER + SESSION_EXTRAS_CHANGED);
|
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
|
|
|
String callId = (String) args.arg1;
|
|
|
|
Bundle extras = (Bundle) args.arg2;
|
|
|
|
handleExtrasChanged(callId, extras);
|
|
|
|
} finally {
|
|
|
|
args.recycle();
|
2016-10-24 16:40:49 -07:00
|
|
|
Log.endSession();
|
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
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-07-04 17:21:07 -07:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-08-07 18:35:18 -07:00
|
|
|
private final Conference.Listener mConferenceListener = new Conference.Listener() {
|
|
|
|
@Override
|
|
|
|
public void onStateChanged(Conference conference, int oldState, int newState) {
|
|
|
|
String id = mIdByConference.get(conference);
|
|
|
|
switch (newState) {
|
|
|
|
case Connection.STATE_ACTIVE:
|
|
|
|
mAdapter.setActive(id);
|
|
|
|
break;
|
|
|
|
case Connection.STATE_HOLDING:
|
|
|
|
mAdapter.setOnHold(id);
|
|
|
|
break;
|
|
|
|
case Connection.STATE_DISCONNECTED:
|
|
|
|
// handled by onDisconnected
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-09-11 17:33:16 -07:00
|
|
|
public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {
|
2014-08-07 18:35:18 -07:00
|
|
|
String id = mIdByConference.get(conference);
|
2014-09-11 17:33:16 -07:00
|
|
|
mAdapter.setDisconnected(id, disconnectCause);
|
2014-08-07 18:35:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onConnectionAdded(Conference conference, Connection connection) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onConnectionRemoved(Conference conference, Connection connection) {
|
|
|
|
}
|
|
|
|
|
2014-09-30 09:17:03 -07:00
|
|
|
@Override
|
|
|
|
public void onConferenceableConnectionsChanged(
|
|
|
|
Conference conference, List<Connection> conferenceableConnections) {
|
|
|
|
mAdapter.setConferenceableConnections(
|
|
|
|
mIdByConference.get(conference),
|
|
|
|
createConnectionIdList(conferenceableConnections));
|
|
|
|
}
|
|
|
|
|
2014-08-07 18:35:18 -07:00
|
|
|
@Override
|
|
|
|
public void onDestroyed(Conference conference) {
|
|
|
|
removeConference(conference);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-11-12 13:41:16 -08:00
|
|
|
public void onConnectionCapabilitiesChanged(
|
|
|
|
Conference conference,
|
|
|
|
int connectionCapabilities) {
|
2014-08-07 18:35:18 -07:00
|
|
|
String id = mIdByConference.get(conference);
|
|
|
|
Log.d(this, "call capabilities: conference: %s",
|
2014-11-12 13:41:16 -08:00
|
|
|
Connection.capabilitiesToString(connectionCapabilities));
|
|
|
|
mAdapter.setConnectionCapabilities(id, connectionCapabilities);
|
2014-08-07 18:35:18 -07:00
|
|
|
}
|
2015-03-24 16:42:31 -07:00
|
|
|
|
2016-03-22 09:02:47 -07:00
|
|
|
@Override
|
|
|
|
public void onConnectionPropertiesChanged(
|
|
|
|
Conference conference,
|
|
|
|
int connectionProperties) {
|
|
|
|
String id = mIdByConference.get(conference);
|
|
|
|
Log.d(this, "call capabilities: conference: %s",
|
|
|
|
Connection.propertiesToString(connectionProperties));
|
|
|
|
mAdapter.setConnectionProperties(id, connectionProperties);
|
|
|
|
}
|
|
|
|
|
2015-03-24 16:42:31 -07:00
|
|
|
@Override
|
|
|
|
public void onVideoStateChanged(Conference c, int videoState) {
|
|
|
|
String id = mIdByConference.get(c);
|
|
|
|
Log.d(this, "onVideoStateChanged set video state %d", videoState);
|
|
|
|
mAdapter.setVideoState(id, videoState);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {
|
|
|
|
String id = mIdByConference.get(c);
|
|
|
|
Log.d(this, "onVideoProviderChanged: Connection: %s, VideoProvider: %s", c,
|
|
|
|
videoProvider);
|
|
|
|
mAdapter.setVideoProvider(id, videoProvider);
|
|
|
|
}
|
2015-04-16 13:11:55 -07:00
|
|
|
|
2015-04-14 13:38:12 -07:00
|
|
|
@Override
|
|
|
|
public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {
|
|
|
|
String id = mIdByConference.get(conference);
|
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
|
|
|
if (id != null) {
|
|
|
|
mAdapter.setStatusHints(id, statusHints);
|
|
|
|
}
|
2015-04-14 13:38:12 -07:00
|
|
|
}
|
2015-05-27 17:21:45 -07:00
|
|
|
|
|
|
|
@Override
|
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
|
|
|
public void onExtrasChanged(Conference c, Bundle extras) {
|
|
|
|
String id = mIdByConference.get(c);
|
|
|
|
if (id != null) {
|
|
|
|
mAdapter.putExtras(id, extras);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onExtrasRemoved(Conference c, List<String> keys) {
|
|
|
|
String id = mIdByConference.get(c);
|
|
|
|
if (id != null) {
|
|
|
|
mAdapter.removeExtras(id, keys);
|
|
|
|
}
|
2015-05-27 17:21:45 -07:00
|
|
|
}
|
2014-08-07 18:35:18 -07:00
|
|
|
};
|
|
|
|
|
2014-05-16 10:22:16 -07:00
|
|
|
private final Connection.Listener mConnectionListener = new Connection.Listener() {
|
|
|
|
@Override
|
|
|
|
public void onStateChanged(Connection c, int state) {
|
|
|
|
String id = mIdByConnection.get(c);
|
2014-05-22 09:49:34 -07:00
|
|
|
Log.d(this, "Adapter set state %s %s", id, Connection.stateToString(state));
|
2014-05-16 10:22:16 -07:00
|
|
|
switch (state) {
|
2014-08-07 19:46:01 -07:00
|
|
|
case Connection.STATE_ACTIVE:
|
2014-07-04 17:21:07 -07:00
|
|
|
mAdapter.setActive(id);
|
2014-05-16 10:22:16 -07:00
|
|
|
break;
|
2014-08-07 19:46:01 -07:00
|
|
|
case Connection.STATE_DIALING:
|
2014-07-04 17:21:07 -07:00
|
|
|
mAdapter.setDialing(id);
|
2014-05-16 10:22:16 -07:00
|
|
|
break;
|
2016-07-07 22:53:57 -07:00
|
|
|
case Connection.STATE_PULLING_CALL:
|
|
|
|
mAdapter.setPulling(id);
|
|
|
|
break;
|
2014-08-07 19:46:01 -07:00
|
|
|
case Connection.STATE_DISCONNECTED:
|
2014-05-16 10:22:16 -07:00
|
|
|
// Handled in onDisconnected()
|
|
|
|
break;
|
2014-08-07 19:46:01 -07:00
|
|
|
case Connection.STATE_HOLDING:
|
2014-07-04 17:21:07 -07:00
|
|
|
mAdapter.setOnHold(id);
|
2014-05-16 10:22:16 -07:00
|
|
|
break;
|
2014-08-07 19:46:01 -07:00
|
|
|
case Connection.STATE_NEW:
|
2014-09-12 22:16:17 -07:00
|
|
|
// Nothing to tell Telecom
|
2014-05-16 10:22:16 -07:00
|
|
|
break;
|
2014-08-07 19:46:01 -07:00
|
|
|
case Connection.STATE_RINGING:
|
2014-07-04 17:21:07 -07:00
|
|
|
mAdapter.setRinging(id);
|
2014-05-16 10:22:16 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-01 11:31:21 -07:00
|
|
|
@Override
|
2014-09-11 17:33:16 -07:00
|
|
|
public void onDisconnected(Connection c, DisconnectCause disconnectCause) {
|
2014-07-01 11:31:21 -07:00
|
|
|
String id = mIdByConnection.get(c);
|
2014-09-16 18:14:59 -07:00
|
|
|
Log.d(this, "Adapter set disconnected %s", disconnectCause);
|
2014-09-11 17:33:16 -07:00
|
|
|
mAdapter.setDisconnected(id, disconnectCause);
|
2014-07-01 11:31:21 -07:00
|
|
|
}
|
|
|
|
|
2014-07-17 07:50:22 -07:00
|
|
|
@Override
|
|
|
|
public void onVideoStateChanged(Connection c, int videoState) {
|
|
|
|
String id = mIdByConnection.get(c);
|
|
|
|
Log.d(this, "Adapter set video state %d", videoState);
|
|
|
|
mAdapter.setVideoState(id, videoState);
|
|
|
|
}
|
|
|
|
|
2014-05-16 10:22:16 -07:00
|
|
|
@Override
|
2014-09-08 15:34:24 -07:00
|
|
|
public void onAddressChanged(Connection c, Uri address, int presentation) {
|
2014-05-16 10:22:16 -07:00
|
|
|
String id = mIdByConnection.get(c);
|
2014-09-08 15:34:24 -07:00
|
|
|
mAdapter.setAddress(id, address, presentation);
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-07-11 14:50:13 -07:00
|
|
|
public void onCallerDisplayNameChanged(
|
|
|
|
Connection c, String callerDisplayName, int presentation) {
|
|
|
|
String id = mIdByConnection.get(c);
|
|
|
|
mAdapter.setCallerDisplayName(id, callerDisplayName, presentation);
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDestroyed(Connection c) {
|
|
|
|
removeConnection(c);
|
|
|
|
}
|
2014-05-28 16:46:42 -07:00
|
|
|
|
2014-06-30 15:15:23 -07:00
|
|
|
@Override
|
2014-07-04 17:21:07 -07:00
|
|
|
public void onPostDialWait(Connection c, String remaining) {
|
2014-06-30 15:15:23 -07:00
|
|
|
String id = mIdByConnection.get(c);
|
|
|
|
Log.d(this, "Adapter onPostDialWait %s, %s", c, remaining);
|
2014-07-04 17:21:07 -07:00
|
|
|
mAdapter.onPostDialWait(id, remaining);
|
2014-06-30 15:15:23 -07:00
|
|
|
}
|
|
|
|
|
2014-12-15 16:12:50 -08:00
|
|
|
@Override
|
|
|
|
public void onPostDialChar(Connection c, char nextChar) {
|
|
|
|
String id = mIdByConnection.get(c);
|
|
|
|
Log.d(this, "Adapter onPostDialChar %s, %s", c, nextChar);
|
|
|
|
mAdapter.onPostDialChar(id, nextChar);
|
|
|
|
}
|
|
|
|
|
2014-05-28 16:46:42 -07:00
|
|
|
@Override
|
2014-09-08 15:34:24 -07:00
|
|
|
public void onRingbackRequested(Connection c, boolean ringback) {
|
2014-05-28 16:46:42 -07:00
|
|
|
String id = mIdByConnection.get(c);
|
|
|
|
Log.d(this, "Adapter onRingback %b", ringback);
|
2014-09-08 15:34:24 -07:00
|
|
|
mAdapter.setRingbackRequested(id, ringback);
|
2014-05-28 16:46:42 -07:00
|
|
|
}
|
2014-06-04 20:20:58 -07:00
|
|
|
|
|
|
|
@Override
|
2014-11-12 13:41:16 -08:00
|
|
|
public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {
|
2014-06-04 20:20:58 -07:00
|
|
|
String id = mIdByConnection.get(c);
|
2014-08-07 19:46:01 -07:00
|
|
|
Log.d(this, "capabilities: parcelableconnection: %s",
|
2014-11-12 13:41:16 -08:00
|
|
|
Connection.capabilitiesToString(capabilities));
|
|
|
|
mAdapter.setConnectionCapabilities(id, capabilities);
|
2014-06-04 20:20:58 -07:00
|
|
|
}
|
|
|
|
|
2016-03-22 09:02:47 -07:00
|
|
|
@Override
|
|
|
|
public void onConnectionPropertiesChanged(Connection c, int properties) {
|
|
|
|
String id = mIdByConnection.get(c);
|
|
|
|
Log.d(this, "properties: parcelableconnection: %s",
|
|
|
|
Connection.propertiesToString(properties));
|
|
|
|
mAdapter.setConnectionProperties(id, properties);
|
|
|
|
}
|
|
|
|
|
2014-06-20 16:29:33 -07:00
|
|
|
@Override
|
2014-08-07 19:46:01 -07:00
|
|
|
public void onVideoProviderChanged(Connection c, Connection.VideoProvider videoProvider) {
|
2014-06-20 16:29:33 -07:00
|
|
|
String id = mIdByConnection.get(c);
|
2015-03-24 16:42:31 -07:00
|
|
|
Log.d(this, "onVideoProviderChanged: Connection: %s, VideoProvider: %s", c,
|
|
|
|
videoProvider);
|
2014-08-07 19:46:01 -07:00
|
|
|
mAdapter.setVideoProvider(id, videoProvider);
|
2014-06-20 16:29:33 -07:00
|
|
|
}
|
2014-07-07 22:49:44 -07:00
|
|
|
|
|
|
|
@Override
|
2014-07-15 14:40:39 -07:00
|
|
|
public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {
|
2014-07-07 22:49:44 -07:00
|
|
|
String id = mIdByConnection.get(c);
|
2014-09-08 15:34:24 -07:00
|
|
|
mAdapter.setIsVoipAudioMode(id, isVoip);
|
2014-07-07 22:49:44 -07:00
|
|
|
}
|
2014-07-08 21:48:22 -07:00
|
|
|
|
|
|
|
@Override
|
2014-07-15 14:40:39 -07:00
|
|
|
public void onStatusHintsChanged(Connection c, StatusHints statusHints) {
|
2014-07-08 21:48:22 -07:00
|
|
|
String id = mIdByConnection.get(c);
|
|
|
|
mAdapter.setStatusHints(id, statusHints);
|
|
|
|
}
|
2014-07-18 14:49:18 -07:00
|
|
|
|
2014-07-28 18:15:48 -07:00
|
|
|
@Override
|
2014-11-17 15:49:51 -08:00
|
|
|
public void onConferenceablesChanged(
|
2015-04-20 09:13:01 -07:00
|
|
|
Connection connection, List<Conferenceable> conferenceables) {
|
2014-08-23 20:34:57 -07:00
|
|
|
mAdapter.setConferenceableConnections(
|
|
|
|
mIdByConnection.get(connection),
|
2014-11-17 15:49:51 -08:00
|
|
|
createIdList(conferenceables));
|
2014-07-28 18:15:48 -07:00
|
|
|
}
|
2014-08-07 18:35:18 -07:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onConferenceChanged(Connection connection, Conference conference) {
|
|
|
|
String id = mIdByConnection.get(connection);
|
|
|
|
if (id != null) {
|
|
|
|
String conferenceId = null;
|
|
|
|
if (conference != null) {
|
|
|
|
conferenceId = mIdByConference.get(conference);
|
|
|
|
}
|
|
|
|
mAdapter.setIsConferenced(id, conferenceId);
|
|
|
|
}
|
|
|
|
}
|
2015-04-24 15:25:29 -07:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onConferenceMergeFailed(Connection connection) {
|
|
|
|
String id = mIdByConnection.get(connection);
|
|
|
|
if (id != null) {
|
|
|
|
mAdapter.onConferenceMergeFailed(id);
|
|
|
|
}
|
|
|
|
}
|
2015-05-27 17:21:45 -07:00
|
|
|
|
|
|
|
@Override
|
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
|
|
|
public void onExtrasChanged(Connection c, Bundle extras) {
|
|
|
|
String id = mIdByConnection.get(c);
|
|
|
|
if (id != null) {
|
|
|
|
mAdapter.putExtras(id, extras);
|
|
|
|
}
|
|
|
|
}
|
2016-10-24 16:40:49 -07:00
|
|
|
|
2017-01-09 09:43:12 -08:00
|
|
|
@Override
|
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
|
|
|
public void onExtrasRemoved(Connection c, List<String> keys) {
|
|
|
|
String id = mIdByConnection.get(c);
|
2015-05-27 17:21:45 -07:00
|
|
|
if (id != null) {
|
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
|
|
|
mAdapter.removeExtras(id, keys);
|
2015-05-27 17:21:45 -07:00
|
|
|
}
|
|
|
|
}
|
2016-02-16 14:36:20 -08:00
|
|
|
|
|
|
|
@Override
|
2016-03-14 15:18:07 -07:00
|
|
|
public void onConnectionEvent(Connection connection, String event, Bundle extras) {
|
2016-02-16 14:36:20 -08:00
|
|
|
String id = mIdByConnection.get(connection);
|
|
|
|
if (id != null) {
|
2016-03-14 15:18:07 -07:00
|
|
|
mAdapter.onConnectionEvent(id, event, extras);
|
2016-02-16 14:36:20 -08:00
|
|
|
}
|
|
|
|
}
|
2017-01-09 09:43:12 -08:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAudioRouteChanged(Connection c, int audioRoute) {
|
|
|
|
String id = mIdByConnection.get(c);
|
|
|
|
if (id != null) {
|
|
|
|
mAdapter.setAudioRoute(id, audioRoute);
|
|
|
|
}
|
|
|
|
}
|
2014-05-16 10:22:16 -07:00
|
|
|
};
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
/** {@inheritDoc} */
|
2014-05-16 10:22:16 -07:00
|
|
|
@Override
|
2014-07-04 17:21:07 -07:00
|
|
|
public final IBinder onBind(Intent intent) {
|
|
|
|
return mBinder;
|
|
|
|
}
|
|
|
|
|
2014-09-11 19:50:24 -07:00
|
|
|
/** {@inheritDoc} */
|
|
|
|
@Override
|
|
|
|
public boolean onUnbind(Intent intent) {
|
|
|
|
endAllConnections();
|
|
|
|
return super.onUnbind(intent);
|
|
|
|
}
|
|
|
|
|
2014-07-14 16:29:44 -07:00
|
|
|
/**
|
2014-09-12 22:16:17 -07:00
|
|
|
* This can be used by telecom to either create a new outgoing call or attach to an existing
|
|
|
|
* incoming call. In either case, telecom will cycle through a set of services and call
|
2014-07-14 16:29:44 -07:00
|
|
|
* createConnection util a connection service cancels the process or completes it successfully.
|
|
|
|
*/
|
2014-07-25 15:14:01 -07:00
|
|
|
private void createConnection(
|
|
|
|
final PhoneAccountHandle callManagerAccount,
|
2014-08-07 19:46:01 -07:00
|
|
|
final String callId,
|
2014-07-25 15:14:01 -07:00
|
|
|
final ConnectionRequest request,
|
2014-10-02 09:38:39 -07:00
|
|
|
boolean isIncoming,
|
|
|
|
boolean isUnknown) {
|
2014-08-20 10:07:19 -07:00
|
|
|
Log.d(this, "createConnection, callManagerAccount: %s, callId: %s, request: %s, " +
|
2015-09-01 10:59:48 -07:00
|
|
|
"isIncoming: %b, isUnknown: %b", callManagerAccount, callId, request,
|
|
|
|
isIncoming,
|
2014-10-02 09:38:39 -07:00
|
|
|
isUnknown);
|
2014-05-16 10:22:16 -07:00
|
|
|
|
2014-10-02 09:38:39 -07:00
|
|
|
Connection connection = isUnknown ? onCreateUnknownConnection(callManagerAccount, request)
|
|
|
|
: isIncoming ? onCreateIncomingConnection(callManagerAccount, request)
|
2014-08-18 09:23:25 -07:00
|
|
|
: onCreateOutgoingConnection(callManagerAccount, request);
|
2014-08-20 10:07:19 -07:00
|
|
|
Log.d(this, "createConnection, connection: %s", connection);
|
|
|
|
if (connection == null) {
|
2014-09-11 17:33:16 -07:00
|
|
|
connection = Connection.createFailedConnection(
|
|
|
|
new DisconnectCause(DisconnectCause.ERROR));
|
2014-07-14 16:29:44 -07:00
|
|
|
}
|
2014-05-16 10:22:16 -07:00
|
|
|
|
2015-09-01 10:59:48 -07:00
|
|
|
connection.setTelecomCallId(callId);
|
2014-08-20 10:07:19 -07:00
|
|
|
if (connection.getState() != Connection.STATE_DISCONNECTED) {
|
2014-08-18 09:23:25 -07:00
|
|
|
addConnection(callId, connection);
|
|
|
|
}
|
|
|
|
|
2014-09-08 15:34:24 -07:00
|
|
|
Uri address = connection.getAddress();
|
|
|
|
String number = address == null ? "null" : address.getSchemeSpecificPart();
|
2016-03-22 09:02:47 -07:00
|
|
|
Log.v(this, "createConnection, number: %s, state: %s, capabilities: %s, properties: %s",
|
2014-08-07 19:46:01 -07:00
|
|
|
Connection.toLogSafePhoneNumber(number),
|
2014-08-20 10:07:19 -07:00
|
|
|
Connection.stateToString(connection.getState()),
|
2016-03-22 09:02:47 -07:00
|
|
|
Connection.capabilitiesToString(connection.getConnectionCapabilities()),
|
|
|
|
Connection.propertiesToString(connection.getConnectionProperties()));
|
2014-07-28 18:15:48 -07:00
|
|
|
|
2014-08-20 10:07:19 -07:00
|
|
|
Log.d(this, "createConnection, calling handleCreateConnectionSuccessful %s", callId);
|
2014-08-18 09:23:25 -07:00
|
|
|
mAdapter.handleCreateConnectionComplete(
|
2014-08-07 19:46:01 -07:00
|
|
|
callId,
|
2014-07-20 22:06:28 -07:00
|
|
|
request,
|
|
|
|
new ParcelableConnection(
|
|
|
|
request.getAccountHandle(),
|
|
|
|
connection.getState(),
|
2014-11-12 13:41:16 -08:00
|
|
|
connection.getConnectionCapabilities(),
|
2016-03-22 09:02:47 -07:00
|
|
|
connection.getConnectionProperties(),
|
2016-11-30 16:06:42 -08:00
|
|
|
connection.getSupportedAudioRoutes(),
|
2014-09-08 15:34:24 -07:00
|
|
|
connection.getAddress(),
|
|
|
|
connection.getAddressPresentation(),
|
2014-07-20 22:06:28 -07:00
|
|
|
connection.getCallerDisplayName(),
|
|
|
|
connection.getCallerDisplayNamePresentation(),
|
2014-08-07 19:46:01 -07:00
|
|
|
connection.getVideoProvider() == null ?
|
|
|
|
null : connection.getVideoProvider().getInterface(),
|
2014-08-14 17:39:34 -07:00
|
|
|
connection.getVideoState(),
|
2014-09-08 15:34:24 -07:00
|
|
|
connection.isRingbackRequested(),
|
2014-08-14 17:39:34 -07:00
|
|
|
connection.getAudioModeIsVoip(),
|
2015-07-15 15:47:21 -07:00
|
|
|
connection.getConnectTimeMillis(),
|
2014-08-18 09:23:25 -07:00
|
|
|
connection.getStatusHints(),
|
2014-08-20 10:07:19 -07:00
|
|
|
connection.getDisconnectCause(),
|
2015-05-27 17:21:45 -07:00
|
|
|
createIdList(connection.getConferenceables()),
|
|
|
|
connection.getExtras()));
|
2017-01-09 09:43:12 -08:00
|
|
|
|
|
|
|
if (isIncoming && request.shouldShowIncomingCallUi() &&
|
|
|
|
(connection.getConnectionProperties() & Connection.PROPERTY_SELF_MANAGED) ==
|
|
|
|
Connection.PROPERTY_SELF_MANAGED) {
|
|
|
|
// Tell ConnectionService to show its incoming call UX.
|
|
|
|
connection.onShowIncomingCallUi();
|
|
|
|
}
|
2014-12-11 17:53:38 -08:00
|
|
|
if (isUnknown) {
|
|
|
|
triggerConferenceRecalculate();
|
|
|
|
}
|
2014-07-20 22:06:28 -07:00
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private void abort(String callId) {
|
2014-05-20 22:32:12 -07:00
|
|
|
Log.d(this, "abort %s", callId);
|
2014-07-04 17:21:07 -07:00
|
|
|
findConnectionForAction(callId, "abort").onAbort();
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2014-08-29 14:51:48 -07:00
|
|
|
private void answerVideo(String callId, int videoState) {
|
|
|
|
Log.d(this, "answerVideo %s", callId);
|
2014-07-16 10:11:42 -07:00
|
|
|
findConnectionForAction(callId, "answer").onAnswer(videoState);
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2014-08-29 14:51:48 -07:00
|
|
|
private void answer(String callId) {
|
|
|
|
Log.d(this, "answer %s", callId);
|
|
|
|
findConnectionForAction(callId, "answer").onAnswer();
|
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private void reject(String callId) {
|
2014-05-20 22:32:12 -07:00
|
|
|
Log.d(this, "reject %s", callId);
|
2014-07-04 17:21:07 -07:00
|
|
|
findConnectionForAction(callId, "reject").onReject();
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2015-08-28 16:38:02 -07:00
|
|
|
private void reject(String callId, String rejectWithMessage) {
|
|
|
|
Log.d(this, "reject %s with message", callId);
|
|
|
|
findConnectionForAction(callId, "reject").onReject(rejectWithMessage);
|
|
|
|
}
|
|
|
|
|
2015-11-17 15:13:29 -08:00
|
|
|
private void silence(String callId) {
|
|
|
|
Log.d(this, "silence %s", callId);
|
|
|
|
findConnectionForAction(callId, "silence").onSilence();
|
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private void disconnect(String callId) {
|
2014-05-20 22:32:12 -07:00
|
|
|
Log.d(this, "disconnect %s", callId);
|
2014-08-21 14:28:11 -07:00
|
|
|
if (mConnectionById.containsKey(callId)) {
|
|
|
|
findConnectionForAction(callId, "disconnect").onDisconnect();
|
|
|
|
} else {
|
|
|
|
findConferenceForAction(callId, "disconnect").onDisconnect();
|
|
|
|
}
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private void hold(String callId) {
|
2014-05-20 22:32:12 -07:00
|
|
|
Log.d(this, "hold %s", callId);
|
2014-08-21 14:28:11 -07:00
|
|
|
if (mConnectionById.containsKey(callId)) {
|
|
|
|
findConnectionForAction(callId, "hold").onHold();
|
|
|
|
} else {
|
|
|
|
findConferenceForAction(callId, "hold").onHold();
|
|
|
|
}
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private void unhold(String callId) {
|
2014-05-20 22:32:12 -07:00
|
|
|
Log.d(this, "unhold %s", callId);
|
2014-08-21 14:28:11 -07:00
|
|
|
if (mConnectionById.containsKey(callId)) {
|
|
|
|
findConnectionForAction(callId, "unhold").onUnhold();
|
|
|
|
} else {
|
|
|
|
findConferenceForAction(callId, "unhold").onUnhold();
|
|
|
|
}
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2015-05-13 14:14:54 -07:00
|
|
|
private void onCallAudioStateChanged(String callId, CallAudioState callAudioState) {
|
|
|
|
Log.d(this, "onAudioStateChanged %s %s", callId, callAudioState);
|
2014-09-15 19:18:13 -07:00
|
|
|
if (mConnectionById.containsKey(callId)) {
|
2015-05-13 14:14:54 -07:00
|
|
|
findConnectionForAction(callId, "onCallAudioStateChanged").setCallAudioState(
|
|
|
|
callAudioState);
|
2014-09-15 19:18:13 -07:00
|
|
|
} else {
|
2015-05-13 14:14:54 -07:00
|
|
|
findConferenceForAction(callId, "onCallAudioStateChanged").setCallAudioState(
|
|
|
|
callAudioState);
|
2014-09-15 19:18:13 -07:00
|
|
|
}
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private void playDtmfTone(String callId, char digit) {
|
|
|
|
Log.d(this, "playDtmfTone %s %c", callId, digit);
|
2014-09-15 19:18:13 -07:00
|
|
|
if (mConnectionById.containsKey(callId)) {
|
|
|
|
findConnectionForAction(callId, "playDtmfTone").onPlayDtmfTone(digit);
|
|
|
|
} else {
|
|
|
|
findConferenceForAction(callId, "playDtmfTone").onPlayDtmfTone(digit);
|
|
|
|
}
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private void stopDtmfTone(String callId) {
|
|
|
|
Log.d(this, "stopDtmfTone %s", callId);
|
2014-09-15 19:18:13 -07:00
|
|
|
if (mConnectionById.containsKey(callId)) {
|
|
|
|
findConnectionForAction(callId, "stopDtmfTone").onStopDtmfTone();
|
|
|
|
} else {
|
|
|
|
findConferenceForAction(callId, "stopDtmfTone").onStopDtmfTone();
|
|
|
|
}
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2014-08-07 18:35:18 -07:00
|
|
|
private void conference(String callId1, String callId2) {
|
|
|
|
Log.d(this, "conference %s, %s", callId1, callId2);
|
2014-06-04 20:20:58 -07:00
|
|
|
|
2014-11-17 15:49:51 -08:00
|
|
|
// Attempt to get second connection or conference.
|
2014-08-07 18:35:18 -07:00
|
|
|
Connection connection2 = findConnectionForAction(callId2, "conference");
|
2014-11-17 15:49:51 -08:00
|
|
|
Conference conference2 = getNullConference();
|
2014-08-20 10:07:19 -07:00
|
|
|
if (connection2 == getNullConnection()) {
|
2014-11-17 15:49:51 -08:00
|
|
|
conference2 = findConferenceForAction(callId2, "conference");
|
|
|
|
if (conference2 == getNullConference()) {
|
|
|
|
Log.w(this, "Connection2 or Conference2 missing in conference request %s.",
|
|
|
|
callId2);
|
|
|
|
return;
|
|
|
|
}
|
2014-08-07 18:35:18 -07:00
|
|
|
}
|
2014-06-04 20:20:58 -07:00
|
|
|
|
2014-11-17 15:49:51 -08:00
|
|
|
// Attempt to get first connection or conference and perform merge.
|
2014-09-30 09:17:03 -07:00
|
|
|
Connection connection1 = findConnectionForAction(callId1, "conference");
|
|
|
|
if (connection1 == getNullConnection()) {
|
|
|
|
Conference conference1 = findConferenceForAction(callId1, "addConnection");
|
|
|
|
if (conference1 == getNullConference()) {
|
|
|
|
Log.w(this,
|
|
|
|
"Connection1 or Conference1 missing in conference request %s.",
|
|
|
|
callId1);
|
|
|
|
} else {
|
2014-11-17 15:49:51 -08:00
|
|
|
// Call 1 is a conference.
|
|
|
|
if (connection2 != getNullConnection()) {
|
|
|
|
// Call 2 is a connection so merge via call 1 (conference).
|
|
|
|
conference1.onMerge(connection2);
|
|
|
|
} else {
|
|
|
|
// Call 2 is ALSO a conference; this should never happen.
|
|
|
|
Log.wtf(this, "There can only be one conference and an attempt was made to " +
|
|
|
|
"merge two conferences.");
|
|
|
|
return;
|
|
|
|
}
|
2014-09-30 09:17:03 -07:00
|
|
|
}
|
|
|
|
} else {
|
2014-11-17 15:49:51 -08:00
|
|
|
// Call 1 is a connection.
|
|
|
|
if (conference2 != getNullConference()) {
|
|
|
|
// Call 2 is a conference, so merge via call 2.
|
|
|
|
conference2.onMerge(connection1);
|
|
|
|
} else {
|
|
|
|
// Call 2 is a connection, so merge together.
|
|
|
|
onConference(connection1, connection2);
|
|
|
|
}
|
2014-09-30 09:17:03 -07:00
|
|
|
}
|
2014-05-31 10:31:19 -07:00
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private void splitFromConference(String callId) {
|
2014-06-04 20:20:58 -07:00
|
|
|
Log.d(this, "splitFromConference(%s)", callId);
|
2014-05-31 10:31:19 -07:00
|
|
|
|
|
|
|
Connection connection = findConnectionForAction(callId, "splitFromConference");
|
2014-08-20 10:07:19 -07:00
|
|
|
if (connection == getNullConnection()) {
|
2014-05-31 10:31:19 -07:00
|
|
|
Log.w(this, "Connection missing in conference request %s.", callId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-21 14:28:11 -07:00
|
|
|
Conference conference = connection.getConference();
|
|
|
|
if (conference != null) {
|
|
|
|
conference.onSeparate(connection);
|
|
|
|
}
|
2014-05-31 10:31:19 -07:00
|
|
|
}
|
|
|
|
|
2014-09-04 17:39:22 -07:00
|
|
|
private void mergeConference(String callId) {
|
|
|
|
Log.d(this, "mergeConference(%s)", callId);
|
|
|
|
Conference conference = findConferenceForAction(callId, "mergeConference");
|
|
|
|
if (conference != null) {
|
|
|
|
conference.onMerge();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void swapConference(String callId) {
|
|
|
|
Log.d(this, "swapConference(%s)", callId);
|
|
|
|
Conference conference = findConferenceForAction(callId, "swapConference");
|
|
|
|
if (conference != null) {
|
|
|
|
conference.onSwap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-14 15:18:07 -07:00
|
|
|
/**
|
|
|
|
* Notifies a {@link Connection} of a request to pull an external call.
|
|
|
|
*
|
|
|
|
* See {@link Call#pullExternalCall()}.
|
|
|
|
*
|
|
|
|
* @param callId The ID of the call to pull.
|
|
|
|
*/
|
|
|
|
private void pullExternalCall(String callId) {
|
|
|
|
Log.d(this, "pullExternalCall(%s)", callId);
|
|
|
|
Connection connection = findConnectionForAction(callId, "pullExternalCall");
|
|
|
|
if (connection != null) {
|
|
|
|
connection.onPullExternalCall();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies a {@link Connection} of a call event.
|
|
|
|
*
|
|
|
|
* See {@link Call#sendCallEvent(String, Bundle)}.
|
|
|
|
*
|
|
|
|
* @param callId The ID of the call receiving the event.
|
|
|
|
* @param event The event.
|
|
|
|
* @param extras Extras associated with the event.
|
|
|
|
*/
|
|
|
|
private void sendCallEvent(String callId, String event, Bundle extras) {
|
|
|
|
Log.d(this, "sendCallEvent(%s, %s)", callId, event);
|
|
|
|
Connection connection = findConnectionForAction(callId, "sendCallEvent");
|
|
|
|
if (connection != null) {
|
|
|
|
connection.onCallEvent(event, extras);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Notifies a {@link Connection} or {@link Conference} of a change to the extras from Telecom.
|
|
|
|
* <p>
|
|
|
|
* These extra changes can originate from Telecom itself, or from an {@link InCallService} via
|
|
|
|
* the {@link android.telecom.Call#putExtra(String, boolean)},
|
|
|
|
* {@link android.telecom.Call#putExtra(String, int)},
|
|
|
|
* {@link android.telecom.Call#putExtra(String, String)},
|
|
|
|
* {@link Call#removeExtras(List)}.
|
|
|
|
*
|
|
|
|
* @param callId The ID of the call receiving the event.
|
|
|
|
* @param extras The new extras bundle.
|
|
|
|
*/
|
|
|
|
private void handleExtrasChanged(String callId, Bundle extras) {
|
|
|
|
Log.d(this, "handleExtrasChanged(%s, %s)", callId, extras);
|
|
|
|
if (mConnectionById.containsKey(callId)) {
|
|
|
|
findConnectionForAction(callId, "handleExtrasChanged").handleExtrasChanged(extras);
|
|
|
|
} else if (mConferenceById.containsKey(callId)) {
|
|
|
|
findConferenceForAction(callId, "handleExtrasChanged").handleExtrasChanged(extras);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private void onPostDialContinue(String callId, boolean proceed) {
|
2014-06-03 14:07:13 -07:00
|
|
|
Log.d(this, "onPostDialContinue(%s)", callId);
|
2014-07-04 17:21:07 -07:00
|
|
|
findConnectionForAction(callId, "stopDtmfTone").onPostDialContinue(proceed);
|
2014-07-02 21:26:12 -07:00
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
private void onAdapterAttached() {
|
2014-06-30 21:17:13 -07:00
|
|
|
if (mAreAccountsInitialized) {
|
2014-06-17 19:08:45 -07:00
|
|
|
// No need to query again if we already did it.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-04 17:21:07 -07:00
|
|
|
mAdapter.queryRemoteConnectionServices(new RemoteServiceCallback.Stub() {
|
2014-06-17 19:08:45 -07:00
|
|
|
@Override
|
|
|
|
public void onResult(
|
|
|
|
final List<ComponentName> componentNames,
|
2014-07-04 17:21:07 -07:00
|
|
|
final List<IBinder> services) {
|
2016-11-01 14:11:38 -07:00
|
|
|
mHandler.post(new android.telecom.Logging.Runnable("oAA.qRCS.oR", null /*lock*/) {
|
2014-08-18 09:23:25 -07:00
|
|
|
@Override
|
2016-11-01 14:11:38 -07:00
|
|
|
public void loggedRun() {
|
2014-07-04 17:21:07 -07:00
|
|
|
for (int i = 0; i < componentNames.size() && i < services.size(); i++) {
|
2014-06-17 19:08:45 -07:00
|
|
|
mRemoteConnectionManager.addConnectionService(
|
|
|
|
componentNames.get(i),
|
2014-07-04 17:21:07 -07:00
|
|
|
IConnectionService.Stub.asInterface(services.get(i)));
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
2014-07-30 10:07:40 -07:00
|
|
|
onAccountsInitialized();
|
2014-07-14 16:29:44 -07:00
|
|
|
Log.d(this, "remote connection services found: " + services);
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
2016-11-01 14:11:38 -07:00
|
|
|
}.prepare());
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onError() {
|
2016-11-01 14:11:38 -07:00
|
|
|
mHandler.post(new android.telecom.Logging.Runnable("oAA.qRCS.oE", null /*lock*/) {
|
2014-08-18 09:23:25 -07:00
|
|
|
@Override
|
2016-11-01 14:11:38 -07:00
|
|
|
public void loggedRun() {
|
2014-06-30 21:17:13 -07:00
|
|
|
mAreAccountsInitialized = true;
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
2016-11-01 14:11:38 -07:00
|
|
|
}.prepare());
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-07-25 15:14:01 -07:00
|
|
|
/**
|
|
|
|
* Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an
|
2014-10-29 13:49:58 -07:00
|
|
|
* incoming request. This is used by {@code ConnectionService}s that are registered with
|
|
|
|
* {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} and want to be able to manage
|
|
|
|
* SIM-based incoming calls.
|
2014-07-25 15:14:01 -07:00
|
|
|
*
|
|
|
|
* @param connectionManagerPhoneAccount See description at
|
|
|
|
* {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
|
|
|
|
* @param request Details about the incoming call.
|
|
|
|
* @return The {@code Connection} object to satisfy this call, or {@code null} to
|
|
|
|
* not handle the call.
|
|
|
|
*/
|
|
|
|
public final RemoteConnection createRemoteIncomingConnection(
|
|
|
|
PhoneAccountHandle connectionManagerPhoneAccount,
|
|
|
|
ConnectionRequest request) {
|
|
|
|
return mRemoteConnectionManager.createRemoteConnection(
|
|
|
|
connectionManagerPhoneAccount, request, true);
|
2014-07-14 16:29:44 -07:00
|
|
|
}
|
|
|
|
|
2014-07-25 15:14:01 -07:00
|
|
|
/**
|
|
|
|
* Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an
|
2014-10-29 13:49:58 -07:00
|
|
|
* outgoing request. This is used by {@code ConnectionService}s that are registered with
|
|
|
|
* {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} and want to be able to use the
|
|
|
|
* SIM-based {@code ConnectionService} to place its outgoing calls.
|
2014-07-25 15:14:01 -07:00
|
|
|
*
|
|
|
|
* @param connectionManagerPhoneAccount See description at
|
|
|
|
* {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
|
2016-09-13 14:49:41 +02:00
|
|
|
* @param request Details about the outgoing call.
|
2014-07-25 15:14:01 -07:00
|
|
|
* @return The {@code Connection} object to satisfy this call, or {@code null} to
|
|
|
|
* not handle the call.
|
|
|
|
*/
|
|
|
|
public final RemoteConnection createRemoteOutgoingConnection(
|
|
|
|
PhoneAccountHandle connectionManagerPhoneAccount,
|
|
|
|
ConnectionRequest request) {
|
|
|
|
return mRemoteConnectionManager.createRemoteConnection(
|
|
|
|
connectionManagerPhoneAccount, request, false);
|
2014-06-17 19:08:45 -07:00
|
|
|
}
|
|
|
|
|
2014-08-23 20:34:57 -07:00
|
|
|
/**
|
2014-10-29 13:49:58 -07:00
|
|
|
* Indicates to the relevant {@code RemoteConnectionService} that the specified
|
|
|
|
* {@link RemoteConnection}s should be merged into a conference call.
|
|
|
|
* <p>
|
|
|
|
* If the conference request is successful, the method {@link #onRemoteConferenceAdded} will
|
|
|
|
* be invoked.
|
|
|
|
*
|
|
|
|
* @param remoteConnection1 The first of the remote connections to conference.
|
|
|
|
* @param remoteConnection2 The second of the remote connections to conference.
|
2014-08-23 20:34:57 -07:00
|
|
|
*/
|
|
|
|
public final void conferenceRemoteConnections(
|
2014-10-29 13:49:58 -07:00
|
|
|
RemoteConnection remoteConnection1,
|
|
|
|
RemoteConnection remoteConnection2) {
|
|
|
|
mRemoteConnectionManager.conferenceRemoteConnections(remoteConnection1, remoteConnection2);
|
2014-08-23 20:34:57 -07:00
|
|
|
}
|
|
|
|
|
2014-08-07 18:35:18 -07:00
|
|
|
/**
|
|
|
|
* Adds a new conference call. When a conference call is created either as a result of an
|
|
|
|
* explicit request via {@link #onConference} or otherwise, the connection service should supply
|
|
|
|
* an instance of {@link Conference} by invoking this method. A conference call provided by this
|
|
|
|
* method will persist until {@link Conference#destroy} is invoked on the conference instance.
|
|
|
|
*
|
|
|
|
* @param conference The new conference object.
|
|
|
|
*/
|
|
|
|
public final void addConference(Conference conference) {
|
2015-03-24 16:42:31 -07:00
|
|
|
Log.d(this, "addConference: conference=%s", conference);
|
|
|
|
|
2014-08-07 18:35:18 -07:00
|
|
|
String id = addConferenceInternal(conference);
|
|
|
|
if (id != null) {
|
|
|
|
List<String> connectionIds = new ArrayList<>(2);
|
|
|
|
for (Connection connection : conference.getConnections()) {
|
|
|
|
if (mIdByConnection.containsKey(connection)) {
|
|
|
|
connectionIds.add(mIdByConnection.get(connection));
|
|
|
|
}
|
|
|
|
}
|
2015-09-01 10:59:48 -07:00
|
|
|
conference.setTelecomCallId(id);
|
2014-08-07 18:35:18 -07:00
|
|
|
ParcelableConference parcelableConference = new ParcelableConference(
|
2014-09-05 16:38:49 -07:00
|
|
|
conference.getPhoneAccountHandle(),
|
2014-08-07 18:35:18 -07:00
|
|
|
conference.getState(),
|
2014-11-12 13:41:16 -08:00
|
|
|
conference.getConnectionCapabilities(),
|
2016-03-22 09:02:47 -07:00
|
|
|
conference.getConnectionProperties(),
|
2015-01-12 09:02:01 -08:00
|
|
|
connectionIds,
|
2015-03-24 16:42:31 -07:00
|
|
|
conference.getVideoProvider() == null ?
|
|
|
|
null : conference.getVideoProvider().getInterface(),
|
|
|
|
conference.getVideoState(),
|
2015-04-16 13:48:43 -07:00
|
|
|
conference.getConnectTimeMillis(),
|
2015-05-27 17:21:45 -07:00
|
|
|
conference.getStatusHints(),
|
|
|
|
conference.getExtras());
|
2015-04-16 13:11:55 -07:00
|
|
|
|
2014-08-07 18:35:18 -07:00
|
|
|
mAdapter.addConferenceCall(id, parcelableConference);
|
2015-03-24 16:42:31 -07:00
|
|
|
mAdapter.setVideoProvider(id, conference.getVideoProvider());
|
|
|
|
mAdapter.setVideoState(id, conference.getVideoState());
|
2014-08-07 18:35:18 -07:00
|
|
|
|
|
|
|
// Go through any child calls and set the parent.
|
|
|
|
for (Connection connection : conference.getConnections()) {
|
|
|
|
String connectionId = mIdByConnection.get(connection);
|
|
|
|
if (connectionId != null) {
|
|
|
|
mAdapter.setIsConferenced(connectionId, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-30 14:27:48 -07:00
|
|
|
/**
|
|
|
|
* Adds a connection created by the {@link ConnectionService} and informs telecom of the new
|
|
|
|
* connection.
|
|
|
|
*
|
|
|
|
* @param phoneAccountHandle The phone account handle for the connection.
|
|
|
|
* @param connection The connection to add.
|
|
|
|
*/
|
|
|
|
public final void addExistingConnection(PhoneAccountHandle phoneAccountHandle,
|
|
|
|
Connection connection) {
|
|
|
|
|
2015-09-01 10:59:48 -07:00
|
|
|
String id = addExistingConnectionInternal(phoneAccountHandle, connection);
|
2014-10-30 14:27:48 -07:00
|
|
|
if (id != null) {
|
|
|
|
List<String> emptyList = new ArrayList<>(0);
|
|
|
|
|
|
|
|
ParcelableConnection parcelableConnection = new ParcelableConnection(
|
|
|
|
phoneAccountHandle,
|
|
|
|
connection.getState(),
|
2014-11-12 13:41:16 -08:00
|
|
|
connection.getConnectionCapabilities(),
|
2016-03-22 09:02:47 -07:00
|
|
|
connection.getConnectionProperties(),
|
2016-11-30 16:06:42 -08:00
|
|
|
connection.getSupportedAudioRoutes(),
|
2014-10-30 14:27:48 -07:00
|
|
|
connection.getAddress(),
|
|
|
|
connection.getAddressPresentation(),
|
|
|
|
connection.getCallerDisplayName(),
|
|
|
|
connection.getCallerDisplayNamePresentation(),
|
|
|
|
connection.getVideoProvider() == null ?
|
|
|
|
null : connection.getVideoProvider().getInterface(),
|
|
|
|
connection.getVideoState(),
|
|
|
|
connection.isRingbackRequested(),
|
|
|
|
connection.getAudioModeIsVoip(),
|
2015-07-15 15:47:21 -07:00
|
|
|
connection.getConnectTimeMillis(),
|
2014-10-30 14:27:48 -07:00
|
|
|
connection.getStatusHints(),
|
|
|
|
connection.getDisconnectCause(),
|
2015-05-27 17:21:45 -07:00
|
|
|
emptyList,
|
|
|
|
connection.getExtras());
|
2014-10-30 14:27:48 -07:00
|
|
|
mAdapter.addExistingConnection(id, parcelableConnection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-04 20:20:58 -07:00
|
|
|
/**
|
2014-07-25 15:14:01 -07:00
|
|
|
* Returns all the active {@code Connection}s for which this {@code ConnectionService}
|
|
|
|
* has taken responsibility.
|
|
|
|
*
|
|
|
|
* @return A collection of {@code Connection}s created by this {@code ConnectionService}.
|
2014-06-04 20:20:58 -07:00
|
|
|
*/
|
2014-06-30 15:15:23 -07:00
|
|
|
public final Collection<Connection> getAllConnections() {
|
2014-06-04 20:20:58 -07:00
|
|
|
return mConnectionById.values();
|
2016-02-16 14:23:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all the active {@code Conference}s for which this {@code ConnectionService}
|
|
|
|
* has taken responsibility.
|
|
|
|
*
|
|
|
|
* @return A collection of {@code Conference}s created by this {@code ConnectionService}.
|
|
|
|
*/
|
|
|
|
public final Collection<Conference> getAllConferences() {
|
|
|
|
return mConferenceById.values();
|
2014-06-04 20:20:58 -07:00
|
|
|
}
|
|
|
|
|
2014-05-16 10:22:16 -07:00
|
|
|
/**
|
2014-07-25 15:14:01 -07:00
|
|
|
* Create a {@code Connection} given an incoming request. This is used to attach to existing
|
|
|
|
* incoming calls.
|
2014-07-20 22:06:28 -07:00
|
|
|
*
|
2014-07-25 15:14:01 -07:00
|
|
|
* @param connectionManagerPhoneAccount See description at
|
|
|
|
* {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
|
|
|
|
* @param request Details about the incoming call.
|
|
|
|
* @return The {@code Connection} object to satisfy this call, or {@code null} to
|
|
|
|
* not handle the call.
|
2014-07-14 16:29:44 -07:00
|
|
|
*/
|
2014-07-25 15:14:01 -07:00
|
|
|
public Connection onCreateIncomingConnection(
|
|
|
|
PhoneAccountHandle connectionManagerPhoneAccount,
|
|
|
|
ConnectionRequest request) {
|
|
|
|
return null;
|
|
|
|
}
|
2014-07-14 16:29:44 -07:00
|
|
|
|
2017-01-09 09:43:12 -08:00
|
|
|
/**
|
|
|
|
* Called by Telecom to inform the {@link ConnectionService} that its request to create a new
|
|
|
|
* incoming {@link Connection} was denied.
|
|
|
|
* <p>
|
|
|
|
* Used when a self-managed {@link ConnectionService} attempts to create a new incoming
|
|
|
|
* {@link Connection}, but Telecom has determined that the call cannot be allowed at this time.
|
|
|
|
* The {@link ConnectionService} is responsible for silently rejecting the new incoming
|
|
|
|
* {@link Connection}.
|
|
|
|
* <p>
|
|
|
|
* See {@link TelecomManager#isIncomingCallPermitted(PhoneAccountHandle)} for more information.
|
|
|
|
*
|
|
|
|
* @param request The incoming connection request.
|
|
|
|
*/
|
|
|
|
public void onCreateIncomingConnectionFailed(ConnectionRequest request) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by Telecom to inform the {@link ConnectionService} that its request to create a new
|
|
|
|
* outgoing {@link Connection} was denied.
|
|
|
|
* <p>
|
|
|
|
* Used when a self-managed {@link ConnectionService} attempts to create a new outgoing
|
|
|
|
* {@link Connection}, but Telecom has determined that the call cannot be placed at this time.
|
|
|
|
* The {@link ConnectionService} is responisible for informing the user that the
|
|
|
|
* {@link Connection} cannot be made at this time.
|
|
|
|
* <p>
|
|
|
|
* See {@link TelecomManager#isOutgoingCallPermitted(PhoneAccountHandle)} for more information.
|
|
|
|
*
|
|
|
|
* @param request The outgoing connection request.
|
|
|
|
*/
|
|
|
|
public void onCreateOutgoingConnectionFailed(ConnectionRequest request) {
|
|
|
|
}
|
|
|
|
|
2014-12-11 17:53:38 -08:00
|
|
|
/**
|
|
|
|
* Trigger recalculate functinality for conference calls. This is used when a Telephony
|
|
|
|
* Connection is part of a conference controller but is not yet added to Connection
|
|
|
|
* Service and hence cannot be added to the conference call.
|
|
|
|
*
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public void triggerConferenceRecalculate() {
|
|
|
|
}
|
|
|
|
|
2014-07-14 16:29:44 -07:00
|
|
|
/**
|
2014-07-25 15:14:01 -07:00
|
|
|
* Create a {@code Connection} given an outgoing request. This is used to initiate new
|
|
|
|
* outgoing calls.
|
2014-05-16 10:22:16 -07:00
|
|
|
*
|
2014-07-25 15:14:01 -07:00
|
|
|
* @param connectionManagerPhoneAccount The connection manager account to use for managing
|
|
|
|
* this call.
|
|
|
|
* <p>
|
|
|
|
* If this parameter is not {@code null}, it means that this {@code ConnectionService}
|
|
|
|
* has registered one or more {@code PhoneAccount}s having
|
|
|
|
* {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}. This parameter will contain
|
|
|
|
* one of these {@code PhoneAccount}s, while the {@code request} will contain another
|
|
|
|
* (usually but not always distinct) {@code PhoneAccount} to be used for actually
|
|
|
|
* making the connection.
|
|
|
|
* <p>
|
|
|
|
* If this parameter is {@code null}, it means that this {@code ConnectionService} is
|
|
|
|
* being asked to make a direct connection. The
|
|
|
|
* {@link ConnectionRequest#getAccountHandle()} of parameter {@code request} will be
|
|
|
|
* a {@code PhoneAccount} registered by this {@code ConnectionService} to use for
|
|
|
|
* making the connection.
|
|
|
|
* @param request Details about the outgoing call.
|
|
|
|
* @return The {@code Connection} object to satisfy this call, or the result of an invocation
|
2014-09-11 17:33:16 -07:00
|
|
|
* of {@link Connection#createFailedConnection(DisconnectCause)} to not handle the call.
|
2014-05-16 10:22:16 -07:00
|
|
|
*/
|
2014-07-25 15:14:01 -07:00
|
|
|
public Connection onCreateOutgoingConnection(
|
|
|
|
PhoneAccountHandle connectionManagerPhoneAccount,
|
|
|
|
ConnectionRequest request) {
|
|
|
|
return null;
|
|
|
|
}
|
2014-05-16 10:22:16 -07:00
|
|
|
|
2014-10-02 09:38:39 -07:00
|
|
|
/**
|
|
|
|
* Create a {@code Connection} for a new unknown call. An unknown call is a call originating
|
|
|
|
* from the ConnectionService that was neither a user-initiated outgoing call, nor an incoming
|
|
|
|
* call created using
|
|
|
|
* {@code TelecomManager#addNewIncomingCall(PhoneAccountHandle, android.os.Bundle)}.
|
|
|
|
*
|
2014-10-06 18:58:52 -07:00
|
|
|
* @hide
|
2014-10-02 09:38:39 -07:00
|
|
|
*/
|
|
|
|
public Connection onCreateUnknownConnection(PhoneAccountHandle connectionManagerPhoneAccount,
|
|
|
|
ConnectionRequest request) {
|
2016-10-24 16:40:49 -07:00
|
|
|
return null;
|
2014-10-02 09:38:39 -07:00
|
|
|
}
|
|
|
|
|
2014-06-04 20:20:58 -07:00
|
|
|
/**
|
2014-08-07 18:35:18 -07:00
|
|
|
* Conference two specified connections. Invoked when the user has made a request to merge the
|
|
|
|
* specified connections into a conference call. In response, the connection service should
|
|
|
|
* create an instance of {@link Conference} and pass it into {@link #addConference}.
|
2014-06-04 20:20:58 -07:00
|
|
|
*
|
2014-08-07 18:35:18 -07:00
|
|
|
* @param connection1 A connection to merge into a conference call.
|
|
|
|
* @param connection2 A connection to merge into a conference call.
|
2014-06-04 20:20:58 -07:00
|
|
|
*/
|
2014-08-07 18:35:18 -07:00
|
|
|
public void onConference(Connection connection1, Connection connection2) {}
|
2014-06-04 20:20:58 -07:00
|
|
|
|
2014-10-29 13:49:58 -07:00
|
|
|
/**
|
|
|
|
* Indicates that a remote conference has been created for existing {@link RemoteConnection}s.
|
|
|
|
* When this method is invoked, this {@link ConnectionService} should create its own
|
|
|
|
* representation of the conference call and send it to telecom using {@link #addConference}.
|
|
|
|
* <p>
|
|
|
|
* This is only relevant to {@link ConnectionService}s which are registered with
|
|
|
|
* {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}.
|
|
|
|
*
|
|
|
|
* @param conference The remote conference call.
|
|
|
|
*/
|
2014-08-23 20:34:57 -07:00
|
|
|
public void onRemoteConferenceAdded(RemoteConference conference) {}
|
|
|
|
|
2014-10-30 14:27:48 -07:00
|
|
|
/**
|
|
|
|
* Called when an existing connection is added remotely.
|
|
|
|
* @param connection The existing connection which was added.
|
|
|
|
*/
|
|
|
|
public void onRemoteExistingConnectionAdded(RemoteConnection connection) {}
|
|
|
|
|
2014-08-07 18:35:18 -07:00
|
|
|
/**
|
|
|
|
* @hide
|
|
|
|
*/
|
|
|
|
public boolean containsConference(Conference conference) {
|
|
|
|
return mIdByConference.containsKey(conference);
|
|
|
|
}
|
|
|
|
|
2014-08-23 20:34:57 -07:00
|
|
|
/** {@hide} */
|
|
|
|
void addRemoteConference(RemoteConference remoteConference) {
|
|
|
|
onRemoteConferenceAdded(remoteConference);
|
|
|
|
}
|
|
|
|
|
2014-10-30 14:27:48 -07:00
|
|
|
/** {@hide} */
|
|
|
|
void addRemoteExistingConnection(RemoteConnection remoteConnection) {
|
|
|
|
onRemoteExistingConnectionAdded(remoteConnection);
|
|
|
|
}
|
|
|
|
|
2014-07-30 10:07:40 -07:00
|
|
|
private void onAccountsInitialized() {
|
|
|
|
mAreAccountsInitialized = true;
|
|
|
|
for (Runnable r : mPreInitializationConnectionRequests) {
|
|
|
|
r.run();
|
|
|
|
}
|
|
|
|
mPreInitializationConnectionRequests.clear();
|
|
|
|
}
|
|
|
|
|
2014-10-30 14:27:48 -07:00
|
|
|
/**
|
2015-09-01 10:59:48 -07:00
|
|
|
* Adds an existing connection to the list of connections, identified by a new call ID unique
|
|
|
|
* to this connection service.
|
2014-10-30 14:27:48 -07:00
|
|
|
*
|
|
|
|
* @param connection The connection.
|
2015-09-01 10:59:48 -07:00
|
|
|
* @return The ID of the connection (e.g. the call-id).
|
2014-10-30 14:27:48 -07:00
|
|
|
*/
|
2015-09-01 10:59:48 -07:00
|
|
|
private String addExistingConnectionInternal(PhoneAccountHandle handle, Connection connection) {
|
|
|
|
String id;
|
|
|
|
if (handle == null) {
|
|
|
|
// If no phone account handle was provided, we cannot be sure the call ID is unique,
|
|
|
|
// so just use a random UUID.
|
|
|
|
id = UUID.randomUUID().toString();
|
|
|
|
} else {
|
|
|
|
// Phone account handle was provided, so use the ConnectionService class name as a
|
|
|
|
// prefix for a unique incremental call ID.
|
|
|
|
id = handle.getComponentName().getClassName() + "@" + getNextCallId();
|
|
|
|
}
|
2014-10-30 14:27:48 -07:00
|
|
|
addConnection(id, connection);
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2014-05-16 10:22:16 -07:00
|
|
|
private void addConnection(String callId, Connection connection) {
|
2015-09-01 10:59:48 -07:00
|
|
|
connection.setTelecomCallId(callId);
|
2014-05-16 10:22:16 -07:00
|
|
|
mConnectionById.put(callId, connection);
|
|
|
|
mIdByConnection.put(connection, callId);
|
|
|
|
connection.addConnectionListener(mConnectionListener);
|
2014-08-07 18:35:18 -07:00
|
|
|
connection.setConnectionService(this);
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2014-11-06 16:30:53 -08:00
|
|
|
/** {@hide} */
|
|
|
|
protected void removeConnection(Connection connection) {
|
2014-08-07 18:35:18 -07:00
|
|
|
connection.unsetConnectionService(this);
|
2014-05-16 10:22:16 -07:00
|
|
|
connection.removeConnectionListener(mConnectionListener);
|
2016-05-12 16:59:43 -07:00
|
|
|
String id = mIdByConnection.get(connection);
|
|
|
|
if (id != null) {
|
|
|
|
mConnectionById.remove(id);
|
|
|
|
mIdByConnection.remove(connection);
|
|
|
|
mAdapter.removeCall(id);
|
|
|
|
}
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
|
|
|
|
2014-08-07 18:35:18 -07:00
|
|
|
private String addConferenceInternal(Conference conference) {
|
|
|
|
if (mIdByConference.containsKey(conference)) {
|
|
|
|
Log.w(this, "Re-adding an existing conference: %s.", conference);
|
|
|
|
} else if (conference != null) {
|
2015-09-01 10:59:48 -07:00
|
|
|
// Conferences do not (yet) have a PhoneAccountHandle associated with them, so we
|
|
|
|
// cannot determine a ConnectionService class name to associate with the ID, so use
|
|
|
|
// a unique UUID (for now).
|
2014-08-07 18:35:18 -07:00
|
|
|
String id = UUID.randomUUID().toString();
|
|
|
|
mConferenceById.put(id, conference);
|
|
|
|
mIdByConference.put(conference, id);
|
|
|
|
conference.addListener(mConferenceListener);
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void removeConference(Conference conference) {
|
|
|
|
if (mIdByConference.containsKey(conference)) {
|
|
|
|
conference.removeListener(mConferenceListener);
|
|
|
|
|
|
|
|
String id = mIdByConference.get(conference);
|
|
|
|
mConferenceById.remove(id);
|
|
|
|
mIdByConference.remove(conference);
|
|
|
|
mAdapter.removeCall(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-16 10:22:16 -07:00
|
|
|
private Connection findConnectionForAction(String callId, String action) {
|
|
|
|
if (mConnectionById.containsKey(callId)) {
|
|
|
|
return mConnectionById.get(callId);
|
|
|
|
}
|
2014-05-20 22:32:12 -07:00
|
|
|
Log.w(this, "%s - Cannot find Connection %s", action, callId);
|
2014-08-20 10:07:19 -07:00
|
|
|
return getNullConnection();
|
|
|
|
}
|
|
|
|
|
|
|
|
static synchronized Connection getNullConnection() {
|
|
|
|
if (sNullConnection == null) {
|
|
|
|
sNullConnection = new Connection() {};
|
|
|
|
}
|
|
|
|
return sNullConnection;
|
2014-05-16 10:22:16 -07:00
|
|
|
}
|
2014-08-21 14:28:11 -07:00
|
|
|
|
|
|
|
private Conference findConferenceForAction(String conferenceId, String action) {
|
|
|
|
if (mConferenceById.containsKey(conferenceId)) {
|
|
|
|
return mConferenceById.get(conferenceId);
|
|
|
|
}
|
|
|
|
Log.w(this, "%s - Cannot find conference %s", action, conferenceId);
|
|
|
|
return getNullConference();
|
|
|
|
}
|
|
|
|
|
2014-08-23 20:34:57 -07:00
|
|
|
private List<String> createConnectionIdList(List<Connection> connections) {
|
|
|
|
List<String> ids = new ArrayList<>();
|
|
|
|
for (Connection c : connections) {
|
|
|
|
if (mIdByConnection.containsKey(c)) {
|
|
|
|
ids.add(mIdByConnection.get(c));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Collections.sort(ids);
|
|
|
|
return ids;
|
|
|
|
}
|
|
|
|
|
2014-11-17 15:49:51 -08:00
|
|
|
/**
|
|
|
|
* Builds a list of {@link Connection} and {@link Conference} IDs based on the list of
|
2015-04-20 09:13:01 -07:00
|
|
|
* {@link Conferenceable}s passed in.
|
2014-11-17 15:49:51 -08:00
|
|
|
*
|
2015-04-20 09:13:01 -07:00
|
|
|
* @param conferenceables The {@link Conferenceable} connections and conferences.
|
2014-11-17 15:49:51 -08:00
|
|
|
* @return List of string conference and call Ids.
|
|
|
|
*/
|
2015-04-20 09:13:01 -07:00
|
|
|
private List<String> createIdList(List<Conferenceable> conferenceables) {
|
2014-11-17 15:49:51 -08:00
|
|
|
List<String> ids = new ArrayList<>();
|
2015-04-20 09:13:01 -07:00
|
|
|
for (Conferenceable c : conferenceables) {
|
2014-11-17 15:49:51 -08:00
|
|
|
// Only allow Connection and Conference conferenceables.
|
|
|
|
if (c instanceof Connection) {
|
|
|
|
Connection connection = (Connection) c;
|
|
|
|
if (mIdByConnection.containsKey(connection)) {
|
|
|
|
ids.add(mIdByConnection.get(connection));
|
|
|
|
}
|
|
|
|
} else if (c instanceof Conference) {
|
|
|
|
Conference conference = (Conference) c;
|
|
|
|
if (mIdByConference.containsKey(conference)) {
|
|
|
|
ids.add(mIdByConference.get(conference));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Collections.sort(ids);
|
|
|
|
return ids;
|
|
|
|
}
|
|
|
|
|
2014-08-21 14:28:11 -07:00
|
|
|
private Conference getNullConference() {
|
|
|
|
if (sNullConference == null) {
|
|
|
|
sNullConference = new Conference(null) {};
|
|
|
|
}
|
|
|
|
return sNullConference;
|
|
|
|
}
|
2014-09-11 19:50:24 -07:00
|
|
|
|
|
|
|
private void endAllConnections() {
|
|
|
|
// Unbound from telecomm. We should end all connections and conferences.
|
|
|
|
for (Connection connection : mIdByConnection.keySet()) {
|
|
|
|
// only operate on top-level calls. Conference calls will be removed on their own.
|
|
|
|
if (connection.getConference() == null) {
|
|
|
|
connection.onDisconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Conference conference : mIdByConference.keySet()) {
|
|
|
|
conference.onDisconnect();
|
|
|
|
}
|
|
|
|
}
|
2015-09-01 10:59:48 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the next call ID as maintainted by the connection service.
|
|
|
|
*
|
|
|
|
* @return The call ID.
|
|
|
|
*/
|
|
|
|
private int getNextCallId() {
|
2016-10-24 16:40:49 -07:00
|
|
|
synchronized (mIdSyncRoot) {
|
2015-09-01 10:59:48 -07:00
|
|
|
return ++mId;
|
|
|
|
}
|
|
|
|
}
|
2014-05-31 10:31:19 -07:00
|
|
|
}
|