Skip to content

Commit

Permalink
Add isOutgoingCallPermitted to ShadowTelecomManager.
Browse files Browse the repository at this point in the history
TelecomManager#isOutgoingCallPermitted will return what was set with ShadowTelecomManager#setIsOutgoingCallPermitted.

PiperOrigin-RevId: 631976176
  • Loading branch information
Googler authored and Copybara-Service committed May 9, 2024
1 parent d383d4b commit 281bd52
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Expand Up @@ -710,6 +710,22 @@ public void handleMmiWithHandle() {
assertThat(telecomService.handleMmi("123", phoneAccountHandle)).isTrue();
}

@Test
@Config(minSdk = O)
public void isOutgoingCallPermitted_false() {
shadowOf(telecomService).setIsOutgoingCallPermitted(false);

assertThat(telecomService.isOutgoingCallPermitted(/* phoneAccountHandle= */ null)).isFalse();
}

@Test
@Config(minSdk = O)
public void isOutgoingCallPermitted_true() {
shadowOf(telecomService).setIsOutgoingCallPermitted(true);

assertThat(telecomService.isOutgoingCallPermitted(/* phoneAccountHandle= */ null)).isTrue();
}

private static PhoneAccountHandle createHandle(String id) {
return new PhoneAccountHandle(
new ComponentName(ApplicationProvider.getApplicationContext(), TestConnectionService.class),
Expand Down
Expand Up @@ -97,6 +97,7 @@ public enum CallRequestMode {
private boolean callPhonePermission = true;
private boolean handleMmiValue = false;
private ConnectionService connectionService;
private boolean isOutgoingCallPermitted = false;

public CallRequestMode getCallRequestMode() {
return callRequestMode;
Expand All @@ -119,6 +120,11 @@ public void removeDefaultOutgoingPhoneAccount(String uriScheme) {
defaultOutgoingPhoneAccounts.remove(uriScheme);
}

/** Sets the result of {@link TelecomManager#isOutgoingCallPermitted(PhoneAccountHandle)}. */
public void setIsOutgoingCallPermitted(boolean isOutgoingCallPermitted) {
this.isOutgoingCallPermitted = isOutgoingCallPermitted;
}

/**
* Returns default outgoing phone account set through {@link
* #setDefaultOutgoingPhoneAccount(String, PhoneAccountHandle)} for corresponding {@code
Expand Down Expand Up @@ -730,6 +736,11 @@ protected Intent createLaunchEmergencyDialerIntent(String number) {
return intent;
}

@Implementation(minSdk = O)
protected boolean isOutgoingCallPermitted(PhoneAccountHandle phoneAccountHandle) {
return this.isOutgoingCallPermitted;
}

/**
* Details about a call request made via {@link TelecomManager#addNewIncomingCall} or {@link
* TelecomManager#addNewUnknownCall}.
Expand Down

0 comments on commit 281bd52

Please sign in to comment.