1 /* 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 */ 16 package com.android.contacts.compat.telecom; 17 18 import android.app.Activity; 19 import android.content.Intent; 20 import androidx.annotation.Nullable; 21 import android.telecom.TelecomManager; 22 23 import com.android.contacts.compat.CompatUtils; 24 25 /** 26 * Compatibility class for {@link android.telecom.TelecomManager}. 27 */ 28 public class TelecomManagerCompat { 29 /** 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 36 */ placeCall(@ullable Activity activity, @Nullable TelecomManager telecomManager, @Nullable Intent intent)37 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 } 42 if (CompatUtils.isMarshmallowCompatible()) { 43 telecomManager.placeCall(intent.getData(), intent.getExtras()); 44 return; 45 } 46 activity.startActivityForResult(intent, 0); 47 } 48 } 49