Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 18 | |
Tyler Gunn | 2ac4010 | 2014-08-18 16:23:10 -0700 | [diff] [blame] | 19 | import android.annotation.SdkConstant; |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 20 | import android.annotation.SystemApi; |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 21 | import android.app.Service; |
| 22 | import android.content.Intent; |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 23 | import android.hardware.camera2.CameraManager; |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 24 | import android.net.Uri; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 25 | import android.os.Handler; |
| 26 | import android.os.IBinder; |
| 27 | import android.os.Looper; |
| 28 | import android.os.Message; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 29 | import android.view.Surface; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 30 | |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 31 | import com.android.internal.os.SomeArgs; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 32 | import com.android.internal.telecom.IInCallAdapter; |
| 33 | import com.android.internal.telecom.IInCallService; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 34 | |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 35 | import java.lang.String; |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 36 | import java.util.Collections; |
| 37 | import java.util.List; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 38 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 39 | /** |
| 40 | * This service is implemented by any app that wishes to provide the user-interface for managing |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 41 | * phone calls. Telecom binds to this service while there exists a live (active or incoming) call, |
Santos Cordon | f2600eb | 2015-06-22 15:02:20 -0700 | [diff] [blame] | 42 | * and uses it to notify the in-call app of any live and recently disconnected calls. An app must |
| 43 | * first be set as the default phone app (See {@link TelecomManager#getDefaultDialerPackage()}) |
| 44 | * before the telecom service will bind to its {@code InCallService} implementation. |
| 45 | * <p> |
| 46 | * Below is an example manifest registration for an {@code InCallService}. The meta-data |
| 47 | * ({@link TelecomManager#METADATA_IN_CALL_SERVICE_UI}) indicates that this particular |
| 48 | * {@code InCallService} implementation intends to replace the built-in in-call UI. |
| 49 | * <pre> |
| 50 | * {@code |
Neil Fuller | 71fbb81 | 2015-11-30 09:51:33 +0000 | [diff] [blame] | 51 | * <service android:name="your.package.YourInCallServiceImplementation" |
Sailesh Nepal | 78f3ba6 | 2015-12-28 16:20:56 -0800 | [diff] [blame] | 52 | * android:permission="android.permission.BIND_INCALL_SERVICE"> |
Neil Fuller | 71fbb81 | 2015-11-30 09:51:33 +0000 | [diff] [blame] | 53 | * <meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" /> |
| 54 | * <intent-filter> |
| 55 | * <action android:name="android.telecom.InCallService"/> |
| 56 | * </intent-filter> |
| 57 | * </service> |
Santos Cordon | f2600eb | 2015-06-22 15:02:20 -0700 | [diff] [blame] | 58 | * } |
| 59 | * </pre> |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 60 | */ |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 61 | public abstract class InCallService extends Service { |
Tyler Gunn | 2ac4010 | 2014-08-18 16:23:10 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
| 64 | * The {@link Intent} that must be declared as handled by the service. |
| 65 | */ |
| 66 | @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 67 | public static final String SERVICE_INTERFACE = "android.telecom.InCallService"; |
Tyler Gunn | 2ac4010 | 2014-08-18 16:23:10 -0700 | [diff] [blame] | 68 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 69 | private static final int MSG_SET_IN_CALL_ADAPTER = 1; |
| 70 | private static final int MSG_ADD_CALL = 2; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 71 | private static final int MSG_UPDATE_CALL = 3; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 72 | private static final int MSG_SET_POST_DIAL_WAIT = 4; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 73 | private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 5; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 74 | private static final int MSG_BRING_TO_FOREGROUND = 6; |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 75 | private static final int MSG_ON_CAN_ADD_CALL_CHANGED = 7; |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame^] | 76 | private static final int MSG_SILENCE_RINGER = 8; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 77 | |
| 78 | /** Default Handler used to consolidate binder method calls onto a single thread. */ |
| 79 | private final Handler mHandler = new Handler(Looper.getMainLooper()) { |
| 80 | @Override |
| 81 | public void handleMessage(Message msg) { |
Jay Shrauner | 5e6162d | 2014-09-22 20:47:45 -0700 | [diff] [blame] | 82 | if (mPhone == null && msg.what != MSG_SET_IN_CALL_ADAPTER) { |
| 83 | return; |
| 84 | } |
| 85 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 86 | switch (msg.what) { |
| 87 | case MSG_SET_IN_CALL_ADAPTER: |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 88 | mPhone = new Phone(new InCallAdapter((IInCallAdapter) msg.obj)); |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 89 | mPhone.addListener(mPhoneListener); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 90 | onPhoneCreated(mPhone); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 91 | break; |
| 92 | case MSG_ADD_CALL: |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 93 | mPhone.internalAddCall((ParcelableCall) msg.obj); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 94 | break; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 95 | case MSG_UPDATE_CALL: |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 96 | mPhone.internalUpdateCall((ParcelableCall) msg.obj); |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 97 | break; |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 98 | case MSG_SET_POST_DIAL_WAIT: { |
| 99 | SomeArgs args = (SomeArgs) msg.obj; |
| 100 | try { |
| 101 | String callId = (String) args.arg1; |
| 102 | String remaining = (String) args.arg2; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 103 | mPhone.internalSetPostDialWait(callId, remaining); |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 104 | } finally { |
| 105 | args.recycle(); |
| 106 | } |
| 107 | break; |
| 108 | } |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 109 | case MSG_ON_CALL_AUDIO_STATE_CHANGED: |
| 110 | mPhone.internalCallAudioStateChanged((CallAudioState) msg.obj); |
Sailesh Nepal | b632e5b | 2014-04-03 12:54:33 -0700 | [diff] [blame] | 111 | break; |
Santos Cordon | 3534ede | 2014-05-29 13:07:10 -0700 | [diff] [blame] | 112 | case MSG_BRING_TO_FOREGROUND: |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 113 | mPhone.internalBringToForeground(msg.arg1 == 1); |
Santos Cordon | 3534ede | 2014-05-29 13:07:10 -0700 | [diff] [blame] | 114 | break; |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 115 | case MSG_ON_CAN_ADD_CALL_CHANGED: |
| 116 | mPhone.internalSetCanAddCall(msg.arg1 == 1); |
| 117 | break; |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame^] | 118 | case MSG_SILENCE_RINGER: |
| 119 | mPhone.internalSilenceRinger(); |
| 120 | break; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 121 | default: |
| 122 | break; |
| 123 | } |
| 124 | } |
| 125 | }; |
| 126 | |
| 127 | /** Manages the binder calls so that the implementor does not need to deal with it. */ |
| 128 | private final class InCallServiceBinder extends IInCallService.Stub { |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 129 | @Override |
| 130 | public void setInCallAdapter(IInCallAdapter inCallAdapter) { |
| 131 | mHandler.obtainMessage(MSG_SET_IN_CALL_ADAPTER, inCallAdapter).sendToTarget(); |
| 132 | } |
| 133 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 134 | @Override |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 135 | public void addCall(ParcelableCall call) { |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 136 | mHandler.obtainMessage(MSG_ADD_CALL, call).sendToTarget(); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 137 | } |
| 138 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 139 | @Override |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 140 | public void updateCall(ParcelableCall call) { |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 141 | mHandler.obtainMessage(MSG_UPDATE_CALL, call).sendToTarget(); |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | @Override |
| 145 | public void setPostDial(String callId, String remaining) { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 146 | // TODO: Unused |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public void setPostDialWait(String callId, String remaining) { |
| 151 | SomeArgs args = SomeArgs.obtain(); |
| 152 | args.arg1 = callId; |
| 153 | args.arg2 = remaining; |
| 154 | mHandler.obtainMessage(MSG_SET_POST_DIAL_WAIT, args).sendToTarget(); |
| 155 | } |
Sailesh Nepal | b632e5b | 2014-04-03 12:54:33 -0700 | [diff] [blame] | 156 | |
| 157 | @Override |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 158 | public void onCallAudioStateChanged(CallAudioState callAudioState) { |
| 159 | mHandler.obtainMessage(MSG_ON_CALL_AUDIO_STATE_CHANGED, callAudioState).sendToTarget(); |
Sailesh Nepal | b632e5b | 2014-04-03 12:54:33 -0700 | [diff] [blame] | 160 | } |
Santos Cordon | 3534ede | 2014-05-29 13:07:10 -0700 | [diff] [blame] | 161 | |
Santos Cordon | 3534ede | 2014-05-29 13:07:10 -0700 | [diff] [blame] | 162 | @Override |
| 163 | public void bringToForeground(boolean showDialpad) { |
| 164 | mHandler.obtainMessage(MSG_BRING_TO_FOREGROUND, showDialpad ? 1 : 0, 0).sendToTarget(); |
| 165 | } |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 166 | |
| 167 | @Override |
| 168 | public void onCanAddCallChanged(boolean canAddCall) { |
| 169 | mHandler.obtainMessage(MSG_ON_CAN_ADD_CALL_CHANGED, canAddCall ? 1 : 0, 0) |
| 170 | .sendToTarget(); |
| 171 | } |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame^] | 172 | |
| 173 | @Override |
| 174 | public void silenceRinger() { |
| 175 | mHandler.obtainMessage(MSG_SILENCE_RINGER).sendToTarget(); |
| 176 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 177 | } |
| 178 | |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 179 | private Phone.Listener mPhoneListener = new Phone.Listener() { |
| 180 | /** ${inheritDoc} */ |
| 181 | @Override |
| 182 | public void onAudioStateChanged(Phone phone, AudioState audioState) { |
| 183 | InCallService.this.onAudioStateChanged(audioState); |
| 184 | } |
| 185 | |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 186 | public void onCallAudioStateChanged(Phone phone, CallAudioState callAudioState) { |
| 187 | InCallService.this.onCallAudioStateChanged(callAudioState); |
| 188 | }; |
| 189 | |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 190 | /** ${inheritDoc} */ |
| 191 | @Override |
| 192 | public void onBringToForeground(Phone phone, boolean showDialpad) { |
| 193 | InCallService.this.onBringToForeground(showDialpad); |
| 194 | } |
| 195 | |
| 196 | /** ${inheritDoc} */ |
| 197 | @Override |
| 198 | public void onCallAdded(Phone phone, Call call) { |
| 199 | InCallService.this.onCallAdded(call); |
| 200 | } |
| 201 | |
| 202 | /** ${inheritDoc} */ |
| 203 | @Override |
| 204 | public void onCallRemoved(Phone phone, Call call) { |
| 205 | InCallService.this.onCallRemoved(call); |
| 206 | } |
| 207 | |
| 208 | /** ${inheritDoc} */ |
| 209 | @Override |
| 210 | public void onCanAddCallChanged(Phone phone, boolean canAddCall) { |
| 211 | InCallService.this.onCanAddCallChanged(canAddCall); |
| 212 | } |
| 213 | |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame^] | 214 | /** ${inheritDoc} */ |
| 215 | @Override |
| 216 | public void onSilenceRinger(Phone phone) { |
| 217 | InCallService.this.onSilenceRinger(); |
| 218 | } |
| 219 | |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 220 | }; |
| 221 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 222 | private Phone mPhone; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 223 | |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 224 | public InCallService() { |
| 225 | } |
Evan Charlton | 924748f | 2014-04-03 08:36:38 -0700 | [diff] [blame] | 226 | |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 227 | @Override |
| 228 | public IBinder onBind(Intent intent) { |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 229 | return new InCallServiceBinder(); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 230 | } |
| 231 | |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 232 | @Override |
| 233 | public boolean onUnbind(Intent intent) { |
Santos Cordon | 619b3c0 | 2014-09-02 17:13:45 -0700 | [diff] [blame] | 234 | if (mPhone != null) { |
| 235 | Phone oldPhone = mPhone; |
| 236 | mPhone = null; |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 237 | |
Santos Cordon | 619b3c0 | 2014-09-02 17:13:45 -0700 | [diff] [blame] | 238 | oldPhone.destroy(); |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 239 | // destroy sets all the calls to disconnected if any live ones still exist. Therefore, |
| 240 | // it is important to remove the Listener *after* the call to destroy so that |
| 241 | // InCallService.on* callbacks are appropriately called. |
| 242 | oldPhone.removeListener(mPhoneListener); |
| 243 | |
Santos Cordon | 619b3c0 | 2014-09-02 17:13:45 -0700 | [diff] [blame] | 244 | onPhoneDestroyed(oldPhone); |
| 245 | } |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 246 | |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 247 | return false; |
| 248 | } |
| 249 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 250 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 251 | * Obtain the {@code Phone} associated with this {@code InCallService}. |
| 252 | * |
| 253 | * @return The {@code Phone} object associated with this {@code InCallService}, or {@code null} |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 254 | * if the {@code InCallService} is not in a state where it has an associated |
| 255 | * {@code Phone}. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 256 | * @hide |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 257 | * @deprecated Use direct methods on InCallService instead of {@link Phone}. |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 258 | */ |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 259 | @SystemApi |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 260 | @Deprecated |
| 261 | public Phone getPhone() { |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 262 | return mPhone; |
Evan Charlton | 924748f | 2014-04-03 08:36:38 -0700 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | /** |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 266 | * Obtains the current list of {@code Call}s to be displayed by this in-call service. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 267 | * |
| 268 | * @return A list of the relevant {@code Call}s. |
| 269 | */ |
| 270 | public final List<Call> getCalls() { |
| 271 | return mPhone == null ? Collections.<Call>emptyList() : mPhone.getCalls(); |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Returns if the device can support additional calls. |
| 276 | * |
| 277 | * @return Whether the phone supports adding more calls. |
| 278 | */ |
| 279 | public final boolean canAddCall() { |
| 280 | return mPhone == null ? false : mPhone.canAddCall(); |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Obtains the current phone call audio state. |
| 285 | * |
| 286 | * @return An object encapsulating the audio state. Returns null if the service is not |
| 287 | * fully initialized. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 288 | * @deprecated Use {@link #getCallAudioState()} instead. |
| 289 | * @hide |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 290 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 291 | @Deprecated |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 292 | public final AudioState getAudioState() { |
| 293 | return mPhone == null ? null : mPhone.getAudioState(); |
| 294 | } |
| 295 | |
| 296 | /** |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 297 | * Obtains the current phone call audio state. |
| 298 | * |
| 299 | * @return An object encapsulating the audio state. Returns null if the service is not |
| 300 | * fully initialized. |
| 301 | */ |
| 302 | public final CallAudioState getCallAudioState() { |
| 303 | return mPhone == null ? null : mPhone.getCallAudioState(); |
| 304 | } |
| 305 | |
| 306 | /** |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 307 | * Sets the microphone mute state. When this request is honored, there will be change to |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 308 | * the {@link #getCallAudioState()}. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 309 | * |
| 310 | * @param state {@code true} if the microphone should be muted; {@code false} otherwise. |
| 311 | */ |
| 312 | public final void setMuted(boolean state) { |
| 313 | if (mPhone != null) { |
| 314 | mPhone.setMuted(state); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | /** |
| 319 | * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 320 | * be change to the {@link #getCallAudioState()}. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 321 | * |
| 322 | * @param route The audio route to use. |
| 323 | */ |
| 324 | public final void setAudioRoute(int route) { |
| 325 | if (mPhone != null) { |
| 326 | mPhone.setAudioRoute(route); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 331 | * Invoked when the {@code Phone} has been created. This is a signal to the in-call experience |
| 332 | * to start displaying in-call information to the user. Each instance of {@code InCallService} |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 333 | * will have only one {@code Phone}, and this method will be called exactly once in the lifetime |
| 334 | * of the {@code InCallService}. |
Evan Charlton | 924748f | 2014-04-03 08:36:38 -0700 | [diff] [blame] | 335 | * |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 336 | * @param phone The {@code Phone} object associated with this {@code InCallService}. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 337 | * @hide |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 338 | * @deprecated Use direct methods on InCallService instead of {@link Phone}. |
Evan Charlton | 924748f | 2014-04-03 08:36:38 -0700 | [diff] [blame] | 339 | */ |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 340 | @SystemApi |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 341 | @Deprecated |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 342 | public void onPhoneCreated(Phone phone) { |
| 343 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 344 | |
| 345 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 346 | * Invoked when a {@code Phone} has been destroyed. This is a signal to the in-call experience |
| 347 | * to stop displaying in-call information to the user. This method will be called exactly once |
| 348 | * in the lifetime of the {@code InCallService}, and it will always be called after a previous |
| 349 | * call to {@link #onPhoneCreated(Phone)}. |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 350 | * |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 351 | * @param phone The {@code Phone} object associated with this {@code InCallService}. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 352 | * @hide |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 353 | * @deprecated Use direct methods on InCallService instead of {@link Phone}. |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 354 | */ |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 355 | @SystemApi |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 356 | @Deprecated |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 357 | public void onPhoneDestroyed(Phone phone) { |
| 358 | } |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 359 | |
| 360 | /** |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 361 | * Called when the audio state changes. |
| 362 | * |
| 363 | * @param audioState The new {@link AudioState}. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 364 | * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState) instead}. |
| 365 | * @hide |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 366 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 367 | @Deprecated |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 368 | public void onAudioStateChanged(AudioState audioState) { |
| 369 | } |
| 370 | |
| 371 | /** |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 372 | * Called when the audio state changes. |
| 373 | * |
| 374 | * @param audioState The new {@link CallAudioState}. |
| 375 | */ |
| 376 | public void onCallAudioStateChanged(CallAudioState audioState) { |
| 377 | } |
| 378 | |
| 379 | /** |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 380 | * Called to bring the in-call screen to the foreground. The in-call experience should |
| 381 | * respond immediately by coming to the foreground to inform the user of the state of |
| 382 | * ongoing {@code Call}s. |
| 383 | * |
| 384 | * @param showDialpad If true, put up the dialpad when the screen is shown. |
| 385 | */ |
| 386 | public void onBringToForeground(boolean showDialpad) { |
| 387 | } |
| 388 | |
| 389 | /** |
| 390 | * Called when a {@code Call} has been added to this in-call session. The in-call user |
| 391 | * experience should add necessary state listeners to the specified {@code Call} and |
| 392 | * immediately start to show the user information about the existence |
| 393 | * and nature of this {@code Call}. Subsequent invocations of {@link #getCalls()} will |
| 394 | * include this {@code Call}. |
| 395 | * |
| 396 | * @param call A newly added {@code Call}. |
| 397 | */ |
| 398 | public void onCallAdded(Call call) { |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Called when a {@code Call} has been removed from this in-call session. The in-call user |
| 403 | * experience should remove any state listeners from the specified {@code Call} and |
| 404 | * immediately stop displaying any information about this {@code Call}. |
| 405 | * Subsequent invocations of {@link #getCalls()} will no longer include this {@code Call}. |
| 406 | * |
| 407 | * @param call A newly removed {@code Call}. |
| 408 | */ |
| 409 | public void onCallRemoved(Call call) { |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * Called when the ability to add more calls changes. If the phone cannot |
| 414 | * support more calls then {@code canAddCall} is set to {@code false}. If it can, then it |
| 415 | * is set to {@code true}. This can be used to control the visibility of UI to add more calls. |
| 416 | * |
| 417 | * @param canAddCall Indicates whether an additional call can be added. |
| 418 | */ |
| 419 | public void onCanAddCallChanged(boolean canAddCall) { |
| 420 | } |
| 421 | |
| 422 | /** |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame^] | 423 | * Called to silence the ringer if a ringing call exists. |
| 424 | */ |
| 425 | public void onSilenceRinger() { |
| 426 | } |
| 427 | |
| 428 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 429 | * Used to issue commands to the {@link Connection.VideoProvider} associated with a |
| 430 | * {@link Call}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 431 | */ |
| 432 | public static abstract class VideoCall { |
| 433 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 434 | /** @hide */ |
| 435 | public abstract void destroy(); |
| 436 | |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 437 | /** |
Andrew Lee | 7c9ee2b | 2015-04-16 15:26:08 -0700 | [diff] [blame] | 438 | * Registers a callback to receive commands and state changes for video calls. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 439 | * |
Andrew Lee | 7c9ee2b | 2015-04-16 15:26:08 -0700 | [diff] [blame] | 440 | * @param callback The video call callback. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 441 | */ |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 442 | public abstract void registerCallback(VideoCall.Callback callback); |
| 443 | |
| 444 | /** |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 445 | * Registers a callback to receive commands and state changes for video calls. |
| 446 | * |
| 447 | * @param callback The video call callback. |
| 448 | * @param handler A handler which commands and status changes will be delivered to. |
| 449 | */ |
| 450 | public abstract void registerCallback(VideoCall.Callback callback, Handler handler); |
| 451 | |
| 452 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 453 | * Clears the video call callback set via {@link #registerCallback}. |
Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 454 | * |
| 455 | * @param callback The video call callback to clear. |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 456 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 457 | public abstract void unregisterCallback(VideoCall.Callback callback); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 458 | |
| 459 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 460 | * Sets the camera to be used for the outgoing video. |
| 461 | * <p> |
| 462 | * Handled by {@link Connection.VideoProvider#onSetCamera(String)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 463 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 464 | * @param cameraId The id of the camera (use ids as reported by |
| 465 | * {@link CameraManager#getCameraIdList()}). |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 466 | */ |
| 467 | public abstract void setCamera(String cameraId); |
| 468 | |
| 469 | /** |
| 470 | * Sets the surface to be used for displaying a preview of what the user's camera is |
| 471 | * currently capturing. When video transmission is enabled, this is the video signal which |
| 472 | * is sent to the remote device. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 473 | * <p> |
| 474 | * Handled by {@link Connection.VideoProvider#onSetPreviewSurface(Surface)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 475 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 476 | * @param surface The {@link Surface}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 477 | */ |
| 478 | public abstract void setPreviewSurface(Surface surface); |
| 479 | |
| 480 | /** |
| 481 | * Sets the surface to be used for displaying the video received from the remote device. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 482 | * <p> |
| 483 | * Handled by {@link Connection.VideoProvider#onSetDisplaySurface(Surface)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 484 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 485 | * @param surface The {@link Surface}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 486 | */ |
| 487 | public abstract void setDisplaySurface(Surface surface); |
| 488 | |
| 489 | /** |
| 490 | * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of |
| 491 | * the device is 0 degrees. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 492 | * <p> |
| 493 | * Handled by {@link Connection.VideoProvider#onSetDeviceOrientation(int)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 494 | * |
| 495 | * @param rotation The device orientation, in degrees. |
| 496 | */ |
| 497 | public abstract void setDeviceOrientation(int rotation); |
| 498 | |
| 499 | /** |
| 500 | * Sets camera zoom ratio. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 501 | * <p> |
| 502 | * Handled by {@link Connection.VideoProvider#onSetZoom(float)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 503 | * |
| 504 | * @param value The camera zoom ratio. |
| 505 | */ |
| 506 | public abstract void setZoom(float value); |
| 507 | |
| 508 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 509 | * Issues a request to modify the properties of the current video session. |
| 510 | * <p> |
| 511 | * Example scenarios include: requesting an audio-only call to be upgraded to a |
| 512 | * bi-directional video call, turning on or off the user's camera, sending a pause signal |
| 513 | * when the {@link InCallService} is no longer the foreground application. |
| 514 | * <p> |
| 515 | * Handled by |
| 516 | * {@link Connection.VideoProvider#onSendSessionModifyRequest(VideoProfile, VideoProfile)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 517 | * |
| 518 | * @param requestProfile The requested call video properties. |
| 519 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 520 | public abstract void sendSessionModifyRequest(VideoProfile requestProfile); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 521 | |
| 522 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 523 | * Provides a response to a request to change the current call video session |
| 524 | * properties. This should be called in response to a request the {@link InCallService} has |
| 525 | * received via {@link VideoCall.Callback#onSessionModifyRequestReceived}. |
| 526 | * <p> |
| 527 | * Handled by |
| 528 | * {@link Connection.VideoProvider#onSendSessionModifyResponse(VideoProfile)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 529 | * |
| 530 | * @param responseProfile The response call video properties. |
| 531 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 532 | public abstract void sendSessionModifyResponse(VideoProfile responseProfile); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 533 | |
| 534 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 535 | * Issues a request to the {@link Connection.VideoProvider} to retrieve the capabilities |
| 536 | * of the current camera. The current camera is selected using |
| 537 | * {@link VideoCall#setCamera(String)}. |
| 538 | * <p> |
| 539 | * Camera capabilities are reported to the caller via |
| 540 | * {@link VideoCall.Callback#onCameraCapabilitiesChanged(VideoProfile.CameraCapabilities)}. |
| 541 | * <p> |
| 542 | * Handled by {@link Connection.VideoProvider#onRequestCameraCapabilities()}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 543 | */ |
| 544 | public abstract void requestCameraCapabilities(); |
| 545 | |
| 546 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 547 | * Issues a request to the {@link Connection.VideoProvider} to retrieve the cumulative data |
| 548 | * usage for the video component of the current call (in bytes). Data usage is reported |
| 549 | * to the caller via {@link VideoCall.Callback#onCallDataUsageChanged}. |
| 550 | * <p> |
| 551 | * Handled by {@link Connection.VideoProvider#onRequestConnectionDataUsage()}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 552 | */ |
| 553 | public abstract void requestCallDataUsage(); |
| 554 | |
| 555 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 556 | * Provides the {@link Connection.VideoProvider} with the {@link Uri} of an image to be |
| 557 | * displayed to the peer device when the video signal is paused. |
| 558 | * <p> |
| 559 | * Handled by {@link Connection.VideoProvider#onSetPauseImage(Uri)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 560 | * |
| 561 | * @param uri URI of image to display. |
| 562 | */ |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 563 | public abstract void setPauseImage(Uri uri); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 564 | |
| 565 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 566 | * The {@link InCallService} extends this class to provide a means of receiving callbacks |
Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 567 | * from the {@link Connection.VideoProvider}. |
| 568 | * <p> |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 569 | * When the {@link InCallService} receives the |
| 570 | * {@link Call.Callback#onVideoCallChanged(Call, VideoCall)} callback, it should create an |
| 571 | * instance its {@link VideoCall.Callback} implementation and set it on the |
| 572 | * {@link VideoCall} using {@link VideoCall#registerCallback(Callback)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 573 | */ |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 574 | public static abstract class Callback { |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 575 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 576 | * Called when the {@link Connection.VideoProvider} receives a session modification |
Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 577 | * request from the peer device. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 578 | * <p> |
| 579 | * The {@link InCallService} may potentially prompt the user to confirm whether they |
| 580 | * wish to accept the request, or decide to automatically accept the request. In either |
| 581 | * case the {@link InCallService} should call |
| 582 | * {@link VideoCall#sendSessionModifyResponse(VideoProfile)} to indicate the video |
| 583 | * profile agreed upon. |
| 584 | * <p> |
| 585 | * Callback originates from |
| 586 | * {@link Connection.VideoProvider#receiveSessionModifyRequest(VideoProfile)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 587 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 588 | * @param videoProfile The requested video profile. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 589 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 590 | public abstract void onSessionModifyRequestReceived(VideoProfile videoProfile); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 591 | |
| 592 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 593 | * Called when the {@link Connection.VideoProvider} receives a response to a session |
| 594 | * modification request previously sent to the peer device. |
| 595 | * <p> |
| 596 | * The new video state should not be considered active by the {@link InCallService} |
| 597 | * until the {@link Call} video state changes (the |
| 598 | * {@link Call.Callback#onDetailsChanged(Call, Call.Details)} callback is triggered |
| 599 | * when the video state changes). |
| 600 | * <p> |
| 601 | * Callback originates from |
| 602 | * {@link Connection.VideoProvider#receiveSessionModifyResponse(int, VideoProfile, |
| 603 | * VideoProfile)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 604 | * |
| 605 | * @param status Status of the session modify request. Valid values are |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 606 | * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS}, |
| 607 | * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_FAIL}, |
| 608 | * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_INVALID}, |
| 609 | * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT}, |
| 610 | * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}. |
| 611 | * @param requestedProfile The original request which was sent to the peer device. |
| 612 | * @param responseProfile The actual profile changes made by the peer device. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 613 | */ |
| 614 | public abstract void onSessionModifyResponseReceived(int status, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 615 | VideoProfile requestedProfile, VideoProfile responseProfile); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 616 | |
| 617 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 618 | * Handles events related to the current video session which the {@link InCallService} |
| 619 | * may wish to handle. These are separate from requested changes to the session due to |
| 620 | * the underlying protocol or connection. |
| 621 | * <p> |
| 622 | * Callback originates from |
| 623 | * {@link Connection.VideoProvider#handleCallSessionEvent(int)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 624 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 625 | * @param event The event. Valid values are: |
| 626 | * {@link Connection.VideoProvider#SESSION_EVENT_RX_PAUSE}, |
| 627 | * {@link Connection.VideoProvider#SESSION_EVENT_RX_RESUME}, |
| 628 | * {@link Connection.VideoProvider#SESSION_EVENT_TX_START}, |
| 629 | * {@link Connection.VideoProvider#SESSION_EVENT_TX_STOP}, |
| 630 | * {@link Connection.VideoProvider#SESSION_EVENT_CAMERA_FAILURE}, |
| 631 | * {@link Connection.VideoProvider#SESSION_EVENT_CAMERA_READY}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 632 | */ |
| 633 | public abstract void onCallSessionEvent(int event); |
| 634 | |
| 635 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 636 | * Handles a change to the video dimensions from the peer device. This could happen if, |
| 637 | * for example, the peer changes orientation of their device, or switches cameras. |
| 638 | * <p> |
| 639 | * Callback originates from |
| 640 | * {@link Connection.VideoProvider#changePeerDimensions(int, int)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 641 | * |
| 642 | * @param width The updated peer video width. |
| 643 | * @param height The updated peer video height. |
| 644 | */ |
| 645 | public abstract void onPeerDimensionsChanged(int width, int height); |
| 646 | |
| 647 | /** |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 648 | * Handles a change to the video quality. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 649 | * <p> |
| 650 | * Callback originates from {@link Connection.VideoProvider#changeVideoQuality(int)}. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 651 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 652 | * @param videoQuality The updated peer video quality. Valid values: |
| 653 | * {@link VideoProfile#QUALITY_HIGH}, |
| 654 | * {@link VideoProfile#QUALITY_MEDIUM}, |
| 655 | * {@link VideoProfile#QUALITY_LOW}, |
| 656 | * {@link VideoProfile#QUALITY_DEFAULT}. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 657 | */ |
| 658 | public abstract void onVideoQualityChanged(int videoQuality); |
| 659 | |
| 660 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 661 | * Handles an update to the total data used for the current video session. |
| 662 | * <p> |
| 663 | * Used by the {@link Connection.VideoProvider} in response to |
| 664 | * {@link VideoCall#requestCallDataUsage()}. May also be called periodically by the |
| 665 | * {@link Connection.VideoProvider}. |
| 666 | * <p> |
| 667 | * Callback originates from {@link Connection.VideoProvider#setCallDataUsage(long)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 668 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 669 | * @param dataUsage The updated data usage (in bytes). |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 670 | */ |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 671 | public abstract void onCallDataUsageChanged(long dataUsage); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 672 | |
| 673 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 674 | * Handles a change in the capabilities of the currently selected camera. |
| 675 | * <p> |
| 676 | * Used by the {@link Connection.VideoProvider} in response to |
| 677 | * {@link VideoCall#requestCameraCapabilities()}. The {@link Connection.VideoProvider} |
| 678 | * may also report the camera capabilities after a call to |
| 679 | * {@link VideoCall#setCamera(String)}. |
| 680 | * <p> |
| 681 | * Callback originates from |
| 682 | * {@link Connection.VideoProvider#changeCameraCapabilities( |
| 683 | * VideoProfile.CameraCapabilities)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 684 | * |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 685 | * @param cameraCapabilities The changed camera capabilities. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 686 | */ |
Yorke Lee | 400470f | 2015-05-12 13:31:25 -0700 | [diff] [blame] | 687 | public abstract void onCameraCapabilitiesChanged( |
| 688 | VideoProfile.CameraCapabilities cameraCapabilities); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 689 | } |
| 690 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 691 | } |