Example usage for android.telecom TelecomManager GATEWAY_ORIGINAL_ADDRESS

List of usage examples for android.telecom TelecomManager GATEWAY_ORIGINAL_ADDRESS

Introduction

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

Prototype

String GATEWAY_ORIGINAL_ADDRESS

To view the source code for android.telecom TelecomManager GATEWAY_ORIGINAL_ADDRESS.

Click Source Link

Document

An optional android.content.Intent#ACTION_CALL intent extra corresponding to the original address to dial for the call.

Usage

From source file:com.android.server.telecom.testapps.TestConnectionService.java

@Override
public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerAccount,
        final ConnectionRequest originalRequest) {

    final Uri handle = originalRequest.getAddress();
    String number = originalRequest.getAddress().getSchemeSpecificPart();
    log("call, number: " + number);

    // Crash on 555-DEAD to test call service crashing.
    if ("5550340".equals(number)) {
        throw new RuntimeException("Goodbye, cruel world.");
    }//from  w  w  w.  j a v  a 2  s  .  c  o  m

    Bundle extras = originalRequest.getExtras();
    String gatewayPackage = extras.getString(TelecomManager.GATEWAY_PROVIDER_PACKAGE);
    Uri originalHandle = extras.getParcelable(TelecomManager.GATEWAY_ORIGINAL_ADDRESS);

    log("gateway package [" + gatewayPackage + "], original handle [" + originalHandle + "]");

    final TestConnection connection = new TestConnection(false /* isIncoming */);
    setAddress(connection, handle);

    // If the number starts with 555, then we handle it ourselves. If not, then we
    // use a remote connection service.
    // TODO: Have a special phone number to test the account-picker dialog flow.
    if (number != null && number.startsWith("555")) {
        // Normally we would use the original request as is, but for testing purposes, we are
        // adding ".." to the end of the number to follow its path more easily through the logs.
        final ConnectionRequest request = new ConnectionRequest(originalRequest.getAccountHandle(),
                Uri.fromParts(handle.getScheme(), handle.getSchemeSpecificPart() + "..", ""),
                originalRequest.getExtras(), originalRequest.getVideoState());
        connection.setVideoState(originalRequest.getVideoState());
        /// M: only VideoCall addVideoProvider @{
        if (originalRequest.getVideoState() == VideoProfile.STATE_BIDIRECTIONAL) {
            addVideoProvider(connection);
        }
        /// @}

        addCall(connection);
        connection.startOutgoing();

        for (Connection c : getAllConnections()) {
            c.setOnHold();
        }
    } else {
        log("Not a test number");
    }
    return connection;
}