Skip to content

Commit

Permalink
Add setPostDialWait() to ShadowInCallService. This method exists in t…
Browse files Browse the repository at this point in the history
…he private inner class `InCallServiceBinder`, but cannot be easily called since services don't actually bind in Robolectric.

Therefore, we are just exposing the method to be publicly accessible via `ShadowInCallService`.

PiperOrigin-RevId: 410618690
  • Loading branch information
Googler authored and hoisie committed Nov 18, 2021
1 parent aeb2ca7 commit 0cb21aa
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -16,6 +16,7 @@
import android.telecom.InCallService;
import android.telecom.ParcelableCall;
import android.telecom.Phone;
import com.android.internal.os.SomeArgs;
import com.android.internal.telecom.IInCallAdapter;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
Expand All @@ -33,6 +34,7 @@ public class ShadowInCallService extends ShadowService {
private static final int MSG_SET_IN_CALL_ADAPTER = 1;
private static final int MSG_ADD_CALL = 2;
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 ShadowPhone shadowPhone;
Expand Down Expand Up @@ -79,6 +81,17 @@ public void addCall(ParcelableCall parcelableCall) {
getHandler().obtainMessage(MSG_ADD_CALL, parcelableCall).sendToTarget();
}

/**
* 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.
*/
public void setPostDialWait(String callId, String remaining) {
SomeArgs args = SomeArgs.obtain();
args.arg1 = callId;
args.arg2 = remaining;
getHandler().obtainMessage(MSG_SET_POST_DIAL_WAIT, args).sendToTarget();
}

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

0 comments on commit 0cb21aa

Please sign in to comment.