Merge "Add connection serivce focus api interface"

This commit is contained in:
Treehugger Robot
2018-01-09 22:54:42 +00:00
committed by Gerrit Code Review
7 changed files with 88 additions and 0 deletions

View File

@@ -39428,12 +39428,15 @@ package android.telecom {
method public final void addConference(android.telecom.Conference); method public final void addConference(android.telecom.Conference);
method public final void addExistingConnection(android.telecom.PhoneAccountHandle, android.telecom.Connection); method public final void addExistingConnection(android.telecom.PhoneAccountHandle, android.telecom.Connection);
method public final void conferenceRemoteConnections(android.telecom.RemoteConnection, android.telecom.RemoteConnection); method public final void conferenceRemoteConnections(android.telecom.RemoteConnection, android.telecom.RemoteConnection);
method public final void connectionServiceFocusReleased();
method public final android.telecom.RemoteConnection createRemoteIncomingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest); method public final android.telecom.RemoteConnection createRemoteIncomingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest);
method public final android.telecom.RemoteConnection createRemoteOutgoingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest); method public final android.telecom.RemoteConnection createRemoteOutgoingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest);
method public final java.util.Collection<android.telecom.Conference> getAllConferences(); method public final java.util.Collection<android.telecom.Conference> getAllConferences();
method public final java.util.Collection<android.telecom.Connection> getAllConnections(); method public final java.util.Collection<android.telecom.Connection> getAllConnections();
method public final android.os.IBinder onBind(android.content.Intent); method public final android.os.IBinder onBind(android.content.Intent);
method public void onConference(android.telecom.Connection, android.telecom.Connection); method public void onConference(android.telecom.Connection, android.telecom.Connection);
method public void onConnectionServiceFocusGained();
method public void onConnectionServiceFocusLost();
method public android.telecom.Connection onCreateIncomingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest); method public android.telecom.Connection onCreateIncomingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest);
method public void onCreateIncomingConnectionFailed(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest); method public void onCreateIncomingConnectionFailed(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest);
method public android.telecom.Connection onCreateIncomingHandoverConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest); method public android.telecom.Connection onCreateIncomingHandoverConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest);

View File

@@ -145,6 +145,8 @@ public abstract class ConnectionService extends Service {
private static final String SESSION_STOP_RTT = "CS.-RTT"; private static final String SESSION_STOP_RTT = "CS.-RTT";
private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR"; private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR";
private static final String SESSION_HANDOVER_FAILED = "CS.haF"; private static final String SESSION_HANDOVER_FAILED = "CS.haF";
private static final String SESSION_CONNECTION_SERVICE_FOCUS_LOST = "CS.cSFL";
private static final String SESSION_CONNECTION_SERVICE_FOCUS_GAINED = "CS.cSFG";
private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1; private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1;
private static final int MSG_CREATE_CONNECTION = 2; private static final int MSG_CREATE_CONNECTION = 2;
@@ -174,6 +176,8 @@ public abstract class ConnectionService extends Service {
private static final int MSG_ON_STOP_RTT = 27; private static final int MSG_ON_STOP_RTT = 27;
private static final int MSG_RTT_UPGRADE_RESPONSE = 28; private static final int MSG_RTT_UPGRADE_RESPONSE = 28;
private static final int MSG_CREATE_CONNECTION_COMPLETE = 29; private static final int MSG_CREATE_CONNECTION_COMPLETE = 29;
private static final int MSG_CONNECTION_SERVICE_FOCUS_LOST = 30;
private static final int MSG_CONNECTION_SERVICE_FOCUS_GAINED = 31;
private static final int MSG_HANDOVER_FAILED = 32; private static final int MSG_HANDOVER_FAILED = 32;
private static Connection sNullConnection; private static Connection sNullConnection;
@@ -610,6 +614,26 @@ public abstract class ConnectionService extends Service {
Log.endSession(); Log.endSession();
} }
} }
@Override
public void connectionServiceFocusLost(Session.Info sessionInfo) throws RemoteException {
Log.startSession(sessionInfo, SESSION_CONNECTION_SERVICE_FOCUS_LOST);
try {
mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_LOST).sendToTarget();
} finally {
Log.endSession();
}
}
@Override
public void connectionServiceFocusGained(Session.Info sessionInfo) throws RemoteException {
Log.startSession(sessionInfo, SESSION_CONNECTION_SERVICE_FOCUS_GAINED);
try {
mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_GAINED).sendToTarget();
} finally {
Log.endSession();
}
}
}; };
private final Handler mHandler = new Handler(Looper.getMainLooper()) { private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@@ -1061,6 +1085,12 @@ public abstract class ConnectionService extends Service {
} }
break; break;
} }
case MSG_CONNECTION_SERVICE_FOCUS_GAINED:
onConnectionServiceFocusGained();
break;
case MSG_CONNECTION_SERVICE_FOCUS_LOST:
onConnectionServiceFocusLost();
break;
default: default:
break; break;
} }
@@ -1929,6 +1959,16 @@ public abstract class ConnectionService extends Service {
addExistingConnection(phoneAccountHandle, connection, null /* conference */); addExistingConnection(phoneAccountHandle, connection, null /* conference */);
} }
/**
* Call to inform Telecom that your {@link ConnectionService} has released call resources (e.g
* microphone, camera).
*
* @see ConnectionService#onConnectionServiceFocusLost()
*/
public final void connectionServiceFocusReleased() {
mAdapter.onConnectionServiceFocusReleased();
}
/** /**
* Adds a connection created by the {@link ConnectionService} and informs telecom of the new * Adds a connection created by the {@link ConnectionService} and informs telecom of the new
* connection. * connection.
@@ -2178,6 +2218,20 @@ public abstract class ConnectionService extends Service {
*/ */
public void onRemoteExistingConnectionAdded(RemoteConnection connection) {} public void onRemoteExistingConnectionAdded(RemoteConnection connection) {}
/**
* Called when the {@link ConnectionService} has lost the call focus.
* The {@link ConnectionService} should release the call resources and invokes
* {@link ConnectionService#connectionServiceFocusReleased()} to inform telecom that it has
* released the call resources.
*/
public void onConnectionServiceFocusLost() {}
/**
* Called when the {@link ConnectionService} has gained the call focus. The
* {@link ConnectionService} can acquire the call resources at this time.
*/
public void onConnectionServiceFocusGained() {}
/** /**
* @hide * @hide
*/ */

View File

@@ -628,4 +628,17 @@ final class ConnectionServiceAdapter implements DeathRecipient {
} }
} }
} }
/**
* Notifies Telecom that the {@link ConnectionService} has released the call resource.
*/
void onConnectionServiceFocusReleased() {
for (IConnectionServiceAdapter adapter : mAdapters) {
try {
Log.d(this, "onConnectionServiceFocusReleased");
adapter.onConnectionServiceFocusReleased(Log.getExternalSession());
} catch (RemoteException ignored) {
}
}
}
} }

View File

@@ -73,6 +73,7 @@ final class ConnectionServiceAdapterServant {
private static final int MSG_ON_RTT_REMOTELY_TERMINATED = 32; private static final int MSG_ON_RTT_REMOTELY_TERMINATED = 32;
private static final int MSG_ON_RTT_UPGRADE_REQUEST = 33; private static final int MSG_ON_RTT_UPGRADE_REQUEST = 33;
private static final int MSG_SET_PHONE_ACCOUNT_CHANGED = 34; private static final int MSG_SET_PHONE_ACCOUNT_CHANGED = 34;
private static final int MSG_CONNECTION_SERVICE_FOCUS_RELEASED = 35;
private final IConnectionServiceAdapter mDelegate; private final IConnectionServiceAdapter mDelegate;
@@ -329,6 +330,9 @@ final class ConnectionServiceAdapterServant {
} }
break; break;
} }
case MSG_CONNECTION_SERVICE_FOCUS_RELEASED:
mDelegate.onConnectionServiceFocusReleased(null /*Session.Info*/);
break;
} }
} }
}; };
@@ -601,6 +605,11 @@ final class ConnectionServiceAdapterServant {
args.arg2 = pHandle; args.arg2 = pHandle;
mHandler.obtainMessage(MSG_SET_PHONE_ACCOUNT_CHANGED, args).sendToTarget(); mHandler.obtainMessage(MSG_SET_PHONE_ACCOUNT_CHANGED, args).sendToTarget();
} }
@Override
public void onConnectionServiceFocusReleased(Session.Info sessionInfo) {
mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_RELEASED).sendToTarget();
}
}; };
public ConnectionServiceAdapterServant(IConnectionServiceAdapter delegate) { public ConnectionServiceAdapterServant(IConnectionServiceAdapter delegate) {

View File

@@ -212,6 +212,9 @@ final class RemoteConnectionService {
Session.Info sessionInfo) { Session.Info sessionInfo) {
} }
@Override
public void onConnectionServiceFocusReleased(Session.Info sessionInfo) {}
@Override @Override
public void addConferenceCall( public void addConferenceCall(
final String callId, ParcelableConference parcel, Session.Info sessionInfo) { final String callId, ParcelableConference parcel, Session.Info sessionInfo) {

View File

@@ -103,4 +103,8 @@ oneway interface IConnectionService {
void handoverFailed(String callId, in ConnectionRequest request, void handoverFailed(String callId, in ConnectionRequest request,
int error, in Session.Info sessionInfo); int error, in Session.Info sessionInfo);
void connectionServiceFocusLost(in Session.Info sessionInfo);
void connectionServiceFocusGained(in Session.Info sessionInfo);
} }

View File

@@ -119,4 +119,6 @@ oneway interface IConnectionServiceAdapter {
void onPhoneAccountChanged(String callId, in PhoneAccountHandle pHandle, void onPhoneAccountChanged(String callId, in PhoneAccountHandle pHandle,
in Session.Info sessionInfo); in Session.Info sessionInfo);
void onConnectionServiceFocusReleased(in Session.Info sessionInfo);
} }