Example usage for android.telecom DisconnectCause DisconnectCause

List of usage examples for android.telecom DisconnectCause DisconnectCause

Introduction

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

Prototype

public DisconnectCause(int code, String reason) 

Source Link

Document

Creates a new DisconnectCause.

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;/*  ww w.  j a  va2  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;/*from   w  w w  . jav a2  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));
    }
}