Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8e0f409 authored by Nancy Chen's avatar Nancy Chen
Browse files

Move TelephonyManagerCompat to ContactsCommon (2/2).

Bug: 25776171
Change-Id: Ifc9749660bf2a960def29d5bc5b36edd1e99594a
parent 334bfaf3
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.contacts.compat;

import android.os.Build;
import android.provider.ContactsContract.ProviderStatus;

import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.compat.SdkVersionOverride;

/**
@@ -33,8 +35,7 @@ public class ProviderStatusCompat {
    private ProviderStatusCompat() {
    }

    public static final boolean USE_CURRENT_VERSION =
            SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.LOLLIPOP) >= Build.VERSION_CODES.M;
    public static final boolean USE_CURRENT_VERSION = CompatUtils.isMarshmallowCompatible();

    public static final int STATUS_EMPTY = USE_CURRENT_VERSION ?
            ProviderStatus.STATUS_EMPTY : ProviderStatusCompat.STATUS_NO_ACCOUNTS_NO_CONTACTS;
+0 −41
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.compat;

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;
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -25,9 +25,10 @@ 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;
import com.android.contacts.compat.TelephonyManagerCompat;
import com.android.contacts.common.compat.TelephonyManagerCompat;

import java.util.List;

@@ -61,7 +62,8 @@ public final class PhoneCapabilityTester {
    }

    private static void initialize(Context context) {
        sIsPhone = TelephonyManagerCompat.isVoiceCapable(context);
        sIsPhone = TelephonyManagerCompat.isVoiceCapable(
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE));
        sIsSipPhone = sIsPhone && SipManager.isVoipSupported(context);
        sIsInitialized = true;
    }