List of usage examples for android.telecom Connection createFailedConnection
public static Connection createFailedConnection(DisconnectCause disconnectCause)
From source file:com.android.server.telecom.testapps.TestConnectionService.java
@Override public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerAccount, final ConnectionRequest request) { PhoneAccountHandle accountHandle = request.getAccountHandle(); ComponentName componentName = new ComponentName(this, TestConnectionService.class); if (accountHandle != null && componentName.equals(accountHandle.getComponentName())) { final TestConnection connection = new TestConnection(true); // Get the stashed intent extra that determines if this is a video call or audio call. Bundle extras = request.getExtras(); boolean isVideoCall = extras.getBoolean(EXTRA_IS_VIDEO_CALL); Uri providedHandle = extras.getParcelable(EXTRA_HANDLE); // Use dummy number for testing incoming calls. Uri address = providedHandle == null ? Uri.fromParts(PhoneAccount.SCHEME_TEL, getDummyNumber(isVideoCall), null) : providedHandle;/*w w w.j a v a 2 s. c o m*/ int videoState = isVideoCall ? VideoProfile.STATE_BIDIRECTIONAL : VideoProfile.STATE_AUDIO_ONLY; connection.setVideoState(videoState); setAddress(connection, address); addVideoProvider(connection); addCall(connection); ConnectionRequest newRequest = new ConnectionRequest(request.getAccountHandle(), address, request.getExtras(), videoState); connection.setVideoState(videoState); return connection; } else { return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "Invalid inputs: " + accountHandle + " " + componentName)); } }
From source file:com.android.server.telecom.testapps.TestConnectionService.java
@Override public Connection onCreateUnknownConnection(PhoneAccountHandle connectionManagerPhoneAccount, final ConnectionRequest request) { PhoneAccountHandle accountHandle = request.getAccountHandle(); ComponentName componentName = new ComponentName(this, TestConnectionService.class); if (accountHandle != null && componentName.equals(accountHandle.getComponentName())) { final TestConnection connection = new TestConnection(false); final Bundle extras = request.getExtras(); final Uri providedHandle = extras.getParcelable(EXTRA_HANDLE); Uri handle = providedHandle == null ? Uri.fromParts(PhoneAccount.SCHEME_TEL, getDummyNumber(false), null) : providedHandle;// w ww . j a va 2 s .c o m connection.setAddress(handle, TelecomManager.PRESENTATION_ALLOWED); connection.setDialing(); addCall(connection); return connection; } else { return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "Invalid inputs: " + accountHandle + " " + componentName)); } }