Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 | |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 19 | import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY; |
| 20 | |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 21 | import android.Manifest.permission; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 22 | import android.app.AppOpsManager; |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 23 | import android.app.PendingIntent; |
Sailesh Nepal | bd76e4e | 2013-10-27 13:59:44 -0700 | [diff] [blame] | 24 | import android.content.ComponentName; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 25 | import android.content.Context; |
| 26 | import android.content.Intent; |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 27 | import android.content.SharedPreferences; |
Nathan Harold | 31d7ff3 | 2018-10-15 20:20:30 -0700 | [diff] [blame] | 28 | import android.content.pm.ApplicationInfo; |
Derek Tan | 740e167 | 2017-06-27 14:56:27 -0700 | [diff] [blame] | 29 | import android.content.pm.ComponentInfo; |
Amith Yamasani | 6e11887 | 2016-02-19 12:53:51 -0800 | [diff] [blame] | 30 | import android.content.pm.PackageInfo; |
Shishir Agrawal | 60f9c95 | 2014-06-23 12:00:43 -0700 | [diff] [blame] | 31 | import android.content.pm.PackageManager; |
Jack Yu | 84291ec | 2017-05-26 16:07:50 -0700 | [diff] [blame] | 32 | import android.net.NetworkStats; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 33 | import android.net.Uri; |
| 34 | import android.os.AsyncResult; |
| 35 | import android.os.Binder; |
| 36 | import android.os.Bundle; |
| 37 | import android.os.Handler; |
yinxu | 504e139 | 2017-04-12 16:03:22 -0700 | [diff] [blame] | 38 | import android.os.IBinder; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 39 | import android.os.Looper; |
| 40 | import android.os.Message; |
yinxu | 504e139 | 2017-04-12 16:03:22 -0700 | [diff] [blame] | 41 | import android.os.Messenger; |
Tyler Gunn | 65d45c2 | 2017-06-05 11:22:26 -0700 | [diff] [blame] | 42 | import android.os.PersistableBundle; |
Brad Ebinger | 5f64b05 | 2017-12-14 14:26:15 -0800 | [diff] [blame] | 43 | import android.os.RemoteException; |
Adam Lesinski | 903a54c | 2016-04-11 14:49:52 -0700 | [diff] [blame] | 44 | import android.os.ResultReceiver; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 45 | import android.os.ServiceManager; |
Brad Ebinger | dac2f00 | 2018-04-03 15:17:52 -0700 | [diff] [blame] | 46 | import android.os.ShellCallback; |
Pengquan Meng | 85728fb | 2018-03-12 16:31:21 -0700 | [diff] [blame] | 47 | import android.os.SystemProperties; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 48 | import android.os.UserHandle; |
Stuart Scott | 981d858 | 2015-04-21 14:09:50 -0700 | [diff] [blame] | 49 | import android.os.UserManager; |
Sooraj Sasindran | 9a90931 | 2016-07-18 11:57:25 -0700 | [diff] [blame] | 50 | import android.os.WorkSource; |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 51 | import android.preference.PreferenceManager; |
Ihab Awad | f2177b7 | 2013-11-25 13:33:23 -0800 | [diff] [blame] | 52 | import android.provider.Settings; |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 53 | import android.service.carrier.CarrierIdentifier; |
Santos Cordon | 7a1885b | 2015-02-03 11:15:19 -0800 | [diff] [blame] | 54 | import android.telecom.PhoneAccount; |
Nancy Chen | 31f9ba1 | 2016-01-06 11:42:12 -0800 | [diff] [blame] | 55 | import android.telecom.PhoneAccountHandle; |
Andrew Lee | 9431b83 | 2015-03-09 18:46:45 -0700 | [diff] [blame] | 56 | import android.telecom.TelecomManager; |
sqian | c5eccab | 2018-10-19 18:46:41 -0700 | [diff] [blame] | 57 | import android.telephony.emergency.EmergencyNumber; |
Junda Liu | 12f7d80 | 2015-05-01 12:06:44 -0700 | [diff] [blame] | 58 | import android.telephony.CarrierConfigManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 59 | import android.telephony.CellInfo; |
Nathan Harold | f180aac | 2018-06-01 18:43:55 -0700 | [diff] [blame] | 60 | import android.telephony.CellInfoGsm; |
| 61 | import android.telephony.CellInfoWcdma; |
Nathan Harold | 3ff8893 | 2018-08-14 10:19:49 -0700 | [diff] [blame] | 62 | import android.telephony.CellLocation; |
Sooraj Sasindran | 9a90931 | 2016-07-18 11:57:25 -0700 | [diff] [blame] | 63 | import android.telephony.ClientRequestStats; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 64 | import android.telephony.IccOpenLogicalChannelResponse; |
Hall Liu | 1aa510f | 2017-11-22 17:40:08 -0800 | [diff] [blame] | 65 | import android.telephony.LocationAccessPolicy; |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 66 | import android.telephony.ModemActivityInfo; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 67 | import android.telephony.NeighboringCellInfo; |
yinxu | 504e139 | 2017-04-12 16:03:22 -0700 | [diff] [blame] | 68 | import android.telephony.NetworkScanRequest; |
Wink Saville | 5d475dd | 2014-10-17 15:00:58 -0700 | [diff] [blame] | 69 | import android.telephony.RadioAccessFamily; |
Tyler Gunn | 65d45c2 | 2017-06-05 11:22:26 -0700 | [diff] [blame] | 70 | import android.telephony.Rlog; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 71 | import android.telephony.ServiceState; |
Nathan Harold | 46b42aa | 2017-03-10 19:38:22 -0800 | [diff] [blame] | 72 | import android.telephony.SignalStrength; |
Jack Yu | 84291ec | 2017-05-26 16:07:50 -0700 | [diff] [blame] | 73 | import android.telephony.SmsManager; |
Wink Saville | 0f3b5fc | 2014-11-11 08:40:49 -0800 | [diff] [blame] | 74 | import android.telephony.SubscriptionInfo; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 75 | import android.telephony.SubscriptionManager; |
Sanket Padawe | 99ef1e3 | 2016-05-18 16:12:33 -0700 | [diff] [blame] | 76 | import android.telephony.TelephonyHistogram; |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame] | 77 | import android.telephony.TelephonyManager; |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 78 | import android.telephony.UiccSlotInfo; |
Tyler Gunn | 65d45c2 | 2017-06-05 11:22:26 -0700 | [diff] [blame] | 79 | import android.telephony.UssdResponse; |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame] | 80 | import android.telephony.VisualVoicemailSmsFilterSettings; |
Nathan Harold | 3ff8893 | 2018-08-14 10:19:49 -0700 | [diff] [blame] | 81 | import android.telephony.cdma.CdmaCellLocation; |
| 82 | import android.telephony.gsm.GsmCellLocation; |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 83 | import android.telephony.ims.aidl.IImsCapabilityCallback; |
Brad Ebinger | 22bc3e4 | 2018-01-16 09:39:35 -0800 | [diff] [blame] | 84 | import android.telephony.ims.aidl.IImsConfig; |
| 85 | import android.telephony.ims.aidl.IImsMmTelFeature; |
| 86 | import android.telephony.ims.aidl.IImsRcsFeature; |
| 87 | import android.telephony.ims.aidl.IImsRegistration; |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 88 | import android.telephony.ims.aidl.IImsRegistrationCallback; |
Brad Ebinger | 1f2b508 | 2018-02-08 16:11:32 -0800 | [diff] [blame] | 89 | import android.telephony.ims.stub.ImsRegistrationImplBase; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 90 | import android.text.TextUtils; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 91 | import android.util.ArraySet; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 92 | import android.util.Log; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 93 | import android.util.Pair; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 94 | import android.util.Slog; |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 95 | |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 96 | import com.android.ims.ImsException; |
Andrew Lee | 312e817 | 2014-10-23 17:01:36 -0700 | [diff] [blame] | 97 | import com.android.ims.ImsManager; |
Brad Ebinger | 34bef92 | 2017-11-09 10:27:08 -0800 | [diff] [blame] | 98 | import com.android.ims.internal.IImsServiceFeatureCallback; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 99 | import com.android.internal.telephony.CallManager; |
Tyler Gunn | 52dcf77 | 2017-04-26 11:30:31 -0700 | [diff] [blame] | 100 | import com.android.internal.telephony.CallStateException; |
pkanwar | 79ec054 | 2017-07-31 14:10:01 -0700 | [diff] [blame] | 101 | import com.android.internal.telephony.CarrierInfoManager; |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 102 | import com.android.internal.telephony.CellNetworkScanResult; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 103 | import com.android.internal.telephony.CommandException; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 104 | import com.android.internal.telephony.DefaultPhoneNotifier; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 105 | import com.android.internal.telephony.ITelephony; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 106 | import com.android.internal.telephony.IccCard; |
Jack Yu | 5f7092c | 2018-04-13 14:05:37 -0700 | [diff] [blame] | 107 | import com.android.internal.telephony.LocaleTracker; |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 108 | import com.android.internal.telephony.MccTable; |
yinxu | b1bed74 | 2017-04-17 11:45:04 -0700 | [diff] [blame] | 109 | import com.android.internal.telephony.NetworkScanRequestTracker; |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 110 | import com.android.internal.telephony.OperatorInfo; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 111 | import com.android.internal.telephony.Phone; |
Malcolm Chen | 2c63d40 | 2018-08-14 16:00:53 -0700 | [diff] [blame] | 112 | import com.android.internal.telephony.PhoneConfigurationManager; |
Nathan Harold | a667c15 | 2016-12-14 11:27:20 -0800 | [diff] [blame] | 113 | import com.android.internal.telephony.PhoneConstantConversions; |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 114 | import com.android.internal.telephony.PhoneConstants; |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 115 | import com.android.internal.telephony.PhoneFactory; |
Wink Saville | 5d475dd | 2014-10-17 15:00:58 -0700 | [diff] [blame] | 116 | import com.android.internal.telephony.ProxyController; |
Sanket Padawe | 99ef1e3 | 2016-05-18 16:12:33 -0700 | [diff] [blame] | 117 | import com.android.internal.telephony.RIL; |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 118 | import com.android.internal.telephony.RILConstants; |
Jack Yu | 5f7092c | 2018-04-13 14:05:37 -0700 | [diff] [blame] | 119 | import com.android.internal.telephony.ServiceStateTracker; |
Makoto Onuki | da3bf79 | 2018-09-18 16:06:29 -0700 | [diff] [blame] | 120 | import com.android.internal.telephony.SmsApplication; |
| 121 | import com.android.internal.telephony.SmsApplication.SmsApplicationData; |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 122 | import com.android.internal.telephony.SubscriptionController; |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 123 | import com.android.internal.telephony.TelephonyPermissions; |
Derek Tan | 740e167 | 2017-06-27 14:56:27 -0700 | [diff] [blame] | 124 | import com.android.internal.telephony.euicc.EuiccConnector; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 125 | import com.android.internal.telephony.uicc.IccIoResult; |
| 126 | import com.android.internal.telephony.uicc.IccUtils; |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 127 | import com.android.internal.telephony.uicc.SIMRecords; |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 128 | import com.android.internal.telephony.uicc.UiccCard; |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 129 | import com.android.internal.telephony.uicc.UiccCardApplication; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 130 | import com.android.internal.telephony.uicc.UiccController; |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 131 | import com.android.internal.telephony.uicc.UiccProfile; |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 132 | import com.android.internal.telephony.uicc.UiccSlot; |
fionaxu | 7ed723d | 2017-05-30 18:58:54 -0700 | [diff] [blame] | 133 | import com.android.internal.telephony.util.VoicemailNotificationSettingsUtil; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 134 | import com.android.internal.util.HexDump; |
Ta-wei Yen | c9df043 | 2017-04-17 17:09:07 -0700 | [diff] [blame] | 135 | import com.android.phone.vvm.PhoneAccountHandleConverter; |
Ta-wei Yen | 527a9c0 | 2017-01-06 15:29:25 -0800 | [diff] [blame] | 136 | import com.android.phone.vvm.RemoteVvmTaskManager; |
Ta-wei Yen | c9df043 | 2017-04-17 17:09:07 -0700 | [diff] [blame] | 137 | import com.android.phone.vvm.VisualVoicemailSettingsUtil; |
Ta-wei Yen | c890531 | 2017-03-28 11:14:45 -0700 | [diff] [blame] | 138 | import com.android.phone.vvm.VisualVoicemailSmsFilterConfig; |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 139 | |
Ta-wei Yen | c236d6b | 2016-06-21 13:33:12 -0700 | [diff] [blame] | 140 | import java.io.FileDescriptor; |
| 141 | import java.io.PrintWriter; |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 142 | import java.nio.charset.StandardCharsets; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 143 | import java.util.ArrayList; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 144 | import java.util.Arrays; |
Makoto Onuki | da3bf79 | 2018-09-18 16:06:29 -0700 | [diff] [blame] | 145 | import java.util.Collection; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 146 | import java.util.List; |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 147 | import java.util.Locale; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 148 | import java.util.Map; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
| 151 | * Implementation of the ITelephony interface. |
| 152 | */ |
Santos Cordon | 117fee7 | 2014-05-16 17:56:12 -0700 | [diff] [blame] | 153 | public class PhoneInterfaceManager extends ITelephony.Stub { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 154 | private static final String LOG_TAG = "PhoneInterfaceManager"; |
| 155 | private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2); |
| 156 | private static final boolean DBG_LOC = false; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 157 | private static final boolean DBG_MERGE = false; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 158 | |
| 159 | // Message codes used with mMainThreadHandler |
| 160 | private static final int CMD_HANDLE_PIN_MMI = 1; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 161 | private static final int CMD_TRANSMIT_APDU_LOGICAL_CHANNEL = 7; |
| 162 | private static final int EVENT_TRANSMIT_APDU_LOGICAL_CHANNEL_DONE = 8; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 163 | private static final int CMD_OPEN_CHANNEL = 9; |
| 164 | private static final int EVENT_OPEN_CHANNEL_DONE = 10; |
| 165 | private static final int CMD_CLOSE_CHANNEL = 11; |
| 166 | private static final int EVENT_CLOSE_CHANNEL_DONE = 12; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 167 | private static final int CMD_NV_READ_ITEM = 13; |
| 168 | private static final int EVENT_NV_READ_ITEM_DONE = 14; |
| 169 | private static final int CMD_NV_WRITE_ITEM = 15; |
| 170 | private static final int EVENT_NV_WRITE_ITEM_DONE = 16; |
| 171 | private static final int CMD_NV_WRITE_CDMA_PRL = 17; |
| 172 | private static final int EVENT_NV_WRITE_CDMA_PRL_DONE = 18; |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 173 | private static final int CMD_RESET_MODEM_CONFIG = 19; |
| 174 | private static final int EVENT_RESET_MODEM_CONFIG_DONE = 20; |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 175 | private static final int CMD_GET_PREFERRED_NETWORK_TYPE = 21; |
| 176 | private static final int EVENT_GET_PREFERRED_NETWORK_TYPE_DONE = 22; |
| 177 | private static final int CMD_SET_PREFERRED_NETWORK_TYPE = 23; |
| 178 | private static final int EVENT_SET_PREFERRED_NETWORK_TYPE_DONE = 24; |
Sailesh Nepal | 35b5945 | 2014-03-06 09:26:56 -0800 | [diff] [blame] | 179 | private static final int CMD_SEND_ENVELOPE = 25; |
| 180 | private static final int EVENT_SEND_ENVELOPE_DONE = 26; |
Shuo Qian | 850e4d6a | 2018-04-25 21:02:08 +0000 | [diff] [blame] | 181 | private static final int CMD_INVOKE_OEM_RIL_REQUEST_RAW = 27; |
| 182 | private static final int EVENT_INVOKE_OEM_RIL_REQUEST_RAW_DONE = 28; |
Derek Tan | 6b088ee | 2014-09-05 14:15:18 -0700 | [diff] [blame] | 183 | private static final int CMD_TRANSMIT_APDU_BASIC_CHANNEL = 29; |
| 184 | private static final int EVENT_TRANSMIT_APDU_BASIC_CHANNEL_DONE = 30; |
| 185 | private static final int CMD_EXCHANGE_SIM_IO = 31; |
| 186 | private static final int EVENT_EXCHANGE_SIM_IO_DONE = 32; |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 187 | private static final int CMD_SET_VOICEMAIL_NUMBER = 33; |
| 188 | private static final int EVENT_SET_VOICEMAIL_NUMBER_DONE = 34; |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 189 | private static final int CMD_SET_NETWORK_SELECTION_MODE_AUTOMATIC = 35; |
| 190 | private static final int EVENT_SET_NETWORK_SELECTION_MODE_AUTOMATIC_DONE = 36; |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 191 | private static final int CMD_GET_MODEM_ACTIVITY_INFO = 37; |
| 192 | private static final int EVENT_GET_MODEM_ACTIVITY_INFO_DONE = 38; |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 193 | private static final int CMD_PERFORM_NETWORK_SCAN = 39; |
| 194 | private static final int EVENT_PERFORM_NETWORK_SCAN_DONE = 40; |
| 195 | private static final int CMD_SET_NETWORK_SELECTION_MODE_MANUAL = 41; |
| 196 | private static final int EVENT_SET_NETWORK_SELECTION_MODE_MANUAL_DONE = 42; |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 197 | private static final int CMD_SET_ALLOWED_CARRIERS = 43; |
| 198 | private static final int EVENT_SET_ALLOWED_CARRIERS_DONE = 44; |
| 199 | private static final int CMD_GET_ALLOWED_CARRIERS = 45; |
| 200 | private static final int EVENT_GET_ALLOWED_CARRIERS_DONE = 46; |
pkanwar | 32d516d | 2016-10-14 19:37:38 -0700 | [diff] [blame] | 201 | private static final int CMD_HANDLE_USSD_REQUEST = 47; |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 202 | private static final int CMD_GET_FORBIDDEN_PLMNS = 48; |
| 203 | private static final int EVENT_GET_FORBIDDEN_PLMNS_DONE = 49; |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 204 | private static final int CMD_SWITCH_SLOTS = 50; |
| 205 | private static final int EVENT_SWITCH_SLOTS_DONE = 51; |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 206 | private static final int CMD_GET_NETWORK_SELECTION_MODE = 52; |
| 207 | private static final int EVENT_GET_NETWORK_SELECTION_MODE_DONE = 53; |
| 208 | private static final int CMD_GET_CDMA_ROAMING_MODE = 54; |
| 209 | private static final int EVENT_GET_CDMA_ROAMING_MODE_DONE = 55; |
| 210 | private static final int CMD_SET_CDMA_ROAMING_MODE = 56; |
| 211 | private static final int EVENT_SET_CDMA_ROAMING_MODE_DONE = 57; |
| 212 | private static final int CMD_SET_CDMA_SUBSCRIPTION_MODE = 58; |
| 213 | private static final int EVENT_SET_CDMA_SUBSCRIPTION_MODE_DONE = 59; |
Nathan Harold | 3ff8893 | 2018-08-14 10:19:49 -0700 | [diff] [blame] | 214 | private static final int CMD_GET_ALL_CELL_INFO = 60; |
| 215 | private static final int EVENT_GET_ALL_CELL_INFO_DONE = 61; |
| 216 | private static final int CMD_GET_CELL_LOCATION = 62; |
| 217 | private static final int EVENT_GET_CELL_LOCATION_DONE = 63; |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 218 | private static final int CMD_MODEM_REBOOT = 64; |
| 219 | private static final int EVENT_CMD_MODEM_REBOOT_DONE = 65; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 220 | |
Holly Jiuyu Sun | 1cc2d55 | 2018-01-26 15:51:16 -0800 | [diff] [blame] | 221 | // Parameters of select command. |
| 222 | private static final int SELECT_COMMAND = 0xA4; |
| 223 | private static final int SELECT_P1 = 0x04; |
| 224 | private static final int SELECT_P2 = 0; |
| 225 | private static final int SELECT_P3 = 0x10; |
| 226 | |
Pengquan Meng | 85728fb | 2018-03-12 16:31:21 -0700 | [diff] [blame] | 227 | private static final String DEFAULT_NETWORK_MODE_PROPERTY_NAME = "ro.telephony.default_network"; |
| 228 | private static final String DEFAULT_DATA_ROAMING_PROPERTY_NAME = "ro.com.android.dataroaming"; |
| 229 | private static final String DEFAULT_MOBILE_DATA_PROPERTY_NAME = "ro.com.android.mobiledata"; |
| 230 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 231 | /** The singleton instance. */ |
| 232 | private static PhoneInterfaceManager sInstance; |
| 233 | |
Wink Saville | 3ab207e | 2014-11-20 13:07:20 -0800 | [diff] [blame] | 234 | private PhoneGlobals mApp; |
| 235 | private Phone mPhone; |
| 236 | private CallManager mCM; |
Stuart Scott | 981d858 | 2015-04-21 14:09:50 -0700 | [diff] [blame] | 237 | private UserManager mUserManager; |
Wink Saville | 3ab207e | 2014-11-20 13:07:20 -0800 | [diff] [blame] | 238 | private AppOpsManager mAppOps; |
| 239 | private MainThreadHandler mMainThreadHandler; |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 240 | private SubscriptionController mSubscriptionController; |
Wink Saville | 3ab207e | 2014-11-20 13:07:20 -0800 | [diff] [blame] | 241 | private SharedPreferences mTelephonySharedPreferences; |
Malcolm Chen | 2c63d40 | 2018-08-14 16:00:53 -0700 | [diff] [blame] | 242 | private PhoneConfigurationManager mPhoneConfigurationManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 243 | |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 244 | private static final String PREF_CARRIERS_ALPHATAG_PREFIX = "carrier_alphtag_"; |
| 245 | private static final String PREF_CARRIERS_NUMBER_PREFIX = "carrier_number_"; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 246 | private static final String PREF_CARRIERS_SUBSCRIBER_PREFIX = "carrier_subscriber_"; |
Derek Tan | 89e89d4 | 2014-07-08 17:00:10 -0700 | [diff] [blame] | 247 | |
Derek Tan | 740e167 | 2017-06-27 14:56:27 -0700 | [diff] [blame] | 248 | // The AID of ISD-R. |
| 249 | private static final String ISDR_AID = "A0000005591010FFFFFFFF8900000100"; |
| 250 | |
yinxu | b1bed74 | 2017-04-17 11:45:04 -0700 | [diff] [blame] | 251 | private NetworkScanRequestTracker mNetworkScanRequestTracker; |
| 252 | |
David Kelly | 5e06a7f | 2018-03-12 14:10:59 +0000 | [diff] [blame] | 253 | private static final int TYPE_ALLOCATION_CODE_LENGTH = 8; |
| 254 | private static final int MANUFACTURER_CODE_LENGTH = 8; |
| 255 | |
Derek Tan | 89e89d4 | 2014-07-08 17:00:10 -0700 | [diff] [blame] | 256 | /** |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 257 | * A request object to use for transmitting data to an ICC. |
| 258 | */ |
| 259 | private static final class IccAPDUArgument { |
| 260 | public int channel, cla, command, p1, p2, p3; |
| 261 | public String data; |
| 262 | |
| 263 | public IccAPDUArgument(int channel, int cla, int command, |
| 264 | int p1, int p2, int p3, String data) { |
| 265 | this.channel = channel; |
| 266 | this.cla = cla; |
| 267 | this.command = command; |
| 268 | this.p1 = p1; |
| 269 | this.p2 = p2; |
| 270 | this.p3 = p3; |
| 271 | this.data = data; |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | /** |
Shishir Agrawal | 77ba317 | 2015-09-10 14:50:19 -0700 | [diff] [blame] | 276 | * A request object to use for transmitting data to an ICC. |
| 277 | */ |
| 278 | private static final class ManualNetworkSelectionArgument { |
| 279 | public OperatorInfo operatorInfo; |
| 280 | public boolean persistSelection; |
| 281 | |
| 282 | public ManualNetworkSelectionArgument(OperatorInfo operatorInfo, boolean persistSelection) { |
| 283 | this.operatorInfo = operatorInfo; |
| 284 | this.persistSelection = persistSelection; |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 289 | * A request object for use with {@link MainThreadHandler}. Requesters should wait() on the |
| 290 | * request after sending. The main thread will notify the request when it is complete. |
| 291 | */ |
| 292 | private static final class MainThreadRequest { |
| 293 | /** The argument to use for the request */ |
| 294 | public Object argument; |
| 295 | /** The result of the request that is run on the main thread */ |
| 296 | public Object result; |
Sanket Padawe | 56e75a3 | 2016-02-08 12:18:19 -0800 | [diff] [blame] | 297 | // The subscriber id that this request applies to. Defaults to |
| 298 | // SubscriptionManager.INVALID_SUBSCRIPTION_ID |
| 299 | public Integer subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 300 | |
Nathan Harold | 92bed18 | 2018-10-12 18:16:49 -0700 | [diff] [blame] | 301 | // In cases where subId is unavailable, the caller needs to specify the phone. |
| 302 | public Phone phone; |
| 303 | |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 304 | public WorkSource workSource; |
| 305 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 306 | public MainThreadRequest(Object argument) { |
| 307 | this.argument = argument; |
| 308 | } |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 309 | |
Nathan Harold | 92bed18 | 2018-10-12 18:16:49 -0700 | [diff] [blame] | 310 | MainThreadRequest(Object argument, Phone phone, WorkSource workSource) { |
| 311 | this.argument = argument; |
| 312 | if (phone != null) { |
| 313 | this.phone = phone; |
| 314 | } |
| 315 | this.workSource = workSource; |
| 316 | } |
| 317 | |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 318 | MainThreadRequest(Object argument, Integer subId, WorkSource workSource) { |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 319 | this.argument = argument; |
Sanket Padawe | 56e75a3 | 2016-02-08 12:18:19 -0800 | [diff] [blame] | 320 | if (subId != null) { |
| 321 | this.subId = subId; |
| 322 | } |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 323 | this.workSource = workSource; |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 324 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Sailesh Nepal | cc0375f | 2013-11-13 09:15:18 -0800 | [diff] [blame] | 327 | private static final class IncomingThirdPartyCallArgs { |
| 328 | public final ComponentName component; |
| 329 | public final String callId; |
| 330 | public final String callerDisplayName; |
| 331 | |
| 332 | public IncomingThirdPartyCallArgs(ComponentName component, String callId, |
| 333 | String callerDisplayName) { |
| 334 | this.component = component; |
| 335 | this.callId = callId; |
| 336 | this.callerDisplayName = callerDisplayName; |
| 337 | } |
| 338 | } |
| 339 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 340 | /** |
| 341 | * A handler that processes messages on the main thread in the phone process. Since many |
| 342 | * of the Phone calls are not thread safe this is needed to shuttle the requests from the |
| 343 | * inbound binder threads to the main thread in the phone process. The Binder thread |
| 344 | * may provide a {@link MainThreadRequest} object in the msg.obj field that they are waiting |
| 345 | * on, which will be notified when the operation completes and will contain the result of the |
| 346 | * request. |
| 347 | * |
| 348 | * <p>If a MainThreadRequest object is provided in the msg.obj field, |
| 349 | * note that request.result must be set to something non-null for the calling thread to |
| 350 | * unblock. |
| 351 | */ |
| 352 | private final class MainThreadHandler extends Handler { |
| 353 | @Override |
| 354 | public void handleMessage(Message msg) { |
| 355 | MainThreadRequest request; |
| 356 | Message onCompleted; |
| 357 | AsyncResult ar; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 358 | UiccCard uiccCard; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 359 | IccAPDUArgument iccArgument; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 360 | |
| 361 | switch (msg.what) { |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 362 | case CMD_HANDLE_USSD_REQUEST: { |
| 363 | request = (MainThreadRequest) msg.obj; |
| 364 | final Phone phone = getPhoneFromRequest(request); |
| 365 | Pair<String, ResultReceiver> ussdObject = (Pair) request.argument; |
| 366 | String ussdRequest = ussdObject.first; |
| 367 | ResultReceiver wrappedCallback = ussdObject.second; |
Tyler Gunn | 65d45c2 | 2017-06-05 11:22:26 -0700 | [diff] [blame] | 368 | |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 369 | if (!isUssdApiAllowed(request.subId)) { |
| 370 | // Carrier does not support use of this API, return failure. |
| 371 | Rlog.w(LOG_TAG, "handleUssdRequest: carrier does not support USSD apis."); |
| 372 | UssdResponse response = new UssdResponse(ussdRequest, null); |
| 373 | Bundle returnData = new Bundle(); |
| 374 | returnData.putParcelable(TelephonyManager.USSD_RESPONSE, response); |
| 375 | wrappedCallback.send(TelephonyManager.USSD_RETURN_FAILURE, returnData); |
Tyler Gunn | 65d45c2 | 2017-06-05 11:22:26 -0700 | [diff] [blame] | 376 | |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 377 | request.result = true; |
| 378 | notifyRequester(request); |
| 379 | return; |
| 380 | } |
Tyler Gunn | 65d45c2 | 2017-06-05 11:22:26 -0700 | [diff] [blame] | 381 | |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 382 | try { |
| 383 | request.result = phone != null |
| 384 | ? phone.handleUssdRequest(ussdRequest, wrappedCallback) : false; |
| 385 | } catch (CallStateException cse) { |
| 386 | request.result = false; |
| 387 | } |
| 388 | // Wake up the requesting thread |
| 389 | notifyRequester(request); |
| 390 | break; |
pkanwar | 32d516d | 2016-10-14 19:37:38 -0700 | [diff] [blame] | 391 | } |
| 392 | |
Yorke Lee | 716f67e | 2015-06-17 15:39:16 -0700 | [diff] [blame] | 393 | case CMD_HANDLE_PIN_MMI: { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 394 | request = (MainThreadRequest) msg.obj; |
Yorke Lee | 716f67e | 2015-06-17 15:39:16 -0700 | [diff] [blame] | 395 | final Phone phone = getPhoneFromRequest(request); |
| 396 | request.result = phone != null ? |
| 397 | getPhoneFromRequest(request).handlePinMmi((String) request.argument) |
| 398 | : false; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 399 | // Wake up the requesting thread |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 400 | notifyRequester(request); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 401 | break; |
Yorke Lee | 716f67e | 2015-06-17 15:39:16 -0700 | [diff] [blame] | 402 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 403 | |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 404 | case CMD_TRANSMIT_APDU_LOGICAL_CHANNEL: |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 405 | request = (MainThreadRequest) msg.obj; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 406 | iccArgument = (IccAPDUArgument) request.argument; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 407 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 408 | if (uiccCard == null) { |
| 409 | loge("iccTransmitApduLogicalChannel: No UICC"); |
| 410 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 411 | notifyRequester(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 412 | } else { |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 413 | onCompleted = obtainMessage(EVENT_TRANSMIT_APDU_LOGICAL_CHANNEL_DONE, |
| 414 | request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 415 | uiccCard.iccTransmitApduLogicalChannel( |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 416 | iccArgument.channel, iccArgument.cla, iccArgument.command, |
| 417 | iccArgument.p1, iccArgument.p2, iccArgument.p3, iccArgument.data, |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 418 | onCompleted); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 419 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 420 | break; |
| 421 | |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 422 | case EVENT_TRANSMIT_APDU_LOGICAL_CHANNEL_DONE: |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 423 | ar = (AsyncResult) msg.obj; |
| 424 | request = (MainThreadRequest) ar.userObj; |
| 425 | if (ar.exception == null && ar.result != null) { |
| 426 | request.result = ar.result; |
| 427 | } else { |
| 428 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 429 | if (ar.result == null) { |
| 430 | loge("iccTransmitApduLogicalChannel: Empty response"); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 431 | } else if (ar.exception instanceof CommandException) { |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 432 | loge("iccTransmitApduLogicalChannel: CommandException: " + |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 433 | ar.exception); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 434 | } else { |
| 435 | loge("iccTransmitApduLogicalChannel: Unknown exception"); |
| 436 | } |
| 437 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 438 | notifyRequester(request); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 439 | break; |
| 440 | |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 441 | case CMD_TRANSMIT_APDU_BASIC_CHANNEL: |
| 442 | request = (MainThreadRequest) msg.obj; |
| 443 | iccArgument = (IccAPDUArgument) request.argument; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 444 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 445 | if (uiccCard == null) { |
| 446 | loge("iccTransmitApduBasicChannel: No UICC"); |
| 447 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 448 | notifyRequester(request); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 449 | } else { |
| 450 | onCompleted = obtainMessage(EVENT_TRANSMIT_APDU_BASIC_CHANNEL_DONE, |
| 451 | request); |
| 452 | uiccCard.iccTransmitApduBasicChannel( |
| 453 | iccArgument.cla, iccArgument.command, iccArgument.p1, iccArgument.p2, |
| 454 | iccArgument.p3, iccArgument.data, onCompleted); |
| 455 | } |
| 456 | break; |
| 457 | |
| 458 | case EVENT_TRANSMIT_APDU_BASIC_CHANNEL_DONE: |
| 459 | ar = (AsyncResult) msg.obj; |
| 460 | request = (MainThreadRequest) ar.userObj; |
| 461 | if (ar.exception == null && ar.result != null) { |
| 462 | request.result = ar.result; |
| 463 | } else { |
| 464 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 465 | if (ar.result == null) { |
| 466 | loge("iccTransmitApduBasicChannel: Empty response"); |
| 467 | } else if (ar.exception instanceof CommandException) { |
| 468 | loge("iccTransmitApduBasicChannel: CommandException: " + |
| 469 | ar.exception); |
| 470 | } else { |
| 471 | loge("iccTransmitApduBasicChannel: Unknown exception"); |
| 472 | } |
| 473 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 474 | notifyRequester(request); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 475 | break; |
| 476 | |
| 477 | case CMD_EXCHANGE_SIM_IO: |
| 478 | request = (MainThreadRequest) msg.obj; |
| 479 | iccArgument = (IccAPDUArgument) request.argument; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 480 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 481 | if (uiccCard == null) { |
| 482 | loge("iccExchangeSimIO: No UICC"); |
| 483 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 484 | notifyRequester(request); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 485 | } else { |
| 486 | onCompleted = obtainMessage(EVENT_EXCHANGE_SIM_IO_DONE, |
| 487 | request); |
| 488 | uiccCard.iccExchangeSimIO(iccArgument.cla, /* fileID */ |
| 489 | iccArgument.command, iccArgument.p1, iccArgument.p2, iccArgument.p3, |
| 490 | iccArgument.data, onCompleted); |
| 491 | } |
| 492 | break; |
| 493 | |
| 494 | case EVENT_EXCHANGE_SIM_IO_DONE: |
| 495 | ar = (AsyncResult) msg.obj; |
| 496 | request = (MainThreadRequest) ar.userObj; |
| 497 | if (ar.exception == null && ar.result != null) { |
| 498 | request.result = ar.result; |
| 499 | } else { |
| 500 | request.result = new IccIoResult(0x6f, 0, (byte[])null); |
| 501 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 502 | notifyRequester(request); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 503 | break; |
| 504 | |
Derek Tan | 4d5e5c1 | 2014-02-04 11:54:58 -0800 | [diff] [blame] | 505 | case CMD_SEND_ENVELOPE: |
| 506 | request = (MainThreadRequest) msg.obj; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 507 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 508 | if (uiccCard == null) { |
| 509 | loge("sendEnvelopeWithStatus: No UICC"); |
| 510 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 511 | notifyRequester(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 512 | } else { |
| 513 | onCompleted = obtainMessage(EVENT_SEND_ENVELOPE_DONE, request); |
| 514 | uiccCard.sendEnvelopeWithStatus((String)request.argument, onCompleted); |
| 515 | } |
Derek Tan | 4d5e5c1 | 2014-02-04 11:54:58 -0800 | [diff] [blame] | 516 | break; |
| 517 | |
| 518 | case EVENT_SEND_ENVELOPE_DONE: |
| 519 | ar = (AsyncResult) msg.obj; |
| 520 | request = (MainThreadRequest) ar.userObj; |
Shishir Agrawal | 9f9877d | 2014-03-14 09:36:27 -0700 | [diff] [blame] | 521 | if (ar.exception == null && ar.result != null) { |
| 522 | request.result = ar.result; |
Derek Tan | 4d5e5c1 | 2014-02-04 11:54:58 -0800 | [diff] [blame] | 523 | } else { |
Shishir Agrawal | 9f9877d | 2014-03-14 09:36:27 -0700 | [diff] [blame] | 524 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 525 | if (ar.result == null) { |
| 526 | loge("sendEnvelopeWithStatus: Empty response"); |
| 527 | } else if (ar.exception instanceof CommandException) { |
| 528 | loge("sendEnvelopeWithStatus: CommandException: " + |
| 529 | ar.exception); |
| 530 | } else { |
| 531 | loge("sendEnvelopeWithStatus: exception:" + ar.exception); |
| 532 | } |
Derek Tan | 4d5e5c1 | 2014-02-04 11:54:58 -0800 | [diff] [blame] | 533 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 534 | notifyRequester(request); |
Derek Tan | 4d5e5c1 | 2014-02-04 11:54:58 -0800 | [diff] [blame] | 535 | break; |
| 536 | |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 537 | case CMD_OPEN_CHANNEL: |
| 538 | request = (MainThreadRequest) msg.obj; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 539 | uiccCard = getUiccCardFromRequest(request); |
Ajay Nambi | d7454d3 | 2015-12-03 13:50:00 -0800 | [diff] [blame] | 540 | Pair<String, Integer> openChannelArgs = (Pair<String, Integer>) request.argument; |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 541 | if (uiccCard == null) { |
| 542 | loge("iccOpenLogicalChannel: No UICC"); |
Shishir Agrawal | fc0492a | 2016-02-17 11:15:33 -0800 | [diff] [blame] | 543 | request.result = new IccOpenLogicalChannelResponse(-1, |
| 544 | IccOpenLogicalChannelResponse.STATUS_MISSING_RESOURCE, null); |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 545 | notifyRequester(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 546 | } else { |
| 547 | onCompleted = obtainMessage(EVENT_OPEN_CHANNEL_DONE, request); |
Ajay Nambi | d7454d3 | 2015-12-03 13:50:00 -0800 | [diff] [blame] | 548 | uiccCard.iccOpenLogicalChannel(openChannelArgs.first, |
| 549 | openChannelArgs.second, onCompleted); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 550 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 551 | break; |
| 552 | |
| 553 | case EVENT_OPEN_CHANNEL_DONE: |
| 554 | ar = (AsyncResult) msg.obj; |
| 555 | request = (MainThreadRequest) ar.userObj; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 556 | IccOpenLogicalChannelResponse openChannelResp; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 557 | if (ar.exception == null && ar.result != null) { |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 558 | int[] result = (int[]) ar.result; |
| 559 | int channelId = result[0]; |
| 560 | byte[] selectResponse = null; |
| 561 | if (result.length > 1) { |
| 562 | selectResponse = new byte[result.length - 1]; |
| 563 | for (int i = 1; i < result.length; ++i) { |
| 564 | selectResponse[i - 1] = (byte) result[i]; |
| 565 | } |
| 566 | } |
| 567 | openChannelResp = new IccOpenLogicalChannelResponse(channelId, |
Shishir Agrawal | 527e8bf | 2014-08-25 08:54:56 -0700 | [diff] [blame] | 568 | IccOpenLogicalChannelResponse.STATUS_NO_ERROR, selectResponse); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 569 | } else { |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 570 | if (ar.result == null) { |
| 571 | loge("iccOpenLogicalChannel: Empty response"); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 572 | } |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 573 | if (ar.exception != null) { |
| 574 | loge("iccOpenLogicalChannel: Exception: " + ar.exception); |
| 575 | } |
| 576 | |
Shishir Agrawal | 527e8bf | 2014-08-25 08:54:56 -0700 | [diff] [blame] | 577 | int errorCode = IccOpenLogicalChannelResponse.STATUS_UNKNOWN_ERROR; |
Junda Liu | a754ba1 | 2015-05-20 01:17:52 -0700 | [diff] [blame] | 578 | if (ar.exception instanceof CommandException) { |
| 579 | CommandException.Error error = |
| 580 | ((CommandException) (ar.exception)).getCommandError(); |
| 581 | if (error == CommandException.Error.MISSING_RESOURCE) { |
Shishir Agrawal | 527e8bf | 2014-08-25 08:54:56 -0700 | [diff] [blame] | 582 | errorCode = IccOpenLogicalChannelResponse.STATUS_MISSING_RESOURCE; |
Junda Liu | a754ba1 | 2015-05-20 01:17:52 -0700 | [diff] [blame] | 583 | } else if (error == CommandException.Error.NO_SUCH_ELEMENT) { |
Shishir Agrawal | 527e8bf | 2014-08-25 08:54:56 -0700 | [diff] [blame] | 584 | errorCode = IccOpenLogicalChannelResponse.STATUS_NO_SUCH_ELEMENT; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 585 | } |
| 586 | } |
| 587 | openChannelResp = new IccOpenLogicalChannelResponse( |
| 588 | IccOpenLogicalChannelResponse.INVALID_CHANNEL, errorCode, null); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 589 | } |
Shishir Agrawal | 82c8a46 | 2014-07-31 18:13:17 -0700 | [diff] [blame] | 590 | request.result = openChannelResp; |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 591 | notifyRequester(request); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 592 | break; |
| 593 | |
| 594 | case CMD_CLOSE_CHANNEL: |
| 595 | request = (MainThreadRequest) msg.obj; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 596 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 597 | if (uiccCard == null) { |
| 598 | loge("iccCloseLogicalChannel: No UICC"); |
Yoshiaki Naka | 2e29d82 | 2016-09-02 19:27:39 +0900 | [diff] [blame] | 599 | request.result = false; |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 600 | notifyRequester(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 601 | } else { |
| 602 | onCompleted = obtainMessage(EVENT_CLOSE_CHANNEL_DONE, request); |
| 603 | uiccCard.iccCloseLogicalChannel((Integer) request.argument, onCompleted); |
| 604 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 605 | break; |
| 606 | |
| 607 | case EVENT_CLOSE_CHANNEL_DONE: |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 608 | handleNullReturnEvent(msg, "iccCloseLogicalChannel"); |
| 609 | break; |
| 610 | |
| 611 | case CMD_NV_READ_ITEM: |
| 612 | request = (MainThreadRequest) msg.obj; |
| 613 | onCompleted = obtainMessage(EVENT_NV_READ_ITEM_DONE, request); |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 614 | mPhone.nvReadItem((Integer) request.argument, onCompleted, request.workSource); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 615 | break; |
| 616 | |
| 617 | case EVENT_NV_READ_ITEM_DONE: |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 618 | ar = (AsyncResult) msg.obj; |
| 619 | request = (MainThreadRequest) ar.userObj; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 620 | if (ar.exception == null && ar.result != null) { |
| 621 | request.result = ar.result; // String |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 622 | } else { |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 623 | request.result = ""; |
| 624 | if (ar.result == null) { |
| 625 | loge("nvReadItem: Empty response"); |
| 626 | } else if (ar.exception instanceof CommandException) { |
| 627 | loge("nvReadItem: CommandException: " + |
| 628 | ar.exception); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 629 | } else { |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 630 | loge("nvReadItem: Unknown exception"); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 631 | } |
| 632 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 633 | notifyRequester(request); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 634 | break; |
| 635 | |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 636 | case CMD_NV_WRITE_ITEM: |
| 637 | request = (MainThreadRequest) msg.obj; |
| 638 | onCompleted = obtainMessage(EVENT_NV_WRITE_ITEM_DONE, request); |
| 639 | Pair<Integer, String> idValue = (Pair<Integer, String>) request.argument; |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 640 | mPhone.nvWriteItem(idValue.first, idValue.second, onCompleted, |
| 641 | request.workSource); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 642 | break; |
| 643 | |
| 644 | case EVENT_NV_WRITE_ITEM_DONE: |
| 645 | handleNullReturnEvent(msg, "nvWriteItem"); |
| 646 | break; |
| 647 | |
| 648 | case CMD_NV_WRITE_CDMA_PRL: |
| 649 | request = (MainThreadRequest) msg.obj; |
| 650 | onCompleted = obtainMessage(EVENT_NV_WRITE_CDMA_PRL_DONE, request); |
| 651 | mPhone.nvWriteCdmaPrl((byte[]) request.argument, onCompleted); |
| 652 | break; |
| 653 | |
| 654 | case EVENT_NV_WRITE_CDMA_PRL_DONE: |
| 655 | handleNullReturnEvent(msg, "nvWriteCdmaPrl"); |
| 656 | break; |
| 657 | |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 658 | case CMD_RESET_MODEM_CONFIG: |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 659 | request = (MainThreadRequest) msg.obj; |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 660 | onCompleted = obtainMessage(EVENT_RESET_MODEM_CONFIG_DONE, request); |
| 661 | mPhone.resetModemConfig(onCompleted); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 662 | break; |
| 663 | |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 664 | case EVENT_RESET_MODEM_CONFIG_DONE: |
| 665 | handleNullReturnEvent(msg, "resetModemConfig"); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 666 | break; |
| 667 | |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 668 | case CMD_GET_PREFERRED_NETWORK_TYPE: |
| 669 | request = (MainThreadRequest) msg.obj; |
| 670 | onCompleted = obtainMessage(EVENT_GET_PREFERRED_NETWORK_TYPE_DONE, request); |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 671 | getPhoneFromRequest(request).getPreferredNetworkType(onCompleted); |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 672 | break; |
| 673 | |
| 674 | case EVENT_GET_PREFERRED_NETWORK_TYPE_DONE: |
| 675 | ar = (AsyncResult) msg.obj; |
| 676 | request = (MainThreadRequest) ar.userObj; |
| 677 | if (ar.exception == null && ar.result != null) { |
| 678 | request.result = ar.result; // Integer |
| 679 | } else { |
Sanket Padawe | cfc2d35 | 2016-01-05 19:52:14 -0800 | [diff] [blame] | 680 | request.result = null; |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 681 | if (ar.result == null) { |
| 682 | loge("getPreferredNetworkType: Empty response"); |
| 683 | } else if (ar.exception instanceof CommandException) { |
| 684 | loge("getPreferredNetworkType: CommandException: " + |
| 685 | ar.exception); |
| 686 | } else { |
| 687 | loge("getPreferredNetworkType: Unknown exception"); |
| 688 | } |
| 689 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 690 | notifyRequester(request); |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 691 | break; |
| 692 | |
| 693 | case CMD_SET_PREFERRED_NETWORK_TYPE: |
| 694 | request = (MainThreadRequest) msg.obj; |
| 695 | onCompleted = obtainMessage(EVENT_SET_PREFERRED_NETWORK_TYPE_DONE, request); |
| 696 | int networkType = (Integer) request.argument; |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 697 | getPhoneFromRequest(request).setPreferredNetworkType(networkType, onCompleted); |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 698 | break; |
| 699 | |
| 700 | case EVENT_SET_PREFERRED_NETWORK_TYPE_DONE: |
| 701 | handleNullReturnEvent(msg, "setPreferredNetworkType"); |
| 702 | break; |
| 703 | |
Shuo Qian | 850e4d6a | 2018-04-25 21:02:08 +0000 | [diff] [blame] | 704 | case CMD_INVOKE_OEM_RIL_REQUEST_RAW: |
| 705 | request = (MainThreadRequest)msg.obj; |
| 706 | onCompleted = obtainMessage(EVENT_INVOKE_OEM_RIL_REQUEST_RAW_DONE, request); |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 707 | mPhone.invokeOemRilRequestRaw((byte[]) request.argument, onCompleted); |
Shuo Qian | 850e4d6a | 2018-04-25 21:02:08 +0000 | [diff] [blame] | 708 | break; |
| 709 | |
| 710 | case EVENT_INVOKE_OEM_RIL_REQUEST_RAW_DONE: |
| 711 | ar = (AsyncResult)msg.obj; |
| 712 | request = (MainThreadRequest)ar.userObj; |
| 713 | request.result = ar; |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 714 | notifyRequester(request); |
Shuo Qian | 850e4d6a | 2018-04-25 21:02:08 +0000 | [diff] [blame] | 715 | break; |
| 716 | |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 717 | case CMD_SET_VOICEMAIL_NUMBER: |
| 718 | request = (MainThreadRequest) msg.obj; |
| 719 | onCompleted = obtainMessage(EVENT_SET_VOICEMAIL_NUMBER_DONE, request); |
| 720 | Pair<String, String> tagNum = (Pair<String, String>) request.argument; |
Stuart Scott | 584921c | 2015-01-15 17:10:34 -0800 | [diff] [blame] | 721 | getPhoneFromRequest(request).setVoiceMailNumber(tagNum.first, tagNum.second, |
| 722 | onCompleted); |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 723 | break; |
| 724 | |
| 725 | case EVENT_SET_VOICEMAIL_NUMBER_DONE: |
| 726 | handleNullReturnEvent(msg, "setVoicemailNumber"); |
| 727 | break; |
| 728 | |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 729 | case CMD_SET_NETWORK_SELECTION_MODE_AUTOMATIC: |
| 730 | request = (MainThreadRequest) msg.obj; |
| 731 | onCompleted = obtainMessage(EVENT_SET_NETWORK_SELECTION_MODE_AUTOMATIC_DONE, |
| 732 | request); |
| 733 | getPhoneFromRequest(request).setNetworkSelectionModeAutomatic(onCompleted); |
| 734 | break; |
| 735 | |
| 736 | case EVENT_SET_NETWORK_SELECTION_MODE_AUTOMATIC_DONE: |
| 737 | handleNullReturnEvent(msg, "setNetworkSelectionModeAutomatic"); |
| 738 | break; |
| 739 | |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 740 | case CMD_PERFORM_NETWORK_SCAN: |
| 741 | request = (MainThreadRequest) msg.obj; |
| 742 | onCompleted = obtainMessage(EVENT_PERFORM_NETWORK_SCAN_DONE, request); |
| 743 | getPhoneFromRequest(request).getAvailableNetworks(onCompleted); |
| 744 | break; |
| 745 | |
| 746 | case EVENT_PERFORM_NETWORK_SCAN_DONE: |
| 747 | ar = (AsyncResult) msg.obj; |
| 748 | request = (MainThreadRequest) ar.userObj; |
| 749 | CellNetworkScanResult cellScanResult; |
| 750 | if (ar.exception == null && ar.result != null) { |
| 751 | cellScanResult = new CellNetworkScanResult( |
| 752 | CellNetworkScanResult.STATUS_SUCCESS, |
| 753 | (List<OperatorInfo>) ar.result); |
| 754 | } else { |
| 755 | if (ar.result == null) { |
| 756 | loge("getCellNetworkScanResults: Empty response"); |
| 757 | } |
| 758 | if (ar.exception != null) { |
| 759 | loge("getCellNetworkScanResults: Exception: " + ar.exception); |
| 760 | } |
| 761 | int errorCode = CellNetworkScanResult.STATUS_UNKNOWN_ERROR; |
| 762 | if (ar.exception instanceof CommandException) { |
| 763 | CommandException.Error error = |
| 764 | ((CommandException) (ar.exception)).getCommandError(); |
| 765 | if (error == CommandException.Error.RADIO_NOT_AVAILABLE) { |
| 766 | errorCode = CellNetworkScanResult.STATUS_RADIO_NOT_AVAILABLE; |
| 767 | } else if (error == CommandException.Error.GENERIC_FAILURE) { |
| 768 | errorCode = CellNetworkScanResult.STATUS_RADIO_GENERIC_FAILURE; |
| 769 | } |
| 770 | } |
| 771 | cellScanResult = new CellNetworkScanResult(errorCode, null); |
| 772 | } |
| 773 | request.result = cellScanResult; |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 774 | notifyRequester(request); |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 775 | break; |
| 776 | |
| 777 | case CMD_SET_NETWORK_SELECTION_MODE_MANUAL: |
| 778 | request = (MainThreadRequest) msg.obj; |
Shishir Agrawal | 77ba317 | 2015-09-10 14:50:19 -0700 | [diff] [blame] | 779 | ManualNetworkSelectionArgument selArg = |
| 780 | (ManualNetworkSelectionArgument) request.argument; |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 781 | onCompleted = obtainMessage(EVENT_SET_NETWORK_SELECTION_MODE_MANUAL_DONE, |
| 782 | request); |
Shishir Agrawal | 77ba317 | 2015-09-10 14:50:19 -0700 | [diff] [blame] | 783 | getPhoneFromRequest(request).selectNetworkManually(selArg.operatorInfo, |
| 784 | selArg.persistSelection, onCompleted); |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 785 | break; |
| 786 | |
| 787 | case EVENT_SET_NETWORK_SELECTION_MODE_MANUAL_DONE: |
Pengquan Meng | e3d01e2 | 2018-09-20 15:25:35 -0700 | [diff] [blame] | 788 | ar = (AsyncResult) msg.obj; |
| 789 | request = (MainThreadRequest) ar.userObj; |
| 790 | if (ar.exception == null) { |
| 791 | request.result = true; |
| 792 | } else { |
| 793 | request.result = false; |
| 794 | loge("setNetworkSelectionModeManual " + ar.exception); |
| 795 | } |
| 796 | notifyRequester(request); |
| 797 | mApp.onNetworkSelectionChanged(request.subId); |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 798 | break; |
| 799 | |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 800 | case CMD_GET_MODEM_ACTIVITY_INFO: |
| 801 | request = (MainThreadRequest) msg.obj; |
| 802 | onCompleted = obtainMessage(EVENT_GET_MODEM_ACTIVITY_INFO_DONE, request); |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 803 | mPhone.getModemActivityInfo(onCompleted, request.workSource); |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 804 | break; |
| 805 | |
| 806 | case EVENT_GET_MODEM_ACTIVITY_INFO_DONE: |
| 807 | ar = (AsyncResult) msg.obj; |
| 808 | request = (MainThreadRequest) ar.userObj; |
| 809 | if (ar.exception == null && ar.result != null) { |
| 810 | request.result = ar.result; |
| 811 | } else { |
| 812 | if (ar.result == null) { |
| 813 | loge("queryModemActivityInfo: Empty response"); |
| 814 | } else if (ar.exception instanceof CommandException) { |
| 815 | loge("queryModemActivityInfo: CommandException: " + |
| 816 | ar.exception); |
| 817 | } else { |
| 818 | loge("queryModemActivityInfo: Unknown exception"); |
| 819 | } |
| 820 | } |
Amit Mahajan | d476622 | 2016-01-28 15:28:28 -0800 | [diff] [blame] | 821 | // Result cannot be null. Return ModemActivityInfo with all fields set to 0. |
| 822 | if (request.result == null) { |
| 823 | request.result = new ModemActivityInfo(0, 0, 0, null, 0, 0); |
| 824 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 825 | notifyRequester(request); |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 826 | break; |
| 827 | |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 828 | case CMD_SET_ALLOWED_CARRIERS: |
| 829 | request = (MainThreadRequest) msg.obj; |
| 830 | onCompleted = obtainMessage(EVENT_SET_ALLOWED_CARRIERS_DONE, request); |
| 831 | mPhone.setAllowedCarriers( |
| 832 | (List<CarrierIdentifier>) request.argument, |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 833 | onCompleted, request.workSource); |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 834 | break; |
| 835 | |
| 836 | case EVENT_SET_ALLOWED_CARRIERS_DONE: |
| 837 | ar = (AsyncResult) msg.obj; |
| 838 | request = (MainThreadRequest) ar.userObj; |
| 839 | if (ar.exception == null && ar.result != null) { |
| 840 | request.result = ar.result; |
| 841 | } else { |
| 842 | if (ar.result == null) { |
| 843 | loge("setAllowedCarriers: Empty response"); |
| 844 | } else if (ar.exception instanceof CommandException) { |
| 845 | loge("setAllowedCarriers: CommandException: " + |
| 846 | ar.exception); |
| 847 | } else { |
| 848 | loge("setAllowedCarriers: Unknown exception"); |
| 849 | } |
| 850 | } |
| 851 | // Result cannot be null. Return -1 on error. |
| 852 | if (request.result == null) { |
| 853 | request.result = new int[]{-1}; |
| 854 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 855 | notifyRequester(request); |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 856 | break; |
| 857 | |
| 858 | case CMD_GET_ALLOWED_CARRIERS: |
| 859 | request = (MainThreadRequest) msg.obj; |
| 860 | onCompleted = obtainMessage(EVENT_GET_ALLOWED_CARRIERS_DONE, request); |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 861 | mPhone.getAllowedCarriers(onCompleted, request.workSource); |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 862 | break; |
| 863 | |
| 864 | case EVENT_GET_ALLOWED_CARRIERS_DONE: |
| 865 | ar = (AsyncResult) msg.obj; |
| 866 | request = (MainThreadRequest) ar.userObj; |
| 867 | if (ar.exception == null && ar.result != null) { |
| 868 | request.result = ar.result; |
| 869 | } else { |
| 870 | if (ar.result == null) { |
| 871 | loge("getAllowedCarriers: Empty response"); |
| 872 | } else if (ar.exception instanceof CommandException) { |
| 873 | loge("getAllowedCarriers: CommandException: " + |
| 874 | ar.exception); |
| 875 | } else { |
| 876 | loge("getAllowedCarriers: Unknown exception"); |
| 877 | } |
| 878 | } |
| 879 | // Result cannot be null. Return empty list of CarrierIdentifier. |
| 880 | if (request.result == null) { |
| 881 | request.result = new ArrayList<CarrierIdentifier>(0); |
| 882 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 883 | notifyRequester(request); |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 884 | break; |
| 885 | |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 886 | case EVENT_GET_FORBIDDEN_PLMNS_DONE: |
| 887 | ar = (AsyncResult) msg.obj; |
| 888 | request = (MainThreadRequest) ar.userObj; |
| 889 | if (ar.exception == null && ar.result != null) { |
| 890 | request.result = ar.result; |
| 891 | } else { |
| 892 | request.result = new IllegalArgumentException( |
| 893 | "Failed to retrieve Forbidden Plmns"); |
| 894 | if (ar.result == null) { |
| 895 | loge("getForbiddenPlmns: Empty response"); |
| 896 | } else { |
| 897 | loge("getForbiddenPlmns: Unknown exception"); |
| 898 | } |
| 899 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 900 | notifyRequester(request); |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 901 | break; |
| 902 | |
| 903 | case CMD_GET_FORBIDDEN_PLMNS: |
| 904 | request = (MainThreadRequest) msg.obj; |
| 905 | uiccCard = getUiccCardFromRequest(request); |
| 906 | if (uiccCard == null) { |
| 907 | loge("getForbiddenPlmns() UiccCard is null"); |
| 908 | request.result = new IllegalArgumentException( |
| 909 | "getForbiddenPlmns() UiccCard is null"); |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 910 | notifyRequester(request); |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 911 | break; |
| 912 | } |
| 913 | Integer appType = (Integer) request.argument; |
| 914 | UiccCardApplication uiccApp = uiccCard.getApplicationByType(appType); |
| 915 | if (uiccApp == null) { |
| 916 | loge("getForbiddenPlmns() no app with specified type -- " |
| 917 | + appType); |
| 918 | request.result = new IllegalArgumentException("Failed to get UICC App"); |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 919 | notifyRequester(request); |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 920 | break; |
| 921 | } else { |
| 922 | if (DBG) logv("getForbiddenPlmns() found app " + uiccApp.getAid() |
| 923 | + " specified type -- " + appType); |
| 924 | } |
| 925 | onCompleted = obtainMessage(EVENT_GET_FORBIDDEN_PLMNS_DONE, request); |
| 926 | ((SIMRecords) uiccApp.getIccRecords()).getForbiddenPlmns( |
| 927 | onCompleted); |
| 928 | break; |
| 929 | |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 930 | case CMD_SWITCH_SLOTS: |
| 931 | request = (MainThreadRequest) msg.obj; |
| 932 | int[] physicalSlots = (int[]) request.argument; |
| 933 | onCompleted = obtainMessage(EVENT_SWITCH_SLOTS_DONE, request); |
| 934 | UiccController.getInstance().switchSlots(physicalSlots, onCompleted); |
| 935 | break; |
| 936 | |
| 937 | case EVENT_SWITCH_SLOTS_DONE: |
| 938 | ar = (AsyncResult) msg.obj; |
| 939 | request = (MainThreadRequest) ar.userObj; |
| 940 | request.result = (ar.exception == null); |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 941 | notifyRequester(request); |
| 942 | break; |
| 943 | case CMD_GET_NETWORK_SELECTION_MODE: |
| 944 | request = (MainThreadRequest) msg.obj; |
| 945 | onCompleted = obtainMessage(EVENT_GET_NETWORK_SELECTION_MODE_DONE, request); |
| 946 | getPhoneFromRequest(request).getNetworkSelectionMode(onCompleted); |
| 947 | break; |
| 948 | |
| 949 | case EVENT_GET_NETWORK_SELECTION_MODE_DONE: |
| 950 | ar = (AsyncResult) msg.obj; |
| 951 | request = (MainThreadRequest) ar.userObj; |
| 952 | if (ar.exception != null) { |
| 953 | request.result = TelephonyManager.NETWORK_SELECTION_MODE_UNKNOWN; |
| 954 | } else { |
| 955 | int mode = ((int[]) ar.result)[0]; |
| 956 | if (mode == 0) { |
| 957 | request.result = TelephonyManager.NETWORK_SELECTION_MODE_AUTO; |
| 958 | } else { |
| 959 | request.result = TelephonyManager.NETWORK_SELECTION_MODE_MANUAL; |
| 960 | } |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 961 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 962 | notifyRequester(request); |
| 963 | break; |
| 964 | case CMD_GET_CDMA_ROAMING_MODE: |
| 965 | request = (MainThreadRequest) msg.obj; |
| 966 | onCompleted = obtainMessage(EVENT_GET_CDMA_ROAMING_MODE_DONE, request); |
| 967 | getPhoneFromRequest(request).queryCdmaRoamingPreference(onCompleted); |
| 968 | break; |
| 969 | case EVENT_GET_CDMA_ROAMING_MODE_DONE: |
| 970 | ar = (AsyncResult) msg.obj; |
| 971 | request = (MainThreadRequest) ar.userObj; |
| 972 | if (ar.exception != null) { |
| 973 | request.result = TelephonyManager.CDMA_ROAMING_MODE_RADIO_DEFAULT; |
| 974 | } else { |
| 975 | request.result = ((int[]) ar.result)[0]; |
| 976 | } |
| 977 | notifyRequester(request); |
| 978 | break; |
| 979 | case CMD_SET_CDMA_ROAMING_MODE: |
| 980 | request = (MainThreadRequest) msg.obj; |
| 981 | onCompleted = obtainMessage(EVENT_SET_CDMA_ROAMING_MODE_DONE, request); |
| 982 | int mode = (int) request.argument; |
| 983 | getPhoneFromRequest(request).setCdmaRoamingPreference(mode, onCompleted); |
| 984 | break; |
| 985 | case EVENT_SET_CDMA_ROAMING_MODE_DONE: |
| 986 | ar = (AsyncResult) msg.obj; |
| 987 | request = (MainThreadRequest) ar.userObj; |
| 988 | request.result = ar.exception == null; |
| 989 | notifyRequester(request); |
| 990 | break; |
| 991 | case CMD_SET_CDMA_SUBSCRIPTION_MODE: |
| 992 | request = (MainThreadRequest) msg.obj; |
| 993 | onCompleted = obtainMessage(EVENT_SET_CDMA_SUBSCRIPTION_MODE_DONE, request); |
| 994 | int subscriptionMode = (int) request.argument; |
| 995 | getPhoneFromRequest(request).setCdmaSubscription(subscriptionMode, onCompleted); |
| 996 | break; |
| 997 | case EVENT_SET_CDMA_SUBSCRIPTION_MODE_DONE: |
| 998 | ar = (AsyncResult) msg.obj; |
| 999 | request = (MainThreadRequest) ar.userObj; |
| 1000 | request.result = ar.exception == null; |
| 1001 | notifyRequester(request); |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 1002 | break; |
| 1003 | |
Nathan Harold | 3ff8893 | 2018-08-14 10:19:49 -0700 | [diff] [blame] | 1004 | case CMD_GET_ALL_CELL_INFO: |
| 1005 | request = (MainThreadRequest) msg.obj; |
Nathan Harold | 3ff8893 | 2018-08-14 10:19:49 -0700 | [diff] [blame] | 1006 | onCompleted = obtainMessage(EVENT_GET_ALL_CELL_INFO_DONE, request); |
Nathan Harold | 92bed18 | 2018-10-12 18:16:49 -0700 | [diff] [blame] | 1007 | request.phone.requestCellInfoUpdate(request.workSource, onCompleted); |
Nathan Harold | 3ff8893 | 2018-08-14 10:19:49 -0700 | [diff] [blame] | 1008 | break; |
| 1009 | |
| 1010 | case EVENT_GET_ALL_CELL_INFO_DONE: |
| 1011 | ar = (AsyncResult) msg.obj; |
| 1012 | request = (MainThreadRequest) ar.userObj; |
Nathan Harold | 8d0f174 | 2018-10-02 12:14:47 -0700 | [diff] [blame] | 1013 | // If a timeout occurs, the response will be null |
| 1014 | request.result = (ar.exception == null && ar.result != null) |
| 1015 | ? ar.result : new ArrayList<CellInfo>(); |
Nathan Harold | 3ff8893 | 2018-08-14 10:19:49 -0700 | [diff] [blame] | 1016 | synchronized (request) { |
| 1017 | request.notifyAll(); |
| 1018 | } |
| 1019 | break; |
| 1020 | |
| 1021 | case CMD_GET_CELL_LOCATION: { |
| 1022 | request = (MainThreadRequest) msg.obj; |
| 1023 | WorkSource ws = (WorkSource) request.argument; |
| 1024 | Phone phone = getPhoneFromRequest(request); |
| 1025 | phone.getCellLocation(ws, obtainMessage(EVENT_GET_CELL_LOCATION_DONE, request)); |
| 1026 | break; |
| 1027 | } |
| 1028 | |
| 1029 | case EVENT_GET_CELL_LOCATION_DONE: { |
| 1030 | ar = (AsyncResult) msg.obj; |
| 1031 | request = (MainThreadRequest) ar.userObj; |
| 1032 | if (ar.exception == null) { |
| 1033 | request.result = ar.result; |
| 1034 | } else { |
| 1035 | Phone phone = getPhoneFromRequest(request); |
| 1036 | request.result = (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) |
| 1037 | ? new CdmaCellLocation() : new GsmCellLocation(); |
| 1038 | } |
| 1039 | |
| 1040 | synchronized (request) { |
| 1041 | request.notifyAll(); |
| 1042 | } |
| 1043 | break; |
| 1044 | } |
| 1045 | |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 1046 | case CMD_MODEM_REBOOT: |
| 1047 | request = (MainThreadRequest) msg.obj; |
| 1048 | onCompleted = obtainMessage(EVENT_RESET_MODEM_CONFIG_DONE, request); |
| 1049 | mPhone.rebootModem(onCompleted); |
| 1050 | break; |
| 1051 | |
| 1052 | case EVENT_CMD_MODEM_REBOOT_DONE: |
| 1053 | handleNullReturnEvent(msg, "rebootModem"); |
| 1054 | break; |
| 1055 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1056 | default: |
| 1057 | Log.w(LOG_TAG, "MainThreadHandler: unexpected message code: " + msg.what); |
| 1058 | break; |
| 1059 | } |
| 1060 | } |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 1061 | |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 1062 | private void notifyRequester(MainThreadRequest request) { |
| 1063 | synchronized (request) { |
| 1064 | request.notifyAll(); |
| 1065 | } |
| 1066 | } |
| 1067 | |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 1068 | private void handleNullReturnEvent(Message msg, String command) { |
| 1069 | AsyncResult ar = (AsyncResult) msg.obj; |
| 1070 | MainThreadRequest request = (MainThreadRequest) ar.userObj; |
| 1071 | if (ar.exception == null) { |
| 1072 | request.result = true; |
| 1073 | } else { |
| 1074 | request.result = false; |
| 1075 | if (ar.exception instanceof CommandException) { |
| 1076 | loge(command + ": CommandException: " + ar.exception); |
| 1077 | } else { |
| 1078 | loge(command + ": Unknown exception"); |
| 1079 | } |
| 1080 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 1081 | notifyRequester(request); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 1082 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | /** |
| 1086 | * Posts the specified command to be executed on the main thread, |
| 1087 | * waits for the request to complete, and returns the result. |
| 1088 | * @see #sendRequestAsync |
| 1089 | */ |
| 1090 | private Object sendRequest(int command, Object argument) { |
Nathan Harold | 92bed18 | 2018-10-12 18:16:49 -0700 | [diff] [blame] | 1091 | return sendRequest( |
| 1092 | command, argument, SubscriptionManager.INVALID_SUBSCRIPTION_ID, null, null); |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 1093 | } |
| 1094 | |
| 1095 | /** |
| 1096 | * Posts the specified command to be executed on the main thread, |
| 1097 | * waits for the request to complete, and returns the result. |
| 1098 | * @see #sendRequestAsync |
| 1099 | */ |
| 1100 | private Object sendRequest(int command, Object argument, WorkSource workSource) { |
| 1101 | return sendRequest(command, argument, SubscriptionManager.INVALID_SUBSCRIPTION_ID, |
Nathan Harold | 92bed18 | 2018-10-12 18:16:49 -0700 | [diff] [blame] | 1102 | null, workSource); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1103 | } |
| 1104 | |
| 1105 | /** |
| 1106 | * Posts the specified command to be executed on the main thread, |
| 1107 | * waits for the request to complete, and returns the result. |
| 1108 | * @see #sendRequestAsync |
| 1109 | */ |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 1110 | private Object sendRequest(int command, Object argument, Integer subId) { |
Nathan Harold | 92bed18 | 2018-10-12 18:16:49 -0700 | [diff] [blame] | 1111 | return sendRequest(command, argument, subId, null, null); |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 1112 | } |
| 1113 | |
| 1114 | /** |
| 1115 | * Posts the specified command to be executed on the main thread, |
| 1116 | * waits for the request to complete, and returns the result. |
| 1117 | * @see #sendRequestAsync |
| 1118 | */ |
Nathan Harold | 92bed18 | 2018-10-12 18:16:49 -0700 | [diff] [blame] | 1119 | private Object sendRequest(int command, Object argument, int subId, WorkSource workSource) { |
| 1120 | return sendRequest(command, argument, subId, null, workSource); |
| 1121 | } |
| 1122 | |
| 1123 | /** |
| 1124 | * Posts the specified command to be executed on the main thread, |
| 1125 | * waits for the request to complete, and returns the result. |
| 1126 | * @see #sendRequestAsync |
| 1127 | */ |
| 1128 | private Object sendRequest(int command, Object argument, Phone phone, WorkSource workSource) { |
| 1129 | return sendRequest( |
| 1130 | command, argument, SubscriptionManager.INVALID_SUBSCRIPTION_ID, phone, workSource); |
| 1131 | } |
| 1132 | |
| 1133 | /** |
| 1134 | * Posts the specified command to be executed on the main thread, |
| 1135 | * waits for the request to complete, and returns the result. |
| 1136 | * @see #sendRequestAsync |
| 1137 | */ |
| 1138 | private Object sendRequest( |
| 1139 | int command, Object argument, Integer subId, Phone phone, WorkSource workSource) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1140 | if (Looper.myLooper() == mMainThreadHandler.getLooper()) { |
| 1141 | throw new RuntimeException("This method will deadlock if called from the main thread."); |
| 1142 | } |
| 1143 | |
Nathan Harold | 92bed18 | 2018-10-12 18:16:49 -0700 | [diff] [blame] | 1144 | MainThreadRequest request = null; |
| 1145 | if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID && phone != null) { |
| 1146 | throw new IllegalArgumentException("subId and phone cannot both be specified!"); |
| 1147 | } else if (phone != null) { |
| 1148 | request = new MainThreadRequest(argument, phone, workSource); |
| 1149 | } else { |
| 1150 | request = new MainThreadRequest(argument, subId, workSource); |
| 1151 | } |
| 1152 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1153 | Message msg = mMainThreadHandler.obtainMessage(command, request); |
| 1154 | msg.sendToTarget(); |
| 1155 | |
| 1156 | // Wait for the request to complete |
| 1157 | synchronized (request) { |
| 1158 | while (request.result == null) { |
| 1159 | try { |
| 1160 | request.wait(); |
| 1161 | } catch (InterruptedException e) { |
| 1162 | // Do nothing, go back and wait until the request is complete |
| 1163 | } |
| 1164 | } |
| 1165 | } |
| 1166 | return request.result; |
| 1167 | } |
| 1168 | |
| 1169 | /** |
| 1170 | * Asynchronous ("fire and forget") version of sendRequest(): |
| 1171 | * Posts the specified command to be executed on the main thread, and |
| 1172 | * returns immediately. |
| 1173 | * @see #sendRequest |
| 1174 | */ |
| 1175 | private void sendRequestAsync(int command) { |
| 1176 | mMainThreadHandler.sendEmptyMessage(command); |
| 1177 | } |
| 1178 | |
| 1179 | /** |
Sailesh Nepal | bd76e4e | 2013-10-27 13:59:44 -0700 | [diff] [blame] | 1180 | * Same as {@link #sendRequestAsync(int)} except it takes an argument. |
| 1181 | * @see {@link #sendRequest(int,Object)} |
| 1182 | */ |
| 1183 | private void sendRequestAsync(int command, Object argument) { |
| 1184 | MainThreadRequest request = new MainThreadRequest(argument); |
| 1185 | Message msg = mMainThreadHandler.obtainMessage(command, request); |
| 1186 | msg.sendToTarget(); |
| 1187 | } |
| 1188 | |
| 1189 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1190 | * Initialize the singleton PhoneInterfaceManager instance. |
| 1191 | * This is only done once, at startup, from PhoneApp.onCreate(). |
| 1192 | */ |
Sailesh Nepal | 194161e | 2014-07-03 08:57:44 -0700 | [diff] [blame] | 1193 | /* package */ static PhoneInterfaceManager init(PhoneGlobals app, Phone phone) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1194 | synchronized (PhoneInterfaceManager.class) { |
| 1195 | if (sInstance == null) { |
Sailesh Nepal | 194161e | 2014-07-03 08:57:44 -0700 | [diff] [blame] | 1196 | sInstance = new PhoneInterfaceManager(app, phone); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1197 | } else { |
| 1198 | Log.wtf(LOG_TAG, "init() called multiple times! sInstance = " + sInstance); |
| 1199 | } |
| 1200 | return sInstance; |
| 1201 | } |
| 1202 | } |
| 1203 | |
| 1204 | /** Private constructor; @see init() */ |
Sailesh Nepal | 194161e | 2014-07-03 08:57:44 -0700 | [diff] [blame] | 1205 | private PhoneInterfaceManager(PhoneGlobals app, Phone phone) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1206 | mApp = app; |
| 1207 | mPhone = phone; |
| 1208 | mCM = PhoneGlobals.getInstance().mCM; |
Stuart Scott | 981d858 | 2015-04-21 14:09:50 -0700 | [diff] [blame] | 1209 | mUserManager = (UserManager) app.getSystemService(Context.USER_SERVICE); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1210 | mAppOps = (AppOpsManager)app.getSystemService(Context.APP_OPS_SERVICE); |
| 1211 | mMainThreadHandler = new MainThreadHandler(); |
Andrew Lee | df14ead | 2014-10-17 14:22:52 -0700 | [diff] [blame] | 1212 | mTelephonySharedPreferences = |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 1213 | PreferenceManager.getDefaultSharedPreferences(mPhone.getContext()); |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 1214 | mSubscriptionController = SubscriptionController.getInstance(); |
yinxu | b1bed74 | 2017-04-17 11:45:04 -0700 | [diff] [blame] | 1215 | mNetworkScanRequestTracker = new NetworkScanRequestTracker(); |
Malcolm Chen | 2c63d40 | 2018-08-14 16:00:53 -0700 | [diff] [blame] | 1216 | mPhoneConfigurationManager = PhoneConfigurationManager.getInstance(); |
Wink Saville | 3ab207e | 2014-11-20 13:07:20 -0800 | [diff] [blame] | 1217 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1218 | publish(); |
| 1219 | } |
| 1220 | |
| 1221 | private void publish() { |
| 1222 | if (DBG) log("publish: " + this); |
| 1223 | |
| 1224 | ServiceManager.addService("phone", this); |
| 1225 | } |
| 1226 | |
Stuart Scott | 584921c | 2015-01-15 17:10:34 -0800 | [diff] [blame] | 1227 | private Phone getPhoneFromRequest(MainThreadRequest request) { |
Sanket Padawe | 56e75a3 | 2016-02-08 12:18:19 -0800 | [diff] [blame] | 1228 | return (request.subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) |
| 1229 | ? mPhone : getPhone(request.subId); |
Stuart Scott | 584921c | 2015-01-15 17:10:34 -0800 | [diff] [blame] | 1230 | } |
| 1231 | |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 1232 | private UiccCard getUiccCardFromRequest(MainThreadRequest request) { |
| 1233 | Phone phone = getPhoneFromRequest(request); |
| 1234 | return phone == null ? null : |
| 1235 | UiccController.getInstance().getUiccCard(phone.getPhoneId()); |
| 1236 | } |
| 1237 | |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1238 | // returns phone associated with the subId. |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1239 | private Phone getPhone(int subId) { |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 1240 | return PhoneFactory.getPhone(mSubscriptionController.getPhoneId(subId)); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1241 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1242 | |
| 1243 | public void dial(String number) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1244 | dialForSubscriber(getPreferredVoiceSubscription(), number); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1245 | } |
| 1246 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1247 | public void dialForSubscriber(int subId, String number) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1248 | if (DBG) log("dial: " + number); |
| 1249 | // No permission check needed here: This is just a wrapper around the |
| 1250 | // ACTION_DIAL intent, which is available to any app since it puts up |
| 1251 | // the UI before it does anything. |
| 1252 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1253 | final long identity = Binder.clearCallingIdentity(); |
| 1254 | try { |
| 1255 | String url = createTelUrl(number); |
| 1256 | if (url == null) { |
| 1257 | return; |
| 1258 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1259 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1260 | // PENDING: should we just silently fail if phone is offhook or ringing? |
| 1261 | PhoneConstants.State state = mCM.getState(subId); |
| 1262 | if (state != PhoneConstants.State.OFFHOOK && state != PhoneConstants.State.RINGING) { |
| 1263 | Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); |
| 1264 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 1265 | mApp.startActivity(intent); |
| 1266 | } |
| 1267 | } finally { |
| 1268 | Binder.restoreCallingIdentity(identity); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | public void call(String callingPackage, String number) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1273 | callForSubscriber(getPreferredVoiceSubscription(), callingPackage, number); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1274 | } |
| 1275 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1276 | public void callForSubscriber(int subId, String callingPackage, String number) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1277 | if (DBG) log("call: " + number); |
| 1278 | |
| 1279 | // This is just a wrapper around the ACTION_CALL intent, but we still |
| 1280 | // need to do a permission check since we're calling startActivity() |
| 1281 | // from the context of the phone app. |
| 1282 | enforceCallPermission(); |
| 1283 | |
| 1284 | if (mAppOps.noteOp(AppOpsManager.OP_CALL_PHONE, Binder.getCallingUid(), callingPackage) |
| 1285 | != AppOpsManager.MODE_ALLOWED) { |
| 1286 | return; |
| 1287 | } |
| 1288 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1289 | final long identity = Binder.clearCallingIdentity(); |
| 1290 | try { |
| 1291 | String url = createTelUrl(number); |
| 1292 | if (url == null) { |
| 1293 | return; |
| 1294 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1295 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1296 | boolean isValid = false; |
| 1297 | final List<SubscriptionInfo> slist = getActiveSubscriptionInfoListPrivileged(); |
| 1298 | if (slist != null) { |
| 1299 | for (SubscriptionInfo subInfoRecord : slist) { |
| 1300 | if (subInfoRecord.getSubscriptionId() == subId) { |
| 1301 | isValid = true; |
| 1302 | break; |
| 1303 | } |
Wink Saville | 3ab207e | 2014-11-20 13:07:20 -0800 | [diff] [blame] | 1304 | } |
Wink Saville | 0887461 | 2014-08-31 19:19:58 -0700 | [diff] [blame] | 1305 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1306 | if (!isValid) { |
| 1307 | return; |
| 1308 | } |
Wink Saville | 0887461 | 2014-08-31 19:19:58 -0700 | [diff] [blame] | 1309 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1310 | Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url)); |
| 1311 | intent.putExtra(SUBSCRIPTION_KEY, subId); |
| 1312 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 1313 | mApp.startActivity(intent); |
| 1314 | } finally { |
| 1315 | Binder.restoreCallingIdentity(identity); |
| 1316 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1317 | } |
| 1318 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1319 | public boolean supplyPin(String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1320 | return supplyPinForSubscriber(getDefaultSubscription(), pin); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1321 | } |
| 1322 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1323 | public boolean supplyPinForSubscriber(int subId, String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1324 | int [] resultArray = supplyPinReportResultForSubscriber(subId, pin); |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1325 | return (resultArray[0] == PhoneConstants.PIN_RESULT_SUCCESS) ? true : false; |
| 1326 | } |
| 1327 | |
| 1328 | public boolean supplyPuk(String puk, String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1329 | return supplyPukForSubscriber(getDefaultSubscription(), puk, pin); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1330 | } |
| 1331 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1332 | public boolean supplyPukForSubscriber(int subId, String puk, String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1333 | int [] resultArray = supplyPukReportResultForSubscriber(subId, puk, pin); |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1334 | return (resultArray[0] == PhoneConstants.PIN_RESULT_SUCCESS) ? true : false; |
| 1335 | } |
| 1336 | |
| 1337 | /** {@hide} */ |
| 1338 | public int[] supplyPinReportResult(String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1339 | return supplyPinReportResultForSubscriber(getDefaultSubscription(), pin); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1340 | } |
| 1341 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1342 | public int[] supplyPinReportResultForSubscriber(int subId, String pin) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1343 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1344 | |
| 1345 | final long identity = Binder.clearCallingIdentity(); |
| 1346 | try { |
| 1347 | final UnlockSim checkSimPin = new UnlockSim(getPhone(subId).getIccCard()); |
| 1348 | checkSimPin.start(); |
| 1349 | return checkSimPin.unlockSim(null, pin); |
| 1350 | } finally { |
| 1351 | Binder.restoreCallingIdentity(identity); |
| 1352 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1353 | } |
| 1354 | |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1355 | /** {@hide} */ |
| 1356 | public int[] supplyPukReportResult(String puk, String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1357 | return supplyPukReportResultForSubscriber(getDefaultSubscription(), puk, pin); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1358 | } |
| 1359 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1360 | public int[] supplyPukReportResultForSubscriber(int subId, String puk, String pin) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1361 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1362 | |
| 1363 | final long identity = Binder.clearCallingIdentity(); |
| 1364 | try { |
| 1365 | final UnlockSim checkSimPuk = new UnlockSim(getPhone(subId).getIccCard()); |
| 1366 | checkSimPuk.start(); |
| 1367 | return checkSimPuk.unlockSim(puk, pin); |
| 1368 | } finally { |
| 1369 | Binder.restoreCallingIdentity(identity); |
| 1370 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1371 | } |
| 1372 | |
| 1373 | /** |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1374 | * Helper thread to turn async call to SimCard#supplyPin into |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1375 | * a synchronous one. |
| 1376 | */ |
| 1377 | private static class UnlockSim extends Thread { |
| 1378 | |
| 1379 | private final IccCard mSimCard; |
| 1380 | |
| 1381 | private boolean mDone = false; |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1382 | private int mResult = PhoneConstants.PIN_GENERAL_FAILURE; |
| 1383 | private int mRetryCount = -1; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1384 | |
| 1385 | // For replies from SimCard interface |
| 1386 | private Handler mHandler; |
| 1387 | |
| 1388 | // For async handler to identify request type |
| 1389 | private static final int SUPPLY_PIN_COMPLETE = 100; |
| 1390 | |
| 1391 | public UnlockSim(IccCard simCard) { |
| 1392 | mSimCard = simCard; |
| 1393 | } |
| 1394 | |
| 1395 | @Override |
| 1396 | public void run() { |
| 1397 | Looper.prepare(); |
| 1398 | synchronized (UnlockSim.this) { |
| 1399 | mHandler = new Handler() { |
| 1400 | @Override |
| 1401 | public void handleMessage(Message msg) { |
| 1402 | AsyncResult ar = (AsyncResult) msg.obj; |
| 1403 | switch (msg.what) { |
| 1404 | case SUPPLY_PIN_COMPLETE: |
| 1405 | Log.d(LOG_TAG, "SUPPLY_PIN_COMPLETE"); |
| 1406 | synchronized (UnlockSim.this) { |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1407 | mRetryCount = msg.arg1; |
| 1408 | if (ar.exception != null) { |
| 1409 | if (ar.exception instanceof CommandException && |
| 1410 | ((CommandException)(ar.exception)).getCommandError() |
| 1411 | == CommandException.Error.PASSWORD_INCORRECT) { |
| 1412 | mResult = PhoneConstants.PIN_PASSWORD_INCORRECT; |
| 1413 | } else { |
| 1414 | mResult = PhoneConstants.PIN_GENERAL_FAILURE; |
| 1415 | } |
| 1416 | } else { |
| 1417 | mResult = PhoneConstants.PIN_RESULT_SUCCESS; |
| 1418 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1419 | mDone = true; |
| 1420 | UnlockSim.this.notifyAll(); |
| 1421 | } |
| 1422 | break; |
| 1423 | } |
| 1424 | } |
| 1425 | }; |
| 1426 | UnlockSim.this.notifyAll(); |
| 1427 | } |
| 1428 | Looper.loop(); |
| 1429 | } |
| 1430 | |
| 1431 | /* |
| 1432 | * Use PIN or PUK to unlock SIM card |
| 1433 | * |
| 1434 | * If PUK is null, unlock SIM card with PIN |
| 1435 | * |
| 1436 | * If PUK is not null, unlock SIM card with PUK and set PIN code |
| 1437 | */ |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1438 | synchronized int[] unlockSim(String puk, String pin) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1439 | |
| 1440 | while (mHandler == null) { |
| 1441 | try { |
| 1442 | wait(); |
| 1443 | } catch (InterruptedException e) { |
| 1444 | Thread.currentThread().interrupt(); |
| 1445 | } |
| 1446 | } |
| 1447 | Message callback = Message.obtain(mHandler, SUPPLY_PIN_COMPLETE); |
| 1448 | |
| 1449 | if (puk == null) { |
| 1450 | mSimCard.supplyPin(pin, callback); |
| 1451 | } else { |
| 1452 | mSimCard.supplyPuk(puk, pin, callback); |
| 1453 | } |
| 1454 | |
| 1455 | while (!mDone) { |
| 1456 | try { |
| 1457 | Log.d(LOG_TAG, "wait for done"); |
| 1458 | wait(); |
| 1459 | } catch (InterruptedException e) { |
| 1460 | // Restore the interrupted status |
| 1461 | Thread.currentThread().interrupt(); |
| 1462 | } |
| 1463 | } |
| 1464 | Log.d(LOG_TAG, "done"); |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1465 | int[] resultArray = new int[2]; |
| 1466 | resultArray[0] = mResult; |
| 1467 | resultArray[1] = mRetryCount; |
| 1468 | return resultArray; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1469 | } |
| 1470 | } |
| 1471 | |
| 1472 | public void updateServiceLocation() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1473 | updateServiceLocationForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1474 | |
| 1475 | } |
| 1476 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1477 | public void updateServiceLocationForSubscriber(int subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1478 | // No permission check needed here: this call is harmless, and it's |
| 1479 | // needed for the ServiceState.requestStateUpdate() call (which is |
| 1480 | // already intentionally exposed to 3rd parties.) |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1481 | final long identity = Binder.clearCallingIdentity(); |
| 1482 | try { |
| 1483 | final Phone phone = getPhone(subId); |
| 1484 | if (phone != null) { |
| 1485 | phone.updateServiceLocation(); |
| 1486 | } |
| 1487 | } finally { |
| 1488 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1489 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1490 | } |
| 1491 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1492 | @Override |
| 1493 | public boolean isRadioOn(String callingPackage) { |
| 1494 | return isRadioOnForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1495 | } |
| 1496 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1497 | @Override |
| 1498 | public boolean isRadioOnForSubscriber(int subId, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 1499 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 1500 | mApp, subId, callingPackage, "isRadioOnForSubscriber")) { |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1501 | return false; |
| 1502 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1503 | |
| 1504 | final long identity = Binder.clearCallingIdentity(); |
| 1505 | try { |
| 1506 | return isRadioOnForSubscriber(subId); |
| 1507 | } finally { |
| 1508 | Binder.restoreCallingIdentity(identity); |
| 1509 | } |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1510 | } |
| 1511 | |
| 1512 | private boolean isRadioOnForSubscriber(int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1513 | final long identity = Binder.clearCallingIdentity(); |
| 1514 | try { |
| 1515 | final Phone phone = getPhone(subId); |
| 1516 | if (phone != null) { |
| 1517 | return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF; |
| 1518 | } else { |
| 1519 | return false; |
| 1520 | } |
| 1521 | } finally { |
| 1522 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1523 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1524 | } |
| 1525 | |
| 1526 | public void toggleRadioOnOff() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1527 | toggleRadioOnOffForSubscriber(getDefaultSubscription()); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1528 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1529 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1530 | public void toggleRadioOnOffForSubscriber(int subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1531 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1532 | |
| 1533 | final long identity = Binder.clearCallingIdentity(); |
| 1534 | try { |
| 1535 | final Phone phone = getPhone(subId); |
| 1536 | if (phone != null) { |
| 1537 | phone.setRadioPower(!isRadioOnForSubscriber(subId)); |
| 1538 | } |
| 1539 | } finally { |
| 1540 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1541 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1542 | } |
| 1543 | |
| 1544 | public boolean setRadio(boolean turnOn) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1545 | return setRadioForSubscriber(getDefaultSubscription(), turnOn); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1546 | } |
| 1547 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1548 | public boolean setRadioForSubscriber(int subId, boolean turnOn) { |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1549 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1550 | |
| 1551 | final long identity = Binder.clearCallingIdentity(); |
| 1552 | try { |
| 1553 | final Phone phone = getPhone(subId); |
| 1554 | if (phone == null) { |
| 1555 | return false; |
| 1556 | } |
| 1557 | if ((phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF) != turnOn) { |
| 1558 | toggleRadioOnOffForSubscriber(subId); |
| 1559 | } |
| 1560 | return true; |
| 1561 | } finally { |
| 1562 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1563 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1564 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1565 | |
Naveen Kalla | 1fd79bd | 2014-08-08 00:48:59 -0700 | [diff] [blame] | 1566 | public boolean needMobileRadioShutdown() { |
| 1567 | /* |
| 1568 | * If any of the Radios are available, it will need to be |
| 1569 | * shutdown. So return true if any Radio is available. |
| 1570 | */ |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1571 | final long identity = Binder.clearCallingIdentity(); |
| 1572 | try { |
| 1573 | for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { |
| 1574 | Phone phone = PhoneFactory.getPhone(i); |
| 1575 | if (phone != null && phone.isRadioAvailable()) return true; |
| 1576 | } |
| 1577 | logv(TelephonyManager.getDefault().getPhoneCount() + " Phones are shutdown."); |
| 1578 | return false; |
| 1579 | } finally { |
| 1580 | Binder.restoreCallingIdentity(identity); |
Naveen Kalla | 1fd79bd | 2014-08-08 00:48:59 -0700 | [diff] [blame] | 1581 | } |
Naveen Kalla | 1fd79bd | 2014-08-08 00:48:59 -0700 | [diff] [blame] | 1582 | } |
| 1583 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1584 | @Override |
Naveen Kalla | 1fd79bd | 2014-08-08 00:48:59 -0700 | [diff] [blame] | 1585 | public void shutdownMobileRadios() { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1586 | enforceModifyPermission(); |
| 1587 | |
| 1588 | final long identity = Binder.clearCallingIdentity(); |
| 1589 | try { |
| 1590 | for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { |
| 1591 | logv("Shutting down Phone " + i); |
| 1592 | shutdownRadioUsingPhoneId(i); |
| 1593 | } |
| 1594 | } finally { |
| 1595 | Binder.restoreCallingIdentity(identity); |
Naveen Kalla | 1fd79bd | 2014-08-08 00:48:59 -0700 | [diff] [blame] | 1596 | } |
| 1597 | } |
| 1598 | |
| 1599 | private void shutdownRadioUsingPhoneId(int phoneId) { |
Naveen Kalla | 1fd79bd | 2014-08-08 00:48:59 -0700 | [diff] [blame] | 1600 | Phone phone = PhoneFactory.getPhone(phoneId); |
| 1601 | if (phone != null && phone.isRadioAvailable()) { |
| 1602 | phone.shutdownRadio(); |
| 1603 | } |
| 1604 | } |
| 1605 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1606 | public boolean setRadioPower(boolean turnOn) { |
Jack Yu | b4e1616 | 2017-05-15 12:48:40 -0700 | [diff] [blame] | 1607 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1608 | |
| 1609 | final long identity = Binder.clearCallingIdentity(); |
| 1610 | try { |
| 1611 | final Phone defaultPhone = PhoneFactory.getDefaultPhone(); |
| 1612 | if (defaultPhone != null) { |
| 1613 | defaultPhone.setRadioPower(turnOn); |
| 1614 | return true; |
| 1615 | } else { |
| 1616 | loge("There's no default phone."); |
| 1617 | return false; |
| 1618 | } |
| 1619 | } finally { |
| 1620 | Binder.restoreCallingIdentity(identity); |
Wei Liu | 9ae2a06 | 2016-08-08 11:09:34 -0700 | [diff] [blame] | 1621 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1622 | } |
| 1623 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1624 | public boolean setRadioPowerForSubscriber(int subId, boolean turnOn) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1625 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1626 | |
| 1627 | final long identity = Binder.clearCallingIdentity(); |
| 1628 | try { |
| 1629 | final Phone phone = getPhone(subId); |
| 1630 | if (phone != null) { |
| 1631 | phone.setRadioPower(turnOn); |
| 1632 | return true; |
| 1633 | } else { |
| 1634 | return false; |
| 1635 | } |
| 1636 | } finally { |
| 1637 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1638 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1639 | } |
| 1640 | |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1641 | // FIXME: subId version needed |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1642 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1643 | public boolean enableDataConnectivity() { |
| 1644 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1645 | |
| 1646 | final long identity = Binder.clearCallingIdentity(); |
| 1647 | try { |
| 1648 | int subId = mSubscriptionController.getDefaultDataSubId(); |
| 1649 | final Phone phone = getPhone(subId); |
| 1650 | if (phone != null) { |
| 1651 | phone.setUserDataEnabled(true); |
| 1652 | return true; |
| 1653 | } else { |
| 1654 | return false; |
| 1655 | } |
| 1656 | } finally { |
| 1657 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1658 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1659 | } |
| 1660 | |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1661 | // FIXME: subId version needed |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1662 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1663 | public boolean disableDataConnectivity() { |
| 1664 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1665 | |
| 1666 | final long identity = Binder.clearCallingIdentity(); |
| 1667 | try { |
| 1668 | int subId = mSubscriptionController.getDefaultDataSubId(); |
| 1669 | final Phone phone = getPhone(subId); |
| 1670 | if (phone != null) { |
| 1671 | phone.setUserDataEnabled(false); |
| 1672 | return true; |
| 1673 | } else { |
| 1674 | return false; |
| 1675 | } |
| 1676 | } finally { |
| 1677 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1678 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1679 | } |
| 1680 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1681 | @Override |
Jack Yu | acf8a13 | 2017-05-01 17:00:48 -0700 | [diff] [blame] | 1682 | public boolean isDataConnectivityPossible(int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1683 | final long identity = Binder.clearCallingIdentity(); |
| 1684 | try { |
| 1685 | final Phone phone = getPhone(subId); |
| 1686 | if (phone != null) { |
| 1687 | return phone.isDataAllowed(); |
| 1688 | } else { |
| 1689 | return false; |
| 1690 | } |
| 1691 | } finally { |
| 1692 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1693 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1694 | } |
| 1695 | |
| 1696 | public boolean handlePinMmi(String dialString) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1697 | return handlePinMmiForSubscriber(getDefaultSubscription(), dialString); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1698 | } |
| 1699 | |
pkanwar | ae03a6b | 2016-11-06 20:37:09 -0800 | [diff] [blame] | 1700 | public void handleUssdRequest(int subId, String ussdRequest, ResultReceiver wrappedCallback) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1701 | enforceCallPermission(); |
| 1702 | |
| 1703 | final long identity = Binder.clearCallingIdentity(); |
| 1704 | try { |
| 1705 | if (!SubscriptionManager.isValidSubscriptionId(subId)) { |
| 1706 | return; |
| 1707 | } |
| 1708 | Pair<String, ResultReceiver> ussdObject = new Pair(ussdRequest, wrappedCallback); |
| 1709 | sendRequest(CMD_HANDLE_USSD_REQUEST, ussdObject, subId); |
| 1710 | } finally { |
| 1711 | Binder.restoreCallingIdentity(identity); |
| 1712 | } |
pkanwar | 32d516d | 2016-10-14 19:37:38 -0700 | [diff] [blame] | 1713 | }; |
| 1714 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1715 | public boolean handlePinMmiForSubscriber(int subId, String dialString) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1716 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1717 | |
| 1718 | final long identity = Binder.clearCallingIdentity(); |
| 1719 | try { |
| 1720 | if (!SubscriptionManager.isValidSubscriptionId(subId)) { |
| 1721 | return false; |
| 1722 | } |
| 1723 | return (Boolean) sendRequest(CMD_HANDLE_PIN_MMI, dialString, subId); |
| 1724 | } finally { |
| 1725 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1726 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1727 | } |
| 1728 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1729 | public int getCallState() { |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 1730 | return getCallStateForSlot(getSlotForDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1731 | } |
| 1732 | |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 1733 | public int getCallStateForSlot(int slotIndex) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1734 | final long identity = Binder.clearCallingIdentity(); |
| 1735 | try { |
| 1736 | Phone phone = PhoneFactory.getPhone(slotIndex); |
| 1737 | return phone == null ? TelephonyManager.CALL_STATE_IDLE : |
| 1738 | PhoneConstantConversions.convertCallState(phone.getState()); |
| 1739 | } finally { |
| 1740 | Binder.restoreCallingIdentity(identity); |
| 1741 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1742 | } |
| 1743 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1744 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1745 | public int getDataState() { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1746 | final long identity = Binder.clearCallingIdentity(); |
| 1747 | try { |
| 1748 | Phone phone = getPhone(mSubscriptionController.getDefaultDataSubId()); |
| 1749 | if (phone != null) { |
| 1750 | return PhoneConstantConversions.convertDataState(phone.getDataConnectionState()); |
| 1751 | } else { |
| 1752 | return PhoneConstantConversions.convertDataState( |
| 1753 | PhoneConstants.DataState.DISCONNECTED); |
| 1754 | } |
| 1755 | } finally { |
| 1756 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1757 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1758 | } |
| 1759 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1760 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1761 | public int getDataActivity() { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1762 | final long identity = Binder.clearCallingIdentity(); |
| 1763 | try { |
| 1764 | Phone phone = getPhone(mSubscriptionController.getDefaultDataSubId()); |
| 1765 | if (phone != null) { |
| 1766 | return DefaultPhoneNotifier.convertDataActivityState(phone.getDataActivityState()); |
| 1767 | } else { |
| 1768 | return TelephonyManager.DATA_ACTIVITY_NONE; |
| 1769 | } |
| 1770 | } finally { |
| 1771 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1772 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1773 | } |
| 1774 | |
| 1775 | @Override |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1776 | public Bundle getCellLocation(String callingPackage) { |
Hall Liu | 1aa510f | 2017-11-22 17:40:08 -0800 | [diff] [blame] | 1777 | mPhone.getContext().getSystemService(AppOpsManager.class) |
| 1778 | .checkPackage(Binder.getCallingUid(), callingPackage); |
Svetoslav Ganov | 4a9d448 | 2017-06-20 19:53:35 -0700 | [diff] [blame] | 1779 | if (!LocationAccessPolicy.canAccessCellLocation(mPhone.getContext(), |
Svet Ganov | 4af6628 | 2018-03-07 19:57:05 -0800 | [diff] [blame] | 1780 | callingPackage, Binder.getCallingUid(), Binder.getCallingPid(), true)) { |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1781 | return null; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1782 | } |
| 1783 | |
Narayan Kamath | f04b5a1 | 2018-01-09 11:47:15 +0000 | [diff] [blame] | 1784 | WorkSource workSource = getWorkSource(Binder.getCallingUid()); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1785 | final long identity = Binder.clearCallingIdentity(); |
| 1786 | try { |
| 1787 | if (DBG_LOC) log("getCellLocation: is active user"); |
| 1788 | Bundle data = new Bundle(); |
Nathan Harold | 3ff8893 | 2018-08-14 10:19:49 -0700 | [diff] [blame] | 1789 | int subId = mSubscriptionController.getDefaultDataSubId(); |
| 1790 | CellLocation cl = (CellLocation) sendRequest(CMD_GET_CELL_LOCATION, workSource, subId); |
| 1791 | cl.fillInNotifierBundle(data); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1792 | return data; |
| 1793 | } finally { |
| 1794 | Binder.restoreCallingIdentity(identity); |
| 1795 | } |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1796 | } |
| 1797 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1798 | @Override |
Jonathan Basseri | bf5362b | 2017-07-19 12:22:35 -0700 | [diff] [blame] | 1799 | public String getNetworkCountryIsoForPhone(int phoneId) { |
| 1800 | // Reporting the correct network country is ambiguous when IWLAN could conflict with |
| 1801 | // registered cell info, so return a NULL country instead. |
| 1802 | final long identity = Binder.clearCallingIdentity(); |
| 1803 | try { |
Malcolm Chen | 3732c2b | 2018-07-18 20:15:24 -0700 | [diff] [blame] | 1804 | if (phoneId == SubscriptionManager.INVALID_PHONE_INDEX) { |
| 1805 | // Get default phone in this case. |
| 1806 | phoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; |
| 1807 | } |
Jonathan Basseri | bf5362b | 2017-07-19 12:22:35 -0700 | [diff] [blame] | 1808 | final int subId = mSubscriptionController.getSubIdUsingPhoneId(phoneId); |
Jack Yu | 5f7092c | 2018-04-13 14:05:37 -0700 | [diff] [blame] | 1809 | // Todo: fix this when we can get the actual cellular network info when the device |
| 1810 | // is on IWLAN. |
Jonathan Basseri | bf5362b | 2017-07-19 12:22:35 -0700 | [diff] [blame] | 1811 | if (TelephonyManager.NETWORK_TYPE_IWLAN |
| 1812 | == getVoiceNetworkTypeForSubscriber(subId, mApp.getPackageName())) { |
| 1813 | return ""; |
| 1814 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1815 | Phone phone = PhoneFactory.getPhone(phoneId); |
| 1816 | if (phone != null) { |
| 1817 | ServiceStateTracker sst = phone.getServiceStateTracker(); |
| 1818 | if (sst != null) { |
| 1819 | LocaleTracker lt = sst.getLocaleTracker(); |
| 1820 | if (lt != null) { |
| 1821 | return lt.getCurrentCountry(); |
| 1822 | } |
| 1823 | } |
| 1824 | } |
| 1825 | return ""; |
Jonathan Basseri | bf5362b | 2017-07-19 12:22:35 -0700 | [diff] [blame] | 1826 | } finally { |
| 1827 | Binder.restoreCallingIdentity(identity); |
| 1828 | } |
Jonathan Basseri | bf5362b | 2017-07-19 12:22:35 -0700 | [diff] [blame] | 1829 | } |
| 1830 | |
| 1831 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1832 | public void enableLocationUpdates() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1833 | enableLocationUpdatesForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1834 | } |
| 1835 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1836 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1837 | public void enableLocationUpdatesForSubscriber(int subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1838 | mApp.enforceCallingOrSelfPermission( |
| 1839 | android.Manifest.permission.CONTROL_LOCATION_UPDATES, null); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1840 | |
| 1841 | final long identity = Binder.clearCallingIdentity(); |
| 1842 | try { |
| 1843 | final Phone phone = getPhone(subId); |
| 1844 | if (phone != null) { |
| 1845 | phone.enableLocationUpdates(); |
| 1846 | } |
| 1847 | } finally { |
| 1848 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1849 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1850 | } |
| 1851 | |
| 1852 | @Override |
| 1853 | public void disableLocationUpdates() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1854 | disableLocationUpdatesForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1855 | } |
| 1856 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1857 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1858 | public void disableLocationUpdatesForSubscriber(int subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1859 | mApp.enforceCallingOrSelfPermission( |
| 1860 | android.Manifest.permission.CONTROL_LOCATION_UPDATES, null); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1861 | |
| 1862 | final long identity = Binder.clearCallingIdentity(); |
| 1863 | try { |
| 1864 | final Phone phone = getPhone(subId); |
| 1865 | if (phone != null) { |
| 1866 | phone.disableLocationUpdates(); |
| 1867 | } |
| 1868 | } finally { |
| 1869 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1870 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1871 | } |
| 1872 | |
Nathan Harold | 31d7ff3 | 2018-10-15 20:20:30 -0700 | [diff] [blame] | 1873 | /** |
| 1874 | * Returns the target SDK version number for a given package name. |
| 1875 | * |
| 1876 | * @return target SDK if the package is found or INT_MAX. |
| 1877 | */ |
| 1878 | private int getTargetSdk(String packageName) { |
| 1879 | try { |
| 1880 | final ApplicationInfo ai = |
| 1881 | mPhone.getContext().getPackageManager().getApplicationInfo(packageName, 0); |
| 1882 | if (ai != null) return ai.targetSdkVersion; |
| 1883 | } catch (PackageManager.NameNotFoundException unexpected) { |
| 1884 | } |
| 1885 | return Integer.MAX_VALUE; |
| 1886 | } |
| 1887 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1888 | @Override |
| 1889 | @SuppressWarnings("unchecked") |
Nathan Harold | 31d7ff3 | 2018-10-15 20:20:30 -0700 | [diff] [blame] | 1890 | public List<NeighboringCellInfo> getNeighboringCellInfo(String callingPackage) { |
| 1891 | final int targetSdk = getTargetSdk(callingPackage); |
Nathan Harold | dbea45a | 2018-08-30 14:35:07 -0700 | [diff] [blame] | 1892 | if (targetSdk >= android.os.Build.VERSION_CODES.Q) { |
| 1893 | throw new SecurityException( |
| 1894 | "getNeighboringCellInfo() is unavailable to callers targeting Q+ SDK levels."); |
| 1895 | } |
Nathan Harold | b4d5561 | 2018-07-20 13:13:08 -0700 | [diff] [blame] | 1896 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1897 | if (mAppOps.noteOp(AppOpsManager.OP_NEIGHBORING_CELLS, Binder.getCallingUid(), |
| 1898 | callingPackage) != AppOpsManager.MODE_ALLOWED) { |
| 1899 | return null; |
| 1900 | } |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1901 | |
Svetoslav Ganov | 4a9d448 | 2017-06-20 19:53:35 -0700 | [diff] [blame] | 1902 | if (DBG_LOC) log("getNeighboringCellInfo: is active user"); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1903 | |
Nathan Harold | f180aac | 2018-06-01 18:43:55 -0700 | [diff] [blame] | 1904 | List<CellInfo> info = getAllCellInfo(callingPackage); |
| 1905 | if (info == null) return null; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1906 | |
Nathan Harold | f180aac | 2018-06-01 18:43:55 -0700 | [diff] [blame] | 1907 | List<NeighboringCellInfo> neighbors = new ArrayList<NeighboringCellInfo>(); |
| 1908 | for (CellInfo ci : info) { |
| 1909 | if (ci instanceof CellInfoGsm) { |
| 1910 | neighbors.add(new NeighboringCellInfo((CellInfoGsm) ci)); |
| 1911 | } else if (ci instanceof CellInfoWcdma) { |
| 1912 | neighbors.add(new NeighboringCellInfo((CellInfoWcdma) ci)); |
| 1913 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1914 | } |
Nathan Harold | f180aac | 2018-06-01 18:43:55 -0700 | [diff] [blame] | 1915 | return (neighbors.size()) > 0 ? neighbors : null; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1916 | } |
| 1917 | |
| 1918 | |
| 1919 | @Override |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1920 | public List<CellInfo> getAllCellInfo(String callingPackage) { |
Hall Liu | 1aa510f | 2017-11-22 17:40:08 -0800 | [diff] [blame] | 1921 | mPhone.getContext().getSystemService(AppOpsManager.class) |
| 1922 | .checkPackage(Binder.getCallingUid(), callingPackage); |
Svetoslav Ganov | 4a9d448 | 2017-06-20 19:53:35 -0700 | [diff] [blame] | 1923 | if (!LocationAccessPolicy.canAccessCellLocation(mPhone.getContext(), |
Svet Ganov | 4af6628 | 2018-03-07 19:57:05 -0800 | [diff] [blame] | 1924 | callingPackage, Binder.getCallingUid(), Binder.getCallingPid(), true)) { |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1925 | return null; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1926 | } |
| 1927 | |
Svetoslav Ganov | 4a9d448 | 2017-06-20 19:53:35 -0700 | [diff] [blame] | 1928 | if (DBG_LOC) log("getAllCellInfo: is active user"); |
Narayan Kamath | f04b5a1 | 2018-01-09 11:47:15 +0000 | [diff] [blame] | 1929 | WorkSource workSource = getWorkSource(Binder.getCallingUid()); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1930 | final long identity = Binder.clearCallingIdentity(); |
| 1931 | try { |
| 1932 | List<CellInfo> cellInfos = new ArrayList<CellInfo>(); |
| 1933 | for (Phone phone : PhoneFactory.getPhones()) { |
Nathan Harold | 3ff8893 | 2018-08-14 10:19:49 -0700 | [diff] [blame] | 1934 | final List<CellInfo> info = (List<CellInfo>) sendRequest( |
Nathan Harold | 92bed18 | 2018-10-12 18:16:49 -0700 | [diff] [blame] | 1935 | CMD_GET_ALL_CELL_INFO, null, phone, workSource); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1936 | if (info != null) cellInfos.addAll(info); |
| 1937 | } |
| 1938 | return cellInfos; |
| 1939 | } finally { |
| 1940 | Binder.restoreCallingIdentity(identity); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1941 | } |
| 1942 | } |
| 1943 | |
Sailesh Nepal | bd76e4e | 2013-10-27 13:59:44 -0700 | [diff] [blame] | 1944 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1945 | public void setCellInfoListRate(int rateInMillis) { |
Jack Yu | a8d8cb8 | 2017-01-16 10:15:34 -0800 | [diff] [blame] | 1946 | enforceModifyPermission(); |
Narayan Kamath | f04b5a1 | 2018-01-09 11:47:15 +0000 | [diff] [blame] | 1947 | WorkSource workSource = getWorkSource(Binder.getCallingUid()); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1948 | |
| 1949 | final long identity = Binder.clearCallingIdentity(); |
| 1950 | try { |
| 1951 | mPhone.setCellInfoListRate(rateInMillis, workSource); |
| 1952 | } finally { |
| 1953 | Binder.restoreCallingIdentity(identity); |
| 1954 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1955 | } |
| 1956 | |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 1957 | @Override |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 1958 | public String getImeiForSlot(int slotIndex, String callingPackage) { |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 1959 | Phone phone = PhoneFactory.getPhone(slotIndex); |
| 1960 | if (phone == null) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 1961 | return null; |
| 1962 | } |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 1963 | int subId = phone.getSubId(); |
Michael Groover | 70af6dc | 2018-10-01 16:23:15 -0700 | [diff] [blame] | 1964 | if (!TelephonyPermissions.checkCallingOrSelfReadDeviceIdentifiers(mApp, subId, |
| 1965 | callingPackage, "getImeiForSlot")) { |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 1966 | return null; |
| 1967 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1968 | |
| 1969 | final long identity = Binder.clearCallingIdentity(); |
| 1970 | try { |
| 1971 | return phone.getImei(); |
| 1972 | } finally { |
| 1973 | Binder.restoreCallingIdentity(identity); |
| 1974 | } |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 1975 | } |
| 1976 | |
| 1977 | @Override |
David Kelly | 5e06a7f | 2018-03-12 14:10:59 +0000 | [diff] [blame] | 1978 | public String getTypeAllocationCodeForSlot(int slotIndex) { |
| 1979 | Phone phone = PhoneFactory.getPhone(slotIndex); |
| 1980 | String tac = null; |
| 1981 | if (phone != null) { |
| 1982 | String imei = phone.getImei(); |
| 1983 | tac = imei == null ? null : imei.substring(0, TYPE_ALLOCATION_CODE_LENGTH); |
| 1984 | } |
| 1985 | return tac; |
| 1986 | } |
| 1987 | |
| 1988 | @Override |
Jack Yu | 2af8d71 | 2017-03-15 17:14:14 -0700 | [diff] [blame] | 1989 | public String getMeidForSlot(int slotIndex, String callingPackage) { |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 1990 | Phone phone = PhoneFactory.getPhone(slotIndex); |
| 1991 | if (phone == null) { |
Jack Yu | 2af8d71 | 2017-03-15 17:14:14 -0700 | [diff] [blame] | 1992 | return null; |
| 1993 | } |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 1994 | int subId = phone.getSubId(); |
Michael Groover | 70af6dc | 2018-10-01 16:23:15 -0700 | [diff] [blame] | 1995 | if (!TelephonyPermissions.checkCallingOrSelfReadDeviceIdentifiers(mApp, subId, |
| 1996 | callingPackage, "getMeidForSlot")) { |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 1997 | return null; |
| 1998 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 1999 | |
| 2000 | final long identity = Binder.clearCallingIdentity(); |
| 2001 | try { |
| 2002 | return phone.getMeid(); |
| 2003 | } finally { |
| 2004 | Binder.restoreCallingIdentity(identity); |
| 2005 | } |
Jack Yu | 2af8d71 | 2017-03-15 17:14:14 -0700 | [diff] [blame] | 2006 | } |
| 2007 | |
| 2008 | @Override |
David Kelly | 5e06a7f | 2018-03-12 14:10:59 +0000 | [diff] [blame] | 2009 | public String getManufacturerCodeForSlot(int slotIndex) { |
| 2010 | Phone phone = PhoneFactory.getPhone(slotIndex); |
| 2011 | String manufacturerCode = null; |
| 2012 | if (phone != null) { |
| 2013 | String meid = phone.getMeid(); |
| 2014 | manufacturerCode = meid == null ? null : meid.substring(0, MANUFACTURER_CODE_LENGTH); |
| 2015 | } |
| 2016 | return manufacturerCode; |
| 2017 | } |
| 2018 | |
| 2019 | @Override |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 2020 | public String getDeviceSoftwareVersionForSlot(int slotIndex, String callingPackage) { |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 2021 | Phone phone = PhoneFactory.getPhone(slotIndex); |
| 2022 | if (phone == null) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2023 | return null; |
| 2024 | } |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 2025 | int subId = phone.getSubId(); |
| 2026 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
| 2027 | mApp, subId, callingPackage, "getDeviceSoftwareVersionForSlot")) { |
| 2028 | return null; |
| 2029 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2030 | |
| 2031 | final long identity = Binder.clearCallingIdentity(); |
| 2032 | try { |
| 2033 | return phone.getDeviceSvn(); |
| 2034 | } finally { |
| 2035 | Binder.restoreCallingIdentity(identity); |
| 2036 | } |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 2037 | } |
| 2038 | |
fionaxu | 43304da | 2017-11-27 22:51:16 -0800 | [diff] [blame] | 2039 | @Override |
| 2040 | public int getSubscriptionCarrierId(int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2041 | final long identity = Binder.clearCallingIdentity(); |
| 2042 | try { |
| 2043 | final Phone phone = getPhone(subId); |
| 2044 | return phone == null ? TelephonyManager.UNKNOWN_CARRIER_ID : phone.getCarrierId(); |
| 2045 | } finally { |
| 2046 | Binder.restoreCallingIdentity(identity); |
| 2047 | } |
fionaxu | 43304da | 2017-11-27 22:51:16 -0800 | [diff] [blame] | 2048 | } |
| 2049 | |
| 2050 | @Override |
| 2051 | public String getSubscriptionCarrierName(int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2052 | final long identity = Binder.clearCallingIdentity(); |
| 2053 | try { |
| 2054 | final Phone phone = getPhone(subId); |
| 2055 | return phone == null ? null : phone.getCarrierName(); |
| 2056 | } finally { |
| 2057 | Binder.restoreCallingIdentity(identity); |
| 2058 | } |
fionaxu | 43304da | 2017-11-27 22:51:16 -0800 | [diff] [blame] | 2059 | } |
| 2060 | |
calvinpan | ffe225e | 2018-11-01 19:43:06 +0800 | [diff] [blame] | 2061 | @Override |
| 2062 | public int getSubscriptionMNOCarrierId(int subId) { |
| 2063 | final long identity = Binder.clearCallingIdentity(); |
| 2064 | try { |
| 2065 | final Phone phone = getPhone(subId); |
| 2066 | return phone == null ? TelephonyManager.UNKNOWN_CARRIER_ID : phone.getMNOCarrierId(); |
| 2067 | } finally { |
| 2068 | Binder.restoreCallingIdentity(identity); |
| 2069 | } |
| 2070 | } |
| 2071 | |
chen xu | 2563722 | 2018-11-04 17:17:00 -0800 | [diff] [blame^] | 2072 | @Override |
| 2073 | public int getSubscriptionPreciseCarrierId(int subId) { |
| 2074 | final long identity = Binder.clearCallingIdentity(); |
| 2075 | try { |
| 2076 | final Phone phone = getPhone(subId); |
| 2077 | return phone == null ? TelephonyManager.UNKNOWN_CARRIER_ID |
| 2078 | : phone.getPreciseCarrierId(); |
| 2079 | } finally { |
| 2080 | Binder.restoreCallingIdentity(identity); |
| 2081 | } |
| 2082 | } |
| 2083 | |
| 2084 | @Override |
| 2085 | public String getSubscriptionPreciseCarrierName(int subId) { |
| 2086 | final long identity = Binder.clearCallingIdentity(); |
| 2087 | try { |
| 2088 | final Phone phone = getPhone(subId); |
| 2089 | return phone == null ? null : phone.getPreciseCarrierName(); |
| 2090 | } finally { |
| 2091 | Binder.restoreCallingIdentity(identity); |
| 2092 | } |
| 2093 | } |
| 2094 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2095 | // |
| 2096 | // Internal helper methods. |
| 2097 | // |
| 2098 | |
Sanket Padawe | ee13a9b | 2016-03-08 17:30:28 -0800 | [diff] [blame] | 2099 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2100 | * Make sure the caller has the MODIFY_PHONE_STATE permission. |
| 2101 | * |
| 2102 | * @throws SecurityException if the caller does not have the required permission |
| 2103 | */ |
| 2104 | private void enforceModifyPermission() { |
| 2105 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE, null); |
| 2106 | } |
| 2107 | |
| 2108 | /** |
| 2109 | * Make sure the caller has the CALL_PHONE permission. |
| 2110 | * |
| 2111 | * @throws SecurityException if the caller does not have the required permission |
| 2112 | */ |
| 2113 | private void enforceCallPermission() { |
| 2114 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.CALL_PHONE, null); |
| 2115 | } |
| 2116 | |
Stuart Scott | 8eef64f | 2015-04-08 15:13:54 -0700 | [diff] [blame] | 2117 | private void enforceConnectivityInternalPermission() { |
| 2118 | mApp.enforceCallingOrSelfPermission( |
| 2119 | android.Manifest.permission.CONNECTIVITY_INTERNAL, |
| 2120 | "ConnectivityService"); |
| 2121 | } |
| 2122 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2123 | private String createTelUrl(String number) { |
| 2124 | if (TextUtils.isEmpty(number)) { |
| 2125 | return null; |
| 2126 | } |
| 2127 | |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 2128 | return "tel:" + number; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2129 | } |
| 2130 | |
Ihab Awad | f9e9273 | 2013-12-05 18:02:52 -0800 | [diff] [blame] | 2131 | private static void log(String msg) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2132 | Log.d(LOG_TAG, "[PhoneIntfMgr] " + msg); |
| 2133 | } |
| 2134 | |
Naveen Kalla | 1fd79bd | 2014-08-08 00:48:59 -0700 | [diff] [blame] | 2135 | private static void logv(String msg) { |
| 2136 | Log.v(LOG_TAG, "[PhoneIntfMgr] " + msg); |
| 2137 | } |
| 2138 | |
Ihab Awad | f9e9273 | 2013-12-05 18:02:52 -0800 | [diff] [blame] | 2139 | private static void loge(String msg) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2140 | Log.e(LOG_TAG, "[PhoneIntfMgr] " + msg); |
| 2141 | } |
| 2142 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2143 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2144 | public int getActivePhoneType() { |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 2145 | return getActivePhoneTypeForSlot(getSlotForDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2146 | } |
| 2147 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2148 | @Override |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 2149 | public int getActivePhoneTypeForSlot(int slotIndex) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2150 | final long identity = Binder.clearCallingIdentity(); |
| 2151 | try { |
| 2152 | final Phone phone = PhoneFactory.getPhone(slotIndex); |
| 2153 | if (phone == null) { |
| 2154 | return PhoneConstants.PHONE_TYPE_NONE; |
| 2155 | } else { |
| 2156 | return phone.getPhoneType(); |
| 2157 | } |
| 2158 | } finally { |
| 2159 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2160 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2161 | } |
| 2162 | |
| 2163 | /** |
| 2164 | * Returns the CDMA ERI icon index to display |
| 2165 | */ |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2166 | @Override |
| 2167 | public int getCdmaEriIconIndex(String callingPackage) { |
| 2168 | return getCdmaEriIconIndexForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2169 | } |
| 2170 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2171 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2172 | public int getCdmaEriIconIndexForSubscriber(int subId, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2173 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 2174 | mApp, subId, callingPackage, "getCdmaEriIconIndexForSubscriber")) { |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2175 | return -1; |
| 2176 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2177 | |
| 2178 | final long identity = Binder.clearCallingIdentity(); |
| 2179 | try { |
| 2180 | final Phone phone = getPhone(subId); |
| 2181 | if (phone != null) { |
| 2182 | return phone.getCdmaEriIconIndex(); |
| 2183 | } else { |
| 2184 | return -1; |
| 2185 | } |
| 2186 | } finally { |
| 2187 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2188 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2189 | } |
| 2190 | |
| 2191 | /** |
| 2192 | * Returns the CDMA ERI icon mode, |
| 2193 | * 0 - ON |
| 2194 | * 1 - FLASHING |
| 2195 | */ |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2196 | @Override |
| 2197 | public int getCdmaEriIconMode(String callingPackage) { |
| 2198 | return getCdmaEriIconModeForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2199 | } |
| 2200 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2201 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2202 | public int getCdmaEriIconModeForSubscriber(int subId, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2203 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 2204 | mApp, subId, callingPackage, "getCdmaEriIconModeForSubscriber")) { |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2205 | return -1; |
| 2206 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2207 | |
| 2208 | final long identity = Binder.clearCallingIdentity(); |
| 2209 | try { |
| 2210 | final Phone phone = getPhone(subId); |
| 2211 | if (phone != null) { |
| 2212 | return phone.getCdmaEriIconMode(); |
| 2213 | } else { |
| 2214 | return -1; |
| 2215 | } |
| 2216 | } finally { |
| 2217 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2218 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2219 | } |
| 2220 | |
| 2221 | /** |
| 2222 | * Returns the CDMA ERI text, |
| 2223 | */ |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2224 | @Override |
| 2225 | public String getCdmaEriText(String callingPackage) { |
| 2226 | return getCdmaEriTextForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2227 | } |
| 2228 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2229 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2230 | public String getCdmaEriTextForSubscriber(int subId, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2231 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 2232 | mApp, subId, callingPackage, "getCdmaEriIconTextForSubscriber")) { |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2233 | return null; |
| 2234 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2235 | |
| 2236 | final long identity = Binder.clearCallingIdentity(); |
| 2237 | try { |
| 2238 | final Phone phone = getPhone(subId); |
| 2239 | if (phone != null) { |
| 2240 | return phone.getCdmaEriText(); |
| 2241 | } else { |
| 2242 | return null; |
| 2243 | } |
| 2244 | } finally { |
| 2245 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2246 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2247 | } |
| 2248 | |
| 2249 | /** |
Junda Liu | ca05d5d | 2014-08-14 22:36:34 -0700 | [diff] [blame] | 2250 | * Returns the CDMA MDN. |
| 2251 | */ |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2252 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 2253 | public String getCdmaMdn(int subId) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2254 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 2255 | mApp, subId, "getCdmaMdn"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2256 | |
| 2257 | final long identity = Binder.clearCallingIdentity(); |
| 2258 | try { |
| 2259 | final Phone phone = getPhone(subId); |
| 2260 | if (mPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA && phone != null) { |
| 2261 | return phone.getLine1Number(); |
| 2262 | } else { |
| 2263 | return null; |
| 2264 | } |
| 2265 | } finally { |
| 2266 | Binder.restoreCallingIdentity(identity); |
Junda Liu | ca05d5d | 2014-08-14 22:36:34 -0700 | [diff] [blame] | 2267 | } |
| 2268 | } |
| 2269 | |
| 2270 | /** |
| 2271 | * Returns the CDMA MIN. |
| 2272 | */ |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2273 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 2274 | public String getCdmaMin(int subId) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2275 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 2276 | mApp, subId, "getCdmaMin"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2277 | |
| 2278 | final long identity = Binder.clearCallingIdentity(); |
| 2279 | try { |
| 2280 | final Phone phone = getPhone(subId); |
| 2281 | if (phone != null && phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) { |
| 2282 | return phone.getCdmaMin(); |
| 2283 | } else { |
| 2284 | return null; |
| 2285 | } |
| 2286 | } finally { |
| 2287 | Binder.restoreCallingIdentity(identity); |
Junda Liu | ca05d5d | 2014-08-14 22:36:34 -0700 | [diff] [blame] | 2288 | } |
| 2289 | } |
| 2290 | |
| 2291 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2292 | * Returns true if CDMA provisioning needs to run. |
| 2293 | */ |
| 2294 | public boolean needsOtaServiceProvisioning() { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2295 | final long identity = Binder.clearCallingIdentity(); |
| 2296 | try { |
| 2297 | return mPhone.needsOtaServiceProvisioning(); |
| 2298 | } finally { |
| 2299 | Binder.restoreCallingIdentity(identity); |
| 2300 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2301 | } |
| 2302 | |
| 2303 | /** |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 2304 | * Sets the voice mail number of a given subId. |
| 2305 | */ |
| 2306 | @Override |
| 2307 | public boolean setVoiceMailNumber(int subId, String alphaTag, String number) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2308 | TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege(subId, "setVoiceMailNumber"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2309 | |
| 2310 | final long identity = Binder.clearCallingIdentity(); |
| 2311 | try { |
| 2312 | Boolean success = (Boolean) sendRequest(CMD_SET_VOICEMAIL_NUMBER, |
| 2313 | new Pair<String, String>(alphaTag, number), new Integer(subId)); |
| 2314 | return success; |
| 2315 | } finally { |
| 2316 | Binder.restoreCallingIdentity(identity); |
| 2317 | } |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 2318 | } |
| 2319 | |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 2320 | @Override |
Ta-wei Yen | c9df043 | 2017-04-17 17:09:07 -0700 | [diff] [blame] | 2321 | public Bundle getVisualVoicemailSettings(String callingPackage, int subId) { |
| 2322 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
| 2323 | String systemDialer = TelecomManager.from(mPhone.getContext()).getSystemDialerPackage(); |
| 2324 | if (!TextUtils.equals(callingPackage, systemDialer)) { |
| 2325 | throw new SecurityException("caller must be system dialer"); |
| 2326 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2327 | |
| 2328 | final long identity = Binder.clearCallingIdentity(); |
| 2329 | try { |
| 2330 | PhoneAccountHandle phoneAccountHandle = PhoneAccountHandleConverter.fromSubId(subId); |
| 2331 | if (phoneAccountHandle == null) { |
| 2332 | return null; |
| 2333 | } |
| 2334 | return VisualVoicemailSettingsUtil.dump(mPhone.getContext(), phoneAccountHandle); |
| 2335 | } finally { |
| 2336 | Binder.restoreCallingIdentity(identity); |
Ta-wei Yen | c9df043 | 2017-04-17 17:09:07 -0700 | [diff] [blame] | 2337 | } |
Ta-wei Yen | c9df043 | 2017-04-17 17:09:07 -0700 | [diff] [blame] | 2338 | } |
| 2339 | |
| 2340 | @Override |
Ta-wei Yen | 409ac56 | 2017-03-06 16:00:44 -0800 | [diff] [blame] | 2341 | public String getVisualVoicemailPackageName(String callingPackage, int subId) { |
Ta-wei Yen | dca928f | 2017-01-10 16:17:08 -0800 | [diff] [blame] | 2342 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2343 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 2344 | mApp, subId, callingPackage, "getVisualVoicemailPackageName")) { |
Ta-wei Yen | dca928f | 2017-01-10 16:17:08 -0800 | [diff] [blame] | 2345 | return null; |
| 2346 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2347 | |
Jeff Davidson | a8e4e24 | 2018-03-15 17:16:18 -0700 | [diff] [blame] | 2348 | final long identity = Binder.clearCallingIdentity(); |
| 2349 | try { |
| 2350 | return RemoteVvmTaskManager |
| 2351 | .getRemotePackage(mPhone.getContext(), subId).getPackageName(); |
| 2352 | } finally { |
| 2353 | Binder.restoreCallingIdentity(identity); |
| 2354 | } |
Ta-wei Yen | dca928f | 2017-01-10 16:17:08 -0800 | [diff] [blame] | 2355 | } |
| 2356 | |
| 2357 | @Override |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame] | 2358 | public void enableVisualVoicemailSmsFilter(String callingPackage, int subId, |
| 2359 | VisualVoicemailSmsFilterSettings settings) { |
| 2360 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2361 | |
| 2362 | final long identity = Binder.clearCallingIdentity(); |
| 2363 | try { |
| 2364 | VisualVoicemailSmsFilterConfig.enableVisualVoicemailSmsFilter( |
| 2365 | mPhone.getContext(), callingPackage, subId, settings); |
| 2366 | } finally { |
| 2367 | Binder.restoreCallingIdentity(identity); |
| 2368 | } |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 2369 | } |
| 2370 | |
| 2371 | @Override |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame] | 2372 | public void disableVisualVoicemailSmsFilter(String callingPackage, int subId) { |
| 2373 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2374 | |
| 2375 | final long identity = Binder.clearCallingIdentity(); |
| 2376 | try { |
| 2377 | VisualVoicemailSmsFilterConfig.disableVisualVoicemailSmsFilter( |
| 2378 | mPhone.getContext(), callingPackage, subId); |
| 2379 | } finally { |
| 2380 | Binder.restoreCallingIdentity(identity); |
| 2381 | } |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 2382 | } |
| 2383 | |
| 2384 | @Override |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame] | 2385 | public VisualVoicemailSmsFilterSettings getVisualVoicemailSmsFilterSettings( |
| 2386 | String callingPackage, int subId) { |
| 2387 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2388 | |
| 2389 | final long identity = Binder.clearCallingIdentity(); |
| 2390 | try { |
| 2391 | return VisualVoicemailSmsFilterConfig.getVisualVoicemailSmsFilterSettings( |
| 2392 | mPhone.getContext(), callingPackage, subId); |
| 2393 | } finally { |
| 2394 | Binder.restoreCallingIdentity(identity); |
| 2395 | } |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 2396 | } |
| 2397 | |
| 2398 | @Override |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 2399 | public VisualVoicemailSmsFilterSettings getActiveVisualVoicemailSmsFilterSettings(int subId) { |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 2400 | enforceReadPrivilegedPermission("getActiveVisualVoicemailSmsFilterSettings"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2401 | |
| 2402 | final long identity = Binder.clearCallingIdentity(); |
| 2403 | try { |
| 2404 | return VisualVoicemailSmsFilterConfig.getActiveVisualVoicemailSmsFilterSettings( |
| 2405 | mPhone.getContext(), subId); |
| 2406 | } finally { |
| 2407 | Binder.restoreCallingIdentity(identity); |
| 2408 | } |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 2409 | } |
| 2410 | |
| 2411 | @Override |
| 2412 | public void sendVisualVoicemailSmsForSubscriber(String callingPackage, int subId, |
| 2413 | String number, int port, String text, PendingIntent sentIntent) { |
| 2414 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Ta-wei Yen | 527a9c0 | 2017-01-06 15:29:25 -0800 | [diff] [blame] | 2415 | enforceVisualVoicemailPackage(callingPackage, subId); |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 2416 | enforceSendSmsPermission(); |
| 2417 | // Make the calls as the phone process. |
| 2418 | final long identity = Binder.clearCallingIdentity(); |
| 2419 | try { |
| 2420 | SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId); |
| 2421 | if (port == 0) { |
| 2422 | smsManager.sendTextMessageWithSelfPermissions(number, null, text, |
| 2423 | sentIntent, null, false); |
| 2424 | } else { |
| 2425 | byte[] data = text.getBytes(StandardCharsets.UTF_8); |
| 2426 | smsManager.sendDataMessageWithSelfPermissions(number, null, |
| 2427 | (short) port, data, sentIntent, null); |
| 2428 | } |
| 2429 | } finally { |
| 2430 | Binder.restoreCallingIdentity(identity); |
| 2431 | } |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 2432 | } |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 2433 | /** |
fionaxu | 0152e51 | 2016-11-14 13:36:14 -0800 | [diff] [blame] | 2434 | * Sets the voice activation state of a given subId. |
| 2435 | */ |
| 2436 | @Override |
| 2437 | public void setVoiceActivationState(int subId, int activationState) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2438 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 2439 | mApp, subId, "setVoiceActivationState"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2440 | |
| 2441 | final long identity = Binder.clearCallingIdentity(); |
| 2442 | try { |
| 2443 | final Phone phone = getPhone(subId); |
| 2444 | if (phone != null) { |
| 2445 | phone.setVoiceActivationState(activationState); |
| 2446 | } else { |
| 2447 | loge("setVoiceActivationState fails with invalid subId: " + subId); |
| 2448 | } |
| 2449 | } finally { |
| 2450 | Binder.restoreCallingIdentity(identity); |
fionaxu | 0152e51 | 2016-11-14 13:36:14 -0800 | [diff] [blame] | 2451 | } |
| 2452 | } |
| 2453 | |
| 2454 | /** |
| 2455 | * Sets the data activation state of a given subId. |
| 2456 | */ |
| 2457 | @Override |
| 2458 | public void setDataActivationState(int subId, int activationState) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2459 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 2460 | mApp, subId, "setDataActivationState"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2461 | |
| 2462 | final long identity = Binder.clearCallingIdentity(); |
| 2463 | try { |
| 2464 | final Phone phone = getPhone(subId); |
| 2465 | if (phone != null) { |
| 2466 | phone.setDataActivationState(activationState); |
| 2467 | } else { |
| 2468 | loge("setVoiceActivationState fails with invalid subId: " + subId); |
| 2469 | } |
| 2470 | } finally { |
| 2471 | Binder.restoreCallingIdentity(identity); |
fionaxu | 0152e51 | 2016-11-14 13:36:14 -0800 | [diff] [blame] | 2472 | } |
| 2473 | } |
| 2474 | |
| 2475 | /** |
| 2476 | * Returns the voice activation state of a given subId. |
| 2477 | */ |
| 2478 | @Override |
| 2479 | public int getVoiceActivationState(int subId, String callingPackage) { |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 2480 | enforceReadPrivilegedPermission("getVoiceActivationState"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2481 | |
fionaxu | 0152e51 | 2016-11-14 13:36:14 -0800 | [diff] [blame] | 2482 | final Phone phone = getPhone(subId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2483 | final long identity = Binder.clearCallingIdentity(); |
| 2484 | try { |
| 2485 | if (phone != null) { |
| 2486 | return phone.getVoiceActivationState(); |
| 2487 | } else { |
| 2488 | return TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN; |
| 2489 | } |
| 2490 | } finally { |
| 2491 | Binder.restoreCallingIdentity(identity); |
fionaxu | 0152e51 | 2016-11-14 13:36:14 -0800 | [diff] [blame] | 2492 | } |
| 2493 | } |
| 2494 | |
| 2495 | /** |
| 2496 | * Returns the data activation state of a given subId. |
| 2497 | */ |
| 2498 | @Override |
| 2499 | public int getDataActivationState(int subId, String callingPackage) { |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 2500 | enforceReadPrivilegedPermission("getDataActivationState"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2501 | |
fionaxu | 0152e51 | 2016-11-14 13:36:14 -0800 | [diff] [blame] | 2502 | final Phone phone = getPhone(subId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2503 | final long identity = Binder.clearCallingIdentity(); |
| 2504 | try { |
| 2505 | if (phone != null) { |
| 2506 | return phone.getDataActivationState(); |
| 2507 | } else { |
| 2508 | return TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN; |
| 2509 | } |
| 2510 | } finally { |
| 2511 | Binder.restoreCallingIdentity(identity); |
fionaxu | 0152e51 | 2016-11-14 13:36:14 -0800 | [diff] [blame] | 2512 | } |
| 2513 | } |
| 2514 | |
| 2515 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2516 | * Returns the unread count of voicemails |
| 2517 | */ |
| 2518 | public int getVoiceMessageCount() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 2519 | return getVoiceMessageCountForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2520 | } |
| 2521 | |
| 2522 | /** |
| 2523 | * Returns the unread count of voicemails for a subId |
| 2524 | */ |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2525 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 2526 | public int getVoiceMessageCountForSubscriber( int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2527 | final long identity = Binder.clearCallingIdentity(); |
| 2528 | try { |
| 2529 | final Phone phone = getPhone(subId); |
| 2530 | if (phone != null) { |
| 2531 | return phone.getVoiceMessageCount(); |
| 2532 | } else { |
| 2533 | return 0; |
| 2534 | } |
| 2535 | } finally { |
| 2536 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2537 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2538 | } |
| 2539 | |
| 2540 | /** |
pkanwar | 8a4dcfb | 2017-01-19 13:43:16 -0800 | [diff] [blame] | 2541 | * returns true, if the device is in a state where both voice and data |
| 2542 | * are supported simultaneously. This can change based on location or network condition. |
| 2543 | */ |
| 2544 | @Override |
| 2545 | public boolean isConcurrentVoiceAndDataAllowed(int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2546 | final long identity = Binder.clearCallingIdentity(); |
| 2547 | try { |
| 2548 | final Phone phone = getPhone(subId); |
| 2549 | return (phone == null ? false : phone.isConcurrentVoiceAndDataAllowed()); |
| 2550 | } finally { |
| 2551 | Binder.restoreCallingIdentity(identity); |
| 2552 | } |
pkanwar | 8a4dcfb | 2017-01-19 13:43:16 -0800 | [diff] [blame] | 2553 | } |
| 2554 | |
| 2555 | /** |
fionaxu | 235cc5e | 2017-03-06 22:25:57 -0800 | [diff] [blame] | 2556 | * Send the dialer code if called from the current default dialer or the caller has |
| 2557 | * carrier privilege. |
| 2558 | * @param inputCode The dialer code to send |
| 2559 | */ |
| 2560 | @Override |
| 2561 | public void sendDialerSpecialCode(String callingPackage, String inputCode) { |
| 2562 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
| 2563 | String defaultDialer = TelecomManager.from(mPhone.getContext()).getDefaultDialerPackage(); |
| 2564 | if (!TextUtils.equals(callingPackage, defaultDialer)) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2565 | TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege( |
| 2566 | getDefaultSubscription(), "sendDialerSpecialCode"); |
fionaxu | 235cc5e | 2017-03-06 22:25:57 -0800 | [diff] [blame] | 2567 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2568 | |
| 2569 | final long identity = Binder.clearCallingIdentity(); |
| 2570 | try { |
| 2571 | mPhone.sendDialerSpecialCode(inputCode); |
| 2572 | } finally { |
| 2573 | Binder.restoreCallingIdentity(identity); |
| 2574 | } |
fionaxu | 235cc5e | 2017-03-06 22:25:57 -0800 | [diff] [blame] | 2575 | } |
| 2576 | |
| 2577 | /** |
Robert Greenwalt | a5dcfcb | 2015-07-10 09:06:29 -0700 | [diff] [blame] | 2578 | * Returns the data network type. |
| 2579 | * Legacy call, permission-free. |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2580 | * |
| 2581 | * @Deprecated to be removed Q3 2013 use {@link #getDataNetworkType}. |
| 2582 | */ |
| 2583 | @Override |
Robert Greenwalt | a5dcfcb | 2015-07-10 09:06:29 -0700 | [diff] [blame] | 2584 | public int getNetworkType() { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2585 | final long identity = Binder.clearCallingIdentity(); |
| 2586 | try { |
| 2587 | final Phone phone = getPhone(getDefaultSubscription()); |
| 2588 | if (phone != null) { |
| 2589 | return phone.getServiceState().getDataNetworkType(); |
| 2590 | } else { |
| 2591 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 2592 | } |
| 2593 | } finally { |
| 2594 | Binder.restoreCallingIdentity(identity); |
Robert Greenwalt | a5dcfcb | 2015-07-10 09:06:29 -0700 | [diff] [blame] | 2595 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2596 | } |
| 2597 | |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 2598 | @Override |
| 2599 | public int getNetworkSelectionMode(int subId) { |
Pengquan Meng | e92a50d | 2018-09-21 15:54:48 -0700 | [diff] [blame] | 2600 | if (!isActiveSubscription(subId)) { |
| 2601 | return TelephonyManager.NETWORK_SELECTION_MODE_UNKNOWN; |
| 2602 | } |
| 2603 | |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 2604 | return (int) sendRequest(CMD_GET_NETWORK_SELECTION_MODE, null /* argument */, subId); |
| 2605 | } |
| 2606 | |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 2607 | @Override |
| 2608 | public void addImsRegistrationCallback(int subId, IImsRegistrationCallback c, |
| 2609 | String callingPackage) throws RemoteException { |
| 2610 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, subId, callingPackage, |
| 2611 | "addImsRegistrationCallback")) { |
| 2612 | return; |
| 2613 | } |
| 2614 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2615 | final long token = Binder.clearCallingIdentity(); |
| 2616 | try { |
| 2617 | ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId)) |
| 2618 | .addRegistrationCallbackForSubscription(c, subId); |
| 2619 | } finally { |
| 2620 | Binder.restoreCallingIdentity(token); |
| 2621 | } |
| 2622 | } |
| 2623 | |
| 2624 | @Override |
| 2625 | public void removeImsRegistrationCallback(int subId, IImsRegistrationCallback c, |
| 2626 | String callingPackage) { |
| 2627 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, subId, callingPackage, |
| 2628 | "removeImsRegistrationCallback")) { |
| 2629 | return; |
| 2630 | } |
| 2631 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2632 | Binder.withCleanCallingIdentity(() -> |
| 2633 | ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId)) |
| 2634 | .removeRegistrationCallbackForSubscription(c, subId)); |
| 2635 | } |
| 2636 | |
| 2637 | @Override |
| 2638 | public void addMmTelCapabilityCallback(int subId, IImsCapabilityCallback c, |
| 2639 | String callingPackage) throws RemoteException { |
| 2640 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, subId, callingPackage, |
| 2641 | "addMmTelCapabilityCallback")) { |
| 2642 | return; |
| 2643 | } |
| 2644 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2645 | final long token = Binder.clearCallingIdentity(); |
| 2646 | try { |
| 2647 | ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId)) |
| 2648 | .addCapabilitiesCallbackForSubscription(c, subId); |
| 2649 | } finally { |
| 2650 | Binder.restoreCallingIdentity(token); |
| 2651 | } |
| 2652 | } |
| 2653 | |
| 2654 | @Override |
| 2655 | public void removeMmTelCapabilityCallback(int subId, IImsCapabilityCallback c, |
| 2656 | String callingPackage) { |
| 2657 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, subId, callingPackage, |
| 2658 | "removeMmTelCapabilityCallback")) { |
| 2659 | return; |
| 2660 | } |
| 2661 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2662 | Binder.withCleanCallingIdentity(() -> |
| 2663 | ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId)) |
| 2664 | .removeCapabilitiesCallbackForSubscription(c, subId)); |
| 2665 | } |
| 2666 | |
| 2667 | @Override |
| 2668 | public boolean isCapable(int subId, int capability, int regTech, String callingPackage) { |
| 2669 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, subId, callingPackage, |
| 2670 | "isCapable")) { |
| 2671 | return false; |
| 2672 | } |
| 2673 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2674 | final long token = Binder.clearCallingIdentity(); |
| 2675 | try { |
| 2676 | return ImsManager.getInstance(mPhone.getContext(), |
| 2677 | getSlotIndexOrException(subId)).queryMmTelCapability(capability, regTech); |
| 2678 | } catch (ImsException e) { |
| 2679 | Log.w(LOG_TAG, "IMS isCapable - service unavailable: " + e.getMessage()); |
| 2680 | return false; |
| 2681 | } finally { |
| 2682 | Binder.restoreCallingIdentity(token); |
| 2683 | } |
| 2684 | } |
| 2685 | |
| 2686 | @Override |
| 2687 | public boolean isAvailable(int subId, int capability, int regTech, String callingPackage) { |
| 2688 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, subId, callingPackage, |
| 2689 | "isAvailable")) { |
| 2690 | return false; |
| 2691 | } |
| 2692 | final long token = Binder.clearCallingIdentity(); |
| 2693 | try { |
| 2694 | Phone phone = getPhone(subId); |
| 2695 | if (phone == null) return false; |
| 2696 | return phone.isImsCapabilityAvailable(capability, regTech); |
| 2697 | } finally { |
| 2698 | Binder.restoreCallingIdentity(token); |
| 2699 | } |
| 2700 | } |
| 2701 | |
| 2702 | @Override |
| 2703 | public boolean isAdvancedCallingSettingEnabled(int subId) { |
| 2704 | enforceReadPrivilegedPermission("enforceReadPrivilegedPermission"); |
| 2705 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2706 | final long token = Binder.clearCallingIdentity(); |
| 2707 | try { |
| 2708 | return ImsManager.getInstance(mPhone.getContext(), |
| 2709 | getSlotIndexOrException(subId)).isEnhanced4gLteModeSettingEnabledByUser(); |
| 2710 | } finally { |
| 2711 | Binder.restoreCallingIdentity(token); |
| 2712 | } |
| 2713 | } |
| 2714 | |
| 2715 | @Override |
| 2716 | public void setAdvancedCallingSetting(int subId, boolean isEnabled) { |
| 2717 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp, subId, |
| 2718 | "setAdvancedCallingSetting"); |
| 2719 | final long identity = Binder.clearCallingIdentity(); |
| 2720 | try { |
| 2721 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2722 | ImsManager.getInstance(mPhone.getContext(), |
| 2723 | getSlotIndexOrException(subId)).setEnhanced4gLteModeSetting(isEnabled); |
| 2724 | } finally { |
| 2725 | Binder.restoreCallingIdentity(identity); |
| 2726 | } |
| 2727 | } |
| 2728 | |
| 2729 | @Override |
| 2730 | public boolean isVtSettingEnabled(int subId, String callingPackage) { |
| 2731 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, subId, callingPackage, |
| 2732 | "isVtSettingEnabled")) { |
| 2733 | return false; |
| 2734 | } |
| 2735 | final long identity = Binder.clearCallingIdentity(); |
| 2736 | try { |
| 2737 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2738 | return ImsManager.getInstance(mPhone.getContext(), |
| 2739 | getSlotIndexOrException(subId)).isVtEnabledByUser(); |
| 2740 | } finally { |
| 2741 | Binder.restoreCallingIdentity(identity); |
| 2742 | } |
| 2743 | } |
| 2744 | |
| 2745 | @Override |
| 2746 | public void setVtSetting(int subId, boolean isEnabled) { |
| 2747 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp, subId, |
| 2748 | "setVtSetting"); |
| 2749 | final long identity = Binder.clearCallingIdentity(); |
| 2750 | try { |
| 2751 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2752 | ImsManager.getInstance(mPhone.getContext(), |
| 2753 | getSlotIndexOrException(subId)).setVtSetting(isEnabled); |
| 2754 | } finally { |
| 2755 | Binder.restoreCallingIdentity(identity); |
| 2756 | } |
| 2757 | } |
| 2758 | |
| 2759 | @Override |
| 2760 | public boolean isVoWiFiSettingEnabled(int subId) { |
| 2761 | enforceReadPrivilegedPermission("isVoWiFiSettingEnabled"); |
| 2762 | final long identity = Binder.clearCallingIdentity(); |
| 2763 | try { |
| 2764 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2765 | return ImsManager.getInstance(mPhone.getContext(), |
| 2766 | getSlotIndexOrException(subId)).isWfcEnabledByUser(); |
| 2767 | } finally { |
| 2768 | Binder.restoreCallingIdentity(identity); |
| 2769 | } |
| 2770 | } |
| 2771 | |
| 2772 | @Override |
| 2773 | public void setVoWiFiSetting(int subId, boolean isEnabled) { |
| 2774 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp, subId, |
| 2775 | "setVoWiFiSetting"); |
| 2776 | final long identity = Binder.clearCallingIdentity(); |
| 2777 | try { |
| 2778 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2779 | ImsManager.getInstance(mPhone.getContext(), |
| 2780 | getSlotIndexOrException(subId)).setWfcSetting(isEnabled); |
| 2781 | } finally { |
| 2782 | Binder.restoreCallingIdentity(identity); |
| 2783 | } |
| 2784 | } |
| 2785 | |
| 2786 | @Override |
| 2787 | public boolean isVoWiFiRoamingSettingEnabled(int subId) { |
| 2788 | enforceReadPrivilegedPermission("isVoWiFiRoamingSettingEnabled"); |
| 2789 | final long identity = Binder.clearCallingIdentity(); |
| 2790 | try { |
| 2791 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2792 | return ImsManager.getInstance(mPhone.getContext(), |
| 2793 | getSlotIndexOrException(subId)).isWfcRoamingEnabledByUser(); |
| 2794 | } finally { |
| 2795 | Binder.restoreCallingIdentity(identity); |
| 2796 | } |
| 2797 | } |
| 2798 | |
| 2799 | @Override |
| 2800 | public void setVoWiFiRoamingSetting(int subId, boolean isEnabled) { |
| 2801 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp, subId, |
| 2802 | "setVoWiFiRoamingSetting"); |
| 2803 | final long identity = Binder.clearCallingIdentity(); |
| 2804 | try { |
| 2805 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2806 | ImsManager.getInstance(mPhone.getContext(), |
| 2807 | getSlotIndexOrException(subId)).setWfcRoamingSetting(isEnabled); |
| 2808 | } finally { |
| 2809 | Binder.restoreCallingIdentity(identity); |
| 2810 | } |
| 2811 | } |
| 2812 | |
| 2813 | @Override |
| 2814 | public void setVoWiFiNonPersistent(int subId, boolean isCapable, int mode) { |
| 2815 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp, subId, |
| 2816 | "setVoWiFiNonPersistent"); |
| 2817 | final long identity = Binder.clearCallingIdentity(); |
| 2818 | try { |
| 2819 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2820 | ImsManager.getInstance(mPhone.getContext(), |
| 2821 | getSlotIndexOrException(subId)).setWfcNonPersistent(isCapable, mode); |
| 2822 | } finally { |
| 2823 | Binder.restoreCallingIdentity(identity); |
| 2824 | } |
| 2825 | } |
| 2826 | |
| 2827 | @Override |
| 2828 | public int getVoWiFiModeSetting(int subId) { |
| 2829 | enforceReadPrivilegedPermission("getVoWiFiModeSetting"); |
| 2830 | final long identity = Binder.clearCallingIdentity(); |
| 2831 | try { |
| 2832 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2833 | return ImsManager.getInstance(mPhone.getContext(), |
| 2834 | getSlotIndexOrException(subId)).getWfcMode(false /*isRoaming*/); |
| 2835 | } finally { |
| 2836 | Binder.restoreCallingIdentity(identity); |
| 2837 | } |
| 2838 | } |
| 2839 | |
| 2840 | @Override |
| 2841 | public void setVoWiFiModeSetting(int subId, int mode) { |
| 2842 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp, subId, |
| 2843 | "setVoWiFiModeSetting"); |
| 2844 | final long identity = Binder.clearCallingIdentity(); |
| 2845 | try { |
| 2846 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2847 | ImsManager.getInstance(mPhone.getContext(), |
| 2848 | getSlotIndexOrException(subId)).setWfcMode(mode, false /*isRoaming*/); |
| 2849 | } finally { |
| 2850 | Binder.restoreCallingIdentity(identity); |
| 2851 | } |
| 2852 | } |
| 2853 | |
| 2854 | @Override |
| 2855 | public int getVoWiFiRoamingModeSetting(int subId) { |
| 2856 | enforceReadPrivilegedPermission("getVoWiFiRoamingModeSetting"); |
| 2857 | final long identity = Binder.clearCallingIdentity(); |
| 2858 | try { |
| 2859 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2860 | return ImsManager.getInstance(mPhone.getContext(), |
| 2861 | getSlotIndexOrException(subId)).getWfcMode(true /*isRoaming*/); |
| 2862 | } finally { |
| 2863 | Binder.restoreCallingIdentity(identity); |
| 2864 | } |
| 2865 | } |
| 2866 | |
| 2867 | @Override |
| 2868 | public void setVoWiFiRoamingModeSetting(int subId, int mode) { |
| 2869 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp, subId, |
| 2870 | "setVoWiFiRoamingModeSetting"); |
| 2871 | final long identity = Binder.clearCallingIdentity(); |
| 2872 | try { |
| 2873 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2874 | ImsManager.getInstance(mPhone.getContext(), |
| 2875 | getSlotIndexOrException(subId)).setWfcMode(mode, true /*isRoaming*/); |
| 2876 | } finally { |
| 2877 | Binder.restoreCallingIdentity(identity); |
| 2878 | } |
| 2879 | } |
| 2880 | |
| 2881 | @Override |
| 2882 | public void setRttCapabilitySetting(int subId, boolean isEnabled) { |
| 2883 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp, subId, |
| 2884 | "setRttCapabilityEnabled"); |
| 2885 | final long identity = Binder.clearCallingIdentity(); |
| 2886 | try { |
| 2887 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2888 | ImsManager.getInstance(mPhone.getContext(), |
| 2889 | getSlotIndexOrException(subId)).setRttEnabled(isEnabled); |
| 2890 | } finally { |
| 2891 | Binder.restoreCallingIdentity(identity); |
| 2892 | } |
| 2893 | } |
| 2894 | |
| 2895 | @Override |
| 2896 | public boolean isTtyOverVolteEnabled(int subId) { |
| 2897 | enforceReadPrivilegedPermission("isTtyOverVolteEnabled"); |
| 2898 | final long identity = Binder.clearCallingIdentity(); |
| 2899 | try { |
| 2900 | // TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly. |
| 2901 | return ImsManager.getInstance(mPhone.getContext(), |
| 2902 | getSlotIndexOrException(subId)).isTtyOnVoLteCapable(); |
| 2903 | } finally { |
| 2904 | Binder.restoreCallingIdentity(identity); |
| 2905 | } |
| 2906 | } |
| 2907 | |
| 2908 | private int getSlotIndexOrException(int subId) throws IllegalArgumentException { |
| 2909 | int slotId = SubscriptionManager.getSlotIndex(subId); |
| 2910 | if (!SubscriptionManager.isValidSlotIndex(slotId)) { |
| 2911 | throw new IllegalArgumentException("Invalid Subscription Id."); |
| 2912 | } |
| 2913 | return slotId; |
| 2914 | } |
| 2915 | |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2916 | /** |
| 2917 | * Returns the network type for a subId |
| 2918 | */ |
| 2919 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2920 | public int getNetworkTypeForSubscriber(int subId, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2921 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 2922 | mApp, subId, callingPackage, "getNetworkTypeForSubscriber")) { |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2923 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 2924 | } |
Robert Greenwalt | a5dcfcb | 2015-07-10 09:06:29 -0700 | [diff] [blame] | 2925 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2926 | final long identity = Binder.clearCallingIdentity(); |
| 2927 | try { |
| 2928 | final Phone phone = getPhone(subId); |
| 2929 | if (phone != null) { |
| 2930 | return phone.getServiceState().getDataNetworkType(); |
| 2931 | } else { |
| 2932 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 2933 | } |
| 2934 | } finally { |
| 2935 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2936 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2937 | } |
| 2938 | |
| 2939 | /** |
| 2940 | * Returns the data network type |
| 2941 | */ |
| 2942 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2943 | public int getDataNetworkType(String callingPackage) { |
| 2944 | return getDataNetworkTypeForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2945 | } |
| 2946 | |
| 2947 | /** |
| 2948 | * Returns the data network type for a subId |
| 2949 | */ |
| 2950 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2951 | public int getDataNetworkTypeForSubscriber(int subId, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2952 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 2953 | mApp, subId, callingPackage, "getDataNetworkTypeForSubscriber")) { |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2954 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 2955 | } |
| 2956 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2957 | final long identity = Binder.clearCallingIdentity(); |
| 2958 | try { |
| 2959 | final Phone phone = getPhone(subId); |
| 2960 | if (phone != null) { |
| 2961 | return phone.getServiceState().getDataNetworkType(); |
| 2962 | } else { |
| 2963 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 2964 | } |
| 2965 | } finally { |
| 2966 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2967 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2968 | } |
| 2969 | |
| 2970 | /** |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2971 | * Returns the Voice network type for a subId |
| 2972 | */ |
| 2973 | @Override |
Robert Greenwalt | a5dcfcb | 2015-07-10 09:06:29 -0700 | [diff] [blame] | 2974 | public int getVoiceNetworkTypeForSubscriber(int subId, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 2975 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 2976 | mApp, subId, callingPackage, "getDataNetworkTypeForSubscriber")) { |
Robert Greenwalt | a5dcfcb | 2015-07-10 09:06:29 -0700 | [diff] [blame] | 2977 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 2978 | } |
| 2979 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 2980 | final long identity = Binder.clearCallingIdentity(); |
| 2981 | try { |
| 2982 | final Phone phone = getPhone(subId); |
| 2983 | if (phone != null) { |
| 2984 | return phone.getServiceState().getVoiceNetworkType(); |
| 2985 | } else { |
| 2986 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 2987 | } |
| 2988 | } finally { |
| 2989 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2990 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2991 | } |
| 2992 | |
| 2993 | /** |
| 2994 | * @return true if a ICC card is present |
| 2995 | */ |
| 2996 | public boolean hasIccCard() { |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2997 | // FIXME Make changes to pass defaultSimId of type int |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 2998 | return hasIccCardUsingSlotIndex(mSubscriptionController.getSlotIndex( |
| 2999 | getDefaultSubscription())); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 3000 | } |
| 3001 | |
| 3002 | /** |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 3003 | * @return true if a ICC card is present for a slotIndex |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 3004 | */ |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 3005 | @Override |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 3006 | public boolean hasIccCardUsingSlotIndex(int slotIndex) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3007 | final long identity = Binder.clearCallingIdentity(); |
| 3008 | try { |
| 3009 | final Phone phone = PhoneFactory.getPhone(slotIndex); |
| 3010 | if (phone != null) { |
| 3011 | return phone.getIccCard().hasIccCard(); |
| 3012 | } else { |
| 3013 | return false; |
| 3014 | } |
| 3015 | } finally { |
| 3016 | Binder.restoreCallingIdentity(identity); |
Amit Mahajan | a6fc2a8 | 2015-01-06 11:53:51 -0800 | [diff] [blame] | 3017 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 3018 | } |
| 3019 | |
| 3020 | /** |
| 3021 | * Return if the current radio is LTE on CDMA. This |
| 3022 | * is a tri-state return value as for a period of time |
| 3023 | * the mode may be unknown. |
| 3024 | * |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 3025 | * @param callingPackage the name of the package making the call. |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 3026 | * @return {@link Phone#LTE_ON_CDMA_UNKNOWN}, {@link Phone#LTE_ON_CDMA_FALSE} |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 3027 | * or {@link Phone#LTE_ON_CDMA_TRUE} |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 3028 | */ |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 3029 | @Override |
| 3030 | public int getLteOnCdmaMode(String callingPackage) { |
| 3031 | return getLteOnCdmaModeForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 3032 | } |
| 3033 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 3034 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 3035 | public int getLteOnCdmaModeForSubscriber(int subId, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3036 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 3037 | mApp, subId, callingPackage, "getLteOnCdmaModeForSubscriber")) { |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 3038 | return PhoneConstants.LTE_ON_CDMA_UNKNOWN; |
| 3039 | } |
| 3040 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3041 | final long identity = Binder.clearCallingIdentity(); |
| 3042 | try { |
| 3043 | final Phone phone = getPhone(subId); |
| 3044 | if (phone == null) { |
| 3045 | return PhoneConstants.LTE_ON_CDMA_UNKNOWN; |
| 3046 | } else { |
| 3047 | return phone.getLteOnCdmaMode(); |
| 3048 | } |
| 3049 | } finally { |
| 3050 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 3051 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 3052 | } |
| 3053 | |
| 3054 | public void setPhone(Phone phone) { |
| 3055 | mPhone = phone; |
| 3056 | } |
| 3057 | |
| 3058 | /** |
| 3059 | * {@hide} |
| 3060 | * Returns Default subId, 0 in the case of single standby. |
| 3061 | */ |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 3062 | private int getDefaultSubscription() { |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 3063 | return mSubscriptionController.getDefaultSubId(); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 3064 | } |
| 3065 | |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 3066 | private int getSlotForDefaultSubscription() { |
| 3067 | return mSubscriptionController.getPhoneId(getDefaultSubscription()); |
| 3068 | } |
| 3069 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 3070 | private int getPreferredVoiceSubscription() { |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 3071 | return mSubscriptionController.getDefaultVoiceSubId(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 3072 | } |
Ihab Awad | f2177b7 | 2013-11-25 13:33:23 -0800 | [diff] [blame] | 3073 | |
Pengquan Meng | e92a50d | 2018-09-21 15:54:48 -0700 | [diff] [blame] | 3074 | private boolean isActiveSubscription(int subId) { |
| 3075 | return mSubscriptionController.isActiveSubId(subId); |
| 3076 | } |
| 3077 | |
Ihab Awad | f2177b7 | 2013-11-25 13:33:23 -0800 | [diff] [blame] | 3078 | /** |
| 3079 | * @see android.telephony.TelephonyManager.WifiCallingChoices |
| 3080 | */ |
| 3081 | public int getWhenToMakeWifiCalls() { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3082 | final long identity = Binder.clearCallingIdentity(); |
| 3083 | try { |
| 3084 | return Settings.System.getInt(mPhone.getContext().getContentResolver(), |
| 3085 | Settings.System.WHEN_TO_MAKE_WIFI_CALLS, |
| 3086 | getWhenToMakeWifiCallsDefaultPreference()); |
| 3087 | } finally { |
| 3088 | Binder.restoreCallingIdentity(identity); |
| 3089 | } |
Ihab Awad | f2177b7 | 2013-11-25 13:33:23 -0800 | [diff] [blame] | 3090 | } |
| 3091 | |
| 3092 | /** |
| 3093 | * @see android.telephony.TelephonyManager.WifiCallingChoices |
| 3094 | */ |
| 3095 | public void setWhenToMakeWifiCalls(int preference) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3096 | final long identity = Binder.clearCallingIdentity(); |
| 3097 | try { |
| 3098 | if (DBG) log("setWhenToMakeWifiCallsStr, storing setting = " + preference); |
| 3099 | Settings.System.putInt(mPhone.getContext().getContentResolver(), |
| 3100 | Settings.System.WHEN_TO_MAKE_WIFI_CALLS, preference); |
| 3101 | } finally { |
| 3102 | Binder.restoreCallingIdentity(identity); |
| 3103 | } |
Ihab Awad | f9e9273 | 2013-12-05 18:02:52 -0800 | [diff] [blame] | 3104 | } |
| 3105 | |
Sailesh Nepal | d1e6815 | 2013-12-12 19:08:02 -0800 | [diff] [blame] | 3106 | private static int getWhenToMakeWifiCallsDefaultPreference() { |
Santos Cordon | da120f4 | 2014-08-06 04:44:34 -0700 | [diff] [blame] | 3107 | // TODO: Use a build property to choose this value. |
Evan Charlton | 9829e88 | 2013-12-19 15:30:38 -0800 | [diff] [blame] | 3108 | return TelephonyManager.WifiCallingChoices.ALWAYS_USE; |
Ihab Awad | f2177b7 | 2013-11-25 13:33:23 -0800 | [diff] [blame] | 3109 | } |
Shishir Agrawal | 69f6812 | 2013-12-16 17:25:49 -0800 | [diff] [blame] | 3110 | |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3111 | @Override |
Derek Tan | 740e167 | 2017-06-27 14:56:27 -0700 | [diff] [blame] | 3112 | public IccOpenLogicalChannelResponse iccOpenLogicalChannel( |
| 3113 | int subId, String callingPackage, String aid, int p2) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3114 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3115 | mApp, subId, "iccOpenLogicalChannel"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3116 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3117 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3118 | final long identity = Binder.clearCallingIdentity(); |
| 3119 | try { |
| 3120 | if (TextUtils.equals(ISDR_AID, aid)) { |
| 3121 | // Only allows LPA to open logical channel to ISD-R. |
| 3122 | ComponentInfo bestComponent = |
| 3123 | EuiccConnector.findBestComponent(mPhone.getContext().getPackageManager()); |
| 3124 | if (bestComponent == null |
| 3125 | || !TextUtils.equals(callingPackage, bestComponent.packageName)) { |
| 3126 | loge("The calling package is not allowed to access ISD-R."); |
| 3127 | throw new SecurityException( |
| 3128 | "The calling package is not allowed to access ISD-R."); |
| 3129 | } |
Derek Tan | 740e167 | 2017-06-27 14:56:27 -0700 | [diff] [blame] | 3130 | } |
Derek Tan | 740e167 | 2017-06-27 14:56:27 -0700 | [diff] [blame] | 3131 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3132 | if (DBG) { |
| 3133 | log("iccOpenLogicalChannel: subId=" + subId + " aid=" + aid + " p2=" + p2); |
| 3134 | } |
| 3135 | IccOpenLogicalChannelResponse response = (IccOpenLogicalChannelResponse) sendRequest( |
| 3136 | CMD_OPEN_CHANNEL, new Pair<String, Integer>(aid, p2), subId); |
| 3137 | if (DBG) log("iccOpenLogicalChannel: " + response); |
| 3138 | return response; |
| 3139 | } finally { |
| 3140 | Binder.restoreCallingIdentity(identity); |
| 3141 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3142 | } |
| 3143 | |
| 3144 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 3145 | public boolean iccCloseLogicalChannel(int subId, int channel) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3146 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3147 | mApp, subId, "iccCloseLogicalChannel"); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3148 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3149 | final long identity = Binder.clearCallingIdentity(); |
| 3150 | try { |
| 3151 | if (DBG) log("iccCloseLogicalChannel: subId=" + subId + " chnl=" + channel); |
| 3152 | if (channel < 0) { |
| 3153 | return false; |
| 3154 | } |
| 3155 | Boolean success = (Boolean) sendRequest(CMD_CLOSE_CHANNEL, channel, subId); |
| 3156 | if (DBG) log("iccCloseLogicalChannel: " + success); |
| 3157 | return success; |
| 3158 | } finally { |
| 3159 | Binder.restoreCallingIdentity(identity); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3160 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3161 | } |
| 3162 | |
| 3163 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 3164 | public String iccTransmitApduLogicalChannel(int subId, int channel, int cla, |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3165 | int command, int p1, int p2, int p3, String data) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3166 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3167 | mApp, subId, "iccTransmitApduLogicalChannel"); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3168 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3169 | final long identity = Binder.clearCallingIdentity(); |
| 3170 | try { |
| 3171 | if (DBG) { |
| 3172 | log("iccTransmitApduLogicalChannel: subId=" + subId + " chnl=" + channel |
| 3173 | + " cla=" + cla + " cmd=" + command + " p1=" + p1 + " p2=" + p2 + " p3=" |
| 3174 | + p3 + " data=" + data); |
| 3175 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3176 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3177 | if (channel < 0) { |
| 3178 | return ""; |
| 3179 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3180 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3181 | IccIoResult response = (IccIoResult) sendRequest(CMD_TRANSMIT_APDU_LOGICAL_CHANNEL, |
| 3182 | new IccAPDUArgument(channel, cla, command, p1, p2, p3, data), subId); |
| 3183 | if (DBG) log("iccTransmitApduLogicalChannel: " + response); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3184 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3185 | // Append the returned status code to the end of the response payload. |
| 3186 | String s = Integer.toHexString( |
| 3187 | (response.sw1 << 8) + response.sw2 + 0x10000).substring(1); |
| 3188 | if (response.payload != null) { |
| 3189 | s = IccUtils.bytesToHexString(response.payload) + s; |
| 3190 | } |
| 3191 | return s; |
| 3192 | } finally { |
| 3193 | Binder.restoreCallingIdentity(identity); |
Shishir Agrawal | 5ec1417 | 2014-08-05 17:05:45 -0700 | [diff] [blame] | 3194 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 3195 | } |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 3196 | |
Evan Charlton | c66da36 | 2014-05-16 14:06:40 -0700 | [diff] [blame] | 3197 | @Override |
Holly Jiuyu Sun | 1cc2d55 | 2018-01-26 15:51:16 -0800 | [diff] [blame] | 3198 | public String iccTransmitApduBasicChannel(int subId, String callingPackage, int cla, |
| 3199 | int command, int p1, int p2, int p3, String data) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3200 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3201 | mApp, subId, "iccTransmitApduBasicChannel"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3202 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 3203 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3204 | final long identity = Binder.clearCallingIdentity(); |
| 3205 | try { |
| 3206 | if (command == SELECT_COMMAND && p1 == SELECT_P1 && p2 == SELECT_P2 && p3 == SELECT_P3 |
| 3207 | && TextUtils.equals(ISDR_AID, data)) { |
| 3208 | // Only allows LPA to select ISD-R. |
| 3209 | ComponentInfo bestComponent = |
| 3210 | EuiccConnector.findBestComponent(mPhone.getContext().getPackageManager()); |
| 3211 | if (bestComponent == null |
| 3212 | || !TextUtils.equals(callingPackage, bestComponent.packageName)) { |
| 3213 | loge("The calling package is not allowed to select ISD-R."); |
| 3214 | throw new SecurityException( |
| 3215 | "The calling package is not allowed to select ISD-R."); |
| 3216 | } |
Holly Jiuyu Sun | 1cc2d55 | 2018-01-26 15:51:16 -0800 | [diff] [blame] | 3217 | } |
Holly Jiuyu Sun | 1cc2d55 | 2018-01-26 15:51:16 -0800 | [diff] [blame] | 3218 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3219 | if (DBG) { |
| 3220 | log("iccTransmitApduBasicChannel: subId=" + subId + " cla=" + cla + " cmd=" |
| 3221 | + command + " p1=" + p1 + " p2=" + p2 + " p3=" + p3 + " data=" + data); |
| 3222 | } |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 3223 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3224 | IccIoResult response = (IccIoResult) sendRequest(CMD_TRANSMIT_APDU_BASIC_CHANNEL, |
| 3225 | new IccAPDUArgument(0, cla, command, p1, p2, p3, data), subId); |
| 3226 | if (DBG) log("iccTransmitApduBasicChannel: " + response); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 3227 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3228 | // Append the returned status code to the end of the response payload. |
| 3229 | String s = Integer.toHexString( |
| 3230 | (response.sw1 << 8) + response.sw2 + 0x10000).substring(1); |
| 3231 | if (response.payload != null) { |
| 3232 | s = IccUtils.bytesToHexString(response.payload) + s; |
| 3233 | } |
| 3234 | return s; |
| 3235 | } finally { |
| 3236 | Binder.restoreCallingIdentity(identity); |
Shishir Agrawal | 5ec1417 | 2014-08-05 17:05:45 -0700 | [diff] [blame] | 3237 | } |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 3238 | } |
| 3239 | |
| 3240 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 3241 | public byte[] iccExchangeSimIO(int subId, int fileID, int command, int p1, int p2, int p3, |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 3242 | String filePath) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3243 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3244 | mApp, subId, "iccExchangeSimIO"); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 3245 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3246 | final long identity = Binder.clearCallingIdentity(); |
| 3247 | try { |
| 3248 | if (DBG) { |
| 3249 | log("Exchange SIM_IO " + subId + ":" + fileID + ":" + command + " " |
| 3250 | + p1 + " " + p2 + " " + p3 + ":" + filePath); |
| 3251 | } |
| 3252 | |
| 3253 | IccIoResult response = |
| 3254 | (IccIoResult) sendRequest(CMD_EXCHANGE_SIM_IO, |
| 3255 | new IccAPDUArgument(-1, fileID, command, p1, p2, p3, filePath), |
| 3256 | subId); |
| 3257 | |
| 3258 | if (DBG) { |
| 3259 | log("Exchange SIM_IO [R]" + response); |
| 3260 | } |
| 3261 | |
| 3262 | byte[] result = null; |
| 3263 | int length = 2; |
| 3264 | if (response.payload != null) { |
| 3265 | length = 2 + response.payload.length; |
| 3266 | result = new byte[length]; |
| 3267 | System.arraycopy(response.payload, 0, result, 0, response.payload.length); |
| 3268 | } else { |
| 3269 | result = new byte[length]; |
| 3270 | } |
| 3271 | |
| 3272 | result[length - 1] = (byte) response.sw2; |
| 3273 | result[length - 2] = (byte) response.sw1; |
| 3274 | return result; |
| 3275 | } finally { |
| 3276 | Binder.restoreCallingIdentity(identity); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 3277 | } |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 3278 | } |
| 3279 | |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 3280 | /** |
| 3281 | * Get the forbidden PLMN List from the given app type (ex APPTYPE_USIM) |
| 3282 | * on a particular subscription |
| 3283 | */ |
sqian | b6e4195 | 2018-03-12 14:54:01 -0700 | [diff] [blame] | 3284 | public String[] getForbiddenPlmns(int subId, int appType, String callingPackage) { |
| 3285 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
| 3286 | mApp, subId, callingPackage, "getForbiddenPlmns")) { |
| 3287 | return null; |
| 3288 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3289 | |
| 3290 | final long identity = Binder.clearCallingIdentity(); |
| 3291 | try { |
| 3292 | if (appType != TelephonyManager.APPTYPE_USIM |
| 3293 | && appType != TelephonyManager.APPTYPE_SIM) { |
| 3294 | loge("getForbiddenPlmnList(): App Type must be USIM or SIM"); |
| 3295 | return null; |
| 3296 | } |
| 3297 | Object response = sendRequest( |
| 3298 | CMD_GET_FORBIDDEN_PLMNS, new Integer(appType), subId); |
| 3299 | if (response instanceof String[]) { |
| 3300 | return (String[]) response; |
| 3301 | } |
| 3302 | // Response is an Exception of some kind, |
| 3303 | // which is signalled to the user as a NULL retval |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 3304 | return null; |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3305 | } finally { |
| 3306 | Binder.restoreCallingIdentity(identity); |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 3307 | } |
Nathan Harold | b301405 | 2017-01-25 15:57:32 -0800 | [diff] [blame] | 3308 | } |
| 3309 | |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 3310 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 3311 | public String sendEnvelopeWithStatus(int subId, String content) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3312 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3313 | mApp, subId, "sendEnvelopeWithStatus"); |
Evan Charlton | c66da36 | 2014-05-16 14:06:40 -0700 | [diff] [blame] | 3314 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3315 | final long identity = Binder.clearCallingIdentity(); |
| 3316 | try { |
| 3317 | IccIoResult response = (IccIoResult) sendRequest(CMD_SEND_ENVELOPE, content, subId); |
| 3318 | if (response.payload == null) { |
| 3319 | return ""; |
| 3320 | } |
Evan Charlton | c66da36 | 2014-05-16 14:06:40 -0700 | [diff] [blame] | 3321 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3322 | // Append the returned status code to the end of the response payload. |
| 3323 | String s = Integer.toHexString( |
| 3324 | (response.sw1 << 8) + response.sw2 + 0x10000).substring(1); |
| 3325 | s = IccUtils.bytesToHexString(response.payload) + s; |
| 3326 | return s; |
| 3327 | } finally { |
| 3328 | Binder.restoreCallingIdentity(identity); |
| 3329 | } |
Evan Charlton | c66da36 | 2014-05-16 14:06:40 -0700 | [diff] [blame] | 3330 | } |
| 3331 | |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 3332 | /** |
| 3333 | * Read one of the NV items defined in {@link com.android.internal.telephony.RadioNVItems} |
| 3334 | * and {@code ril_nv_items.h}. Used for device configuration by some CDMA operators. |
| 3335 | * |
| 3336 | * @param itemID the ID of the item to read |
| 3337 | * @return the NV item as a String, or null on error. |
| 3338 | */ |
| 3339 | @Override |
| 3340 | public String nvReadItem(int itemID) { |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 3341 | WorkSource workSource = getWorkSource(Binder.getCallingUid()); |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3342 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3343 | mApp, getDefaultSubscription(), "nvReadItem"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3344 | |
| 3345 | final long identity = Binder.clearCallingIdentity(); |
| 3346 | try { |
| 3347 | if (DBG) log("nvReadItem: item " + itemID); |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 3348 | String value = (String) sendRequest(CMD_NV_READ_ITEM, itemID, workSource); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3349 | if (DBG) log("nvReadItem: item " + itemID + " is \"" + value + '"'); |
| 3350 | return value; |
| 3351 | } finally { |
| 3352 | Binder.restoreCallingIdentity(identity); |
| 3353 | } |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 3354 | } |
| 3355 | |
| 3356 | /** |
| 3357 | * Write one of the NV items defined in {@link com.android.internal.telephony.RadioNVItems} |
| 3358 | * and {@code ril_nv_items.h}. Used for device configuration by some CDMA operators. |
| 3359 | * |
| 3360 | * @param itemID the ID of the item to read |
| 3361 | * @param itemValue the value to write, as a String |
| 3362 | * @return true on success; false on any failure |
| 3363 | */ |
| 3364 | @Override |
| 3365 | public boolean nvWriteItem(int itemID, String itemValue) { |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 3366 | WorkSource workSource = getWorkSource(Binder.getCallingUid()); |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3367 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3368 | mApp, getDefaultSubscription(), "nvWriteItem"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3369 | |
| 3370 | final long identity = Binder.clearCallingIdentity(); |
| 3371 | try { |
| 3372 | if (DBG) log("nvWriteItem: item " + itemID + " value \"" + itemValue + '"'); |
| 3373 | Boolean success = (Boolean) sendRequest(CMD_NV_WRITE_ITEM, |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 3374 | new Pair<Integer, String>(itemID, itemValue), workSource); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3375 | if (DBG) log("nvWriteItem: item " + itemID + ' ' + (success ? "ok" : "fail")); |
| 3376 | return success; |
| 3377 | } finally { |
| 3378 | Binder.restoreCallingIdentity(identity); |
| 3379 | } |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 3380 | } |
| 3381 | |
| 3382 | /** |
| 3383 | * Update the CDMA Preferred Roaming List (PRL) in the radio NV storage. |
| 3384 | * Used for device configuration by some CDMA operators. |
| 3385 | * |
| 3386 | * @param preferredRoamingList byte array containing the new PRL |
| 3387 | * @return true on success; false on any failure |
| 3388 | */ |
| 3389 | @Override |
| 3390 | public boolean nvWriteCdmaPrl(byte[] preferredRoamingList) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3391 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3392 | mApp, getDefaultSubscription(), "nvWriteCdmaPrl"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3393 | |
| 3394 | final long identity = Binder.clearCallingIdentity(); |
| 3395 | try { |
| 3396 | if (DBG) log("nvWriteCdmaPrl: value: " + HexDump.toHexString(preferredRoamingList)); |
| 3397 | Boolean success = (Boolean) sendRequest(CMD_NV_WRITE_CDMA_PRL, preferredRoamingList); |
| 3398 | if (DBG) log("nvWriteCdmaPrl: " + (success ? "ok" : "fail")); |
| 3399 | return success; |
| 3400 | } finally { |
| 3401 | Binder.restoreCallingIdentity(identity); |
| 3402 | } |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 3403 | } |
| 3404 | |
| 3405 | /** |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 3406 | * Rollback modem configurations to factory default except some config which are in whitelist. |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 3407 | * Used for device configuration by some CDMA operators. |
| 3408 | * |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 3409 | * @param slotIndex - device slot. |
| 3410 | * |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 3411 | * @return true on success; false on any failure |
| 3412 | */ |
| 3413 | @Override |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 3414 | public boolean resetModemConfig(int slotIndex) { |
| 3415 | Phone phone = PhoneFactory.getPhone(slotIndex); |
| 3416 | if (phone != null) { |
| 3417 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3418 | mApp, phone.getSubId(), "resetModemConfig"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3419 | |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 3420 | final long identity = Binder.clearCallingIdentity(); |
| 3421 | try { |
| 3422 | Boolean success = (Boolean) sendRequest(CMD_RESET_MODEM_CONFIG, null); |
| 3423 | if (DBG) log("resetModemConfig:" + ' ' + (success ? "ok" : "fail")); |
| 3424 | return success; |
| 3425 | } finally { |
| 3426 | Binder.restoreCallingIdentity(identity); |
| 3427 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3428 | } |
chen xu | 6dac5ab | 2018-10-26 17:39:23 -0700 | [diff] [blame] | 3429 | return false; |
| 3430 | } |
| 3431 | |
| 3432 | /** |
| 3433 | * Generate a radio modem reset. Used for device configuration by some CDMA operators. |
| 3434 | * |
| 3435 | * @param slotIndex - device slot. |
| 3436 | * |
| 3437 | * @return true on success; false on any failure |
| 3438 | */ |
| 3439 | @Override |
| 3440 | public boolean rebootModem(int slotIndex) { |
| 3441 | Phone phone = PhoneFactory.getPhone(slotIndex); |
| 3442 | if (phone != null) { |
| 3443 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3444 | mApp, phone.getSubId(), "rebootModem"); |
| 3445 | |
| 3446 | final long identity = Binder.clearCallingIdentity(); |
| 3447 | try { |
| 3448 | Boolean success = (Boolean) sendRequest(CMD_MODEM_REBOOT, null); |
| 3449 | if (DBG) log("rebootModem:" + ' ' + (success ? "ok" : "fail")); |
| 3450 | return success; |
| 3451 | } finally { |
| 3452 | Binder.restoreCallingIdentity(identity); |
| 3453 | } |
| 3454 | } |
| 3455 | return false; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 3456 | } |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 3457 | |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 3458 | public String[] getPcscfAddress(String apnType, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3459 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 3460 | mApp, mPhone.getSubId(), callingPackage, "getPcscfAddress")) { |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 3461 | return new String[0]; |
| 3462 | } |
| 3463 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3464 | final long identity = Binder.clearCallingIdentity(); |
| 3465 | try { |
| 3466 | return mPhone.getPcscfAddress(apnType); |
| 3467 | } finally { |
| 3468 | Binder.restoreCallingIdentity(identity); |
| 3469 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 3470 | } |
| 3471 | |
Brad Ebinger | 51f743a | 2017-01-23 13:50:20 -0800 | [diff] [blame] | 3472 | /** |
Brad Ebinger | 22bc3e4 | 2018-01-16 09:39:35 -0800 | [diff] [blame] | 3473 | * Enables IMS for the framework. This will trigger IMS registration and ImsFeature capability |
| 3474 | * status updates, if not already enabled. |
Brad Ebinger | 51f743a | 2017-01-23 13:50:20 -0800 | [diff] [blame] | 3475 | */ |
Brad Ebinger | 22bc3e4 | 2018-01-16 09:39:35 -0800 | [diff] [blame] | 3476 | public void enableIms(int slotId) { |
Brad Ebinger | 51f743a | 2017-01-23 13:50:20 -0800 | [diff] [blame] | 3477 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3478 | |
| 3479 | final long identity = Binder.clearCallingIdentity(); |
| 3480 | try { |
| 3481 | PhoneFactory.getImsResolver().enableIms(slotId); |
| 3482 | } finally { |
| 3483 | Binder.restoreCallingIdentity(identity); |
| 3484 | } |
Brad Ebinger | 34bef92 | 2017-11-09 10:27:08 -0800 | [diff] [blame] | 3485 | } |
| 3486 | |
| 3487 | /** |
Brad Ebinger | 22bc3e4 | 2018-01-16 09:39:35 -0800 | [diff] [blame] | 3488 | * Disables IMS for the framework. This will trigger IMS de-registration and trigger ImsFeature |
| 3489 | * status updates to disabled. |
Brad Ebinger | 34bef92 | 2017-11-09 10:27:08 -0800 | [diff] [blame] | 3490 | */ |
Brad Ebinger | 22bc3e4 | 2018-01-16 09:39:35 -0800 | [diff] [blame] | 3491 | public void disableIms(int slotId) { |
| 3492 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3493 | |
| 3494 | final long identity = Binder.clearCallingIdentity(); |
| 3495 | try { |
| 3496 | PhoneFactory.getImsResolver().disableIms(slotId); |
| 3497 | } finally { |
| 3498 | Binder.restoreCallingIdentity(identity); |
| 3499 | } |
Brad Ebinger | 22bc3e4 | 2018-01-16 09:39:35 -0800 | [diff] [blame] | 3500 | } |
| 3501 | |
| 3502 | /** |
| 3503 | * Returns the {@link IImsMmTelFeature} that corresponds to the given slot Id for the MMTel |
| 3504 | * feature or {@link null} if the service is not available. If the feature is available, the |
| 3505 | * {@link IImsServiceFeatureCallback} callback is registered as a listener for feature updates. |
| 3506 | */ |
| 3507 | public IImsMmTelFeature getMmTelFeatureAndListen(int slotId, |
Brad Ebinger | 34bef92 | 2017-11-09 10:27:08 -0800 | [diff] [blame] | 3508 | IImsServiceFeatureCallback callback) { |
| 3509 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3510 | |
| 3511 | final long identity = Binder.clearCallingIdentity(); |
| 3512 | try { |
| 3513 | return PhoneFactory.getImsResolver().getMmTelFeatureAndListen(slotId, callback); |
| 3514 | } finally { |
| 3515 | Binder.restoreCallingIdentity(identity); |
| 3516 | } |
Brad Ebinger | 34bef92 | 2017-11-09 10:27:08 -0800 | [diff] [blame] | 3517 | } |
| 3518 | |
| 3519 | /** |
| 3520 | * Returns the {@link IImsRcsFeature} that corresponds to the given slot Id for the RCS |
| 3521 | * feature during emergency calling or {@link null} if the service is not available. If the |
| 3522 | * feature is available, the {@link IImsServiceFeatureCallback} callback is registered as a |
| 3523 | * listener for feature updates. |
| 3524 | */ |
| 3525 | public IImsRcsFeature getRcsFeatureAndListen(int slotId, IImsServiceFeatureCallback callback) { |
| 3526 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3527 | |
| 3528 | final long identity = Binder.clearCallingIdentity(); |
| 3529 | try { |
| 3530 | return PhoneFactory.getImsResolver().getRcsFeatureAndListen(slotId, callback); |
| 3531 | } finally { |
| 3532 | Binder.restoreCallingIdentity(identity); |
| 3533 | } |
Brad Ebinger | 51f743a | 2017-01-23 13:50:20 -0800 | [diff] [blame] | 3534 | } |
| 3535 | |
Brad Ebinger | 5f64b05 | 2017-12-14 14:26:15 -0800 | [diff] [blame] | 3536 | /** |
| 3537 | * Returns the {@link IImsRegistration} structure associated with the slotId and feature |
| 3538 | * specified. |
| 3539 | */ |
| 3540 | public IImsRegistration getImsRegistration(int slotId, int feature) throws RemoteException { |
| 3541 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3542 | |
| 3543 | final long identity = Binder.clearCallingIdentity(); |
| 3544 | try { |
| 3545 | return PhoneFactory.getImsResolver().getImsRegistration(slotId, feature); |
| 3546 | } finally { |
| 3547 | Binder.restoreCallingIdentity(identity); |
| 3548 | } |
Brad Ebinger | 5f64b05 | 2017-12-14 14:26:15 -0800 | [diff] [blame] | 3549 | } |
| 3550 | |
Brad Ebinger | 22bc3e4 | 2018-01-16 09:39:35 -0800 | [diff] [blame] | 3551 | /** |
| 3552 | * Returns the {@link IImsConfig} structure associated with the slotId and feature |
| 3553 | * specified. |
| 3554 | */ |
| 3555 | public IImsConfig getImsConfig(int slotId, int feature) throws RemoteException { |
| 3556 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3557 | |
| 3558 | final long identity = Binder.clearCallingIdentity(); |
| 3559 | try { |
| 3560 | return PhoneFactory.getImsResolver().getImsConfig(slotId, feature); |
| 3561 | } finally { |
| 3562 | Binder.restoreCallingIdentity(identity); |
| 3563 | } |
Brad Ebinger | 22bc3e4 | 2018-01-16 09:39:35 -0800 | [diff] [blame] | 3564 | } |
| 3565 | |
Brad Ebinger | 884c07b | 2018-02-15 16:17:40 -0800 | [diff] [blame] | 3566 | /** |
Brad Ebinger | dac2f00 | 2018-04-03 15:17:52 -0700 | [diff] [blame] | 3567 | * Sets the ImsService Package Name that Telephony will bind to. |
| 3568 | * |
| 3569 | * @param slotId the slot ID that the ImsService should bind for. |
| 3570 | * @param isCarrierImsService true if the ImsService is the carrier override, false if the |
| 3571 | * ImsService is the device default ImsService. |
| 3572 | * @param packageName The package name of the application that contains the ImsService to bind |
| 3573 | * to. |
| 3574 | * @return true if setting the ImsService to bind to succeeded, false if it did not. |
| 3575 | * @hide |
| 3576 | */ |
| 3577 | public boolean setImsService(int slotId, boolean isCarrierImsService, String packageName) { |
Brad Ebinger | de696de | 2018-04-06 09:56:40 -0700 | [diff] [blame] | 3578 | int[] subIds = SubscriptionManager.getSubId(slotId); |
| 3579 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp, |
| 3580 | (subIds != null ? subIds[0] : SubscriptionManager.INVALID_SUBSCRIPTION_ID), |
| 3581 | "setImsService"); |
| 3582 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3583 | final long identity = Binder.clearCallingIdentity(); |
| 3584 | try { |
| 3585 | return PhoneFactory.getImsResolver().overrideImsServiceConfiguration(slotId, |
| 3586 | isCarrierImsService, packageName); |
| 3587 | } finally { |
| 3588 | Binder.restoreCallingIdentity(identity); |
| 3589 | } |
Brad Ebinger | dac2f00 | 2018-04-03 15:17:52 -0700 | [diff] [blame] | 3590 | } |
| 3591 | |
| 3592 | /** |
| 3593 | * Return the ImsService configuration. |
| 3594 | * |
| 3595 | * @param slotId The slot that the ImsService is associated with. |
| 3596 | * @param isCarrierImsService true, if the ImsService is a carrier override, false if it is |
| 3597 | * the device default. |
| 3598 | * @return the package name of the ImsService configuration. |
| 3599 | */ |
| 3600 | public String getImsService(int slotId, boolean isCarrierImsService) { |
Brad Ebinger | de696de | 2018-04-06 09:56:40 -0700 | [diff] [blame] | 3601 | int[] subIds = SubscriptionManager.getSubId(slotId); |
| 3602 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp, |
| 3603 | (subIds != null ? subIds[0] : SubscriptionManager.INVALID_SUBSCRIPTION_ID), |
| 3604 | "getImsService"); |
| 3605 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3606 | final long identity = Binder.clearCallingIdentity(); |
| 3607 | try { |
| 3608 | return PhoneFactory.getImsResolver().getImsServiceConfiguration(slotId, |
| 3609 | isCarrierImsService); |
| 3610 | } finally { |
| 3611 | Binder.restoreCallingIdentity(identity); |
| 3612 | } |
Brad Ebinger | dac2f00 | 2018-04-03 15:17:52 -0700 | [diff] [blame] | 3613 | } |
| 3614 | |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 3615 | public void setImsRegistrationState(boolean registered) { |
| 3616 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3617 | |
| 3618 | final long identity = Binder.clearCallingIdentity(); |
| 3619 | try { |
| 3620 | mPhone.setImsRegistrationState(registered); |
| 3621 | } finally { |
| 3622 | Binder.restoreCallingIdentity(identity); |
| 3623 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 3624 | } |
| 3625 | |
| 3626 | /** |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 3627 | * Set the network selection mode to automatic. |
| 3628 | * |
| 3629 | */ |
| 3630 | @Override |
| 3631 | public void setNetworkSelectionModeAutomatic(int subId) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3632 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3633 | mApp, subId, "setNetworkSelectionModeAutomatic"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3634 | |
Pengquan Meng | e92a50d | 2018-09-21 15:54:48 -0700 | [diff] [blame] | 3635 | if (!isActiveSubscription(subId)) { |
| 3636 | return; |
| 3637 | } |
| 3638 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3639 | final long identity = Binder.clearCallingIdentity(); |
| 3640 | try { |
| 3641 | if (DBG) log("setNetworkSelectionModeAutomatic: subId " + subId); |
| 3642 | sendRequest(CMD_SET_NETWORK_SELECTION_MODE_AUTOMATIC, null, subId); |
| 3643 | } finally { |
| 3644 | Binder.restoreCallingIdentity(identity); |
| 3645 | } |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 3646 | } |
| 3647 | |
Pengquan Meng | ea84e04 | 2018-09-20 14:57:26 -0700 | [diff] [blame] | 3648 | /** |
| 3649 | * Ask the radio to connect to the input network and change selection mode to manual. |
| 3650 | * |
| 3651 | * @param subId the id of the subscription. |
| 3652 | * @param operatorInfo the operator information, included the PLMN, long name and short name of |
| 3653 | * the operator to attach to. |
| 3654 | * @param persistSelection whether the selection will persist until reboot. If true, only allows |
| 3655 | * attaching to the selected PLMN until reboot; otherwise, attach to the chosen PLMN and resume |
| 3656 | * normal network selection next time. |
| 3657 | * @return {@code true} on success; {@code true} on any failure. |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 3658 | */ |
| 3659 | @Override |
Pengquan Meng | ea84e04 | 2018-09-20 14:57:26 -0700 | [diff] [blame] | 3660 | public boolean setNetworkSelectionModeManual( |
| 3661 | int subId, OperatorInfo operatorInfo, boolean persistSelection) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3662 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3663 | mApp, subId, "setNetworkSelectionModeManual"); |
Pengquan Meng | e92a50d | 2018-09-21 15:54:48 -0700 | [diff] [blame] | 3664 | |
| 3665 | if (!isActiveSubscription(subId)) { |
| 3666 | return false; |
| 3667 | } |
| 3668 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3669 | final long identity = Binder.clearCallingIdentity(); |
| 3670 | try { |
Pengquan Meng | ea84e04 | 2018-09-20 14:57:26 -0700 | [diff] [blame] | 3671 | ManualNetworkSelectionArgument arg = new ManualNetworkSelectionArgument(operatorInfo, |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3672 | persistSelection); |
Pengquan Meng | ea84e04 | 2018-09-20 14:57:26 -0700 | [diff] [blame] | 3673 | if (DBG) { |
| 3674 | log("setNetworkSelectionModeManual: subId: " + subId |
| 3675 | + " operator: " + operatorInfo); |
| 3676 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3677 | return (Boolean) sendRequest(CMD_SET_NETWORK_SELECTION_MODE_MANUAL, arg, subId); |
| 3678 | } finally { |
| 3679 | Binder.restoreCallingIdentity(identity); |
| 3680 | } |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 3681 | } |
| 3682 | |
| 3683 | /** |
| 3684 | * Scans for available networks. |
| 3685 | */ |
| 3686 | @Override |
| 3687 | public CellNetworkScanResult getCellNetworkScanResults(int subId) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3688 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3689 | mApp, subId, "getCellNetworkScanResults"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3690 | |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 3691 | long identity = Binder.clearCallingIdentity(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3692 | try { |
| 3693 | if (DBG) log("getCellNetworkScanResults: subId " + subId); |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 3694 | return (CellNetworkScanResult) sendRequest( |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3695 | CMD_PERFORM_NETWORK_SCAN, null, subId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3696 | } finally { |
| 3697 | Binder.restoreCallingIdentity(identity); |
| 3698 | } |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 3699 | } |
| 3700 | |
| 3701 | /** |
yinxu | b1bed74 | 2017-04-17 11:45:04 -0700 | [diff] [blame] | 3702 | * Starts a new network scan and returns the id of this scan. |
yinxu | 504e139 | 2017-04-12 16:03:22 -0700 | [diff] [blame] | 3703 | * |
yinxu | b1bed74 | 2017-04-17 11:45:04 -0700 | [diff] [blame] | 3704 | * @param subId id of the subscription |
| 3705 | * @param request contains the radio access networks with bands/channels to scan |
| 3706 | * @param messenger callback messenger for scan results or errors |
| 3707 | * @param binder for the purpose of auto clean when the user thread crashes |
yinxu | 504e139 | 2017-04-12 16:03:22 -0700 | [diff] [blame] | 3708 | * @return the id of the requested scan which can be used to stop the scan. |
| 3709 | */ |
| 3710 | @Override |
| 3711 | public int requestNetworkScan(int subId, NetworkScanRequest request, Messenger messenger, |
| 3712 | IBinder binder) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3713 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3714 | mApp, subId, "requestNetworkScan"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3715 | |
| 3716 | final long identity = Binder.clearCallingIdentity(); |
| 3717 | try { |
| 3718 | return mNetworkScanRequestTracker.startNetworkScan( |
| 3719 | request, messenger, binder, getPhone(subId)); |
| 3720 | } finally { |
| 3721 | Binder.restoreCallingIdentity(identity); |
| 3722 | } |
yinxu | 504e139 | 2017-04-12 16:03:22 -0700 | [diff] [blame] | 3723 | } |
| 3724 | |
| 3725 | /** |
| 3726 | * Stops an existing network scan with the given scanId. |
yinxu | b1bed74 | 2017-04-17 11:45:04 -0700 | [diff] [blame] | 3727 | * |
| 3728 | * @param subId id of the subscription |
| 3729 | * @param scanId id of the scan that needs to be stopped |
yinxu | 504e139 | 2017-04-12 16:03:22 -0700 | [diff] [blame] | 3730 | */ |
| 3731 | @Override |
| 3732 | public void stopNetworkScan(int subId, int scanId) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3733 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3734 | mApp, subId, "stopNetworkScan"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3735 | |
| 3736 | final long identity = Binder.clearCallingIdentity(); |
| 3737 | try { |
| 3738 | mNetworkScanRequestTracker.stopNetworkScan(scanId); |
| 3739 | } finally { |
| 3740 | Binder.restoreCallingIdentity(identity); |
| 3741 | } |
yinxu | 504e139 | 2017-04-12 16:03:22 -0700 | [diff] [blame] | 3742 | } |
| 3743 | |
| 3744 | /** |
Junda Liu | 84d15a2 | 2014-07-02 11:21:04 -0700 | [diff] [blame] | 3745 | * Get the calculated preferred network type. |
| 3746 | * Used for debugging incorrect network type. |
| 3747 | * |
| 3748 | * @return the preferred network type, defined in RILConstants.java. |
| 3749 | */ |
| 3750 | @Override |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 3751 | public int getCalculatedPreferredNetworkType(String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3752 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 3753 | mApp, mPhone.getSubId(), callingPackage, "getCalculatedPreferredNetworkType")) { |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 3754 | return RILConstants.PREFERRED_NETWORK_MODE; |
| 3755 | } |
| 3756 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3757 | final long identity = Binder.clearCallingIdentity(); |
| 3758 | try { |
| 3759 | // FIXME: need to get SubId from somewhere. |
| 3760 | return PhoneFactory.calculatePreferredNetworkType(mPhone.getContext(), 0); |
| 3761 | } finally { |
| 3762 | Binder.restoreCallingIdentity(identity); |
| 3763 | } |
Junda Liu | 84d15a2 | 2014-07-02 11:21:04 -0700 | [diff] [blame] | 3764 | } |
| 3765 | |
| 3766 | /** |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 3767 | * Get the preferred network type. |
| 3768 | * Used for device configuration by some CDMA operators. |
| 3769 | * |
| 3770 | * @return the preferred network type, defined in RILConstants.java. |
| 3771 | */ |
| 3772 | @Override |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 3773 | public int getPreferredNetworkType(int subId) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3774 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3775 | mApp, subId, "getPreferredNetworkType"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3776 | |
| 3777 | final long identity = Binder.clearCallingIdentity(); |
| 3778 | try { |
| 3779 | if (DBG) log("getPreferredNetworkType"); |
| 3780 | int[] result = (int[]) sendRequest(CMD_GET_PREFERRED_NETWORK_TYPE, null, subId); |
| 3781 | int networkType = (result != null ? result[0] : -1); |
| 3782 | if (DBG) log("getPreferredNetworkType: " + networkType); |
| 3783 | return networkType; |
| 3784 | } finally { |
| 3785 | Binder.restoreCallingIdentity(identity); |
| 3786 | } |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 3787 | } |
| 3788 | |
| 3789 | /** |
| 3790 | * Set the preferred network type. |
| 3791 | * Used for device configuration by some CDMA operators. |
| 3792 | * |
| 3793 | * @param networkType the preferred network type, defined in RILConstants.java. |
| 3794 | * @return true on success; false on any failure. |
| 3795 | */ |
| 3796 | @Override |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 3797 | public boolean setPreferredNetworkType(int subId, int networkType) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3798 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3799 | mApp, subId, "setPreferredNetworkType"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3800 | |
| 3801 | final long identity = Binder.clearCallingIdentity(); |
| 3802 | try { |
| 3803 | if (DBG) log("setPreferredNetworkType: subId " + subId + " type " + networkType); |
| 3804 | Boolean success = (Boolean) sendRequest( |
| 3805 | CMD_SET_PREFERRED_NETWORK_TYPE, networkType, subId); |
| 3806 | if (DBG) log("setPreferredNetworkType: " + (success ? "ok" : "fail")); |
| 3807 | if (success) { |
| 3808 | Settings.Global.putInt(mPhone.getContext().getContentResolver(), |
| 3809 | Settings.Global.PREFERRED_NETWORK_MODE + subId, networkType); |
| 3810 | } |
| 3811 | return success; |
| 3812 | } finally { |
| 3813 | Binder.restoreCallingIdentity(identity); |
Junda Liu | 80bc0d1 | 2014-07-14 16:36:44 -0700 | [diff] [blame] | 3814 | } |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 3815 | } |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 3816 | |
| 3817 | /** |
Junda Liu | 475951f | 2014-11-07 16:45:03 -0800 | [diff] [blame] | 3818 | * Check TETHER_DUN_REQUIRED and TETHER_DUN_APN settings, net.tethering.noprovisioning |
Jack Yu | 3cda1cd | 2018-10-30 17:41:31 -0700 | [diff] [blame] | 3819 | * SystemProperty to decide whether DUN APN is required for |
Junda Liu | 475951f | 2014-11-07 16:45:03 -0800 | [diff] [blame] | 3820 | * tethering. |
| 3821 | * |
| 3822 | * @return 0: Not required. 1: required. 2: Not set. |
| 3823 | * @hide |
| 3824 | */ |
| 3825 | @Override |
| 3826 | public int getTetherApnRequired() { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 3827 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3828 | |
| 3829 | final long identity = Binder.clearCallingIdentity(); |
| 3830 | try { |
| 3831 | int dunRequired = Settings.Global.getInt(mPhone.getContext().getContentResolver(), |
| 3832 | Settings.Global.TETHER_DUN_REQUIRED, 2); |
Jack Yu | 3cda1cd | 2018-10-30 17:41:31 -0700 | [diff] [blame] | 3833 | // If not set, check net.tethering.noprovisioning, TETHER_DUN_APN setting |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3834 | if (dunRequired == 2 && mPhone.hasMatchedTetherApnSetting()) { |
| 3835 | dunRequired = 1; |
| 3836 | } |
| 3837 | return dunRequired; |
| 3838 | } finally { |
| 3839 | Binder.restoreCallingIdentity(identity); |
Junda Liu | 475951f | 2014-11-07 16:45:03 -0800 | [diff] [blame] | 3840 | } |
Junda Liu | 475951f | 2014-11-07 16:45:03 -0800 | [diff] [blame] | 3841 | } |
| 3842 | |
| 3843 | /** |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 3844 | * Set mobile data enabled |
| 3845 | * Used by the user through settings etc to turn on/off mobile data |
| 3846 | * |
| 3847 | * @param enable {@code true} turn turn data on, else {@code false} |
| 3848 | */ |
| 3849 | @Override |
Malcolm Chen | 964682d | 2017-11-28 16:20:07 -0800 | [diff] [blame] | 3850 | public void setUserDataEnabled(int subId, boolean enable) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3851 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3852 | mApp, subId, "setUserDataEnabled"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3853 | |
| 3854 | final long identity = Binder.clearCallingIdentity(); |
| 3855 | try { |
| 3856 | int phoneId = mSubscriptionController.getPhoneId(subId); |
| 3857 | if (DBG) log("setUserDataEnabled: subId=" + subId + " phoneId=" + phoneId); |
| 3858 | Phone phone = PhoneFactory.getPhone(phoneId); |
| 3859 | if (phone != null) { |
| 3860 | if (DBG) log("setUserDataEnabled: subId=" + subId + " enable=" + enable); |
| 3861 | phone.setUserDataEnabled(enable); |
| 3862 | } else { |
| 3863 | loge("setUserDataEnabled: no phone for subId=" + subId); |
| 3864 | } |
| 3865 | } finally { |
| 3866 | Binder.restoreCallingIdentity(identity); |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 3867 | } |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 3868 | } |
| 3869 | |
| 3870 | /** |
Malcolm Chen | 964682d | 2017-11-28 16:20:07 -0800 | [diff] [blame] | 3871 | * Get the user enabled state of Mobile Data. |
| 3872 | * |
| 3873 | * TODO: remove and use isUserDataEnabled. |
| 3874 | * This can't be removed now because some vendor codes |
| 3875 | * calls through ITelephony directly while they should |
| 3876 | * use TelephonyManager. |
| 3877 | * |
| 3878 | * @return true on enabled |
| 3879 | */ |
| 3880 | @Override |
| 3881 | public boolean getDataEnabled(int subId) { |
| 3882 | return isUserDataEnabled(subId); |
| 3883 | } |
| 3884 | |
| 3885 | /** |
| 3886 | * Get whether mobile data is enabled per user setting. |
| 3887 | * |
| 3888 | * There are other factors deciding whether mobile data is actually enabled, but they are |
| 3889 | * not considered here. See {@link #isDataEnabled(int)} for more details. |
Robert Greenwalt | 646120a | 2014-05-23 11:54:03 -0700 | [diff] [blame] | 3890 | * |
Jeff Davidson | a192071 | 2016-11-18 17:05:56 -0800 | [diff] [blame] | 3891 | * Accepts either ACCESS_NETWORK_STATE, MODIFY_PHONE_STATE or carrier privileges. |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 3892 | * |
| 3893 | * @return {@code true} if data is enabled else {@code false} |
| 3894 | */ |
| 3895 | @Override |
Malcolm Chen | 964682d | 2017-11-28 16:20:07 -0800 | [diff] [blame] | 3896 | public boolean isUserDataEnabled(int subId) { |
Robert Greenwalt | 646120a | 2014-05-23 11:54:03 -0700 | [diff] [blame] | 3897 | try { |
| 3898 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.ACCESS_NETWORK_STATE, |
| 3899 | null); |
| 3900 | } catch (Exception e) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3901 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3902 | mApp, subId, "isUserDataEnabled"); |
Robert Greenwalt | 646120a | 2014-05-23 11:54:03 -0700 | [diff] [blame] | 3903 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3904 | |
| 3905 | final long identity = Binder.clearCallingIdentity(); |
| 3906 | try { |
| 3907 | int phoneId = mSubscriptionController.getPhoneId(subId); |
| 3908 | if (DBG) log("isUserDataEnabled: subId=" + subId + " phoneId=" + phoneId); |
| 3909 | Phone phone = PhoneFactory.getPhone(phoneId); |
| 3910 | if (phone != null) { |
| 3911 | boolean retVal = phone.isUserDataEnabled(); |
| 3912 | if (DBG) log("isUserDataEnabled: subId=" + subId + " retVal=" + retVal); |
| 3913 | return retVal; |
| 3914 | } else { |
| 3915 | if (DBG) loge("isUserDataEnabled: no phone subId=" + subId + " retVal=false"); |
| 3916 | return false; |
| 3917 | } |
| 3918 | } finally { |
| 3919 | Binder.restoreCallingIdentity(identity); |
Malcolm Chen | 964682d | 2017-11-28 16:20:07 -0800 | [diff] [blame] | 3920 | } |
| 3921 | } |
| 3922 | |
| 3923 | /** |
| 3924 | * Get whether mobile data is enabled. |
| 3925 | * |
| 3926 | * Comparable to {@link #isUserDataEnabled(int)}, this considers all factors deciding |
| 3927 | * whether mobile data is actually enabled. |
| 3928 | * |
| 3929 | * Accepts either ACCESS_NETWORK_STATE, MODIFY_PHONE_STATE or carrier privileges. |
| 3930 | * |
| 3931 | * @return {@code true} if data is enabled else {@code false} |
| 3932 | */ |
| 3933 | @Override |
| 3934 | public boolean isDataEnabled(int subId) { |
| 3935 | try { |
| 3936 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.ACCESS_NETWORK_STATE, |
| 3937 | null); |
| 3938 | } catch (Exception e) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3939 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 3940 | mApp, subId, "isDataEnabled"); |
Malcolm Chen | 964682d | 2017-11-28 16:20:07 -0800 | [diff] [blame] | 3941 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 3942 | |
| 3943 | final long identity = Binder.clearCallingIdentity(); |
| 3944 | try { |
| 3945 | int phoneId = mSubscriptionController.getPhoneId(subId); |
| 3946 | if (DBG) log("isDataEnabled: subId=" + subId + " phoneId=" + phoneId); |
| 3947 | Phone phone = PhoneFactory.getPhone(phoneId); |
| 3948 | if (phone != null) { |
| 3949 | boolean retVal = phone.isDataEnabled(); |
| 3950 | if (DBG) log("isDataEnabled: subId=" + subId + " retVal=" + retVal); |
| 3951 | return retVal; |
| 3952 | } else { |
| 3953 | if (DBG) loge("isDataEnabled: no phone subId=" + subId + " retVal=false"); |
| 3954 | return false; |
| 3955 | } |
| 3956 | } finally { |
| 3957 | Binder.restoreCallingIdentity(identity); |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 3958 | } |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 3959 | } |
Shishir Agrawal | 60f9c95 | 2014-06-23 12:00:43 -0700 | [diff] [blame] | 3960 | |
| 3961 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 3962 | public int getCarrierPrivilegeStatus(int subId) { |
| 3963 | final Phone phone = getPhone(subId); |
| 3964 | if (phone == null) { |
| 3965 | loge("getCarrierPrivilegeStatus: Invalid subId"); |
| 3966 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS; |
| 3967 | } |
| 3968 | UiccCard card = UiccController.getInstance().getUiccCard(phone.getPhoneId()); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 3969 | if (card == null) { |
Shishir Agrawal | 5e5becd | 2014-11-18 11:38:23 -0800 | [diff] [blame] | 3970 | loge("getCarrierPrivilegeStatus: No UICC"); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 3971 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED; |
| 3972 | } |
| 3973 | return card.getCarrierPrivilegeStatusForCurrentTransaction( |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 3974 | phone.getContext().getPackageManager()); |
Shishir Agrawal | 60f9c95 | 2014-06-23 12:00:43 -0700 | [diff] [blame] | 3975 | } |
Junda Liu | 2934034 | 2014-07-10 15:23:27 -0700 | [diff] [blame] | 3976 | |
| 3977 | @Override |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 3978 | public int getCarrierPrivilegeStatusForUid(int subId, int uid) { |
| 3979 | final Phone phone = getPhone(subId); |
| 3980 | if (phone == null) { |
| 3981 | loge("getCarrierPrivilegeStatus: Invalid subId"); |
| 3982 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS; |
| 3983 | } |
| 3984 | UiccProfile profile = |
| 3985 | UiccController.getInstance().getUiccProfileForPhone(phone.getPhoneId()); |
| 3986 | if (profile == null) { |
| 3987 | loge("getCarrierPrivilegeStatus: No UICC"); |
| 3988 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED; |
| 3989 | } |
| 3990 | return profile.getCarrierPrivilegeStatusForUid(phone.getContext().getPackageManager(), uid); |
| 3991 | } |
| 3992 | |
| 3993 | @Override |
Zach Johnson | 50ecba3 | 2015-05-19 00:24:21 -0700 | [diff] [blame] | 3994 | public int checkCarrierPrivilegesForPackage(String pkgName) { |
Junda Liu | 317d70b | 2016-03-08 09:33:53 -0800 | [diff] [blame] | 3995 | if (TextUtils.isEmpty(pkgName)) |
| 3996 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS; |
Shishir Agrawal | 2140925 | 2015-01-15 23:33:50 -0800 | [diff] [blame] | 3997 | UiccCard card = UiccController.getInstance().getUiccCard(mPhone.getPhoneId()); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 3998 | if (card == null) { |
| 3999 | loge("checkCarrierPrivilegesForPackage: No UICC"); |
| 4000 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED; |
| 4001 | } |
Zach Johnson | 50ecba3 | 2015-05-19 00:24:21 -0700 | [diff] [blame] | 4002 | return card.getCarrierPrivilegeStatus(mPhone.getContext().getPackageManager(), pkgName); |
| 4003 | } |
| 4004 | |
| 4005 | @Override |
| 4006 | public int checkCarrierPrivilegesForPackageAnyPhone(String pkgName) { |
Junda Liu | 317d70b | 2016-03-08 09:33:53 -0800 | [diff] [blame] | 4007 | if (TextUtils.isEmpty(pkgName)) |
| 4008 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS; |
Zach Johnson | 50ecba3 | 2015-05-19 00:24:21 -0700 | [diff] [blame] | 4009 | int result = TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED; |
| 4010 | for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { |
| 4011 | UiccCard card = UiccController.getInstance().getUiccCard(i); |
| 4012 | if (card == null) { |
Jonathan Basseri | 7d320df | 2015-06-16 12:17:08 -0700 | [diff] [blame] | 4013 | // No UICC in that slot. |
Zach Johnson | 50ecba3 | 2015-05-19 00:24:21 -0700 | [diff] [blame] | 4014 | continue; |
| 4015 | } |
| 4016 | |
| 4017 | result = card.getCarrierPrivilegeStatus( |
| 4018 | mPhone.getContext().getPackageManager(), pkgName); |
| 4019 | if (result == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { |
| 4020 | break; |
| 4021 | } |
| 4022 | } |
| 4023 | |
| 4024 | return result; |
Junda Liu | 2934034 | 2014-07-10 15:23:27 -0700 | [diff] [blame] | 4025 | } |
Derek Tan | 89e89d4 | 2014-07-08 17:00:10 -0700 | [diff] [blame] | 4026 | |
| 4027 | @Override |
Junda Liu | e64de78 | 2015-04-16 17:19:16 -0700 | [diff] [blame] | 4028 | public List<String> getCarrierPackageNamesForIntentAndPhone(Intent intent, int phoneId) { |
| 4029 | if (!SubscriptionManager.isValidPhoneId(phoneId)) { |
| 4030 | loge("phoneId " + phoneId + " is not valid."); |
| 4031 | return null; |
| 4032 | } |
| 4033 | UiccCard card = UiccController.getInstance().getUiccCard(phoneId); |
Shishir Agrawal | eb6439a | 2014-07-21 13:19:38 -0700 | [diff] [blame] | 4034 | if (card == null) { |
Diego Pontoriero | af74c86 | 2014-08-28 11:51:16 -0700 | [diff] [blame] | 4035 | loge("getCarrierPackageNamesForIntent: No UICC"); |
Shishir Agrawal | eb6439a | 2014-07-21 13:19:38 -0700 | [diff] [blame] | 4036 | return null ; |
| 4037 | } |
Diego Pontoriero | af74c86 | 2014-08-28 11:51:16 -0700 | [diff] [blame] | 4038 | return card.getCarrierPackageNamesForIntent( |
Svetoslav | 483aff7 | 2015-04-21 14:16:07 -0700 | [diff] [blame] | 4039 | mPhone.getContext().getPackageManager(), intent); |
Shishir Agrawal | eb6439a | 2014-07-21 13:19:38 -0700 | [diff] [blame] | 4040 | } |
| 4041 | |
Amith Yamasani | 6e11887 | 2016-02-19 12:53:51 -0800 | [diff] [blame] | 4042 | @Override |
| 4043 | public List<String> getPackagesWithCarrierPrivileges() { |
| 4044 | PackageManager pm = mPhone.getContext().getPackageManager(); |
| 4045 | List<String> privilegedPackages = new ArrayList<>(); |
| 4046 | List<PackageInfo> packages = null; |
| 4047 | for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { |
| 4048 | UiccCard card = UiccController.getInstance().getUiccCard(i); |
| 4049 | if (card == null) { |
| 4050 | // No UICC in that slot. |
| 4051 | continue; |
| 4052 | } |
| 4053 | if (card.hasCarrierPrivilegeRules()) { |
| 4054 | if (packages == null) { |
| 4055 | // Only check packages in user 0 for now |
| 4056 | packages = pm.getInstalledPackagesAsUser( |
| 4057 | PackageManager.MATCH_DISABLED_COMPONENTS |
| 4058 | | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS |
| 4059 | | PackageManager.GET_SIGNATURES, UserHandle.USER_SYSTEM); |
| 4060 | } |
| 4061 | for (int p = packages.size() - 1; p >= 0; p--) { |
| 4062 | PackageInfo pkgInfo = packages.get(p); |
| 4063 | if (pkgInfo != null && pkgInfo.packageName != null |
| 4064 | && card.getCarrierPrivilegeStatus(pkgInfo) |
| 4065 | == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { |
| 4066 | privilegedPackages.add(pkgInfo.packageName); |
| 4067 | } |
| 4068 | } |
| 4069 | } |
| 4070 | } |
| 4071 | return privilegedPackages; |
| 4072 | } |
| 4073 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 4074 | private String getIccId(int subId) { |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 4075 | final Phone phone = getPhone(subId); |
| 4076 | UiccCard card = phone == null ? null : phone.getUiccCard(); |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 4077 | if (card == null) { |
| 4078 | loge("getIccId: No UICC"); |
| 4079 | return null; |
| 4080 | } |
| 4081 | String iccId = card.getIccId(); |
| 4082 | if (TextUtils.isEmpty(iccId)) { |
| 4083 | loge("getIccId: ICC ID is null or empty."); |
| 4084 | return null; |
| 4085 | } |
| 4086 | return iccId; |
| 4087 | } |
| 4088 | |
Shishir Agrawal | eb6439a | 2014-07-21 13:19:38 -0700 | [diff] [blame] | 4089 | @Override |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 4090 | public boolean setLine1NumberForDisplayForSubscriber(int subId, String alphaTag, |
| 4091 | String number) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 4092 | TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege( |
| 4093 | subId, "setLine1NumberForDisplayForSubscriber"); |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 4094 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4095 | final long identity = Binder.clearCallingIdentity(); |
| 4096 | try { |
| 4097 | final String iccId = getIccId(subId); |
| 4098 | final Phone phone = getPhone(subId); |
| 4099 | if (phone == null) { |
| 4100 | return false; |
| 4101 | } |
| 4102 | final String subscriberId = phone.getSubscriberId(); |
| 4103 | |
| 4104 | if (DBG_MERGE) { |
| 4105 | Slog.d(LOG_TAG, "Setting line number for ICC=" + iccId + ", subscriberId=" |
| 4106 | + subscriberId + " to " + number); |
| 4107 | } |
| 4108 | |
| 4109 | if (TextUtils.isEmpty(iccId)) { |
| 4110 | return false; |
| 4111 | } |
| 4112 | |
| 4113 | final SharedPreferences.Editor editor = mTelephonySharedPreferences.edit(); |
| 4114 | |
| 4115 | final String alphaTagPrefKey = PREF_CARRIERS_ALPHATAG_PREFIX + iccId; |
| 4116 | if (alphaTag == null) { |
| 4117 | editor.remove(alphaTagPrefKey); |
| 4118 | } else { |
| 4119 | editor.putString(alphaTagPrefKey, alphaTag); |
| 4120 | } |
| 4121 | |
| 4122 | // Record both the line number and IMSI for this ICCID, since we need to |
| 4123 | // track all merged IMSIs based on line number |
| 4124 | final String numberPrefKey = PREF_CARRIERS_NUMBER_PREFIX + iccId; |
| 4125 | final String subscriberPrefKey = PREF_CARRIERS_SUBSCRIBER_PREFIX + iccId; |
| 4126 | if (number == null) { |
| 4127 | editor.remove(numberPrefKey); |
| 4128 | editor.remove(subscriberPrefKey); |
| 4129 | } else { |
| 4130 | editor.putString(numberPrefKey, number); |
| 4131 | editor.putString(subscriberPrefKey, subscriberId); |
| 4132 | } |
| 4133 | |
| 4134 | editor.commit(); |
| 4135 | return true; |
| 4136 | } finally { |
| 4137 | Binder.restoreCallingIdentity(identity); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 4138 | } |
Derek Tan | 7226c84 | 2014-07-02 17:42:23 -0700 | [diff] [blame] | 4139 | } |
| 4140 | |
| 4141 | @Override |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 4142 | public String getLine1NumberForDisplay(int subId, String callingPackage) { |
Makoto Onuki | fee6934 | 2015-06-29 14:44:50 -0700 | [diff] [blame] | 4143 | // This is open to apps with WRITE_SMS. |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 4144 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneNumber( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4145 | mApp, subId, callingPackage, "getLine1NumberForDisplay")) { |
Amit Mahajan | 9cf1151 | 2015-11-09 11:40:48 -0800 | [diff] [blame] | 4146 | if (DBG_MERGE) log("getLine1NumberForDisplay returning null due to permission"); |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 4147 | return null; |
| 4148 | } |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 4149 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4150 | final long identity = Binder.clearCallingIdentity(); |
| 4151 | try { |
| 4152 | String iccId = getIccId(subId); |
| 4153 | if (iccId != null) { |
| 4154 | String numberPrefKey = PREF_CARRIERS_NUMBER_PREFIX + iccId; |
| 4155 | if (DBG_MERGE) { |
| 4156 | log("getLine1NumberForDisplay returning " |
| 4157 | + mTelephonySharedPreferences.getString(numberPrefKey, null)); |
| 4158 | } |
| 4159 | return mTelephonySharedPreferences.getString(numberPrefKey, null); |
Amit Mahajan | 9cf1151 | 2015-11-09 11:40:48 -0800 | [diff] [blame] | 4160 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4161 | if (DBG_MERGE) log("getLine1NumberForDisplay returning null as iccId is null"); |
| 4162 | return null; |
| 4163 | } finally { |
| 4164 | Binder.restoreCallingIdentity(identity); |
Derek Tan | 7226c84 | 2014-07-02 17:42:23 -0700 | [diff] [blame] | 4165 | } |
Derek Tan | 7226c84 | 2014-07-02 17:42:23 -0700 | [diff] [blame] | 4166 | } |
| 4167 | |
| 4168 | @Override |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 4169 | public String getLine1AlphaTagForDisplay(int subId, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 4170 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4171 | mApp, subId, callingPackage, "getLine1AlphaTagForDisplay")) { |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 4172 | return null; |
| 4173 | } |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 4174 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4175 | final long identity = Binder.clearCallingIdentity(); |
| 4176 | try { |
| 4177 | String iccId = getIccId(subId); |
| 4178 | if (iccId != null) { |
| 4179 | String alphaTagPrefKey = PREF_CARRIERS_ALPHATAG_PREFIX + iccId; |
| 4180 | return mTelephonySharedPreferences.getString(alphaTagPrefKey, null); |
| 4181 | } |
| 4182 | return null; |
| 4183 | } finally { |
| 4184 | Binder.restoreCallingIdentity(identity); |
Derek Tan | 7226c84 | 2014-07-02 17:42:23 -0700 | [diff] [blame] | 4185 | } |
Derek Tan | 7226c84 | 2014-07-02 17:42:23 -0700 | [diff] [blame] | 4186 | } |
Shishir Agrawal | b1ebf8c | 2014-07-17 16:32:41 -0700 | [diff] [blame] | 4187 | |
| 4188 | @Override |
Fyodor Kupolov | 8e53b0b | 2015-06-17 13:17:50 -0700 | [diff] [blame] | 4189 | public String[] getMergedSubscriberIds(String callingPackage) { |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4190 | // This API isn't public, so no need to provide a valid subscription ID - we're not worried |
| 4191 | // about carrier-privileged callers not having access. |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 4192 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4193 | mApp, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage, |
| 4194 | "getMergedSubscriberIds")) { |
Fyodor Kupolov | 8e53b0b | 2015-06-17 13:17:50 -0700 | [diff] [blame] | 4195 | return null; |
| 4196 | } |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 4197 | |
Fyodor Kupolov | 8e53b0b | 2015-06-17 13:17:50 -0700 | [diff] [blame] | 4198 | final long identity = Binder.clearCallingIdentity(); |
| 4199 | try { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4200 | final Context context = mPhone.getContext(); |
| 4201 | final TelephonyManager tele = TelephonyManager.from(context); |
| 4202 | final SubscriptionManager sub = SubscriptionManager.from(context); |
| 4203 | |
| 4204 | // Figure out what subscribers are currently active |
| 4205 | final ArraySet<String> activeSubscriberIds = new ArraySet<>(); |
| 4206 | // Clear calling identity, when calling TelephonyManager, because callerUid must be |
| 4207 | // the process, where TelephonyManager was instantiated. |
| 4208 | // Otherwise AppOps check will fail. |
| 4209 | |
Fyodor Kupolov | 8e53b0b | 2015-06-17 13:17:50 -0700 | [diff] [blame] | 4210 | final int[] subIds = sub.getActiveSubscriptionIdList(); |
| 4211 | for (int subId : subIds) { |
| 4212 | activeSubscriberIds.add(tele.getSubscriberId(subId)); |
| 4213 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4214 | |
| 4215 | // First pass, find a number override for an active subscriber |
| 4216 | String mergeNumber = null; |
| 4217 | final Map<String, ?> prefs = mTelephonySharedPreferences.getAll(); |
| 4218 | for (String key : prefs.keySet()) { |
| 4219 | if (key.startsWith(PREF_CARRIERS_SUBSCRIBER_PREFIX)) { |
| 4220 | final String subscriberId = (String) prefs.get(key); |
| 4221 | if (activeSubscriberIds.contains(subscriberId)) { |
| 4222 | final String iccId = key.substring( |
| 4223 | PREF_CARRIERS_SUBSCRIBER_PREFIX.length()); |
| 4224 | final String numberKey = PREF_CARRIERS_NUMBER_PREFIX + iccId; |
| 4225 | mergeNumber = (String) prefs.get(numberKey); |
| 4226 | if (DBG_MERGE) { |
| 4227 | Slog.d(LOG_TAG, "Found line number " + mergeNumber |
| 4228 | + " for active subscriber " + subscriberId); |
| 4229 | } |
| 4230 | if (!TextUtils.isEmpty(mergeNumber)) { |
| 4231 | break; |
| 4232 | } |
| 4233 | } |
| 4234 | } |
| 4235 | } |
| 4236 | |
| 4237 | // Shortcut when no active merged subscribers |
| 4238 | if (TextUtils.isEmpty(mergeNumber)) { |
| 4239 | return null; |
| 4240 | } |
| 4241 | |
| 4242 | // Second pass, find all subscribers under that line override |
| 4243 | final ArraySet<String> result = new ArraySet<>(); |
| 4244 | for (String key : prefs.keySet()) { |
| 4245 | if (key.startsWith(PREF_CARRIERS_NUMBER_PREFIX)) { |
| 4246 | final String number = (String) prefs.get(key); |
| 4247 | if (mergeNumber.equals(number)) { |
| 4248 | final String iccId = key.substring(PREF_CARRIERS_NUMBER_PREFIX.length()); |
| 4249 | final String subscriberKey = PREF_CARRIERS_SUBSCRIBER_PREFIX + iccId; |
| 4250 | final String subscriberId = (String) prefs.get(subscriberKey); |
| 4251 | if (!TextUtils.isEmpty(subscriberId)) { |
| 4252 | result.add(subscriberId); |
| 4253 | } |
| 4254 | } |
| 4255 | } |
| 4256 | } |
| 4257 | |
| 4258 | final String[] resultArray = result.toArray(new String[result.size()]); |
| 4259 | Arrays.sort(resultArray); |
| 4260 | if (DBG_MERGE) { |
| 4261 | Slog.d(LOG_TAG, |
| 4262 | "Found subscribers " + Arrays.toString(resultArray) + " after merge"); |
| 4263 | } |
| 4264 | return resultArray; |
Fyodor Kupolov | 8e53b0b | 2015-06-17 13:17:50 -0700 | [diff] [blame] | 4265 | } finally { |
| 4266 | Binder.restoreCallingIdentity(identity); |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 4267 | } |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 4268 | } |
| 4269 | |
| 4270 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 4271 | public boolean setOperatorBrandOverride(int subId, String brand) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 4272 | TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege( |
| 4273 | subId, "setOperatorBrandOverride"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4274 | |
| 4275 | final long identity = Binder.clearCallingIdentity(); |
| 4276 | try { |
| 4277 | final Phone phone = getPhone(subId); |
| 4278 | return phone == null ? false : phone.setOperatorBrandOverride(brand); |
| 4279 | } finally { |
| 4280 | Binder.restoreCallingIdentity(identity); |
| 4281 | } |
Shishir Agrawal | b1ebf8c | 2014-07-17 16:32:41 -0700 | [diff] [blame] | 4282 | } |
Steven Liu | 4bf01bc | 2014-07-17 11:05:29 -0500 | [diff] [blame] | 4283 | |
| 4284 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 4285 | public boolean setRoamingOverride(int subId, List<String> gsmRoamingList, |
Shishir Agrawal | 621a47c | 2014-12-01 10:25:09 -0800 | [diff] [blame] | 4286 | List<String> gsmNonRoamingList, List<String> cdmaRoamingList, |
| 4287 | List<String> cdmaNonRoamingList) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 4288 | TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege(subId, "setRoamingOverride"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4289 | |
| 4290 | final long identity = Binder.clearCallingIdentity(); |
| 4291 | try { |
| 4292 | final Phone phone = getPhone(subId); |
| 4293 | if (phone == null) { |
| 4294 | return false; |
| 4295 | } |
| 4296 | return phone.setRoamingOverride(gsmRoamingList, gsmNonRoamingList, cdmaRoamingList, |
| 4297 | cdmaNonRoamingList); |
| 4298 | } finally { |
| 4299 | Binder.restoreCallingIdentity(identity); |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 4300 | } |
Shishir Agrawal | 621a47c | 2014-12-01 10:25:09 -0800 | [diff] [blame] | 4301 | } |
| 4302 | |
| 4303 | @Override |
Shuo Qian | 850e4d6a | 2018-04-25 21:02:08 +0000 | [diff] [blame] | 4304 | @Deprecated |
| 4305 | public int invokeOemRilRequestRaw(byte[] oemReq, byte[] oemResp) { |
| 4306 | enforceModifyPermission(); |
| 4307 | |
| 4308 | int returnValue = 0; |
| 4309 | try { |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 4310 | AsyncResult result = (AsyncResult) sendRequest(CMD_INVOKE_OEM_RIL_REQUEST_RAW, oemReq); |
Shuo Qian | 850e4d6a | 2018-04-25 21:02:08 +0000 | [diff] [blame] | 4311 | if(result.exception == null) { |
| 4312 | if (result.result != null) { |
| 4313 | byte[] responseData = (byte[])(result.result); |
| 4314 | if(responseData.length > oemResp.length) { |
| 4315 | Log.w(LOG_TAG, "Buffer to copy response too small: Response length is " + |
| 4316 | responseData.length + "bytes. Buffer Size is " + |
| 4317 | oemResp.length + "bytes."); |
| 4318 | } |
| 4319 | System.arraycopy(responseData, 0, oemResp, 0, responseData.length); |
| 4320 | returnValue = responseData.length; |
| 4321 | } |
| 4322 | } else { |
| 4323 | CommandException ex = (CommandException) result.exception; |
| 4324 | returnValue = ex.getCommandError().ordinal(); |
| 4325 | if(returnValue > 0) returnValue *= -1; |
| 4326 | } |
| 4327 | } catch (RuntimeException e) { |
| 4328 | Log.w(LOG_TAG, "sendOemRilRequestRaw: Runtime Exception"); |
| 4329 | returnValue = (CommandException.Error.GENERIC_FAILURE.ordinal()); |
| 4330 | if(returnValue > 0) returnValue *= -1; |
| 4331 | } |
| 4332 | |
| 4333 | return returnValue; |
| 4334 | } |
| 4335 | |
| 4336 | @Override |
Wink Saville | 5d475dd | 2014-10-17 15:00:58 -0700 | [diff] [blame] | 4337 | public void setRadioCapability(RadioAccessFamily[] rafs) { |
| 4338 | try { |
| 4339 | ProxyController.getInstance().setRadioCapability(rafs); |
| 4340 | } catch (RuntimeException e) { |
| 4341 | Log.w(LOG_TAG, "setRadioCapability: Runtime Exception"); |
| 4342 | } |
| 4343 | } |
| 4344 | |
| 4345 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 4346 | public int getRadioAccessFamily(int phoneId, String callingPackage) { |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4347 | Phone phone = PhoneFactory.getPhone(phoneId); |
chen xu | b97461a | 2018-10-26 14:17:57 -0700 | [diff] [blame] | 4348 | int raf = RadioAccessFamily.RAF_UNKNOWN; |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4349 | if (phone == null) { |
chen xu | b97461a | 2018-10-26 14:17:57 -0700 | [diff] [blame] | 4350 | return raf; |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4351 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4352 | final long identity = Binder.clearCallingIdentity(); |
| 4353 | try { |
chen xu | b97461a | 2018-10-26 14:17:57 -0700 | [diff] [blame] | 4354 | TelephonyPermissions |
| 4355 | .enforeceCallingOrSelfReadPrivilegedPhoneStatePermissionOrCarrierPrivilege( |
| 4356 | mApp, phone.getSubId(), "getRadioAccessFamily"); |
| 4357 | raf = ProxyController.getInstance().getRadioAccessFamily(phoneId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4358 | } finally { |
| 4359 | Binder.restoreCallingIdentity(identity); |
| 4360 | } |
chen xu | b97461a | 2018-10-26 14:17:57 -0700 | [diff] [blame] | 4361 | return raf; |
Wink Saville | 5d475dd | 2014-10-17 15:00:58 -0700 | [diff] [blame] | 4362 | } |
Andrew Lee | df14ead | 2014-10-17 14:22:52 -0700 | [diff] [blame] | 4363 | |
| 4364 | @Override |
| 4365 | public void enableVideoCalling(boolean enable) { |
| 4366 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4367 | |
| 4368 | final long identity = Binder.clearCallingIdentity(); |
| 4369 | try { |
| 4370 | ImsManager.getInstance(mPhone.getContext(), mPhone.getPhoneId()).setVtSetting(enable); |
| 4371 | } finally { |
| 4372 | Binder.restoreCallingIdentity(identity); |
| 4373 | } |
Andrew Lee | df14ead | 2014-10-17 14:22:52 -0700 | [diff] [blame] | 4374 | } |
| 4375 | |
| 4376 | @Override |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 4377 | public boolean isVideoCallingEnabled(String callingPackage) { |
Amit Mahajan | 578e53d | 2018-03-20 16:18:38 +0000 | [diff] [blame] | 4378 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
| 4379 | mApp, mPhone.getSubId(), callingPackage, "isVideoCallingEnabled")) { |
| 4380 | return false; |
| 4381 | } |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 4382 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4383 | final long identity = Binder.clearCallingIdentity(); |
| 4384 | try { |
| 4385 | // Check the user preference and the system-level IMS setting. Even if the user has |
| 4386 | // enabled video calling, if IMS is disabled we aren't able to support video calling. |
| 4387 | // In the long run, we may instead need to check if there exists a connection service |
| 4388 | // which can support video calling. |
| 4389 | ImsManager imsManager = |
| 4390 | ImsManager.getInstance(mPhone.getContext(), mPhone.getPhoneId()); |
| 4391 | return imsManager.isVtEnabledByPlatform() |
| 4392 | && imsManager.isEnhanced4gLteModeSettingEnabledByUser() |
| 4393 | && imsManager.isVtEnabledByUser(); |
| 4394 | } finally { |
| 4395 | Binder.restoreCallingIdentity(identity); |
| 4396 | } |
Andrew Lee | df14ead | 2014-10-17 14:22:52 -0700 | [diff] [blame] | 4397 | } |
Libin.Tang@motorola.com | afe8264 | 2014-12-18 13:27:53 -0600 | [diff] [blame] | 4398 | |
Andrew Lee | a1239f2 | 2015-03-02 17:44:07 -0800 | [diff] [blame] | 4399 | @Override |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4400 | public boolean canChangeDtmfToneLength(int subId, String callingPackage) { |
| 4401 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
| 4402 | mApp, subId, callingPackage, "isVideoCallingEnabled")) { |
| 4403 | return false; |
| 4404 | } |
| 4405 | |
| 4406 | final long identity = Binder.clearCallingIdentity(); |
| 4407 | try { |
| 4408 | CarrierConfigManager configManager = |
| 4409 | (CarrierConfigManager) mApp.getSystemService(Context.CARRIER_CONFIG_SERVICE); |
| 4410 | return configManager.getConfigForSubId(mPhone.getSubId()) |
| 4411 | .getBoolean(CarrierConfigManager.KEY_DTMF_TYPE_ENABLED_BOOL); |
| 4412 | } finally { |
| 4413 | Binder.restoreCallingIdentity(identity); |
| 4414 | } |
Andrew Lee | a1239f2 | 2015-03-02 17:44:07 -0800 | [diff] [blame] | 4415 | } |
| 4416 | |
| 4417 | @Override |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4418 | public boolean isWorldPhone(int subId, String callingPackage) { |
| 4419 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
| 4420 | mApp, subId, callingPackage, "isVideoCallingEnabled")) { |
| 4421 | return false; |
| 4422 | } |
| 4423 | |
| 4424 | final long identity = Binder.clearCallingIdentity(); |
| 4425 | try { |
| 4426 | CarrierConfigManager configManager = |
| 4427 | (CarrierConfigManager) mApp.getSystemService(Context.CARRIER_CONFIG_SERVICE); |
| 4428 | return configManager.getConfigForSubId(mPhone.getSubId()) |
| 4429 | .getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL); |
| 4430 | } finally { |
| 4431 | Binder.restoreCallingIdentity(identity); |
| 4432 | } |
Andrew Lee | a1239f2 | 2015-03-02 17:44:07 -0800 | [diff] [blame] | 4433 | } |
| 4434 | |
Andrew Lee | 9431b83 | 2015-03-09 18:46:45 -0700 | [diff] [blame] | 4435 | @Override |
| 4436 | public boolean isTtyModeSupported() { |
| 4437 | TelecomManager telecomManager = TelecomManager.from(mPhone.getContext()); |
Wooki Wu | 1f82f7a | 2016-02-15 15:59:58 +0800 | [diff] [blame] | 4438 | return telecomManager.isTtySupported(); |
Andrew Lee | 9431b83 | 2015-03-09 18:46:45 -0700 | [diff] [blame] | 4439 | } |
| 4440 | |
| 4441 | @Override |
| 4442 | public boolean isHearingAidCompatibilitySupported() { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4443 | final long identity = Binder.clearCallingIdentity(); |
| 4444 | try { |
| 4445 | return mPhone.getContext().getResources().getBoolean(R.bool.hac_enabled); |
| 4446 | } finally { |
| 4447 | Binder.restoreCallingIdentity(identity); |
| 4448 | } |
Andrew Lee | 9431b83 | 2015-03-09 18:46:45 -0700 | [diff] [blame] | 4449 | } |
| 4450 | |
Hall Liu | f666891 | 2018-10-31 17:05:23 -0700 | [diff] [blame] | 4451 | /** |
| 4452 | * Determines whether the device currently supports RTT (Real-time text). Based both on carrier |
| 4453 | * support for the feature and device firmware support. |
| 4454 | * |
| 4455 | * @return {@code true} if the device and carrier both support RTT, {@code false} otherwise. |
| 4456 | */ |
| 4457 | @Override |
| 4458 | public boolean isRttSupported(int subscriptionId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4459 | final long identity = Binder.clearCallingIdentity(); |
| 4460 | try { |
| 4461 | boolean isCarrierSupported = mApp.getCarrierConfigForSubId( |
| 4462 | mPhone.getSubId()).getBoolean( |
| 4463 | CarrierConfigManager.KEY_RTT_SUPPORTED_BOOL); |
| 4464 | boolean isDeviceSupported = |
| 4465 | mPhone.getContext().getResources().getBoolean(R.bool.config_support_rtt); |
| 4466 | return isCarrierSupported && isDeviceSupported; |
| 4467 | } finally { |
| 4468 | Binder.restoreCallingIdentity(identity); |
| 4469 | } |
Hall Liu | 9818758 | 2018-01-22 19:15:32 -0800 | [diff] [blame] | 4470 | } |
| 4471 | |
Hall Liu | f666891 | 2018-10-31 17:05:23 -0700 | [diff] [blame] | 4472 | /** |
| 4473 | * Determines whether the user has turned on RTT. Only returns true if the device and carrier |
| 4474 | * both also support RTT. |
| 4475 | */ |
| 4476 | public boolean isRttEnabled(int subscriptionId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4477 | final long identity = Binder.clearCallingIdentity(); |
| 4478 | try { |
Hall Liu | f666891 | 2018-10-31 17:05:23 -0700 | [diff] [blame] | 4479 | return isRttSupported(subscriptionId) && Settings.Secure.getInt( |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4480 | mPhone.getContext().getContentResolver(), |
| 4481 | Settings.Secure.RTT_CALLING_MODE, 0) != 0; |
| 4482 | } finally { |
| 4483 | Binder.restoreCallingIdentity(identity); |
| 4484 | } |
Hall Liu | 3ad5f01 | 2018-04-06 16:23:39 -0700 | [diff] [blame] | 4485 | } |
| 4486 | |
Sanket Padawe | 7310cc7 | 2015-01-14 09:53:20 -0800 | [diff] [blame] | 4487 | /** |
| 4488 | * Returns the unique device ID of phone, for example, the IMEI for |
| 4489 | * GSM and the MEID for CDMA phones. Return null if device ID is not available. |
| 4490 | * |
| 4491 | * <p>Requires Permission: |
| 4492 | * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} |
| 4493 | */ |
| 4494 | @Override |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 4495 | public String getDeviceId(String callingPackage) { |
Sanket Padawe | 7310cc7 | 2015-01-14 09:53:20 -0800 | [diff] [blame] | 4496 | final Phone phone = PhoneFactory.getPhone(0); |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4497 | if (phone == null) { |
Sanket Padawe | 7310cc7 | 2015-01-14 09:53:20 -0800 | [diff] [blame] | 4498 | return null; |
| 4499 | } |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4500 | int subId = phone.getSubId(); |
Michael Groover | 70af6dc | 2018-10-01 16:23:15 -0700 | [diff] [blame] | 4501 | if (!TelephonyPermissions.checkCallingOrSelfReadDeviceIdentifiers(mApp, subId, |
| 4502 | callingPackage, "getDeviceId")) { |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4503 | return null; |
| 4504 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4505 | |
| 4506 | final long identity = Binder.clearCallingIdentity(); |
| 4507 | try { |
| 4508 | return phone.getDeviceId(); |
| 4509 | } finally { |
| 4510 | Binder.restoreCallingIdentity(identity); |
| 4511 | } |
Sanket Padawe | 7310cc7 | 2015-01-14 09:53:20 -0800 | [diff] [blame] | 4512 | } |
| 4513 | |
Ping Sun | c67b7c2 | 2016-03-02 19:16:45 +0800 | [diff] [blame] | 4514 | /** |
| 4515 | * {@hide} |
| 4516 | * Returns the IMS Registration Status on a particular subid |
| 4517 | * |
| 4518 | * @param subId |
| 4519 | */ |
Brad Ebinger | 1f2b508 | 2018-02-08 16:11:32 -0800 | [diff] [blame] | 4520 | public boolean isImsRegistered(int subId) { |
Ping Sun | c67b7c2 | 2016-03-02 19:16:45 +0800 | [diff] [blame] | 4521 | Phone phone = getPhone(subId); |
| 4522 | if (phone != null) { |
| 4523 | return phone.isImsRegistered(); |
| 4524 | } else { |
| 4525 | return false; |
| 4526 | } |
| 4527 | } |
| 4528 | |
Santos Cordon | 7a1885b | 2015-02-03 11:15:19 -0800 | [diff] [blame] | 4529 | @Override |
| 4530 | public int getSubIdForPhoneAccount(PhoneAccount phoneAccount) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4531 | final long identity = Binder.clearCallingIdentity(); |
| 4532 | try { |
| 4533 | return PhoneUtils.getSubIdForPhoneAccount(phoneAccount); |
| 4534 | } finally { |
| 4535 | Binder.restoreCallingIdentity(identity); |
| 4536 | } |
Santos Cordon | 7a1885b | 2015-02-03 11:15:19 -0800 | [diff] [blame] | 4537 | } |
Nathan Harold | dcfc793 | 2015-03-18 10:01:20 -0700 | [diff] [blame] | 4538 | |
Brad Ebinger | 1f2b508 | 2018-02-08 16:11:32 -0800 | [diff] [blame] | 4539 | /** |
| 4540 | * @return the VoWiFi calling availability. |
Nathan Harold | c55097a | 2015-03-11 18:14:50 -0700 | [diff] [blame] | 4541 | */ |
Brad Ebinger | 1f2b508 | 2018-02-08 16:11:32 -0800 | [diff] [blame] | 4542 | public boolean isWifiCallingAvailable(int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4543 | final long identity = Binder.clearCallingIdentity(); |
| 4544 | try { |
| 4545 | Phone phone = getPhone(subId); |
| 4546 | if (phone != null) { |
| 4547 | return phone.isWifiCallingEnabled(); |
| 4548 | } else { |
| 4549 | return false; |
| 4550 | } |
| 4551 | } finally { |
| 4552 | Binder.restoreCallingIdentity(identity); |
Brad Ebinger | 1f2b508 | 2018-02-08 16:11:32 -0800 | [diff] [blame] | 4553 | } |
Nathan Harold | c55097a | 2015-03-11 18:14:50 -0700 | [diff] [blame] | 4554 | } |
| 4555 | |
Brad Ebinger | 1f2b508 | 2018-02-08 16:11:32 -0800 | [diff] [blame] | 4556 | /** |
Brad Ebinger | 1f2b508 | 2018-02-08 16:11:32 -0800 | [diff] [blame] | 4557 | * @return the VT calling availability. |
Etan Cohen | 3b7a1bc | 2015-05-28 15:57:13 -0700 | [diff] [blame] | 4558 | */ |
Brad Ebinger | 1f2b508 | 2018-02-08 16:11:32 -0800 | [diff] [blame] | 4559 | public boolean isVideoTelephonyAvailable(int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4560 | final long identity = Binder.clearCallingIdentity(); |
| 4561 | try { |
| 4562 | Phone phone = getPhone(subId); |
| 4563 | if (phone != null) { |
| 4564 | return phone.isVideoEnabled(); |
| 4565 | } else { |
| 4566 | return false; |
| 4567 | } |
| 4568 | } finally { |
| 4569 | Binder.restoreCallingIdentity(identity); |
Brad Ebinger | 1f2b508 | 2018-02-08 16:11:32 -0800 | [diff] [blame] | 4570 | } |
| 4571 | } |
| 4572 | |
| 4573 | /** |
| 4574 | * @return the IMS registration technology for the MMTEL feature. Valid return values are |
| 4575 | * defined in {@link ImsRegistrationImplBase}. |
| 4576 | */ |
| 4577 | public @ImsRegistrationImplBase.ImsRegistrationTech int getImsRegTechnologyForMmTel(int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4578 | final long identity = Binder.clearCallingIdentity(); |
| 4579 | try { |
| 4580 | Phone phone = getPhone(subId); |
| 4581 | if (phone != null) { |
| 4582 | return phone.getImsRegistrationTech(); |
| 4583 | } else { |
| 4584 | return ImsRegistrationImplBase.REGISTRATION_TECH_NONE; |
| 4585 | } |
| 4586 | } finally { |
| 4587 | Binder.restoreCallingIdentity(identity); |
Brad Ebinger | 1f2b508 | 2018-02-08 16:11:32 -0800 | [diff] [blame] | 4588 | } |
Etan Cohen | 3b7a1bc | 2015-05-28 15:57:13 -0700 | [diff] [blame] | 4589 | } |
| 4590 | |
Stuart Scott | 8eef64f | 2015-04-08 15:13:54 -0700 | [diff] [blame] | 4591 | @Override |
| 4592 | public void factoryReset(int subId) { |
| 4593 | enforceConnectivityInternalPermission(); |
Stuart Scott | 981d858 | 2015-04-21 14:09:50 -0700 | [diff] [blame] | 4594 | if (mUserManager.hasUserRestriction(UserManager.DISALLOW_NETWORK_RESET)) { |
| 4595 | return; |
| 4596 | } |
| 4597 | |
Svet Ganov | cc087f8 | 2015-05-12 20:35:54 -0700 | [diff] [blame] | 4598 | final long identity = Binder.clearCallingIdentity(); |
| 4599 | try { |
Stuart Scott | 981d858 | 2015-04-21 14:09:50 -0700 | [diff] [blame] | 4600 | if (SubscriptionManager.isUsableSubIdValue(subId) && !mUserManager.hasUserRestriction( |
| 4601 | UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) { |
Pengquan Meng | 85728fb | 2018-03-12 16:31:21 -0700 | [diff] [blame] | 4602 | setUserDataEnabled(subId, getDefaultDataEnabled()); |
Svet Ganov | cc087f8 | 2015-05-12 20:35:54 -0700 | [diff] [blame] | 4603 | setNetworkSelectionModeAutomatic(subId); |
Pengquan Meng | 85728fb | 2018-03-12 16:31:21 -0700 | [diff] [blame] | 4604 | setPreferredNetworkType(subId, getDefaultNetworkType(subId)); |
| 4605 | mPhone.setDataRoamingEnabled(getDefaultDataRoamingEnabled(subId)); |
pkanwar | 79ec054 | 2017-07-31 14:10:01 -0700 | [diff] [blame] | 4606 | CarrierInfoManager.deleteAllCarrierKeysForImsiEncryption(mPhone.getContext()); |
Svet Ganov | cc087f8 | 2015-05-12 20:35:54 -0700 | [diff] [blame] | 4607 | } |
| 4608 | } finally { |
| 4609 | Binder.restoreCallingIdentity(identity); |
Stuart Scott | 8eef64f | 2015-04-08 15:13:54 -0700 | [diff] [blame] | 4610 | } |
| 4611 | } |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 4612 | |
| 4613 | @Override |
| 4614 | public String getLocaleFromDefaultSim() { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4615 | final long identity = Binder.clearCallingIdentity(); |
| 4616 | try { |
| 4617 | // We query all subscriptions instead of just the active ones, because |
| 4618 | // this might be called early on in the provisioning flow when the |
| 4619 | // subscriptions potentially aren't active yet. |
| 4620 | final List<SubscriptionInfo> slist = getAllSubscriptionInfoList(); |
| 4621 | if (slist == null || slist.isEmpty()) { |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 4622 | return null; |
| 4623 | } |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 4624 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4625 | // This function may be called very early, say, from the setup wizard, at |
| 4626 | // which point we won't have a default subscription set. If that's the case |
| 4627 | // we just choose the first, which will be valid in "most cases". |
| 4628 | final int defaultSubId = getDefaultSubscription(); |
| 4629 | SubscriptionInfo info = null; |
| 4630 | if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { |
| 4631 | info = slist.get(0); |
| 4632 | } else { |
| 4633 | for (SubscriptionInfo item : slist) { |
| 4634 | if (item.getSubscriptionId() == defaultSubId) { |
| 4635 | info = item; |
| 4636 | break; |
| 4637 | } |
| 4638 | } |
| 4639 | |
| 4640 | if (info == null) { |
| 4641 | return null; |
Tony Hill | 183b2de | 2015-06-24 14:53:58 +0100 | [diff] [blame] | 4642 | } |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 4643 | } |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 4644 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4645 | // Try and fetch the locale from the carrier properties or from the SIM language |
| 4646 | // preferences (EF-PL and EF-LI)... |
| 4647 | final int mcc = info.getMcc(); |
| 4648 | final Phone defaultPhone = getPhone(info.getSubscriptionId()); |
| 4649 | String simLanguage = null; |
| 4650 | if (defaultPhone != null) { |
| 4651 | final Locale localeFromDefaultSim = defaultPhone.getLocaleFromSimAndCarrierPrefs(); |
| 4652 | if (localeFromDefaultSim != null) { |
| 4653 | if (!localeFromDefaultSim.getCountry().isEmpty()) { |
| 4654 | if (DBG) log("Using locale from default SIM:" + localeFromDefaultSim); |
| 4655 | return localeFromDefaultSim.toLanguageTag(); |
| 4656 | } else { |
| 4657 | simLanguage = localeFromDefaultSim.getLanguage(); |
| 4658 | } |
| 4659 | } |
| 4660 | } |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 4661 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4662 | // The SIM language preferences only store a language (e.g. fr = French), not an |
| 4663 | // exact locale (e.g. fr_FR = French/France). So, if the locale returned from |
| 4664 | // the SIM and carrier preferences does not include a country we add the country |
| 4665 | // determined from the SIM MCC to provide an exact locale. |
| 4666 | final Locale mccLocale = MccTable.getLocaleFromMcc(mPhone.getContext(), mcc, |
| 4667 | simLanguage); |
| 4668 | if (mccLocale != null) { |
| 4669 | if (DBG) log("No locale from default SIM, using mcc locale:" + mccLocale); |
| 4670 | return mccLocale.toLanguageTag(); |
| 4671 | } |
| 4672 | |
| 4673 | if (DBG) log("No locale found - returning null"); |
| 4674 | return null; |
| 4675 | } finally { |
| 4676 | Binder.restoreCallingIdentity(identity); |
| 4677 | } |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 4678 | } |
| 4679 | |
| 4680 | private List<SubscriptionInfo> getAllSubscriptionInfoList() { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4681 | return mSubscriptionController.getAllSubInfoList( |
| 4682 | mPhone.getContext().getOpPackageName()); |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 4683 | } |
| 4684 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4685 | /** |
| 4686 | * NOTE: this method assumes permission checks are done and caller identity has been cleared. |
| 4687 | */ |
| 4688 | private List<SubscriptionInfo> getActiveSubscriptionInfoListPrivileged() { |
| 4689 | return mSubscriptionController.getActiveSubscriptionInfoList( |
| 4690 | mPhone.getContext().getOpPackageName()); |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 4691 | } |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 4692 | |
Chenjie Yu | 1ba9725 | 2018-01-11 18:16:20 -0800 | [diff] [blame] | 4693 | private final ModemActivityInfo mLastModemActivityInfo = |
| 4694 | new ModemActivityInfo(0, 0, 0, new int[0], 0, 0); |
| 4695 | |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 4696 | /** |
Adam Lesinski | 903a54c | 2016-04-11 14:49:52 -0700 | [diff] [blame] | 4697 | * Responds to the ResultReceiver with the {@link android.telephony.ModemActivityInfo} object |
| 4698 | * representing the state of the modem. |
| 4699 | * |
Chenjie Yu | 1ba9725 | 2018-01-11 18:16:20 -0800 | [diff] [blame] | 4700 | * NOTE: The underlying implementation clears the modem state, so there should only ever be one |
| 4701 | * caller to it. Everyone should call this class to get cumulative data. |
Adam Lesinski | 903a54c | 2016-04-11 14:49:52 -0700 | [diff] [blame] | 4702 | * @hide |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 4703 | */ |
| 4704 | @Override |
Adam Lesinski | 903a54c | 2016-04-11 14:49:52 -0700 | [diff] [blame] | 4705 | public void requestModemActivityInfo(ResultReceiver result) { |
| 4706 | enforceModifyPermission(); |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 4707 | WorkSource workSource = getWorkSource(Binder.getCallingUid()); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4708 | |
| 4709 | final long identity = Binder.clearCallingIdentity(); |
| 4710 | try { |
| 4711 | ModemActivityInfo ret = null; |
| 4712 | synchronized (mLastModemActivityInfo) { |
| 4713 | ModemActivityInfo info = (ModemActivityInfo) sendRequest( |
| 4714 | CMD_GET_MODEM_ACTIVITY_INFO, |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 4715 | null, workSource); |
Siddharth Ray | b811406 | 2018-06-17 15:02:38 -0700 | [diff] [blame] | 4716 | if (isModemActivityInfoValid(info)) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4717 | int[] mergedTxTimeMs = new int[ModemActivityInfo.TX_POWER_LEVELS]; |
| 4718 | for (int i = 0; i < mergedTxTimeMs.length; i++) { |
| 4719 | mergedTxTimeMs[i] = |
| 4720 | info.getTxTimeMillis()[i] |
| 4721 | + mLastModemActivityInfo.getTxTimeMillis()[i]; |
| 4722 | } |
| 4723 | mLastModemActivityInfo.setTimestamp(info.getTimestamp()); |
| 4724 | mLastModemActivityInfo.setSleepTimeMillis( |
| 4725 | info.getSleepTimeMillis() |
| 4726 | + mLastModemActivityInfo.getSleepTimeMillis()); |
| 4727 | mLastModemActivityInfo.setIdleTimeMillis( |
| 4728 | info.getIdleTimeMillis() + mLastModemActivityInfo.getIdleTimeMillis()); |
| 4729 | mLastModemActivityInfo.setTxTimeMillis(mergedTxTimeMs); |
| 4730 | mLastModemActivityInfo.setRxTimeMillis( |
| 4731 | info.getRxTimeMillis() + mLastModemActivityInfo.getRxTimeMillis()); |
| 4732 | mLastModemActivityInfo.setEnergyUsed( |
| 4733 | info.getEnergyUsed() + mLastModemActivityInfo.getEnergyUsed()); |
Chenjie Yu | 1ba9725 | 2018-01-11 18:16:20 -0800 | [diff] [blame] | 4734 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4735 | ret = new ModemActivityInfo(mLastModemActivityInfo.getTimestamp(), |
| 4736 | mLastModemActivityInfo.getSleepTimeMillis(), |
| 4737 | mLastModemActivityInfo.getIdleTimeMillis(), |
| 4738 | mLastModemActivityInfo.getTxTimeMillis(), |
| 4739 | mLastModemActivityInfo.getRxTimeMillis(), |
| 4740 | mLastModemActivityInfo.getEnergyUsed()); |
Chenjie Yu | 1ba9725 | 2018-01-11 18:16:20 -0800 | [diff] [blame] | 4741 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4742 | Bundle bundle = new Bundle(); |
| 4743 | bundle.putParcelable(TelephonyManager.MODEM_ACTIVITY_RESULT_KEY, ret); |
| 4744 | result.send(0, bundle); |
| 4745 | } finally { |
| 4746 | Binder.restoreCallingIdentity(identity); |
Chenjie Yu | 1ba9725 | 2018-01-11 18:16:20 -0800 | [diff] [blame] | 4747 | } |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 4748 | } |
Jack Yu | 85bd38a | 2015-11-09 11:34:32 -0800 | [diff] [blame] | 4749 | |
Siddharth Ray | b811406 | 2018-06-17 15:02:38 -0700 | [diff] [blame] | 4750 | // Checks that ModemActivityInfo is valid. Sleep time, Idle time, Rx time and Tx time should be |
| 4751 | // less than total activity duration. |
| 4752 | private boolean isModemActivityInfoValid(ModemActivityInfo info) { |
| 4753 | if (info == null) { |
| 4754 | return false; |
| 4755 | } |
| 4756 | int activityDurationMs = |
| 4757 | (int) (info.getTimestamp() - mLastModemActivityInfo.getTimestamp()); |
| 4758 | int totalTxTimeMs = 0; |
| 4759 | for (int i = 0; i < info.getTxTimeMillis().length; i++) { |
| 4760 | totalTxTimeMs += info.getTxTimeMillis()[i]; |
| 4761 | } |
| 4762 | return (info.isValid() |
| 4763 | && (info.getSleepTimeMillis() <= activityDurationMs) |
| 4764 | && (info.getIdleTimeMillis() <= activityDurationMs) |
| 4765 | && (info.getRxTimeMillis() <= activityDurationMs) |
| 4766 | && (totalTxTimeMs <= activityDurationMs)); |
| 4767 | } |
| 4768 | |
Jack Yu | 85bd38a | 2015-11-09 11:34:32 -0800 | [diff] [blame] | 4769 | /** |
| 4770 | * {@hide} |
| 4771 | * Returns the service state information on specified subscription. |
| 4772 | */ |
| 4773 | @Override |
| 4774 | public ServiceState getServiceStateForSubscriber(int subId, String callingPackage) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 4775 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 4776 | mApp, subId, callingPackage, "getServiceStateForSubscriber")) { |
Jack Yu | 85bd38a | 2015-11-09 11:34:32 -0800 | [diff] [blame] | 4777 | return null; |
| 4778 | } |
| 4779 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4780 | final long identity = Binder.clearCallingIdentity(); |
| 4781 | try { |
| 4782 | final Phone phone = getPhone(subId); |
| 4783 | if (phone == null) { |
| 4784 | return null; |
| 4785 | } |
Jack Yu | 85bd38a | 2015-11-09 11:34:32 -0800 | [diff] [blame] | 4786 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4787 | return phone.getServiceState(); |
| 4788 | } finally { |
| 4789 | Binder.restoreCallingIdentity(identity); |
| 4790 | } |
Jack Yu | 85bd38a | 2015-11-09 11:34:32 -0800 | [diff] [blame] | 4791 | } |
Nancy Chen | 31f9ba1 | 2016-01-06 11:42:12 -0800 | [diff] [blame] | 4792 | |
| 4793 | /** |
| 4794 | * Returns the URI for the per-account voicemail ringtone set in Phone settings. |
| 4795 | * |
| 4796 | * @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the |
| 4797 | * voicemail ringtone. |
| 4798 | * @return The URI for the ringtone to play when receiving a voicemail from a specific |
| 4799 | * PhoneAccount. |
| 4800 | */ |
| 4801 | @Override |
| 4802 | public Uri getVoicemailRingtoneUri(PhoneAccountHandle accountHandle) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4803 | final long identity = Binder.clearCallingIdentity(); |
| 4804 | try { |
| 4805 | Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(accountHandle); |
| 4806 | if (phone == null) { |
| 4807 | phone = mPhone; |
| 4808 | } |
Nancy Chen | 31f9ba1 | 2016-01-06 11:42:12 -0800 | [diff] [blame] | 4809 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4810 | return VoicemailNotificationSettingsUtil.getRingtoneUri(phone.getContext()); |
| 4811 | } finally { |
| 4812 | Binder.restoreCallingIdentity(identity); |
| 4813 | } |
Nancy Chen | 31f9ba1 | 2016-01-06 11:42:12 -0800 | [diff] [blame] | 4814 | } |
| 4815 | |
| 4816 | /** |
Ta-wei Yen | c33877d | 2017-01-23 18:11:21 -0800 | [diff] [blame] | 4817 | * Sets the per-account voicemail ringtone. |
| 4818 | * |
| 4819 | * <p>Requires that the calling app is the default dialer, or has carrier privileges, or |
| 4820 | * has permission {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. |
| 4821 | * |
| 4822 | * @param phoneAccountHandle The handle for the {@link PhoneAccount} for which to set the |
| 4823 | * voicemail ringtone. |
| 4824 | * @param uri The URI for the ringtone to play when receiving a voicemail from a specific |
| 4825 | * PhoneAccount. |
| 4826 | */ |
| 4827 | @Override |
| 4828 | public void setVoicemailRingtoneUri(String callingPackage, |
| 4829 | PhoneAccountHandle phoneAccountHandle, Uri uri) { |
| 4830 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
| 4831 | if (!TextUtils.equals(callingPackage, |
| 4832 | TelecomManager.from(mPhone.getContext()).getDefaultDialerPackage())) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 4833 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 4834 | mApp, PhoneUtils.getSubIdForPhoneAccountHandle(phoneAccountHandle), |
| 4835 | "setVoicemailRingtoneUri"); |
Ta-wei Yen | c33877d | 2017-01-23 18:11:21 -0800 | [diff] [blame] | 4836 | } |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4837 | |
| 4838 | final long identity = Binder.clearCallingIdentity(); |
| 4839 | try { |
| 4840 | Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(phoneAccountHandle); |
| 4841 | if (phone == null) { |
| 4842 | phone = mPhone; |
| 4843 | } |
| 4844 | VoicemailNotificationSettingsUtil.setRingtoneUri(phone.getContext(), uri); |
| 4845 | } finally { |
| 4846 | Binder.restoreCallingIdentity(identity); |
Ta-wei Yen | c33877d | 2017-01-23 18:11:21 -0800 | [diff] [blame] | 4847 | } |
Ta-wei Yen | c33877d | 2017-01-23 18:11:21 -0800 | [diff] [blame] | 4848 | } |
| 4849 | |
| 4850 | /** |
Nancy Chen | 31f9ba1 | 2016-01-06 11:42:12 -0800 | [diff] [blame] | 4851 | * Returns whether vibration is set for voicemail notification in Phone settings. |
| 4852 | * |
| 4853 | * @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the |
| 4854 | * voicemail vibration setting. |
| 4855 | * @return {@code true} if the vibration is set for this PhoneAccount, {@code false} otherwise. |
| 4856 | */ |
| 4857 | @Override |
| 4858 | public boolean isVoicemailVibrationEnabled(PhoneAccountHandle accountHandle) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4859 | final long identity = Binder.clearCallingIdentity(); |
| 4860 | try { |
| 4861 | Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(accountHandle); |
| 4862 | if (phone == null) { |
| 4863 | phone = mPhone; |
| 4864 | } |
Nancy Chen | 31f9ba1 | 2016-01-06 11:42:12 -0800 | [diff] [blame] | 4865 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4866 | return VoicemailNotificationSettingsUtil.isVibrationEnabled(phone.getContext()); |
| 4867 | } finally { |
| 4868 | Binder.restoreCallingIdentity(identity); |
| 4869 | } |
Nancy Chen | 31f9ba1 | 2016-01-06 11:42:12 -0800 | [diff] [blame] | 4870 | } |
| 4871 | |
Youhan Wang | e64578a | 2016-05-02 15:32:42 -0700 | [diff] [blame] | 4872 | /** |
Ta-wei Yen | c33877d | 2017-01-23 18:11:21 -0800 | [diff] [blame] | 4873 | * Sets the per-account voicemail vibration. |
| 4874 | * |
| 4875 | * <p>Requires that the calling app is the default dialer, or has carrier privileges, or |
| 4876 | * has permission {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. |
| 4877 | * |
| 4878 | * @param phoneAccountHandle The handle for the {@link PhoneAccount} for which to set the |
| 4879 | * voicemail vibration setting. |
| 4880 | * @param enabled Whether to enable or disable vibration for voicemail notifications from a |
| 4881 | * specific PhoneAccount. |
| 4882 | */ |
| 4883 | @Override |
| 4884 | public void setVoicemailVibrationEnabled(String callingPackage, |
| 4885 | PhoneAccountHandle phoneAccountHandle, boolean enabled) { |
| 4886 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
| 4887 | if (!TextUtils.equals(callingPackage, |
| 4888 | TelecomManager.from(mPhone.getContext()).getDefaultDialerPackage())) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 4889 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 4890 | mApp, PhoneUtils.getSubIdForPhoneAccountHandle(phoneAccountHandle), |
| 4891 | "setVoicemailVibrationEnabled"); |
Ta-wei Yen | c33877d | 2017-01-23 18:11:21 -0800 | [diff] [blame] | 4892 | } |
| 4893 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4894 | final long identity = Binder.clearCallingIdentity(); |
| 4895 | try { |
| 4896 | Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(phoneAccountHandle); |
| 4897 | if (phone == null) { |
| 4898 | phone = mPhone; |
| 4899 | } |
| 4900 | VoicemailNotificationSettingsUtil.setVibrationEnabled(phone.getContext(), enabled); |
| 4901 | } finally { |
| 4902 | Binder.restoreCallingIdentity(identity); |
Ta-wei Yen | c33877d | 2017-01-23 18:11:21 -0800 | [diff] [blame] | 4903 | } |
Ta-wei Yen | c33877d | 2017-01-23 18:11:21 -0800 | [diff] [blame] | 4904 | } |
| 4905 | |
| 4906 | /** |
Youhan Wang | e64578a | 2016-05-02 15:32:42 -0700 | [diff] [blame] | 4907 | * Make sure either called from same process as self (phone) or IPC caller has read privilege. |
| 4908 | * |
| 4909 | * @throws SecurityException if the caller does not have the required permission |
| 4910 | */ |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 4911 | private void enforceReadPrivilegedPermission(String message) { |
Youhan Wang | e64578a | 2016-05-02 15:32:42 -0700 | [diff] [blame] | 4912 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 4913 | message); |
Youhan Wang | e64578a | 2016-05-02 15:32:42 -0700 | [diff] [blame] | 4914 | } |
| 4915 | |
| 4916 | /** |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 4917 | * Make sure either called from same process as self (phone) or IPC caller has send SMS |
| 4918 | * permission. |
| 4919 | * |
| 4920 | * @throws SecurityException if the caller does not have the required permission |
| 4921 | */ |
| 4922 | private void enforceSendSmsPermission() { |
| 4923 | mApp.enforceCallingOrSelfPermission(permission.SEND_SMS, null); |
| 4924 | } |
| 4925 | |
| 4926 | /** |
Ta-wei Yen | 527a9c0 | 2017-01-06 15:29:25 -0800 | [diff] [blame] | 4927 | * Make sure called from the package in charge of visual voicemail. |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 4928 | * |
Ta-wei Yen | 527a9c0 | 2017-01-06 15:29:25 -0800 | [diff] [blame] | 4929 | * @throws SecurityException if the caller is not the visual voicemail package. |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 4930 | */ |
Ta-wei Yen | 527a9c0 | 2017-01-06 15:29:25 -0800 | [diff] [blame] | 4931 | private void enforceVisualVoicemailPackage(String callingPackage, int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4932 | final long identity = Binder.clearCallingIdentity(); |
| 4933 | try { |
| 4934 | ComponentName componentName = |
| 4935 | RemoteVvmTaskManager.getRemotePackage(mPhone.getContext(), subId); |
| 4936 | if (componentName == null) { |
| 4937 | throw new SecurityException( |
| 4938 | "Caller not current active visual voicemail package[null]"); |
| 4939 | } |
| 4940 | String vvmPackage = componentName.getPackageName(); |
| 4941 | if (!callingPackage.equals(vvmPackage)) { |
| 4942 | throw new SecurityException("Caller not current active visual voicemail package[" |
| 4943 | + vvmPackage + "]"); |
| 4944 | } |
| 4945 | } finally { |
| 4946 | Binder.restoreCallingIdentity(identity); |
Ta-wei Yen | 30a69c8 | 2016-12-27 14:52:32 -0800 | [diff] [blame] | 4947 | } |
| 4948 | } |
| 4949 | |
| 4950 | /** |
Youhan Wang | e64578a | 2016-05-02 15:32:42 -0700 | [diff] [blame] | 4951 | * Return the application ID for the app type. |
| 4952 | * |
| 4953 | * @param subId the subscription ID that this request applies to. |
| 4954 | * @param appType the uicc app type. |
| 4955 | * @return Application ID for specificied app type, or null if no uicc. |
| 4956 | */ |
| 4957 | @Override |
| 4958 | public String getAidForAppType(int subId, int appType) { |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 4959 | enforceReadPrivilegedPermission("getAidForAppType"); |
Youhan Wang | e64578a | 2016-05-02 15:32:42 -0700 | [diff] [blame] | 4960 | Phone phone = getPhone(subId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4961 | |
| 4962 | final long identity = Binder.clearCallingIdentity(); |
Youhan Wang | e64578a | 2016-05-02 15:32:42 -0700 | [diff] [blame] | 4963 | try { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4964 | if (phone == null) { |
| 4965 | return null; |
| 4966 | } |
| 4967 | String aid = null; |
| 4968 | try { |
| 4969 | aid = UiccController.getInstance().getUiccCard(phone.getPhoneId()) |
| 4970 | .getApplicationByType(appType).getAid(); |
| 4971 | } catch (Exception e) { |
| 4972 | Log.e(LOG_TAG, "Not getting aid. Exception ex=" + e); |
| 4973 | } |
| 4974 | return aid; |
| 4975 | } finally { |
| 4976 | Binder.restoreCallingIdentity(identity); |
Youhan Wang | e64578a | 2016-05-02 15:32:42 -0700 | [diff] [blame] | 4977 | } |
Youhan Wang | e64578a | 2016-05-02 15:32:42 -0700 | [diff] [blame] | 4978 | } |
| 4979 | |
Youhan Wang | 4001d25 | 2016-05-11 10:29:41 -0700 | [diff] [blame] | 4980 | /** |
| 4981 | * Return the Electronic Serial Number. |
| 4982 | * |
| 4983 | * @param subId the subscription ID that this request applies to. |
| 4984 | * @return ESN or null if error. |
| 4985 | */ |
| 4986 | @Override |
| 4987 | public String getEsn(int subId) { |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 4988 | enforceReadPrivilegedPermission("getEsn"); |
Youhan Wang | 4001d25 | 2016-05-11 10:29:41 -0700 | [diff] [blame] | 4989 | Phone phone = getPhone(subId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4990 | |
| 4991 | final long identity = Binder.clearCallingIdentity(); |
Youhan Wang | 4001d25 | 2016-05-11 10:29:41 -0700 | [diff] [blame] | 4992 | try { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 4993 | if (phone == null) { |
| 4994 | return null; |
| 4995 | } |
| 4996 | String esn = null; |
| 4997 | try { |
| 4998 | esn = phone.getEsn(); |
| 4999 | } catch (Exception e) { |
| 5000 | Log.e(LOG_TAG, "Not getting ESN. Exception ex=" + e); |
| 5001 | } |
| 5002 | return esn; |
| 5003 | } finally { |
| 5004 | Binder.restoreCallingIdentity(identity); |
Youhan Wang | 4001d25 | 2016-05-11 10:29:41 -0700 | [diff] [blame] | 5005 | } |
Youhan Wang | 4001d25 | 2016-05-11 10:29:41 -0700 | [diff] [blame] | 5006 | } |
| 5007 | |
Sanket Padawe | 99ef1e3 | 2016-05-18 16:12:33 -0700 | [diff] [blame] | 5008 | /** |
Youhan Wang | 66ad5d7 | 2016-07-18 17:56:58 -0700 | [diff] [blame] | 5009 | * Return the Preferred Roaming List Version. |
| 5010 | * |
| 5011 | * @param subId the subscription ID that this request applies to. |
| 5012 | * @return PRLVersion or null if error. |
| 5013 | */ |
| 5014 | @Override |
| 5015 | public String getCdmaPrlVersion(int subId) { |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 5016 | enforceReadPrivilegedPermission("getCdmaPrlVersion"); |
Youhan Wang | 66ad5d7 | 2016-07-18 17:56:58 -0700 | [diff] [blame] | 5017 | Phone phone = getPhone(subId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5018 | |
| 5019 | final long identity = Binder.clearCallingIdentity(); |
Youhan Wang | 66ad5d7 | 2016-07-18 17:56:58 -0700 | [diff] [blame] | 5020 | try { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5021 | if (phone == null) { |
| 5022 | return null; |
| 5023 | } |
| 5024 | String cdmaPrlVersion = null; |
| 5025 | try { |
| 5026 | cdmaPrlVersion = phone.getCdmaPrlVersion(); |
| 5027 | } catch (Exception e) { |
| 5028 | Log.e(LOG_TAG, "Not getting PRLVersion", e); |
| 5029 | } |
| 5030 | return cdmaPrlVersion; |
| 5031 | } finally { |
| 5032 | Binder.restoreCallingIdentity(identity); |
Youhan Wang | 66ad5d7 | 2016-07-18 17:56:58 -0700 | [diff] [blame] | 5033 | } |
Youhan Wang | 66ad5d7 | 2016-07-18 17:56:58 -0700 | [diff] [blame] | 5034 | } |
| 5035 | |
| 5036 | /** |
Sanket Padawe | 99ef1e3 | 2016-05-18 16:12:33 -0700 | [diff] [blame] | 5037 | * Get snapshot of Telephony histograms |
| 5038 | * @return List of Telephony histograms |
| 5039 | * @hide |
| 5040 | */ |
| 5041 | @Override |
| 5042 | public List<TelephonyHistogram> getTelephonyHistograms() { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 5043 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 5044 | mApp, getDefaultSubscription(), "getTelephonyHistograms"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5045 | |
| 5046 | final long identity = Binder.clearCallingIdentity(); |
| 5047 | try { |
| 5048 | return RIL.getTelephonyRILTimingHistograms(); |
| 5049 | } finally { |
| 5050 | Binder.restoreCallingIdentity(identity); |
| 5051 | } |
Sanket Padawe | 99ef1e3 | 2016-05-18 16:12:33 -0700 | [diff] [blame] | 5052 | } |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 5053 | |
| 5054 | /** |
| 5055 | * {@hide} |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 5056 | * Set the allowed carrier list for slotIndex |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 5057 | * Require system privileges. In the future we may add this to carrier APIs. |
| 5058 | * |
| 5059 | * @return The number of carriers set successfully, should match length of carriers |
| 5060 | */ |
| 5061 | @Override |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 5062 | public int setAllowedCarriers(int slotIndex, List<CarrierIdentifier> carriers) { |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 5063 | enforceModifyPermission(); |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 5064 | WorkSource workSource = getWorkSource(Binder.getCallingUid()); |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 5065 | |
Meng Wang | 9b7c4e9 | 2017-02-17 11:41:27 -0800 | [diff] [blame] | 5066 | if (carriers == null) { |
| 5067 | throw new NullPointerException("carriers cannot be null"); |
| 5068 | } |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 5069 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5070 | final long identity = Binder.clearCallingIdentity(); |
| 5071 | try { |
| 5072 | int subId = SubscriptionManager.getSubId(slotIndex)[0]; |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 5073 | int[] retVal = (int[]) sendRequest(CMD_SET_ALLOWED_CARRIERS, carriers, subId, |
| 5074 | workSource); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5075 | return retVal[0]; |
| 5076 | } finally { |
| 5077 | Binder.restoreCallingIdentity(identity); |
| 5078 | } |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 5079 | } |
| 5080 | |
| 5081 | /** |
| 5082 | * {@hide} |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 5083 | * Get the allowed carrier list for slotIndex. |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 5084 | * Require system privileges. In the future we may add this to carrier APIs. |
| 5085 | * |
| 5086 | * @return List of {@link android.service.telephony.CarrierIdentifier}; empty list |
| 5087 | * means all carriers are allowed. |
| 5088 | */ |
| 5089 | @Override |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 5090 | public List<CarrierIdentifier> getAllowedCarriers(int slotIndex) { |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 5091 | enforceReadPrivilegedPermission("getAllowedCarriers"); |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 5092 | WorkSource workSource = getWorkSource(Binder.getCallingUid()); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5093 | |
| 5094 | final long identity = Binder.clearCallingIdentity(); |
| 5095 | try { |
| 5096 | int subId = SubscriptionManager.getSubId(slotIndex)[0]; |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 5097 | return (List<CarrierIdentifier>) sendRequest(CMD_GET_ALLOWED_CARRIERS, null, subId, |
| 5098 | workSource); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5099 | } finally { |
| 5100 | Binder.restoreCallingIdentity(identity); |
| 5101 | } |
Meng Wang | 1a7c35a | 2016-05-05 20:56:15 -0700 | [diff] [blame] | 5102 | } |
| 5103 | |
fionaxu | 59545b4 | 2016-05-25 15:53:37 -0700 | [diff] [blame] | 5104 | /** |
| 5105 | * Action set from carrier signalling broadcast receivers to enable/disable metered apns |
| 5106 | * @param subId the subscription ID that this action applies to. |
| 5107 | * @param enabled control enable or disable metered apns. |
| 5108 | * {@hide} |
| 5109 | */ |
| 5110 | @Override |
| 5111 | public void carrierActionSetMeteredApnsEnabled(int subId, boolean enabled) { |
| 5112 | enforceModifyPermission(); |
| 5113 | final Phone phone = getPhone(subId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5114 | |
| 5115 | final long identity = Binder.clearCallingIdentity(); |
fionaxu | 59545b4 | 2016-05-25 15:53:37 -0700 | [diff] [blame] | 5116 | if (phone == null) { |
| 5117 | loge("carrierAction: SetMeteredApnsEnabled fails with invalid subId: " + subId); |
| 5118 | return; |
| 5119 | } |
| 5120 | try { |
| 5121 | phone.carrierActionSetMeteredApnsEnabled(enabled); |
| 5122 | } catch (Exception e) { |
| 5123 | Log.e(LOG_TAG, "carrierAction: SetMeteredApnsEnabled fails. Exception ex=" + e); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5124 | } finally { |
| 5125 | Binder.restoreCallingIdentity(identity); |
fionaxu | 59545b4 | 2016-05-25 15:53:37 -0700 | [diff] [blame] | 5126 | } |
| 5127 | } |
| 5128 | |
| 5129 | /** |
| 5130 | * Action set from carrier signalling broadcast receivers to enable/disable radio |
| 5131 | * @param subId the subscription ID that this action applies to. |
| 5132 | * @param enabled control enable or disable radio. |
| 5133 | * {@hide} |
| 5134 | */ |
| 5135 | @Override |
| 5136 | public void carrierActionSetRadioEnabled(int subId, boolean enabled) { |
| 5137 | enforceModifyPermission(); |
| 5138 | final Phone phone = getPhone(subId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5139 | |
| 5140 | final long identity = Binder.clearCallingIdentity(); |
fionaxu | 59545b4 | 2016-05-25 15:53:37 -0700 | [diff] [blame] | 5141 | if (phone == null) { |
| 5142 | loge("carrierAction: SetRadioEnabled fails with invalid sibId: " + subId); |
| 5143 | return; |
| 5144 | } |
| 5145 | try { |
| 5146 | phone.carrierActionSetRadioEnabled(enabled); |
| 5147 | } catch (Exception e) { |
| 5148 | Log.e(LOG_TAG, "carrierAction: SetRadioEnabled fails. Exception ex=" + e); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5149 | } finally { |
| 5150 | Binder.restoreCallingIdentity(identity); |
fionaxu | 59545b4 | 2016-05-25 15:53:37 -0700 | [diff] [blame] | 5151 | } |
| 5152 | } |
| 5153 | |
Ta-wei Yen | c236d6b | 2016-06-21 13:33:12 -0700 | [diff] [blame] | 5154 | /** |
fionaxu | 8da9cb1 | 2017-05-23 15:02:46 -0700 | [diff] [blame] | 5155 | * Action set from carrier signalling broadcast receivers to start/stop reporting the default |
| 5156 | * network status based on which carrier apps could apply actions accordingly, |
| 5157 | * enable/disable default url handler for example. |
| 5158 | * |
| 5159 | * @param subId the subscription ID that this action applies to. |
| 5160 | * @param report control start/stop reporting the default network status. |
| 5161 | * {@hide} |
| 5162 | */ |
| 5163 | @Override |
| 5164 | public void carrierActionReportDefaultNetworkStatus(int subId, boolean report) { |
| 5165 | enforceModifyPermission(); |
| 5166 | final Phone phone = getPhone(subId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5167 | |
| 5168 | final long identity = Binder.clearCallingIdentity(); |
fionaxu | 8da9cb1 | 2017-05-23 15:02:46 -0700 | [diff] [blame] | 5169 | if (phone == null) { |
| 5170 | loge("carrierAction: ReportDefaultNetworkStatus fails with invalid sibId: " + subId); |
| 5171 | return; |
| 5172 | } |
| 5173 | try { |
| 5174 | phone.carrierActionReportDefaultNetworkStatus(report); |
| 5175 | } catch (Exception e) { |
| 5176 | Log.e(LOG_TAG, "carrierAction: ReportDefaultNetworkStatus fails. Exception ex=" + e); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5177 | } finally { |
| 5178 | Binder.restoreCallingIdentity(identity); |
fionaxu | 8da9cb1 | 2017-05-23 15:02:46 -0700 | [diff] [blame] | 5179 | } |
| 5180 | } |
| 5181 | |
| 5182 | /** |
Ta-wei Yen | c236d6b | 2016-06-21 13:33:12 -0700 | [diff] [blame] | 5183 | * Called when "adb shell dumpsys phone" is invoked. Dump is also automatically invoked when a |
| 5184 | * bug report is being generated. |
| 5185 | */ |
| 5186 | @Override |
Ta-wei Yen | 99282e0 | 2016-06-21 18:19:35 -0700 | [diff] [blame] | 5187 | protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) { |
dcashman | 22b950d | 2016-06-27 11:39:02 -0700 | [diff] [blame] | 5188 | if (mPhone.getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 5189 | != PackageManager.PERMISSION_GRANTED) { |
| 5190 | writer.println("Permission Denial: can't dump Phone from pid=" |
| 5191 | + Binder.getCallingPid() |
| 5192 | + ", uid=" + Binder.getCallingUid() |
| 5193 | + "without permission " |
| 5194 | + android.Manifest.permission.DUMP); |
| 5195 | return; |
| 5196 | } |
Ta-wei Yen | 99282e0 | 2016-06-21 18:19:35 -0700 | [diff] [blame] | 5197 | DumpsysHandler.dump(mPhone.getContext(), fd, writer, args); |
Ta-wei Yen | c236d6b | 2016-06-21 13:33:12 -0700 | [diff] [blame] | 5198 | } |
Jack Yu | eb89b24 | 2016-06-22 13:27:47 -0700 | [diff] [blame] | 5199 | |
Brad Ebinger | dac2f00 | 2018-04-03 15:17:52 -0700 | [diff] [blame] | 5200 | @Override |
| 5201 | public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err, |
| 5202 | String[] args, ShellCallback callback, ResultReceiver resultReceiver) |
| 5203 | throws RemoteException { |
| 5204 | (new TelephonyShellCommand(this)).exec(this, in, out, err, args, callback, resultReceiver); |
| 5205 | } |
| 5206 | |
Jack Yu | eb89b24 | 2016-06-22 13:27:47 -0700 | [diff] [blame] | 5207 | /** |
Jack Yu | 84291ec | 2017-05-26 16:07:50 -0700 | [diff] [blame] | 5208 | * Get aggregated video call data usage since boot. |
| 5209 | * |
| 5210 | * @param perUidStats True if requesting data usage per uid, otherwise overall usage. |
| 5211 | * @return Snapshot of video call data usage |
Jack Yu | eb89b24 | 2016-06-22 13:27:47 -0700 | [diff] [blame] | 5212 | * {@hide} |
| 5213 | */ |
| 5214 | @Override |
Jack Yu | 84291ec | 2017-05-26 16:07:50 -0700 | [diff] [blame] | 5215 | public NetworkStats getVtDataUsage(int subId, boolean perUidStats) { |
Jack Yu | eb89b24 | 2016-06-22 13:27:47 -0700 | [diff] [blame] | 5216 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_NETWORK_USAGE_HISTORY, |
| 5217 | null); |
| 5218 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5219 | final long identity = Binder.clearCallingIdentity(); |
| 5220 | try { |
| 5221 | // NetworkStatsService keeps tracking the active network interface and identity. It |
| 5222 | // records the delta with the corresponding network identity. |
| 5223 | // We just return the total video call data usage snapshot since boot. |
| 5224 | Phone phone = getPhone(subId); |
| 5225 | if (phone != null) { |
| 5226 | return phone.getVtDataUsage(perUidStats); |
| 5227 | } |
| 5228 | return null; |
| 5229 | } finally { |
| 5230 | Binder.restoreCallingIdentity(identity); |
Jack Yu | eb89b24 | 2016-06-22 13:27:47 -0700 | [diff] [blame] | 5231 | } |
Jack Yu | eb89b24 | 2016-06-22 13:27:47 -0700 | [diff] [blame] | 5232 | } |
Jack Yu | 75ab295 | 2016-07-08 14:29:33 -0700 | [diff] [blame] | 5233 | |
| 5234 | /** |
| 5235 | * Policy control of data connection. Usually used when data limit is passed. |
| 5236 | * @param enabled True if enabling the data, otherwise disabling. |
| 5237 | * @param subId Subscription index |
| 5238 | * {@hide} |
| 5239 | */ |
| 5240 | @Override |
| 5241 | public void setPolicyDataEnabled(boolean enabled, int subId) { |
| 5242 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5243 | |
| 5244 | final long identity = Binder.clearCallingIdentity(); |
| 5245 | try { |
| 5246 | Phone phone = getPhone(subId); |
| 5247 | if (phone != null) { |
| 5248 | phone.setPolicyDataEnabled(enabled); |
| 5249 | } |
| 5250 | } finally { |
| 5251 | Binder.restoreCallingIdentity(identity); |
Jack Yu | 75ab295 | 2016-07-08 14:29:33 -0700 | [diff] [blame] | 5252 | } |
| 5253 | } |
Sooraj Sasindran | 9a90931 | 2016-07-18 11:57:25 -0700 | [diff] [blame] | 5254 | |
| 5255 | /** |
| 5256 | * Get Client request stats |
| 5257 | * @return List of Client Request Stats |
| 5258 | * @hide |
| 5259 | */ |
| 5260 | @Override |
| 5261 | public List<ClientRequestStats> getClientRequestStats(String callingPackage, int subId) { |
Jeff Davidson | 7e17e31 | 2018-02-13 18:17:36 -0800 | [diff] [blame] | 5262 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
Jeff Davidson | 913390f | 2018-02-23 17:11:49 -0800 | [diff] [blame] | 5263 | mApp, subId, callingPackage, "getClientRequestStats")) { |
Sooraj Sasindran | 9a90931 | 2016-07-18 11:57:25 -0700 | [diff] [blame] | 5264 | return null; |
| 5265 | } |
Sooraj Sasindran | 9a90931 | 2016-07-18 11:57:25 -0700 | [diff] [blame] | 5266 | Phone phone = getPhone(subId); |
Sooraj Sasindran | 9a90931 | 2016-07-18 11:57:25 -0700 | [diff] [blame] | 5267 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5268 | final long identity = Binder.clearCallingIdentity(); |
| 5269 | try { |
| 5270 | if (phone != null) { |
| 5271 | return phone.getClientRequestStats(); |
| 5272 | } |
| 5273 | |
| 5274 | return null; |
| 5275 | } finally { |
| 5276 | Binder.restoreCallingIdentity(identity); |
| 5277 | } |
Sooraj Sasindran | 9a90931 | 2016-07-18 11:57:25 -0700 | [diff] [blame] | 5278 | } |
| 5279 | |
Narayan Kamath | f04b5a1 | 2018-01-09 11:47:15 +0000 | [diff] [blame] | 5280 | private WorkSource getWorkSource(int uid) { |
Sooraj Sasindran | 9a90931 | 2016-07-18 11:57:25 -0700 | [diff] [blame] | 5281 | String packageName = mPhone.getContext().getPackageManager().getNameForUid(uid); |
Narayan Kamath | f04b5a1 | 2018-01-09 11:47:15 +0000 | [diff] [blame] | 5282 | return new WorkSource(uid, packageName); |
Sooraj Sasindran | 9a90931 | 2016-07-18 11:57:25 -0700 | [diff] [blame] | 5283 | } |
Jack Yu | eb4124c | 2017-02-16 15:32:43 -0800 | [diff] [blame] | 5284 | |
| 5285 | /** |
Grace Chen | 7099007 | 2017-03-24 17:21:30 -0700 | [diff] [blame] | 5286 | * Set SIM card power state. |
Jack Yu | eb4124c | 2017-02-16 15:32:43 -0800 | [diff] [blame] | 5287 | * |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 5288 | * @param slotIndex SIM slot id. |
Grace Chen | 7099007 | 2017-03-24 17:21:30 -0700 | [diff] [blame] | 5289 | * @param state State of SIM (power down, power up, pass through) |
| 5290 | * - {@link android.telephony.TelephonyManager#CARD_POWER_DOWN} |
| 5291 | * - {@link android.telephony.TelephonyManager#CARD_POWER_UP} |
| 5292 | * - {@link android.telephony.TelephonyManager#CARD_POWER_UP_PASS_THROUGH} |
Jack Yu | eb4124c | 2017-02-16 15:32:43 -0800 | [diff] [blame] | 5293 | * |
| 5294 | **/ |
| 5295 | @Override |
Grace Chen | 7099007 | 2017-03-24 17:21:30 -0700 | [diff] [blame] | 5296 | public void setSimPowerStateForSlot(int slotIndex, int state) { |
Jack Yu | eb4124c | 2017-02-16 15:32:43 -0800 | [diff] [blame] | 5297 | enforceModifyPermission(); |
Sanket Padawe | 13bac7b | 2017-03-20 15:04:47 -0700 | [diff] [blame] | 5298 | Phone phone = PhoneFactory.getPhone(slotIndex); |
| 5299 | |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 5300 | WorkSource workSource = getWorkSource(Binder.getCallingUid()); |
| 5301 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5302 | final long identity = Binder.clearCallingIdentity(); |
| 5303 | try { |
| 5304 | if (phone != null) { |
vagdevi | af9a5b9 | 2018-08-15 16:01:53 -0700 | [diff] [blame] | 5305 | phone.setSimPowerState(state, workSource); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5306 | } |
| 5307 | } finally { |
| 5308 | Binder.restoreCallingIdentity(identity); |
Jack Yu | eb4124c | 2017-02-16 15:32:43 -0800 | [diff] [blame] | 5309 | } |
| 5310 | } |
Shuo Qian | dd21031 | 2017-04-12 22:11:33 +0000 | [diff] [blame] | 5311 | |
Tyler Gunn | 65d45c2 | 2017-06-05 11:22:26 -0700 | [diff] [blame] | 5312 | private boolean isUssdApiAllowed(int subId) { |
| 5313 | CarrierConfigManager configManager = |
| 5314 | (CarrierConfigManager) mPhone.getContext().getSystemService( |
| 5315 | Context.CARRIER_CONFIG_SERVICE); |
| 5316 | if (configManager == null) { |
| 5317 | return false; |
| 5318 | } |
| 5319 | PersistableBundle pb = configManager.getConfigForSubId(subId); |
| 5320 | if (pb == null) { |
| 5321 | return false; |
| 5322 | } |
| 5323 | return pb.getBoolean( |
| 5324 | CarrierConfigManager.KEY_ALLOW_USSD_REQUESTS_VIA_TELEPHONY_MANAGER_BOOL); |
| 5325 | } |
| 5326 | |
Shuo Qian | dd21031 | 2017-04-12 22:11:33 +0000 | [diff] [blame] | 5327 | /** |
| 5328 | * Check if phone is in emergency callback mode |
| 5329 | * @return true if phone is in emergency callback mode |
| 5330 | * @param subId sub id |
| 5331 | */ |
goneil | 9c5f487 | 2017-12-05 14:07:56 -0800 | [diff] [blame] | 5332 | @Override |
Shuo Qian | dd21031 | 2017-04-12 22:11:33 +0000 | [diff] [blame] | 5333 | public boolean getEmergencyCallbackMode(int subId) { |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 5334 | enforceReadPrivilegedPermission("getEmergencyCallbackMode"); |
Shuo Qian | dd21031 | 2017-04-12 22:11:33 +0000 | [diff] [blame] | 5335 | final Phone phone = getPhone(subId); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5336 | |
| 5337 | final long identity = Binder.clearCallingIdentity(); |
| 5338 | try { |
| 5339 | if (phone != null) { |
| 5340 | return phone.isInEcm(); |
| 5341 | } else { |
| 5342 | return false; |
| 5343 | } |
| 5344 | } finally { |
| 5345 | Binder.restoreCallingIdentity(identity); |
Shuo Qian | dd21031 | 2017-04-12 22:11:33 +0000 | [diff] [blame] | 5346 | } |
| 5347 | } |
Nathan Harold | 46b42aa | 2017-03-10 19:38:22 -0800 | [diff] [blame] | 5348 | |
| 5349 | /** |
| 5350 | * Get the current signal strength information for the given subscription. |
| 5351 | * Because this information is not updated when the device is in a low power state |
| 5352 | * it should not be relied-upon to be current. |
| 5353 | * @param subId Subscription index |
| 5354 | * @return the most recent cached signal strength info from the modem |
| 5355 | */ |
| 5356 | @Override |
| 5357 | public SignalStrength getSignalStrength(int subId) { |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5358 | final long identity = Binder.clearCallingIdentity(); |
| 5359 | try { |
| 5360 | Phone p = getPhone(subId); |
| 5361 | if (p == null) { |
| 5362 | return null; |
| 5363 | } |
Nathan Harold | 46b42aa | 2017-03-10 19:38:22 -0800 | [diff] [blame] | 5364 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5365 | return p.getSignalStrength(); |
| 5366 | } finally { |
| 5367 | Binder.restoreCallingIdentity(identity); |
| 5368 | } |
Nathan Harold | 46b42aa | 2017-03-10 19:38:22 -0800 | [diff] [blame] | 5369 | } |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 5370 | |
Pengquan Meng | 77b7f13 | 2018-08-22 14:49:57 -0700 | [diff] [blame] | 5371 | /** |
Chen Xu | f792fd6 | 2018-10-17 17:54:36 +0000 | [diff] [blame] | 5372 | * Get the current modem radio state for the given slot. |
| 5373 | * @param slotIndex slot index. |
| 5374 | * @param callingPackage the name of the package making the call. |
| 5375 | * @return the current radio power state from the modem |
| 5376 | */ |
| 5377 | @Override |
| 5378 | public int getRadioPowerState(int slotIndex, String callingPackage) { |
| 5379 | Phone phone = PhoneFactory.getPhone(slotIndex); |
| 5380 | if (phone != null) { |
| 5381 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
| 5382 | mApp, phone.getSubId(), callingPackage, "getRadioPowerState")) { |
| 5383 | return TelephonyManager.RADIO_POWER_UNAVAILABLE; |
| 5384 | } |
| 5385 | |
| 5386 | final long identity = Binder.clearCallingIdentity(); |
| 5387 | try { |
| 5388 | return phone.getRadioPowerState(); |
| 5389 | } finally { |
| 5390 | Binder.restoreCallingIdentity(identity); |
| 5391 | } |
| 5392 | } |
| 5393 | return TelephonyManager.RADIO_POWER_UNAVAILABLE; |
| 5394 | } |
| 5395 | |
| 5396 | /** |
Pengquan Meng | 77b7f13 | 2018-08-22 14:49:57 -0700 | [diff] [blame] | 5397 | * Checks if data roaming is enabled on the subscription with id {@code subId}. |
| 5398 | * |
| 5399 | * <p>Requires one of the following permissions: |
| 5400 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}, |
| 5401 | * {@link android.Manifest.permission#READ_PHONE_STATE} or that the calling app has carrier |
| 5402 | * privileges. |
| 5403 | * |
| 5404 | * @param subId subscription id |
| 5405 | * @return {@code true} if data roaming is enabled on this subscription, otherwise return |
| 5406 | * {@code false}. |
| 5407 | */ |
| 5408 | @Override |
| 5409 | public boolean isDataRoamingEnabled(int subId) { |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 5410 | boolean isEnabled = false; |
| 5411 | final long identity = Binder.clearCallingIdentity(); |
Pengquan Meng | 77b7f13 | 2018-08-22 14:49:57 -0700 | [diff] [blame] | 5412 | try { |
| 5413 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.ACCESS_NETWORK_STATE, |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 5414 | null /* message */); |
| 5415 | Phone phone = getPhone(subId); |
| 5416 | isEnabled = phone != null ? phone.getDataRoamingEnabled() : false; |
Pengquan Meng | 77b7f13 | 2018-08-22 14:49:57 -0700 | [diff] [blame] | 5417 | } catch (Exception e) { |
| 5418 | TelephonyPermissions.enforeceCallingOrSelfReadPhoneStatePermissionOrCarrierPrivilege( |
| 5419 | mApp, subId, "isDataRoamingEnabled"); |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 5420 | } finally { |
| 5421 | Binder.restoreCallingIdentity(identity); |
Pengquan Meng | 77b7f13 | 2018-08-22 14:49:57 -0700 | [diff] [blame] | 5422 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 5423 | return isEnabled; |
Pengquan Meng | 77b7f13 | 2018-08-22 14:49:57 -0700 | [diff] [blame] | 5424 | } |
| 5425 | |
| 5426 | |
| 5427 | /** |
| 5428 | * Enables/Disables the data roaming on the subscription with id {@code subId}. |
| 5429 | * |
| 5430 | * <p> Requires permission: |
| 5431 | * {@link android.Manifest.permission#MODIFY_PHONE_STATE} or that the calling app has carrier |
| 5432 | * privileges. |
| 5433 | * |
| 5434 | * @param subId subscription id |
| 5435 | * @param isEnabled {@code true} means enable, {@code false} means disable. |
| 5436 | */ |
| 5437 | @Override |
| 5438 | public void setDataRoamingEnabled(int subId, boolean isEnabled) { |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 5439 | final long identity = Binder.clearCallingIdentity(); |
| 5440 | try { |
| 5441 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 5442 | mApp, subId, "setDataRoamingEnabled"); |
Pengquan Meng | 77b7f13 | 2018-08-22 14:49:57 -0700 | [diff] [blame] | 5443 | |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 5444 | Phone phone = getPhone(subId); |
| 5445 | if (phone != null) { |
| 5446 | phone.setDataRoamingEnabled(isEnabled); |
| 5447 | } |
| 5448 | } finally { |
| 5449 | Binder.restoreCallingIdentity(identity); |
Pengquan Meng | 77b7f13 | 2018-08-22 14:49:57 -0700 | [diff] [blame] | 5450 | } |
| 5451 | } |
| 5452 | |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 5453 | @Override |
Pengquan Meng | 6884a2c | 2018-10-03 12:19:13 -0700 | [diff] [blame] | 5454 | public boolean isManualNetworkSelectionAllowed(int subId) { |
| 5455 | boolean isAllowed = true; |
| 5456 | final long identity = Binder.clearCallingIdentity(); |
| 5457 | try { |
| 5458 | TelephonyPermissions.enforeceCallingOrSelfReadPhoneStatePermissionOrCarrierPrivilege( |
| 5459 | mApp, subId, "isManualNetworkSelectionAllowed"); |
| 5460 | Phone phone = getPhone(subId); |
| 5461 | if (phone != null) { |
| 5462 | isAllowed = phone.isCspPlmnEnabled(); |
| 5463 | } |
| 5464 | } finally { |
| 5465 | Binder.restoreCallingIdentity(identity); |
| 5466 | } |
| 5467 | return isAllowed; |
| 5468 | } |
| 5469 | |
| 5470 | @Override |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 5471 | public UiccSlotInfo[] getUiccSlotsInfo() { |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 5472 | enforceReadPrivilegedPermission("getUiccSlotsInfo"); |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 5473 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5474 | final long identity = Binder.clearCallingIdentity(); |
| 5475 | try { |
| 5476 | UiccSlot[] slots = UiccController.getInstance().getUiccSlots(); |
| 5477 | if (slots == null) { |
| 5478 | Rlog.i(LOG_TAG, "slots is null."); |
| 5479 | return null; |
| 5480 | } |
| 5481 | |
| 5482 | UiccSlotInfo[] infos = new UiccSlotInfo[slots.length]; |
| 5483 | for (int i = 0; i < slots.length; i++) { |
| 5484 | UiccSlot slot = slots[i]; |
| 5485 | if (slot == null) { |
| 5486 | continue; |
| 5487 | } |
| 5488 | |
| 5489 | String cardId; |
| 5490 | UiccCard card = slot.getUiccCard(); |
| 5491 | if (card != null) { |
| 5492 | cardId = card.getCardId(); |
| 5493 | } else { |
| 5494 | cardId = slot.getIccId(); |
| 5495 | } |
| 5496 | |
| 5497 | int cardState = 0; |
| 5498 | switch (slot.getCardState()) { |
| 5499 | case CARDSTATE_ABSENT: |
| 5500 | cardState = UiccSlotInfo.CARD_STATE_INFO_ABSENT; |
| 5501 | break; |
| 5502 | case CARDSTATE_PRESENT: |
| 5503 | cardState = UiccSlotInfo.CARD_STATE_INFO_PRESENT; |
| 5504 | break; |
| 5505 | case CARDSTATE_ERROR: |
| 5506 | cardState = UiccSlotInfo.CARD_STATE_INFO_ERROR; |
| 5507 | break; |
| 5508 | case CARDSTATE_RESTRICTED: |
| 5509 | cardState = UiccSlotInfo.CARD_STATE_INFO_RESTRICTED; |
| 5510 | break; |
| 5511 | default: |
| 5512 | break; |
| 5513 | |
| 5514 | } |
| 5515 | |
| 5516 | infos[i] = new UiccSlotInfo( |
| 5517 | slot.isActive(), |
| 5518 | slot.isEuicc(), |
| 5519 | cardId, |
| 5520 | cardState, |
| 5521 | slot.getPhoneId(), |
| 5522 | slot.isExtendedApduSupported()); |
| 5523 | } |
| 5524 | return infos; |
| 5525 | } finally { |
| 5526 | Binder.restoreCallingIdentity(identity); |
Holly Jiuyu Sun | 1d957c5 | 2018-04-04 13:52:42 -0700 | [diff] [blame] | 5527 | } |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 5528 | } |
| 5529 | |
| 5530 | @Override |
| 5531 | public boolean switchSlots(int[] physicalSlots) { |
| 5532 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5533 | |
| 5534 | final long identity = Binder.clearCallingIdentity(); |
| 5535 | try { |
| 5536 | return (Boolean) sendRequest(CMD_SWITCH_SLOTS, physicalSlots); |
| 5537 | } finally { |
| 5538 | Binder.restoreCallingIdentity(identity); |
| 5539 | } |
Holly Jiuyu Sun | 01c47ad | 2018-01-24 17:56:33 +0000 | [diff] [blame] | 5540 | } |
Jack Yu | 4c98804 | 2018-02-27 15:30:01 -0800 | [diff] [blame] | 5541 | |
| 5542 | @Override |
| 5543 | public void setRadioIndicationUpdateMode(int subId, int filters, int mode) { |
| 5544 | enforceModifyPermission(); |
| 5545 | final Phone phone = getPhone(subId); |
| 5546 | if (phone == null) { |
| 5547 | loge("setRadioIndicationUpdateMode fails with invalid subId: " + subId); |
| 5548 | return; |
| 5549 | } |
| 5550 | |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5551 | final long identity = Binder.clearCallingIdentity(); |
| 5552 | try { |
| 5553 | phone.setRadioIndicationUpdateMode(filters, mode); |
| 5554 | } finally { |
| 5555 | Binder.restoreCallingIdentity(identity); |
| 5556 | } |
Jack Yu | 4c98804 | 2018-02-27 15:30:01 -0800 | [diff] [blame] | 5557 | } |
Pengquan Meng | 85728fb | 2018-03-12 16:31:21 -0700 | [diff] [blame] | 5558 | |
| 5559 | /** |
goneil | 47ffb6e | 2018-04-06 15:40:58 -0700 | [diff] [blame] | 5560 | * A test API to reload the UICC profile. |
| 5561 | * |
| 5562 | * <p>Requires that the calling app has permission |
| 5563 | * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. |
| 5564 | * @hide |
| 5565 | */ |
| 5566 | @Override |
| 5567 | public void refreshUiccProfile(int subId) { |
| 5568 | enforceModifyPermission(); |
| 5569 | |
| 5570 | final long identity = Binder.clearCallingIdentity(); |
| 5571 | try { |
| 5572 | Phone phone = getPhone(subId); |
| 5573 | if (phone == null) { |
| 5574 | return; |
| 5575 | } |
| 5576 | UiccCard uiccCard = phone.getUiccCard(); |
| 5577 | if (uiccCard == null) { |
| 5578 | return; |
| 5579 | } |
| 5580 | UiccProfile uiccProfile = uiccCard.getUiccProfile(); |
| 5581 | if (uiccProfile == null) { |
| 5582 | return; |
| 5583 | } |
| 5584 | uiccProfile.refresh(); |
| 5585 | } finally { |
| 5586 | Binder.restoreCallingIdentity(identity); |
| 5587 | } |
| 5588 | } |
| 5589 | |
| 5590 | /** |
Pengquan Meng | 85728fb | 2018-03-12 16:31:21 -0700 | [diff] [blame] | 5591 | * Returns false if the mobile data is disabled by default, otherwise return true. |
| 5592 | */ |
| 5593 | private boolean getDefaultDataEnabled() { |
| 5594 | return "true".equalsIgnoreCase( |
| 5595 | SystemProperties.get(DEFAULT_MOBILE_DATA_PROPERTY_NAME, "true")); |
| 5596 | } |
| 5597 | |
| 5598 | /** |
| 5599 | * Returns true if the data roaming is enabled by default, i.e the system property |
| 5600 | * of {@link #DEFAULT_DATA_ROAMING_PROPERTY_NAME} is true or the config of |
| 5601 | * {@link CarrierConfigManager#KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL} is true. |
| 5602 | */ |
| 5603 | private boolean getDefaultDataRoamingEnabled(int subId) { |
| 5604 | final CarrierConfigManager configMgr = (CarrierConfigManager) |
| 5605 | mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); |
| 5606 | boolean isDataRoamingEnabled = "true".equalsIgnoreCase( |
| 5607 | SystemProperties.get(DEFAULT_DATA_ROAMING_PROPERTY_NAME, "false")); |
| 5608 | isDataRoamingEnabled |= configMgr.getConfigForSubId(subId).getBoolean( |
| 5609 | CarrierConfigManager.KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL); |
| 5610 | return isDataRoamingEnabled; |
| 5611 | } |
| 5612 | |
| 5613 | /** |
| 5614 | * Returns the default network type for the given {@code subId}, if the default network type is |
| 5615 | * not set, return {@link Phone#PREFERRED_NT_MODE}. |
| 5616 | */ |
| 5617 | private int getDefaultNetworkType(int subId) { |
| 5618 | return Integer.parseInt( |
| 5619 | TelephonyManager.getTelephonyProperty( |
| 5620 | mSubscriptionController.getPhoneId(subId), |
| 5621 | DEFAULT_NETWORK_MODE_PROPERTY_NAME, |
| 5622 | String.valueOf(Phone.PREFERRED_NT_MODE))); |
| 5623 | } |
fionaxu | a13278b | 2018-03-21 00:08:13 -0700 | [diff] [blame] | 5624 | |
| 5625 | @Override |
| 5626 | public void setCarrierTestOverride(int subId, String mccmnc, String imsi, String iccid, String |
| 5627 | gid1, String gid2, String plmn, String spn) { |
| 5628 | enforceModifyPermission(); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5629 | |
| 5630 | final long identity = Binder.clearCallingIdentity(); |
| 5631 | try { |
| 5632 | final Phone phone = getPhone(subId); |
| 5633 | if (phone == null) { |
| 5634 | loge("setCarrierTestOverride fails with invalid subId: " + subId); |
| 5635 | return; |
| 5636 | } |
| 5637 | phone.setCarrierTestOverride(mccmnc, imsi, iccid, gid1, gid2, plmn, spn); |
| 5638 | } finally { |
| 5639 | Binder.restoreCallingIdentity(identity); |
fionaxu | a13278b | 2018-03-21 00:08:13 -0700 | [diff] [blame] | 5640 | } |
fionaxu | a13278b | 2018-03-21 00:08:13 -0700 | [diff] [blame] | 5641 | } |
| 5642 | |
| 5643 | @Override |
| 5644 | public int getCarrierIdListVersion(int subId) { |
Brad Ebinger | 35c841c | 2018-10-01 10:40:55 -0700 | [diff] [blame] | 5645 | enforceReadPrivilegedPermission("getCarrierIdListVersion"); |
Malcolm Chen | aa4a853 | 2018-02-28 15:00:40 -0800 | [diff] [blame] | 5646 | |
| 5647 | final long identity = Binder.clearCallingIdentity(); |
| 5648 | try { |
| 5649 | final Phone phone = getPhone(subId); |
| 5650 | if (phone == null) { |
| 5651 | loge("getCarrierIdListVersion fails with invalid subId: " + subId); |
| 5652 | return TelephonyManager.UNKNOWN_CARRIER_ID_LIST_VERSION; |
| 5653 | } |
| 5654 | return phone.getCarrierIdListVersion(); |
| 5655 | } finally { |
| 5656 | Binder.restoreCallingIdentity(identity); |
fionaxu | a13278b | 2018-03-21 00:08:13 -0700 | [diff] [blame] | 5657 | } |
fionaxu | a13278b | 2018-03-21 00:08:13 -0700 | [diff] [blame] | 5658 | } |
Malcolm Chen | 2c63d40 | 2018-08-14 16:00:53 -0700 | [diff] [blame] | 5659 | |
| 5660 | @Override |
| 5661 | public int getNumberOfModemsWithSimultaneousDataConnections(int subId, String callingPackage) { |
| 5662 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
| 5663 | mApp, subId, callingPackage, "getNumberOfModemsWithSimultaneousDataConnections")) { |
| 5664 | return -1; |
| 5665 | } |
| 5666 | |
| 5667 | final long identity = Binder.clearCallingIdentity(); |
| 5668 | try { |
| 5669 | return mPhoneConfigurationManager.getNumberOfModemsWithSimultaneousDataConnections(); |
| 5670 | } finally { |
| 5671 | Binder.restoreCallingIdentity(identity); |
| 5672 | } |
| 5673 | } |
Pengquan Meng | a1bb627 | 2018-09-06 09:59:22 -0700 | [diff] [blame] | 5674 | |
| 5675 | @Override |
| 5676 | public int getCdmaRoamingMode(int subId) { |
| 5677 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 5678 | mApp, subId, "getCdmaRoamingMode"); |
| 5679 | |
| 5680 | final long identity = Binder.clearCallingIdentity(); |
| 5681 | try { |
| 5682 | return (int) sendRequest(CMD_GET_CDMA_ROAMING_MODE, null /* argument */, subId); |
| 5683 | } finally { |
| 5684 | Binder.restoreCallingIdentity(identity); |
| 5685 | } |
| 5686 | } |
| 5687 | |
| 5688 | @Override |
| 5689 | public boolean setCdmaRoamingMode(int subId, int mode) { |
| 5690 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 5691 | mApp, subId, "setCdmaRoamingMode"); |
| 5692 | |
| 5693 | final long identity = Binder.clearCallingIdentity(); |
| 5694 | try { |
| 5695 | return (boolean) sendRequest(CMD_SET_CDMA_ROAMING_MODE, mode, subId); |
| 5696 | } finally { |
| 5697 | Binder.restoreCallingIdentity(identity); |
| 5698 | } |
| 5699 | } |
| 5700 | |
| 5701 | @Override |
| 5702 | public boolean setCdmaSubscriptionMode(int subId, int mode) { |
| 5703 | TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege( |
| 5704 | mApp, subId, "setCdmaSubscriptionMode"); |
| 5705 | |
| 5706 | final long identity = Binder.clearCallingIdentity(); |
| 5707 | try { |
| 5708 | return (boolean) sendRequest(CMD_SET_CDMA_SUBSCRIPTION_MODE, mode, subId); |
| 5709 | } finally { |
| 5710 | Binder.restoreCallingIdentity(identity); |
| 5711 | } |
| 5712 | } |
Makoto Onuki | da3bf79 | 2018-09-18 16:06:29 -0700 | [diff] [blame] | 5713 | |
| 5714 | private void ensureUserRunning(int userId) { |
| 5715 | if (!mUserManager.isUserRunning(userId)) { |
| 5716 | throw new IllegalStateException("User " + userId + " does not exist or not running"); |
| 5717 | } |
| 5718 | } |
| 5719 | |
| 5720 | /** |
| 5721 | * Returns a list of SMS apps on a given user. |
| 5722 | * |
| 5723 | * Only the shell user (UID 2000 or 0) can call it. |
| 5724 | * Target user must be running. |
| 5725 | */ |
| 5726 | @Override |
| 5727 | public String[] getSmsApps(int userId) { |
| 5728 | TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "getSmsApps"); |
| 5729 | ensureUserRunning(userId); |
| 5730 | |
| 5731 | final Collection<SmsApplicationData> apps = |
| 5732 | SmsApplication.getApplicationCollectionAsUser(mApp, userId); |
| 5733 | |
| 5734 | String[] ret = new String[apps.size()]; |
| 5735 | int i = 0; |
| 5736 | for (SmsApplicationData app : apps) { |
| 5737 | ret[i++] = app.mPackageName; |
| 5738 | } |
| 5739 | return ret; |
| 5740 | } |
| 5741 | |
| 5742 | /** |
| 5743 | * Returns the default SMS app package name on a given user. |
| 5744 | * |
| 5745 | * Only the shell user (UID 2000 or 0) can call it. |
| 5746 | * Target user must be running. |
| 5747 | */ |
| 5748 | @Override |
| 5749 | public String getDefaultSmsApp(int userId) { |
| 5750 | TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "getDefaultSmsApp"); |
| 5751 | ensureUserRunning(userId); |
| 5752 | |
| 5753 | final ComponentName cn = SmsApplication.getDefaultSmsApplicationAsUser(mApp, |
| 5754 | /* updateIfNeeded= */ true, userId); |
| 5755 | return cn == null ? null : cn.getPackageName(); |
| 5756 | } |
| 5757 | |
| 5758 | /** |
| 5759 | * Set a package as the default SMS app on a given user. |
| 5760 | * |
| 5761 | * Only the shell user (UID 2000 or 0) can call it. |
| 5762 | * Target user must be running. |
| 5763 | */ |
| 5764 | @Override |
| 5765 | public void setDefaultSmsApp(int userId, String packageName) { |
| 5766 | TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "setDefaultSmsApp"); |
| 5767 | ensureUserRunning(userId); |
| 5768 | |
| 5769 | boolean found = false; |
| 5770 | for (String pkg : getSmsApps(userId)) { |
| 5771 | if (TextUtils.equals(packageName, pkg)) { |
| 5772 | found = true; |
| 5773 | break; |
| 5774 | } |
| 5775 | } |
| 5776 | if (!found) { |
| 5777 | throw new IllegalArgumentException("Package " + packageName + " is not an SMS app"); |
| 5778 | } |
| 5779 | |
| 5780 | SmsApplication.setDefaultApplicationAsUser(packageName, mApp, userId); |
| 5781 | } |
sqian | c5eccab | 2018-10-19 18:46:41 -0700 | [diff] [blame] | 5782 | |
| 5783 | @Override |
| 5784 | public Map<Integer, List<EmergencyNumber>> getCurrentEmergencyNumberList( |
| 5785 | String callingPackage) { |
| 5786 | // TODO connect with internal content |
| 5787 | return null; |
| 5788 | } |
| 5789 | |
| 5790 | @Override |
| 5791 | public boolean isCurrentEmergencyNumber(String number) { |
| 5792 | // TODO connect with internal content |
| 5793 | return false; |
| 5794 | } |
chen xu | d6b45bd | 2018-10-30 22:27:10 -0700 | [diff] [blame] | 5795 | |
| 5796 | @Override |
| 5797 | public List<String> getCertsFromCarrierPrivilegeAccessRules(int subId) { |
| 5798 | enforceReadPrivilegedPermission("getCertsFromCarrierPrivilegeAccessRules"); |
| 5799 | Phone phone = getPhone(subId); |
| 5800 | if (phone == null) { |
| 5801 | return null; |
| 5802 | } |
| 5803 | final long identity = Binder.clearCallingIdentity(); |
| 5804 | try { |
| 5805 | UiccProfile profile = UiccController.getInstance() |
| 5806 | .getUiccProfileForPhone(phone.getPhoneId()); |
| 5807 | if (profile != null) { |
| 5808 | return profile.getCertsFromCarrierPrivilegeAccessRules(); |
| 5809 | } |
| 5810 | } finally { |
| 5811 | Binder.restoreCallingIdentity(identity); |
| 5812 | } |
| 5813 | return null; |
| 5814 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 5815 | } |