Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 18 | |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 19 | import android.net.Uri; |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 20 | import android.os.Bundle; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 21 | import android.os.Parcel; |
| 22 | import android.os.Parcelable; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Simple data container encapsulating a request to some entity to |
| 26 | * create a new {@link Connection}. |
| 27 | */ |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 28 | public final class ConnectionRequest implements Parcelable { |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 29 | |
| 30 | // TODO: Token to limit recursive invocations |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 31 | private final PhoneAccountHandle mAccountHandle; |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 32 | private final Uri mAddress; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 33 | private final Bundle mExtras; |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 34 | private final int mVideoState; |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 35 | private final String mTelecomCallId; |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 36 | private final boolean mShouldShowIncomingCallUi; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 37 | |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 38 | /** |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 39 | * @param accountHandle The accountHandle which should be used to place the call. |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 40 | * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect. |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 41 | * @param extras Application-specific extra data. |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 42 | */ |
| 43 | public ConnectionRequest( |
| 44 | PhoneAccountHandle accountHandle, |
| 45 | Uri handle, |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 46 | Bundle extras) { |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 47 | this(accountHandle, handle, extras, VideoProfile.STATE_AUDIO_ONLY, null, false); |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | /** |
| 51 | * @param accountHandle The accountHandle which should be used to place the call. |
| 52 | * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect. |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 53 | * @param extras Application-specific extra data. |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 54 | * @param videoState Determines the video state for the connection. |
| 55 | */ |
| 56 | public ConnectionRequest( |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 57 | PhoneAccountHandle accountHandle, |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 58 | Uri handle, |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 59 | Bundle extras, |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 60 | int videoState) { |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 61 | this(accountHandle, handle, extras, videoState, null, false); |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @param accountHandle The accountHandle which should be used to place the call. |
| 66 | * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect. |
| 67 | * @param extras Application-specific extra data. |
| 68 | * @param videoState Determines the video state for the connection. |
| 69 | * @param telecomCallId The telecom call ID. |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 70 | * @param shouldShowIncomingCallUi For a self-managed {@link ConnectionService}, will be |
| 71 | * {@code true} if the {@link ConnectionService} should show its |
| 72 | * own incoming call UI for an incoming call. When |
| 73 | * {@code false}, Telecom shows the incoming call UI. |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 74 | * @hide |
| 75 | */ |
| 76 | public ConnectionRequest( |
| 77 | PhoneAccountHandle accountHandle, |
| 78 | Uri handle, |
| 79 | Bundle extras, |
| 80 | int videoState, |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 81 | String telecomCallId, |
| 82 | boolean shouldShowIncomingCallUi) { |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 83 | mAccountHandle = accountHandle; |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 84 | mAddress = handle; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 85 | mExtras = extras; |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 86 | mVideoState = videoState; |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 87 | mTelecomCallId = telecomCallId; |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 88 | mShouldShowIncomingCallUi = shouldShowIncomingCallUi; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 91 | private ConnectionRequest(Parcel in) { |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 92 | mAccountHandle = in.readParcelable(getClass().getClassLoader()); |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 93 | mAddress = in.readParcelable(getClass().getClassLoader()); |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 94 | mExtras = in.readParcelable(getClass().getClassLoader()); |
| 95 | mVideoState = in.readInt(); |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 96 | mTelecomCallId = in.readString(); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 97 | mShouldShowIncomingCallUi = in.readInt() == 1; |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 100 | /** |
Ihab Awad | 9c3f188 | 2014-06-30 21:17:13 -0700 | [diff] [blame] | 101 | * The account which should be used to place the call. |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 102 | */ |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 103 | public PhoneAccountHandle getAccountHandle() { return mAccountHandle; } |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 104 | |
| 105 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 106 | * The handle (e.g., phone number) to which the {@link Connection} is to connect. |
| 107 | */ |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 108 | public Uri getAddress() { return mAddress; } |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 109 | |
| 110 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 111 | * Application-specific extra data. Used for passing back information from an incoming |
| 112 | * call {@code Intent}, and for any proprietary extensions arranged between a client |
| 113 | * and servant {@code ConnectionService} which agree on a vocabulary for such data. |
| 114 | */ |
| 115 | public Bundle getExtras() { return mExtras; } |
| 116 | |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 117 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 118 | * Describes the video states supported by the client requesting the connection. |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 119 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 120 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 121 | * {@link VideoProfile#STATE_TX_ENABLED}, |
| 122 | * {@link VideoProfile#STATE_RX_ENABLED}. |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 123 | * |
| 124 | * @return The video state for the connection. |
| 125 | */ |
| 126 | public int getVideoState() { |
| 127 | return mVideoState; |
| 128 | } |
| 129 | |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 130 | /** |
| 131 | * Returns the internal Telecom ID associated with the connection request. |
| 132 | * |
| 133 | * @return The Telecom ID. |
| 134 | * @hide |
| 135 | */ |
| 136 | public String getTelecomCallId() { |
| 137 | return mTelecomCallId; |
| 138 | } |
| 139 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 140 | /** |
| 141 | * For a self-managed {@link ConnectionService}, indicates for an incoming call whether the |
| 142 | * {@link ConnectionService} should show its own incoming call UI for an incoming call. |
| 143 | * |
| 144 | * @return {@code true} if the {@link ConnectionService} should show its own incoming call UI. |
| 145 | * When {@code false}, Telecom shows the incoming call UI for the call. |
| 146 | * @hide |
| 147 | */ |
| 148 | public boolean shouldShowIncomingCallUi() { |
| 149 | return mShouldShowIncomingCallUi; |
| 150 | } |
| 151 | |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 152 | @Override |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 153 | public String toString() { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 154 | return String.format("ConnectionRequest %s %s", |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 155 | mAddress == null |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 156 | ? Uri.EMPTY |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 157 | : Connection.toLogSafePhoneNumber(mAddress.toString()), |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 158 | mExtras == null ? "" : mExtras); |
| 159 | } |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 160 | |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 161 | public static final Creator<ConnectionRequest> CREATOR = new Creator<ConnectionRequest> () { |
| 162 | @Override |
| 163 | public ConnectionRequest createFromParcel(Parcel source) { |
| 164 | return new ConnectionRequest(source); |
| 165 | } |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 166 | |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 167 | @Override |
| 168 | public ConnectionRequest[] newArray(int size) { |
| 169 | return new ConnectionRequest[size]; |
| 170 | } |
| 171 | }; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 172 | |
| 173 | /** |
| 174 | * {@inheritDoc} |
| 175 | */ |
| 176 | @Override |
| 177 | public int describeContents() { |
| 178 | return 0; |
| 179 | } |
| 180 | |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 181 | @Override |
| 182 | public void writeToParcel(Parcel destination, int flags) { |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 183 | destination.writeParcelable(mAccountHandle, 0); |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 184 | destination.writeParcelable(mAddress, 0); |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 185 | destination.writeParcelable(mExtras, 0); |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 186 | destination.writeInt(mVideoState); |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 187 | destination.writeString(mTelecomCallId); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 188 | destination.writeInt(mShouldShowIncomingCallUi ? 1 : 0); |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 189 | } |
| 190 | } |