Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onConnectionEvent() to ShadowInCallService. #6870

Merged
merged 1 commit into from Nov 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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