Throw new IllegalStateException in CallRedirectionService when the call redirection is not initialized yet

Test: Build
Bug: 193482535
Change-Id: I3609362043684249b6d6981fc7d2ab42c676db76
This commit is contained in:
Shuo Qian 2021-07-15 10:31:11 -07:00
parent 4b939ccd2f
commit f5f508c01d

View File

@ -100,6 +100,9 @@ public abstract class CallRedirectionService extends Service {
*/
public final void placeCallUnmodified() {
try {
if (mCallRedirectionAdapter == null) {
throw new IllegalStateException("Can only be called from onPlaceCall.");
}
mCallRedirectionAdapter.placeCallUnmodified();
} catch (RemoteException e) {
e.rethrowAsRuntimeException();
@ -128,6 +131,9 @@ public abstract class CallRedirectionService extends Service {
@NonNull PhoneAccountHandle targetPhoneAccount,
boolean confirmFirst) {
try {
if (mCallRedirectionAdapter == null) {
throw new IllegalStateException("Can only be called from onPlaceCall.");
}
mCallRedirectionAdapter.redirectCall(gatewayUri, targetPhoneAccount, confirmFirst);
} catch (RemoteException e) {
e.rethrowAsRuntimeException();
@ -146,6 +152,9 @@ public abstract class CallRedirectionService extends Service {
*/
public final void cancelCall() {
try {
if (mCallRedirectionAdapter == null) {
throw new IllegalStateException("Can only be called from onPlaceCall.");
}
mCallRedirectionAdapter.cancelCall();
} catch (RemoteException e) {
e.rethrowAsRuntimeException();