Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | |
| 17 | package com.android.phone; |
| 18 | |
Andrew Lee | a6bc312 | 2015-01-29 14:47:34 -0800 | [diff] [blame] | 19 | import android.content.Context; |
| 20 | import android.util.Log; |
| 21 | |
| 22 | import com.android.ims.ImsConfig; |
| 23 | import com.android.ims.ImsManager; |
Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 24 | import com.android.phone.PhoneGlobals; |
| 25 | |
| 26 | public class ImsUtil { |
Andrew Lee | a6bc312 | 2015-01-29 14:47:34 -0800 | [diff] [blame] | 27 | private static final String LOG_TAG = ImsUtil.class.getSimpleName(); |
| 28 | private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2); |
Andrew Lee | 77527ac | 2014-10-21 16:57:39 -0700 | [diff] [blame] | 29 | |
Andrew Lee | 77527ac | 2014-10-21 16:57:39 -0700 | [diff] [blame] | 30 | private static boolean sImsPhoneSupported = false; |
| 31 | |
Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 32 | private ImsUtil() { |
| 33 | } |
| 34 | |
Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 35 | static { |
| 36 | PhoneGlobals app = PhoneGlobals.getInstance(); |
| 37 | sImsPhoneSupported = true; |
| 38 | } |
| 39 | |
| 40 | /** |
Andrew Lee | a6bc312 | 2015-01-29 14:47:34 -0800 | [diff] [blame] | 41 | * @return {@code true} if this device supports voice calls using the built-in SIP stack. |
Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 42 | */ |
| 43 | static boolean isImsPhoneSupported() { |
| 44 | return sImsPhoneSupported; |
Andrew Lee | 77527ac | 2014-10-21 16:57:39 -0700 | [diff] [blame] | 45 | |
| 46 | } |
Andrew Lee | a6bc312 | 2015-01-29 14:47:34 -0800 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * @return {@code true} if WFC is supported by the platform and has been enabled by the user. |
| 50 | */ |
| 51 | public static boolean isWfcEnabled(Context context) { |
| 52 | boolean isEnabledByPlatform = ImsManager.isWfcEnabledByPlatform(context); |
| 53 | boolean isEnabledByUser = ImsManager.isWfcEnabledByUser(context); |
| 54 | if (DBG) Log.d(LOG_TAG, "isWfcEnabled :: isEnabledByPlatform=" + isEnabledByPlatform); |
| 55 | if (DBG) Log.d(LOG_TAG, "isWfcEnabled :: isEnabledByUser=" + isEnabledByUser); |
| 56 | return isEnabledByPlatform && isEnabledByUser; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * @return {@code true} if the device is configured to use "Wi-Fi only" mode. If WFC is not |
| 61 | * enabled, this will return {@code false}. |
| 62 | */ |
| 63 | public static boolean isWfcModeWifiOnly(Context context) { |
| 64 | boolean isWifiOnlyMode = |
| 65 | ImsManager.getWfcMode(context) == ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY; |
| 66 | if (DBG) Log.d(LOG_TAG, "isWfcModeWifiOnly :: isWifiOnlyMode" + isWifiOnlyMode); |
| 67 | return isWfcEnabled(context) && isWifiOnlyMode; |
| 68 | } |
Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 69 | } |