Loading src/com/android/contacts/util/PhoneCapabilityTester.java +1 −4 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.net.Uri; import android.net.sip.SipManager; import android.provider.MediaStore; import android.provider.Telephony; import android.telephony.TelephonyManager; import com.android.contacts.common.ContactsUtils; Loading Loading @@ -61,9 +60,7 @@ public final class PhoneCapabilityTester { } private static void initialize(Context context) { final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); sIsPhone = telephonyManager.isVoiceCapable(); sIsPhone = TelephonyManagerCompat.isVoiceCapable(context); sIsSipPhone = sIsPhone && SipManager.isVoipSupported(context); sIsInitialized = true; } Loading src/com/android/contacts/util/TelephonyManagerCompat.java 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.contacts.util; import android.content.Context; import android.os.Build; import android.telephony.TelephonyManager; import com.android.contacts.common.compat.SdkVersionOverride; public class TelephonyManagerCompat { public static boolean isVoiceCapable(Context context) { final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager == null) { return false; } if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.LOLLIPOP_MR1) { // isVoiceCapable was unhidden in L-MR1 return telephonyManager.isVoiceCapable(); } final int phoneType = telephonyManager.getPhoneType(); return phoneType == TelephonyManager.PHONE_TYPE_CDMA || phoneType == TelephonyManager.PHONE_TYPE_GSM; } } Loading
src/com/android/contacts/util/PhoneCapabilityTester.java +1 −4 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.net.Uri; import android.net.sip.SipManager; import android.provider.MediaStore; import android.provider.Telephony; import android.telephony.TelephonyManager; import com.android.contacts.common.ContactsUtils; Loading Loading @@ -61,9 +60,7 @@ public final class PhoneCapabilityTester { } private static void initialize(Context context) { final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); sIsPhone = telephonyManager.isVoiceCapable(); sIsPhone = TelephonyManagerCompat.isVoiceCapable(context); sIsSipPhone = sIsPhone && SipManager.isVoipSupported(context); sIsInitialized = true; } Loading
src/com/android/contacts/util/TelephonyManagerCompat.java 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.contacts.util; import android.content.Context; import android.os.Build; import android.telephony.TelephonyManager; import com.android.contacts.common.compat.SdkVersionOverride; public class TelephonyManagerCompat { public static boolean isVoiceCapable(Context context) { final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager == null) { return false; } if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.LOLLIPOP_MR1) { // isVoiceCapable was unhidden in L-MR1 return telephonyManager.isVoiceCapable(); } final int phoneType = telephonyManager.getPhoneType(); return phoneType == TelephonyManager.PHONE_TYPE_CDMA || phoneType == TelephonyManager.PHONE_TYPE_GSM; } }