Example usage for android.telecom DisconnectCause ERROR

List of usage examples for android.telecom DisconnectCause ERROR

Introduction

In this page you can find the example usage for android.telecom DisconnectCause ERROR.

Prototype

int ERROR

To view the source code for android.telecom DisconnectCause ERROR.

Click Source Link

Document

Disconnected because there was an error, such as a problem with the network.

Usage

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  .co  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;/*from  www .  j av  a2  s.  co  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));
    }
}