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 | |
| 19 | import android.app.PendingIntent; |
| 20 | import android.content.Context; |
| 21 | import android.content.Intent; |
Andrew Lee | 77527ac | 2014-10-21 16:57:39 -0700 | [diff] [blame^] | 22 | import android.provider.Settings.SettingNotFoundException; |
| 23 | import android.util.Log; |
Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 24 | |
Andrew Lee | 77527ac | 2014-10-21 16:57:39 -0700 | [diff] [blame^] | 25 | import com.android.internal.telephony.Phone; |
Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 26 | import com.android.phone.PhoneGlobals; |
| 27 | |
| 28 | public class ImsUtil { |
Andrew Lee | 77527ac | 2014-10-21 16:57:39 -0700 | [diff] [blame^] | 29 | |
| 30 | private static final String TAG = ImsUtil.class.getSimpleName(); |
| 31 | private static boolean sImsPhoneSupported = false; |
| 32 | |
Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 33 | private ImsUtil() { |
| 34 | } |
| 35 | |
Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 36 | static { |
| 37 | PhoneGlobals app = PhoneGlobals.getInstance(); |
| 38 | sImsPhoneSupported = true; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @return true if this device supports voice calls using the built-in SIP stack. |
| 43 | */ |
| 44 | static boolean isImsPhoneSupported() { |
| 45 | return sImsPhoneSupported; |
Andrew Lee | 77527ac | 2014-10-21 16:57:39 -0700 | [diff] [blame^] | 46 | |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @see MobileNetworkSettings#setIMS |
| 51 | * @param context The context to get the content resolver from. |
| 52 | * @return Whether IMS is turned on by the user system setting. |
| 53 | */ |
| 54 | static boolean isImsEnabled(Context context) { |
| 55 | int value = 0; |
| 56 | try { |
| 57 | value = android.provider.Settings.Global.getInt( |
| 58 | context.getContentResolver(), |
| 59 | android.provider.Settings.Global.VOLTE_VT_ENABLED); |
| 60 | } catch (SettingNotFoundException e) { |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | switch (value) { |
| 65 | case 0: |
| 66 | return false; |
| 67 | case 1: |
| 68 | return true; |
| 69 | default: |
| 70 | Log.wtf(TAG,"Unexpected value for VOLTE_VT_ENABLED: " + value); |
| 71 | return false; |
| 72 | } |
Etan Cohen | 0ca1c80 | 2014-07-07 15:35:48 -0700 | [diff] [blame] | 73 | } |
| 74 | } |