blob: aa990ad6d6b5fb1e8205a698a2f2d952fd2afdd0 [file] [log] [blame]
Nancy Chenbbf35962015-12-28 17:17:27 -08001/*
2 * Copyright (C) 2015 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 */
Gary Mai69c182a2016-12-05 13:07:03 -080016package com.android.contacts.compat.telecom;
Nancy Chenbbf35962015-12-28 17:17:27 -080017
18import android.app.Activity;
19import android.content.Intent;
Aravind Sreekumar71212852018-04-06 15:47:45 -070020import androidx.annotation.Nullable;
Nancy Chenbbf35962015-12-28 17:17:27 -080021import android.telecom.TelecomManager;
Nancy Chenbbf35962015-12-28 17:17:27 -080022
Gary Mai69c182a2016-12-05 13:07:03 -080023import com.android.contacts.compat.CompatUtils;
Nancy Chenbbf35962015-12-28 17:17:27 -080024
25/**
Nancy Chen78384182015-12-22 17:21:13 -080026 * Compatibility class for {@link android.telecom.TelecomManager}.
Nancy Chenbbf35962015-12-28 17:17:27 -080027 */
28public class TelecomManagerCompat {
Nancy Chenbbf35962015-12-28 17:17:27 -080029 /**
30 * Places a new outgoing call to the provided address using the system telecom service with
31 * the specified intent.
32 *
33 * @param activity {@link Activity} used to start another activity for the given intent
34 * @param telecomManager the {@link TelecomManager} used to place a call, if possible
35 * @param intent the intent for the call
Nancy Chenbbf35962015-12-28 17:17:27 -080036 */
Nancy Chen78384182015-12-22 17:21:13 -080037 public static void placeCall(@Nullable Activity activity,
38 @Nullable TelecomManager telecomManager, @Nullable Intent intent) {
39 if (activity == null || telecomManager == null || intent == null) {
40 return;
41 }
Nancy Chenbbf35962015-12-28 17:17:27 -080042 if (CompatUtils.isMarshmallowCompatible()) {
43 telecomManager.placeCall(intent.getData(), intent.getExtras());
44 return;
45 }
46 activity.startActivityForResult(intent, 0);
47 }
Nancy Chenbbf35962015-12-28 17:17:27 -080048}