blob: ef1544caa015859a7c7be314ce45e698ff3d868c [file] [log] [blame]
Christine Chen03741c62013-10-23 16:17:03 -07001/*
2 * Copyright (C) 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 */
Gary Mai69c182a2016-12-05 13:07:03 -080016package com.android.contacts.util;
Christine Chen03741c62013-10-23 16:17:03 -070017
18import android.content.Context;
Christine Chen03741c62013-10-23 16:17:03 -070019import android.telephony.TelephonyManager;
Christine Chen03741c62013-10-23 16:17:03 -070020import android.util.Log;
21
22import java.util.Locale;
23
24/**
25 * This class provides several TelephonyManager util functions.
26 */
27public class TelephonyManagerUtils {
28
29 private static final String LOG_TAG = TelephonyManagerUtils.class.getSimpleName();
30
31 /**
32 * Gets the voicemail tag from Telephony Manager.
33 * @param context Current application context
34 * @return Voicemail tag, the alphabetic identifier associated with the voice mail number.
35 */
36 public static String getVoiceMailAlphaTag(Context context) {
37 final TelephonyManager telephonyManager =
38 (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
39 final String voiceMailLabel = telephonyManager.getVoiceMailAlphaTag();
40 return voiceMailLabel;
41 }
42
Christine Chen03741c62013-10-23 16:17:03 -070043 /**
44 * @return The ISO 3166-1 two letters country code of the country the user
45 * is in based on the network location. If the network location does not exist, fall
46 * back to the locale setting.
47 */
48 public static String getCurrentCountryIso(Context context, Locale locale) {
49 // Without framework function calls, this seems to be the most accurate location service
50 // we can rely on.
51 final TelephonyManager telephonyManager =
52 (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Yorke Leeba3c8392014-04-11 14:34:40 -070053 String countryIso = telephonyManager.getNetworkCountryIso().toUpperCase();
Christine Chen03741c62013-10-23 16:17:03 -070054
55 if (countryIso == null) {
56 countryIso = locale.getCountry();
57 Log.w(LOG_TAG, "No CountryDetector; falling back to countryIso based on locale: "
58 + countryIso);
59 }
60 return countryIso;
61 }
Andrew Leebf8600e2014-07-01 16:07:59 -070062
63 /**
64 * @param context Current application context.
65 * @return True if there is a subscription which supports video calls. False otherwise.
66 */
67 public static boolean hasVideoCallSubscription(Context context) {
68 // TODO: Check the telephony manager's subscriptions to see if any support video calls.
69 return true;
70 }
Christine Chen03741c62013-10-23 16:17:03 -070071}