blob: 868a0f174d3b1d495f5ff1e509085f7cb2f39c53 [file] [log] [blame]
Etan Cohen0ca1c802014-07-07 15:35:48 -07001/*
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
17package com.android.phone;
18
Andrew Leea6bc3122015-01-29 14:47:34 -080019import android.content.Context;
20import android.util.Log;
21
22import com.android.ims.ImsConfig;
23import com.android.ims.ImsManager;
Etan Cohen0ca1c802014-07-07 15:35:48 -070024import com.android.phone.PhoneGlobals;
25
26public class ImsUtil {
Andrew Leea6bc3122015-01-29 14:47:34 -080027 private static final String LOG_TAG = ImsUtil.class.getSimpleName();
28 private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
Andrew Lee77527ac2014-10-21 16:57:39 -070029
Andrew Lee77527ac2014-10-21 16:57:39 -070030 private static boolean sImsPhoneSupported = false;
31
Etan Cohen0ca1c802014-07-07 15:35:48 -070032 private ImsUtil() {
33 }
34
Etan Cohen0ca1c802014-07-07 15:35:48 -070035 static {
36 PhoneGlobals app = PhoneGlobals.getInstance();
37 sImsPhoneSupported = true;
38 }
39
40 /**
Andrew Leea6bc3122015-01-29 14:47:34 -080041 * @return {@code true} if this device supports voice calls using the built-in SIP stack.
Etan Cohen0ca1c802014-07-07 15:35:48 -070042 */
43 static boolean isImsPhoneSupported() {
44 return sImsPhoneSupported;
Andrew Lee77527ac2014-10-21 16:57:39 -070045
46 }
Andrew Leea6bc3122015-01-29 14:47:34 -080047
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 Cohen0ca1c802014-07-07 15:35:48 -070069}