1542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad/* 2542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * Copyright (C) 2014 The Android Open Source Project 3542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * 4542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * Licensed under the Apache License, Version 2.0 (the "License"); 5542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * you may not use this file except in compliance with the License. 6542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * You may obtain a copy of the License at 7542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * 8542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * http://www.apache.org/licenses/LICENSE-2.0 9542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * 10542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * Unless required by applicable law or agreed to in writing, software 11542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * distributed under the License is distributed on an "AS IS" BASIS, 12542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * See the License for the specific language governing permissions and 14542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * limitations under the License. 15542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad */ 16542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad 17ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunnpackage android.telecom; 18542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad 190e094d926c306c3667bcdf6f23c52cc7181f25f3Evan Charltonimport android.annotation.SystemApi; 20542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awadimport android.net.Uri; 21612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepalimport android.os.Bundle; 22fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awadimport android.os.Parcel; 23fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awadimport android.os.Parcelable; 24542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad 25542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad/** 26542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * Simple data container encapsulating a request to some entity to 27542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * create a new {@link Connection}. 280e094d926c306c3667bcdf6f23c52cc7181f25f3Evan Charlton * @hide 29542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad */ 300e094d926c306c3667bcdf6f23c52cc7181f25f3Evan Charlton@SystemApi 31fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awadpublic final class ConnectionRequest implements Parcelable { 32542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad 33542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad // TODO: Token to limit recursive invocations 348c8a062f521d39ceecc99e8fc6cef9c60b773da5Evan Charlton private final PhoneAccountHandle mAccountHandle; 35ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen private final Uri mAddress; 36542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad private final Bundle mExtras; 3712013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn private final int mVideoState; 38542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad 39612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal /** 408c8a062f521d39ceecc99e8fc6cef9c60b773da5Evan Charlton * @param accountHandle The accountHandle which should be used to place the call. 41612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect. 42612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal * @param extras Application-specific extra data. 43be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn */ 44be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn public ConnectionRequest( 45be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn PhoneAccountHandle accountHandle, 46be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn Uri handle, 47be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn Bundle extras) { 48ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen this(accountHandle, handle, extras, VideoProfile.VideoState.AUDIO_ONLY); 49be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn } 50be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn 51be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn /** 52be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn * @param accountHandle The accountHandle which should be used to place the call. 53be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect. 54be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn * @param extras Application-specific extra data. 55612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal * @param videoState Determines the video state for the connection. 56be74de0978a7eaa577f6b61902b550a3161aff8bTyler Gunn * @hide 57612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal */ 58612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal public ConnectionRequest( 598c8a062f521d39ceecc99e8fc6cef9c60b773da5Evan Charlton PhoneAccountHandle accountHandle, 60612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal Uri handle, 61612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal Bundle extras, 6212013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn int videoState) { 638c8a062f521d39ceecc99e8fc6cef9c60b773da5Evan Charlton mAccountHandle = accountHandle; 64ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen mAddress = handle; 65fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad mExtras = extras; 6612013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn mVideoState = videoState; 67fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad } 68fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad 69c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal private ConnectionRequest(Parcel in) { 708c8a062f521d39ceecc99e8fc6cef9c60b773da5Evan Charlton mAccountHandle = in.readParcelable(getClass().getClassLoader()); 71ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen mAddress = in.readParcelable(getClass().getClassLoader()); 72c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal mExtras = in.readParcelable(getClass().getClassLoader()); 73c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal mVideoState = in.readInt(); 74c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal } 75c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal 76fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad /** 779c3f18846aaa9340cc222f825c9c32ec42f9d0c9Ihab Awad * The account which should be used to place the call. 7852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon */ 798c8a062f521d39ceecc99e8fc6cef9c60b773da5Evan Charlton public PhoneAccountHandle getAccountHandle() { return mAccountHandle; } 8052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon 8152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon /** 82542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * The handle (e.g., phone number) to which the {@link Connection} is to connect. 83542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad */ 84ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen public Uri getAddress() { return mAddress; } 85612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal 86612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal /** 87542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * Application-specific extra data. Used for passing back information from an incoming 88542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * call {@code Intent}, and for any proprietary extensions arranged between a client 89542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad * and servant {@code ConnectionService} which agree on a vocabulary for such data. 90542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad */ 91542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad public Bundle getExtras() { return mExtras; } 92542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad 9312013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn /** 94b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * Describes the video states supported by the client requesting the connection. 95b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * Valid values: {@link VideoProfile.VideoState#AUDIO_ONLY}, 96b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * {@link VideoProfile.VideoState#BIDIRECTIONAL}, 97b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * {@link VideoProfile.VideoState#TX_ENABLED}, 98b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * {@link VideoProfile.VideoState#RX_ENABLED}. 9912013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn * 10012013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn * @return The video state for the connection. 10127d1e257f3cba2d5954e5562db69035df9ecf290Tyler Gunn * @hide 10212013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn */ 10312013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn public int getVideoState() { 10412013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn return mVideoState; 10512013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn } 10612013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn 107bf11f98deb09ef54ff4161fba75d22b1a0a458eeEvan Charlton @Override 108542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad public String toString() { 109b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad return String.format("ConnectionRequest %s %s", 110ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen mAddress == null 111542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad ? Uri.EMPTY 112ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen : Connection.toLogSafePhoneNumber(mAddress.toString()), 113542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad mExtras == null ? "" : mExtras); 114542e0ea8bfa60f09c33e4be366adf8681c25d0bfIhab Awad } 115fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad 116c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal public static final Creator<ConnectionRequest> CREATOR = new Creator<ConnectionRequest> () { 117c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal @Override 118c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal public ConnectionRequest createFromParcel(Parcel source) { 119c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal return new ConnectionRequest(source); 120c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal } 121c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal 122c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal @Override 123c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal public ConnectionRequest[] newArray(int size) { 124c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal return new ConnectionRequest[size]; 125c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal } 126c5b01573a0918db20af1a827d1bbec9d2e57d069Sailesh Nepal }; 127fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad 128fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad /** 129fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad * {@inheritDoc} 130fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad */ 131fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad @Override 132fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad public int describeContents() { 133fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad return 0; 134fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad } 135fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad 136fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad @Override 137fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad public void writeToParcel(Parcel destination, int flags) { 1388c8a062f521d39ceecc99e8fc6cef9c60b773da5Evan Charlton destination.writeParcelable(mAccountHandle, 0); 139ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen destination.writeParcelable(mAddress, 0); 140fbb092f26e796fe638fb8bb4a91de2d4525bcaccIhab Awad destination.writeParcelable(mExtras, 0); 14112013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn destination.writeInt(mVideoState); 14212013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn } 14312013ad193135a07b9b8e8656391acff5f971a90Tyler Gunn} 144