Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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.voicemailomtp; |
| 18 | |
| 19 | import android.annotation.TargetApi; |
| 20 | import android.content.Context; |
| 21 | import android.os.Build.VERSION_CODES; |
| 22 | import android.os.PersistableBundle; |
| 23 | import android.telecom.PhoneAccount; |
| 24 | import android.telecom.PhoneAccountHandle; |
| 25 | import android.telephony.CarrierConfigManager; |
| 26 | import android.telephony.SubscriptionManager; |
| 27 | import android.telephony.TelephonyManager; |
| 28 | import java.lang.reflect.Method; |
| 29 | |
| 30 | /** |
| 31 | * Temporary stub for public APIs that should be added into telephony manager. |
| 32 | * |
| 33 | * <p>TODO(b/32637799) remove this. |
| 34 | */ |
| 35 | @TargetApi(VERSION_CODES.CUR_DEVELOPMENT) |
| 36 | public class TelephonyManagerStub { |
| 37 | |
| 38 | private static final String TAG = "TelephonyManagerStub"; |
| 39 | |
| 40 | public static void showVoicemailNotification(int voicemailCount) { |
| 41 | |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Dismisses the message waiting (voicemail) indicator. |
| 46 | * |
| 47 | * @param subId the subscription id we should dismiss the notification for. |
| 48 | */ |
| 49 | public static void clearMwiIndicator(int subId) { |
| 50 | |
| 51 | } |
| 52 | |
| 53 | public static void setShouldCheckVisualVoicemailConfigurationForMwi(int subId, |
| 54 | boolean enabled) { |
| 55 | |
| 56 | } |
| 57 | |
| 58 | public static int getSubIdForPhoneAccount(Context context, PhoneAccount phoneAccount) { |
| 59 | // Hidden |
| 60 | TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class); |
| 61 | try { |
| 62 | Method method = TelephonyManager.class |
| 63 | .getMethod("getSubIdForPhoneAccount", PhoneAccount.class); |
| 64 | return (int) method.invoke(telephonyManager, phoneAccount); |
| 65 | } catch (Exception e) { |
| 66 | VvmLog.e(TAG, "reflection call to getSubIdForPhoneAccount failed:", e); |
| 67 | } |
| 68 | return SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
| 69 | } |
| 70 | |
| 71 | public static String getNetworkSpecifierForPhoneAccountHandle(Context context, |
| 72 | PhoneAccountHandle phoneAccountHandle) { |
| 73 | return String.valueOf(SubscriptionManager.getDefaultDataSubscriptionId()); |
| 74 | } |
| 75 | |
| 76 | public static PersistableBundle getCarrirConfigForPhoneAccountHandle(Context context, |
| 77 | PhoneAccountHandle phoneAccountHandle) { |
| 78 | return context.getSystemService(CarrierConfigManager.class).getConfig(); |
| 79 | } |
| 80 | } |