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 isOutgoingCallPermitted to ShadowTelecomManager. #9068

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading