Skip to content

Commit

Permalink
Add onConnectionEvent() to ShadowInCallService.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 410879168
  • Loading branch information
Googler authored and hoisie committed Nov 20, 2021
1 parent 0cb21aa commit 16b60e4
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -9,6 +9,7 @@
import android.annotation.TargetApi;
import android.bluetooth.BluetoothDevice;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.telecom.Call;
import android.telecom.CallAudioState;
Expand Down Expand Up @@ -36,6 +37,7 @@ public class ShadowInCallService extends ShadowService {
private static final int MSG_UPDATE_CALL = 3;
private static final int MSG_SET_POST_DIAL_WAIT = 4;
private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 5;
private static final int MSG_ON_CONNECTION_EVENT = 9;

private ShadowPhone shadowPhone;
private boolean canAddCall;
Expand Down Expand Up @@ -83,7 +85,7 @@ public void addCall(ParcelableCall parcelableCall) {

/**
* Exposes {@link IIInCallService.Stub#setPostDialWait}. This is normally invoked by Telecom but
* in Robolectric Telecom doesn't exist, so tests can invoke this to simulate Telecom's actions.
* in Robolectric, Telecom doesn't exist, so tests can invoke this to simulate Telecom's actions.
*/
public void setPostDialWait(String callId, String remaining) {
SomeArgs args = SomeArgs.obtain();
Expand All @@ -92,6 +94,18 @@ public void setPostDialWait(String callId, String remaining) {
getHandler().obtainMessage(MSG_SET_POST_DIAL_WAIT, args).sendToTarget();
}

/**
* Exposes {@link IIInCallService.Stub#onConnectionEvent}. This is normally invoked by Telecom but
* in Robolectric, Telecom doesn't exist, so tests can invoke this to simulate Telecom's actions.
*/
public void onConnectionEvent(String callId, String event, Bundle extras) {
SomeArgs args = SomeArgs.obtain();
args.arg1 = callId;
args.arg2 = event;
args.arg3 = extras;
getHandler().obtainMessage(MSG_ON_CONNECTION_EVENT, args).sendToTarget();
}

public void removeCall(Call call) {
shadowPhone.removeCall(call);
}
Expand Down

0 comments on commit 16b60e4

Please sign in to comment.