Home | History | Annotate | Download | only in phone
      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 
     19 import android.content.Context;
     20 import android.util.Log;
     21 
     22 import com.android.ims.ImsConfig;
     23 import com.android.ims.ImsManager;
     24 import com.android.phone.PhoneGlobals;
     25 
     26 public class ImsUtil {
     27     private static final String LOG_TAG = ImsUtil.class.getSimpleName();
     28     private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
     29 
     30     private static boolean sImsPhoneSupported = false;
     31 
     32     private ImsUtil() {
     33     }
     34 
     35     static {
     36         PhoneGlobals app = PhoneGlobals.getInstance();
     37         sImsPhoneSupported = true;
     38     }
     39 
     40     /**
     41      * @return {@code true} if this device supports voice calls using the built-in SIP stack.
     42      */
     43     static boolean isImsPhoneSupported() {
     44         return sImsPhoneSupported;
     45 
     46     }
     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     }
     69 }
     70