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 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 21 | import android.app.ActivityManager; |
| 22 | import android.app.AppOpsManager; |
Sailesh Nepal | bd76e4e | 2013-10-27 13:59:44 -0700 | [diff] [blame] | 23 | import android.content.ComponentName; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 24 | import android.content.Context; |
| 25 | import android.content.Intent; |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 26 | import android.content.SharedPreferences; |
Amith Yamasani | 6e11887 | 2016-02-19 12:53:51 -0800 | [diff] [blame] | 27 | import android.content.pm.PackageInfo; |
Shishir Agrawal | 60f9c95 | 2014-06-23 12:00:43 -0700 | [diff] [blame] | 28 | import android.content.pm.PackageManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 29 | import android.net.Uri; |
| 30 | import android.os.AsyncResult; |
| 31 | import android.os.Binder; |
| 32 | import android.os.Bundle; |
| 33 | import android.os.Handler; |
| 34 | import android.os.Looper; |
| 35 | import android.os.Message; |
| 36 | import android.os.Process; |
Adam Lesinski | 903a54c | 2016-04-11 14:49:52 -0700 | [diff] [blame] | 37 | import android.os.ResultReceiver; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 38 | import android.os.ServiceManager; |
| 39 | import android.os.UserHandle; |
Stuart Scott | 981d858 | 2015-04-21 14:09:50 -0700 | [diff] [blame] | 40 | import android.os.UserManager; |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 41 | import android.preference.PreferenceManager; |
Ihab Awad | f2177b7 | 2013-11-25 13:33:23 -0800 | [diff] [blame] | 42 | import android.provider.Settings; |
Santos Cordon | 7a1885b | 2015-02-03 11:15:19 -0800 | [diff] [blame] | 43 | import android.telecom.PhoneAccount; |
Nancy Chen | 31f9ba1 | 2016-01-06 11:42:12 -0800 | [diff] [blame] | 44 | import android.telecom.PhoneAccountHandle; |
Andrew Lee | 9431b83 | 2015-03-09 18:46:45 -0700 | [diff] [blame] | 45 | import android.telecom.TelecomManager; |
Junda Liu | 12f7d80 | 2015-05-01 12:06:44 -0700 | [diff] [blame] | 46 | import android.telephony.CarrierConfigManager; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 47 | import android.telephony.CellInfo; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 48 | import android.telephony.IccOpenLogicalChannelResponse; |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 49 | import android.telephony.ModemActivityInfo; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 50 | import android.telephony.NeighboringCellInfo; |
Wink Saville | 5d475dd | 2014-10-17 15:00:58 -0700 | [diff] [blame] | 51 | import android.telephony.RadioAccessFamily; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 52 | import android.telephony.ServiceState; |
Wink Saville | 0f3b5fc | 2014-11-11 08:40:49 -0800 | [diff] [blame] | 53 | import android.telephony.SubscriptionInfo; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 54 | import android.telephony.SubscriptionManager; |
Sanket Padawe | 99ef1e3 | 2016-05-18 16:12:33 -0700 | [diff] [blame] | 55 | import android.telephony.TelephonyHistogram; |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame^] | 56 | import android.telephony.TelephonyManager; |
| 57 | import android.telephony.VisualVoicemailSmsFilterSettings; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 58 | import android.text.TextUtils; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 59 | import android.util.ArraySet; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 60 | import android.util.Log; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 61 | import android.util.Pair; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 62 | import android.util.Slog; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 63 | |
Andrew Lee | 312e817 | 2014-10-23 17:01:36 -0700 | [diff] [blame] | 64 | import com.android.ims.ImsManager; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 65 | import com.android.internal.telephony.CallManager; |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 66 | import com.android.internal.telephony.CellNetworkScanResult; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 67 | import com.android.internal.telephony.CommandException; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 68 | import com.android.internal.telephony.DefaultPhoneNotifier; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 69 | import com.android.internal.telephony.ITelephony; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 70 | import com.android.internal.telephony.IccCard; |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 71 | import com.android.internal.telephony.MccTable; |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 72 | import com.android.internal.telephony.OperatorInfo; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 73 | import com.android.internal.telephony.Phone; |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 74 | import com.android.internal.telephony.PhoneConstants; |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 75 | import com.android.internal.telephony.PhoneFactory; |
Wink Saville | 5d475dd | 2014-10-17 15:00:58 -0700 | [diff] [blame] | 76 | import com.android.internal.telephony.ProxyController; |
Sanket Padawe | 99ef1e3 | 2016-05-18 16:12:33 -0700 | [diff] [blame] | 77 | import com.android.internal.telephony.RIL; |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 78 | import com.android.internal.telephony.RILConstants; |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 79 | import com.android.internal.telephony.SubscriptionController; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 80 | import com.android.internal.telephony.uicc.IccIoResult; |
| 81 | import com.android.internal.telephony.uicc.IccUtils; |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 82 | import com.android.internal.telephony.uicc.UiccCard; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 83 | import com.android.internal.telephony.uicc.UiccController; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 84 | import com.android.internal.util.HexDump; |
Nancy Chen | 31f9ba1 | 2016-01-06 11:42:12 -0800 | [diff] [blame] | 85 | import com.android.phone.settings.VoicemailNotificationSettingsUtil; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 86 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 87 | import java.util.ArrayList; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 88 | import java.util.Arrays; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 89 | import java.util.List; |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 90 | import java.util.Locale; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 91 | import java.util.Map; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
| 94 | * Implementation of the ITelephony interface. |
| 95 | */ |
Santos Cordon | 117fee7 | 2014-05-16 17:56:12 -0700 | [diff] [blame] | 96 | public class PhoneInterfaceManager extends ITelephony.Stub { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 97 | private static final String LOG_TAG = "PhoneInterfaceManager"; |
| 98 | private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2); |
| 99 | private static final boolean DBG_LOC = false; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 100 | private static final boolean DBG_MERGE = false; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 101 | |
| 102 | // Message codes used with mMainThreadHandler |
| 103 | private static final int CMD_HANDLE_PIN_MMI = 1; |
| 104 | private static final int CMD_HANDLE_NEIGHBORING_CELL = 2; |
| 105 | private static final int EVENT_NEIGHBORING_CELL_DONE = 3; |
| 106 | private static final int CMD_ANSWER_RINGING_CALL = 4; |
| 107 | private static final int CMD_END_CALL = 5; // not used yet |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 108 | private static final int CMD_TRANSMIT_APDU_LOGICAL_CHANNEL = 7; |
| 109 | private static final int EVENT_TRANSMIT_APDU_LOGICAL_CHANNEL_DONE = 8; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 110 | private static final int CMD_OPEN_CHANNEL = 9; |
| 111 | private static final int EVENT_OPEN_CHANNEL_DONE = 10; |
| 112 | private static final int CMD_CLOSE_CHANNEL = 11; |
| 113 | private static final int EVENT_CLOSE_CHANNEL_DONE = 12; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 114 | private static final int CMD_NV_READ_ITEM = 13; |
| 115 | private static final int EVENT_NV_READ_ITEM_DONE = 14; |
| 116 | private static final int CMD_NV_WRITE_ITEM = 15; |
| 117 | private static final int EVENT_NV_WRITE_ITEM_DONE = 16; |
| 118 | private static final int CMD_NV_WRITE_CDMA_PRL = 17; |
| 119 | private static final int EVENT_NV_WRITE_CDMA_PRL_DONE = 18; |
| 120 | private static final int CMD_NV_RESET_CONFIG = 19; |
| 121 | private static final int EVENT_NV_RESET_CONFIG_DONE = 20; |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 122 | private static final int CMD_GET_PREFERRED_NETWORK_TYPE = 21; |
| 123 | private static final int EVENT_GET_PREFERRED_NETWORK_TYPE_DONE = 22; |
| 124 | private static final int CMD_SET_PREFERRED_NETWORK_TYPE = 23; |
| 125 | private static final int EVENT_SET_PREFERRED_NETWORK_TYPE_DONE = 24; |
Sailesh Nepal | 35b5945 | 2014-03-06 09:26:56 -0800 | [diff] [blame] | 126 | private static final int CMD_SEND_ENVELOPE = 25; |
| 127 | private static final int EVENT_SEND_ENVELOPE_DONE = 26; |
Derek Tan | 6b088ee | 2014-09-05 14:15:18 -0700 | [diff] [blame] | 128 | private static final int CMD_INVOKE_OEM_RIL_REQUEST_RAW = 27; |
| 129 | private static final int EVENT_INVOKE_OEM_RIL_REQUEST_RAW_DONE = 28; |
| 130 | private static final int CMD_TRANSMIT_APDU_BASIC_CHANNEL = 29; |
| 131 | private static final int EVENT_TRANSMIT_APDU_BASIC_CHANNEL_DONE = 30; |
| 132 | private static final int CMD_EXCHANGE_SIM_IO = 31; |
| 133 | private static final int EVENT_EXCHANGE_SIM_IO_DONE = 32; |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 134 | private static final int CMD_SET_VOICEMAIL_NUMBER = 33; |
| 135 | private static final int EVENT_SET_VOICEMAIL_NUMBER_DONE = 34; |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 136 | private static final int CMD_SET_NETWORK_SELECTION_MODE_AUTOMATIC = 35; |
| 137 | private static final int EVENT_SET_NETWORK_SELECTION_MODE_AUTOMATIC_DONE = 36; |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 138 | private static final int CMD_GET_MODEM_ACTIVITY_INFO = 37; |
| 139 | private static final int EVENT_GET_MODEM_ACTIVITY_INFO_DONE = 38; |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 140 | private static final int CMD_PERFORM_NETWORK_SCAN = 39; |
| 141 | private static final int EVENT_PERFORM_NETWORK_SCAN_DONE = 40; |
| 142 | private static final int CMD_SET_NETWORK_SELECTION_MODE_MANUAL = 41; |
| 143 | private static final int EVENT_SET_NETWORK_SELECTION_MODE_MANUAL_DONE = 42; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 144 | |
| 145 | /** The singleton instance. */ |
| 146 | private static PhoneInterfaceManager sInstance; |
| 147 | |
Wink Saville | 3ab207e | 2014-11-20 13:07:20 -0800 | [diff] [blame] | 148 | private PhoneGlobals mApp; |
| 149 | private Phone mPhone; |
| 150 | private CallManager mCM; |
Stuart Scott | 981d858 | 2015-04-21 14:09:50 -0700 | [diff] [blame] | 151 | private UserManager mUserManager; |
Wink Saville | 3ab207e | 2014-11-20 13:07:20 -0800 | [diff] [blame] | 152 | private AppOpsManager mAppOps; |
| 153 | private MainThreadHandler mMainThreadHandler; |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 154 | private SubscriptionController mSubscriptionController; |
Wink Saville | 3ab207e | 2014-11-20 13:07:20 -0800 | [diff] [blame] | 155 | private SharedPreferences mTelephonySharedPreferences; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 156 | |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 157 | private static final String PREF_CARRIERS_ALPHATAG_PREFIX = "carrier_alphtag_"; |
| 158 | private static final String PREF_CARRIERS_NUMBER_PREFIX = "carrier_number_"; |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 159 | private static final String PREF_CARRIERS_SUBSCRIBER_PREFIX = "carrier_subscriber_"; |
Derek Tan | 89e89d4 | 2014-07-08 17:00:10 -0700 | [diff] [blame] | 160 | |
| 161 | /** |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 162 | * A request object to use for transmitting data to an ICC. |
| 163 | */ |
| 164 | private static final class IccAPDUArgument { |
| 165 | public int channel, cla, command, p1, p2, p3; |
| 166 | public String data; |
| 167 | |
| 168 | public IccAPDUArgument(int channel, int cla, int command, |
| 169 | int p1, int p2, int p3, String data) { |
| 170 | this.channel = channel; |
| 171 | this.cla = cla; |
| 172 | this.command = command; |
| 173 | this.p1 = p1; |
| 174 | this.p2 = p2; |
| 175 | this.p3 = p3; |
| 176 | this.data = data; |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | /** |
Shishir Agrawal | 77ba317 | 2015-09-10 14:50:19 -0700 | [diff] [blame] | 181 | * A request object to use for transmitting data to an ICC. |
| 182 | */ |
| 183 | private static final class ManualNetworkSelectionArgument { |
| 184 | public OperatorInfo operatorInfo; |
| 185 | public boolean persistSelection; |
| 186 | |
| 187 | public ManualNetworkSelectionArgument(OperatorInfo operatorInfo, boolean persistSelection) { |
| 188 | this.operatorInfo = operatorInfo; |
| 189 | this.persistSelection = persistSelection; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 194 | * A request object for use with {@link MainThreadHandler}. Requesters should wait() on the |
| 195 | * request after sending. The main thread will notify the request when it is complete. |
| 196 | */ |
| 197 | private static final class MainThreadRequest { |
| 198 | /** The argument to use for the request */ |
| 199 | public Object argument; |
| 200 | /** The result of the request that is run on the main thread */ |
| 201 | public Object result; |
Sanket Padawe | 56e75a3 | 2016-02-08 12:18:19 -0800 | [diff] [blame] | 202 | // The subscriber id that this request applies to. Defaults to |
| 203 | // SubscriptionManager.INVALID_SUBSCRIPTION_ID |
| 204 | public Integer subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 205 | |
| 206 | public MainThreadRequest(Object argument) { |
| 207 | this.argument = argument; |
| 208 | } |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 209 | |
| 210 | public MainThreadRequest(Object argument, Integer subId) { |
| 211 | this.argument = argument; |
Sanket Padawe | 56e75a3 | 2016-02-08 12:18:19 -0800 | [diff] [blame] | 212 | if (subId != null) { |
| 213 | this.subId = subId; |
| 214 | } |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 215 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Sailesh Nepal | cc0375f | 2013-11-13 09:15:18 -0800 | [diff] [blame] | 218 | private static final class IncomingThirdPartyCallArgs { |
| 219 | public final ComponentName component; |
| 220 | public final String callId; |
| 221 | public final String callerDisplayName; |
| 222 | |
| 223 | public IncomingThirdPartyCallArgs(ComponentName component, String callId, |
| 224 | String callerDisplayName) { |
| 225 | this.component = component; |
| 226 | this.callId = callId; |
| 227 | this.callerDisplayName = callerDisplayName; |
| 228 | } |
| 229 | } |
| 230 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 231 | /** |
| 232 | * A handler that processes messages on the main thread in the phone process. Since many |
| 233 | * of the Phone calls are not thread safe this is needed to shuttle the requests from the |
| 234 | * inbound binder threads to the main thread in the phone process. The Binder thread |
| 235 | * may provide a {@link MainThreadRequest} object in the msg.obj field that they are waiting |
| 236 | * on, which will be notified when the operation completes and will contain the result of the |
| 237 | * request. |
| 238 | * |
| 239 | * <p>If a MainThreadRequest object is provided in the msg.obj field, |
| 240 | * note that request.result must be set to something non-null for the calling thread to |
| 241 | * unblock. |
| 242 | */ |
| 243 | private final class MainThreadHandler extends Handler { |
| 244 | @Override |
| 245 | public void handleMessage(Message msg) { |
| 246 | MainThreadRequest request; |
| 247 | Message onCompleted; |
| 248 | AsyncResult ar; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 249 | UiccCard uiccCard; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 250 | IccAPDUArgument iccArgument; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 251 | |
| 252 | switch (msg.what) { |
Yorke Lee | 716f67e | 2015-06-17 15:39:16 -0700 | [diff] [blame] | 253 | case CMD_HANDLE_PIN_MMI: { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 254 | request = (MainThreadRequest) msg.obj; |
Yorke Lee | 716f67e | 2015-06-17 15:39:16 -0700 | [diff] [blame] | 255 | final Phone phone = getPhoneFromRequest(request); |
| 256 | request.result = phone != null ? |
| 257 | getPhoneFromRequest(request).handlePinMmi((String) request.argument) |
| 258 | : false; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 259 | // Wake up the requesting thread |
| 260 | synchronized (request) { |
| 261 | request.notifyAll(); |
| 262 | } |
| 263 | break; |
Yorke Lee | 716f67e | 2015-06-17 15:39:16 -0700 | [diff] [blame] | 264 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 265 | |
| 266 | case CMD_HANDLE_NEIGHBORING_CELL: |
| 267 | request = (MainThreadRequest) msg.obj; |
| 268 | onCompleted = obtainMessage(EVENT_NEIGHBORING_CELL_DONE, |
| 269 | request); |
| 270 | mPhone.getNeighboringCids(onCompleted); |
| 271 | break; |
| 272 | |
| 273 | case EVENT_NEIGHBORING_CELL_DONE: |
| 274 | ar = (AsyncResult) msg.obj; |
| 275 | request = (MainThreadRequest) ar.userObj; |
| 276 | if (ar.exception == null && ar.result != null) { |
| 277 | request.result = ar.result; |
| 278 | } else { |
| 279 | // create an empty list to notify the waiting thread |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 280 | request.result = new ArrayList<NeighboringCellInfo>(0); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 281 | } |
| 282 | // Wake up the requesting thread |
| 283 | synchronized (request) { |
| 284 | request.notifyAll(); |
| 285 | } |
| 286 | break; |
| 287 | |
| 288 | case CMD_ANSWER_RINGING_CALL: |
Wink Saville | 0887461 | 2014-08-31 19:19:58 -0700 | [diff] [blame] | 289 | request = (MainThreadRequest) msg.obj; |
Stuart Scott | 584921c | 2015-01-15 17:10:34 -0800 | [diff] [blame] | 290 | int answer_subId = request.subId; |
Wink Saville | 0887461 | 2014-08-31 19:19:58 -0700 | [diff] [blame] | 291 | answerRingingCallInternal(answer_subId); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 292 | break; |
| 293 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 294 | case CMD_END_CALL: |
| 295 | request = (MainThreadRequest) msg.obj; |
Stuart Scott | 584921c | 2015-01-15 17:10:34 -0800 | [diff] [blame] | 296 | int end_subId = request.subId; |
Wink Saville | 0887461 | 2014-08-31 19:19:58 -0700 | [diff] [blame] | 297 | final boolean hungUp; |
Anthony Lee | ae4e36d | 2015-05-21 07:17:46 -0700 | [diff] [blame] | 298 | Phone phone = getPhone(end_subId); |
| 299 | if (phone == null) { |
| 300 | if (DBG) log("CMD_END_CALL: no phone for id: " + end_subId); |
| 301 | break; |
| 302 | } |
| 303 | int phoneType = phone.getPhoneType(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 304 | if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) { |
| 305 | // CDMA: If the user presses the Power button we treat it as |
| 306 | // ending the complete call session |
Wink Saville | 0887461 | 2014-08-31 19:19:58 -0700 | [diff] [blame] | 307 | hungUp = PhoneUtils.hangupRingingAndActive(getPhone(end_subId)); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 308 | } else if (phoneType == PhoneConstants.PHONE_TYPE_GSM) { |
| 309 | // GSM: End the call as per the Phone state |
| 310 | hungUp = PhoneUtils.hangup(mCM); |
| 311 | } else { |
| 312 | throw new IllegalStateException("Unexpected phone type: " + phoneType); |
| 313 | } |
| 314 | if (DBG) log("CMD_END_CALL: " + (hungUp ? "hung up!" : "no call to hang up")); |
| 315 | request.result = hungUp; |
| 316 | // Wake up the requesting thread |
| 317 | synchronized (request) { |
| 318 | request.notifyAll(); |
| 319 | } |
| 320 | break; |
| 321 | |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 322 | case CMD_TRANSMIT_APDU_LOGICAL_CHANNEL: |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 323 | request = (MainThreadRequest) msg.obj; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 324 | iccArgument = (IccAPDUArgument) request.argument; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 325 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 326 | if (uiccCard == null) { |
| 327 | loge("iccTransmitApduLogicalChannel: No UICC"); |
| 328 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 329 | synchronized (request) { |
| 330 | request.notifyAll(); |
| 331 | } |
| 332 | } else { |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 333 | onCompleted = obtainMessage(EVENT_TRANSMIT_APDU_LOGICAL_CHANNEL_DONE, |
| 334 | request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 335 | uiccCard.iccTransmitApduLogicalChannel( |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 336 | iccArgument.channel, iccArgument.cla, iccArgument.command, |
| 337 | iccArgument.p1, iccArgument.p2, iccArgument.p3, iccArgument.data, |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 338 | onCompleted); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 339 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 340 | break; |
| 341 | |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 342 | case EVENT_TRANSMIT_APDU_LOGICAL_CHANNEL_DONE: |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 343 | ar = (AsyncResult) msg.obj; |
| 344 | request = (MainThreadRequest) ar.userObj; |
| 345 | if (ar.exception == null && ar.result != null) { |
| 346 | request.result = ar.result; |
| 347 | } else { |
| 348 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 349 | if (ar.result == null) { |
| 350 | loge("iccTransmitApduLogicalChannel: Empty response"); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 351 | } else if (ar.exception instanceof CommandException) { |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 352 | loge("iccTransmitApduLogicalChannel: CommandException: " + |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 353 | ar.exception); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 354 | } else { |
| 355 | loge("iccTransmitApduLogicalChannel: Unknown exception"); |
| 356 | } |
| 357 | } |
| 358 | synchronized (request) { |
| 359 | request.notifyAll(); |
| 360 | } |
| 361 | break; |
| 362 | |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 363 | case CMD_TRANSMIT_APDU_BASIC_CHANNEL: |
| 364 | request = (MainThreadRequest) msg.obj; |
| 365 | iccArgument = (IccAPDUArgument) request.argument; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 366 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 367 | if (uiccCard == null) { |
| 368 | loge("iccTransmitApduBasicChannel: No UICC"); |
| 369 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 370 | synchronized (request) { |
| 371 | request.notifyAll(); |
| 372 | } |
| 373 | } else { |
| 374 | onCompleted = obtainMessage(EVENT_TRANSMIT_APDU_BASIC_CHANNEL_DONE, |
| 375 | request); |
| 376 | uiccCard.iccTransmitApduBasicChannel( |
| 377 | iccArgument.cla, iccArgument.command, iccArgument.p1, iccArgument.p2, |
| 378 | iccArgument.p3, iccArgument.data, onCompleted); |
| 379 | } |
| 380 | break; |
| 381 | |
| 382 | case EVENT_TRANSMIT_APDU_BASIC_CHANNEL_DONE: |
| 383 | ar = (AsyncResult) msg.obj; |
| 384 | request = (MainThreadRequest) ar.userObj; |
| 385 | if (ar.exception == null && ar.result != null) { |
| 386 | request.result = ar.result; |
| 387 | } else { |
| 388 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 389 | if (ar.result == null) { |
| 390 | loge("iccTransmitApduBasicChannel: Empty response"); |
| 391 | } else if (ar.exception instanceof CommandException) { |
| 392 | loge("iccTransmitApduBasicChannel: CommandException: " + |
| 393 | ar.exception); |
| 394 | } else { |
| 395 | loge("iccTransmitApduBasicChannel: Unknown exception"); |
| 396 | } |
| 397 | } |
| 398 | synchronized (request) { |
| 399 | request.notifyAll(); |
| 400 | } |
| 401 | break; |
| 402 | |
| 403 | case CMD_EXCHANGE_SIM_IO: |
| 404 | request = (MainThreadRequest) msg.obj; |
| 405 | iccArgument = (IccAPDUArgument) request.argument; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 406 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 407 | if (uiccCard == null) { |
| 408 | loge("iccExchangeSimIO: No UICC"); |
| 409 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 410 | synchronized (request) { |
| 411 | request.notifyAll(); |
| 412 | } |
| 413 | } else { |
| 414 | onCompleted = obtainMessage(EVENT_EXCHANGE_SIM_IO_DONE, |
| 415 | request); |
| 416 | uiccCard.iccExchangeSimIO(iccArgument.cla, /* fileID */ |
| 417 | iccArgument.command, iccArgument.p1, iccArgument.p2, iccArgument.p3, |
| 418 | iccArgument.data, onCompleted); |
| 419 | } |
| 420 | break; |
| 421 | |
| 422 | case EVENT_EXCHANGE_SIM_IO_DONE: |
| 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 | } |
| 430 | synchronized (request) { |
| 431 | request.notifyAll(); |
| 432 | } |
| 433 | break; |
| 434 | |
Derek Tan | 4d5e5c1 | 2014-02-04 11:54:58 -0800 | [diff] [blame] | 435 | case CMD_SEND_ENVELOPE: |
| 436 | request = (MainThreadRequest) msg.obj; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 437 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 438 | if (uiccCard == null) { |
| 439 | loge("sendEnvelopeWithStatus: No UICC"); |
| 440 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 441 | synchronized (request) { |
| 442 | request.notifyAll(); |
| 443 | } |
| 444 | } else { |
| 445 | onCompleted = obtainMessage(EVENT_SEND_ENVELOPE_DONE, request); |
| 446 | uiccCard.sendEnvelopeWithStatus((String)request.argument, onCompleted); |
| 447 | } |
Derek Tan | 4d5e5c1 | 2014-02-04 11:54:58 -0800 | [diff] [blame] | 448 | break; |
| 449 | |
| 450 | case EVENT_SEND_ENVELOPE_DONE: |
| 451 | ar = (AsyncResult) msg.obj; |
| 452 | request = (MainThreadRequest) ar.userObj; |
Shishir Agrawal | 9f9877d | 2014-03-14 09:36:27 -0700 | [diff] [blame] | 453 | if (ar.exception == null && ar.result != null) { |
| 454 | request.result = ar.result; |
Derek Tan | 4d5e5c1 | 2014-02-04 11:54:58 -0800 | [diff] [blame] | 455 | } else { |
Shishir Agrawal | 9f9877d | 2014-03-14 09:36:27 -0700 | [diff] [blame] | 456 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 457 | if (ar.result == null) { |
| 458 | loge("sendEnvelopeWithStatus: Empty response"); |
| 459 | } else if (ar.exception instanceof CommandException) { |
| 460 | loge("sendEnvelopeWithStatus: CommandException: " + |
| 461 | ar.exception); |
| 462 | } else { |
| 463 | loge("sendEnvelopeWithStatus: exception:" + ar.exception); |
| 464 | } |
Derek Tan | 4d5e5c1 | 2014-02-04 11:54:58 -0800 | [diff] [blame] | 465 | } |
| 466 | synchronized (request) { |
| 467 | request.notifyAll(); |
| 468 | } |
| 469 | break; |
| 470 | |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 471 | case CMD_OPEN_CHANNEL: |
| 472 | request = (MainThreadRequest) msg.obj; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 473 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 474 | if (uiccCard == null) { |
| 475 | loge("iccOpenLogicalChannel: No UICC"); |
Shishir Agrawal | fc0492a | 2016-02-17 11:15:33 -0800 | [diff] [blame] | 476 | request.result = new IccOpenLogicalChannelResponse(-1, |
| 477 | IccOpenLogicalChannelResponse.STATUS_MISSING_RESOURCE, null); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 478 | synchronized (request) { |
| 479 | request.notifyAll(); |
| 480 | } |
| 481 | } else { |
| 482 | onCompleted = obtainMessage(EVENT_OPEN_CHANNEL_DONE, request); |
| 483 | uiccCard.iccOpenLogicalChannel((String)request.argument, onCompleted); |
| 484 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 485 | break; |
| 486 | |
| 487 | case EVENT_OPEN_CHANNEL_DONE: |
| 488 | ar = (AsyncResult) msg.obj; |
| 489 | request = (MainThreadRequest) ar.userObj; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 490 | IccOpenLogicalChannelResponse openChannelResp; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 491 | if (ar.exception == null && ar.result != null) { |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 492 | int[] result = (int[]) ar.result; |
| 493 | int channelId = result[0]; |
| 494 | byte[] selectResponse = null; |
| 495 | if (result.length > 1) { |
| 496 | selectResponse = new byte[result.length - 1]; |
| 497 | for (int i = 1; i < result.length; ++i) { |
| 498 | selectResponse[i - 1] = (byte) result[i]; |
| 499 | } |
| 500 | } |
| 501 | openChannelResp = new IccOpenLogicalChannelResponse(channelId, |
Shishir Agrawal | 527e8bf | 2014-08-25 08:54:56 -0700 | [diff] [blame] | 502 | IccOpenLogicalChannelResponse.STATUS_NO_ERROR, selectResponse); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 503 | } else { |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 504 | if (ar.result == null) { |
| 505 | loge("iccOpenLogicalChannel: Empty response"); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 506 | } |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 507 | if (ar.exception != null) { |
| 508 | loge("iccOpenLogicalChannel: Exception: " + ar.exception); |
| 509 | } |
| 510 | |
Shishir Agrawal | 527e8bf | 2014-08-25 08:54:56 -0700 | [diff] [blame] | 511 | int errorCode = IccOpenLogicalChannelResponse.STATUS_UNKNOWN_ERROR; |
Junda Liu | a754ba1 | 2015-05-20 01:17:52 -0700 | [diff] [blame] | 512 | if (ar.exception instanceof CommandException) { |
| 513 | CommandException.Error error = |
| 514 | ((CommandException) (ar.exception)).getCommandError(); |
| 515 | if (error == CommandException.Error.MISSING_RESOURCE) { |
Shishir Agrawal | 527e8bf | 2014-08-25 08:54:56 -0700 | [diff] [blame] | 516 | errorCode = IccOpenLogicalChannelResponse.STATUS_MISSING_RESOURCE; |
Junda Liu | a754ba1 | 2015-05-20 01:17:52 -0700 | [diff] [blame] | 517 | } else if (error == CommandException.Error.NO_SUCH_ELEMENT) { |
Shishir Agrawal | 527e8bf | 2014-08-25 08:54:56 -0700 | [diff] [blame] | 518 | errorCode = IccOpenLogicalChannelResponse.STATUS_NO_SUCH_ELEMENT; |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 519 | } |
| 520 | } |
| 521 | openChannelResp = new IccOpenLogicalChannelResponse( |
| 522 | IccOpenLogicalChannelResponse.INVALID_CHANNEL, errorCode, null); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 523 | } |
Shishir Agrawal | 82c8a46 | 2014-07-31 18:13:17 -0700 | [diff] [blame] | 524 | request.result = openChannelResp; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 525 | synchronized (request) { |
| 526 | request.notifyAll(); |
| 527 | } |
| 528 | break; |
| 529 | |
| 530 | case CMD_CLOSE_CHANNEL: |
| 531 | request = (MainThreadRequest) msg.obj; |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 532 | uiccCard = getUiccCardFromRequest(request); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 533 | if (uiccCard == null) { |
| 534 | loge("iccCloseLogicalChannel: No UICC"); |
| 535 | request.result = new IccIoResult(0x6F, 0, (byte[])null); |
| 536 | synchronized (request) { |
| 537 | request.notifyAll(); |
| 538 | } |
| 539 | } else { |
| 540 | onCompleted = obtainMessage(EVENT_CLOSE_CHANNEL_DONE, request); |
| 541 | uiccCard.iccCloseLogicalChannel((Integer) request.argument, onCompleted); |
| 542 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 543 | break; |
| 544 | |
| 545 | case EVENT_CLOSE_CHANNEL_DONE: |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 546 | handleNullReturnEvent(msg, "iccCloseLogicalChannel"); |
| 547 | break; |
| 548 | |
| 549 | case CMD_NV_READ_ITEM: |
| 550 | request = (MainThreadRequest) msg.obj; |
| 551 | onCompleted = obtainMessage(EVENT_NV_READ_ITEM_DONE, request); |
| 552 | mPhone.nvReadItem((Integer) request.argument, onCompleted); |
| 553 | break; |
| 554 | |
| 555 | case EVENT_NV_READ_ITEM_DONE: |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 556 | ar = (AsyncResult) msg.obj; |
| 557 | request = (MainThreadRequest) ar.userObj; |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 558 | if (ar.exception == null && ar.result != null) { |
| 559 | request.result = ar.result; // String |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 560 | } else { |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 561 | request.result = ""; |
| 562 | if (ar.result == null) { |
| 563 | loge("nvReadItem: Empty response"); |
| 564 | } else if (ar.exception instanceof CommandException) { |
| 565 | loge("nvReadItem: CommandException: " + |
| 566 | ar.exception); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 567 | } else { |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 568 | loge("nvReadItem: Unknown exception"); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 569 | } |
| 570 | } |
| 571 | synchronized (request) { |
| 572 | request.notifyAll(); |
| 573 | } |
| 574 | break; |
| 575 | |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 576 | case CMD_NV_WRITE_ITEM: |
| 577 | request = (MainThreadRequest) msg.obj; |
| 578 | onCompleted = obtainMessage(EVENT_NV_WRITE_ITEM_DONE, request); |
| 579 | Pair<Integer, String> idValue = (Pair<Integer, String>) request.argument; |
| 580 | mPhone.nvWriteItem(idValue.first, idValue.second, onCompleted); |
| 581 | break; |
| 582 | |
| 583 | case EVENT_NV_WRITE_ITEM_DONE: |
| 584 | handleNullReturnEvent(msg, "nvWriteItem"); |
| 585 | break; |
| 586 | |
| 587 | case CMD_NV_WRITE_CDMA_PRL: |
| 588 | request = (MainThreadRequest) msg.obj; |
| 589 | onCompleted = obtainMessage(EVENT_NV_WRITE_CDMA_PRL_DONE, request); |
| 590 | mPhone.nvWriteCdmaPrl((byte[]) request.argument, onCompleted); |
| 591 | break; |
| 592 | |
| 593 | case EVENT_NV_WRITE_CDMA_PRL_DONE: |
| 594 | handleNullReturnEvent(msg, "nvWriteCdmaPrl"); |
| 595 | break; |
| 596 | |
| 597 | case CMD_NV_RESET_CONFIG: |
| 598 | request = (MainThreadRequest) msg.obj; |
| 599 | onCompleted = obtainMessage(EVENT_NV_RESET_CONFIG_DONE, request); |
| 600 | mPhone.nvResetConfig((Integer) request.argument, onCompleted); |
| 601 | break; |
| 602 | |
| 603 | case EVENT_NV_RESET_CONFIG_DONE: |
| 604 | handleNullReturnEvent(msg, "nvResetConfig"); |
| 605 | break; |
| 606 | |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 607 | case CMD_GET_PREFERRED_NETWORK_TYPE: |
| 608 | request = (MainThreadRequest) msg.obj; |
| 609 | onCompleted = obtainMessage(EVENT_GET_PREFERRED_NETWORK_TYPE_DONE, request); |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 610 | getPhoneFromRequest(request).getPreferredNetworkType(onCompleted); |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 611 | break; |
| 612 | |
| 613 | case EVENT_GET_PREFERRED_NETWORK_TYPE_DONE: |
| 614 | ar = (AsyncResult) msg.obj; |
| 615 | request = (MainThreadRequest) ar.userObj; |
| 616 | if (ar.exception == null && ar.result != null) { |
| 617 | request.result = ar.result; // Integer |
| 618 | } else { |
Sanket Padawe | cfc2d35 | 2016-01-05 19:52:14 -0800 | [diff] [blame] | 619 | request.result = null; |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 620 | if (ar.result == null) { |
| 621 | loge("getPreferredNetworkType: Empty response"); |
| 622 | } else if (ar.exception instanceof CommandException) { |
| 623 | loge("getPreferredNetworkType: CommandException: " + |
| 624 | ar.exception); |
| 625 | } else { |
| 626 | loge("getPreferredNetworkType: Unknown exception"); |
| 627 | } |
| 628 | } |
| 629 | synchronized (request) { |
| 630 | request.notifyAll(); |
| 631 | } |
| 632 | break; |
| 633 | |
| 634 | case CMD_SET_PREFERRED_NETWORK_TYPE: |
| 635 | request = (MainThreadRequest) msg.obj; |
| 636 | onCompleted = obtainMessage(EVENT_SET_PREFERRED_NETWORK_TYPE_DONE, request); |
| 637 | int networkType = (Integer) request.argument; |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 638 | getPhoneFromRequest(request).setPreferredNetworkType(networkType, onCompleted); |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 639 | break; |
| 640 | |
| 641 | case EVENT_SET_PREFERRED_NETWORK_TYPE_DONE: |
| 642 | handleNullReturnEvent(msg, "setPreferredNetworkType"); |
| 643 | break; |
| 644 | |
Steven Liu | 4bf01bc | 2014-07-17 11:05:29 -0500 | [diff] [blame] | 645 | case CMD_INVOKE_OEM_RIL_REQUEST_RAW: |
| 646 | request = (MainThreadRequest)msg.obj; |
| 647 | onCompleted = obtainMessage(EVENT_INVOKE_OEM_RIL_REQUEST_RAW_DONE, request); |
| 648 | mPhone.invokeOemRilRequestRaw((byte[])request.argument, onCompleted); |
| 649 | break; |
| 650 | |
| 651 | case EVENT_INVOKE_OEM_RIL_REQUEST_RAW_DONE: |
| 652 | ar = (AsyncResult)msg.obj; |
| 653 | request = (MainThreadRequest)ar.userObj; |
| 654 | request.result = ar; |
| 655 | synchronized (request) { |
| 656 | request.notifyAll(); |
| 657 | } |
| 658 | break; |
| 659 | |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 660 | case CMD_SET_VOICEMAIL_NUMBER: |
| 661 | request = (MainThreadRequest) msg.obj; |
| 662 | onCompleted = obtainMessage(EVENT_SET_VOICEMAIL_NUMBER_DONE, request); |
| 663 | Pair<String, String> tagNum = (Pair<String, String>) request.argument; |
Stuart Scott | 584921c | 2015-01-15 17:10:34 -0800 | [diff] [blame] | 664 | getPhoneFromRequest(request).setVoiceMailNumber(tagNum.first, tagNum.second, |
| 665 | onCompleted); |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 666 | break; |
| 667 | |
| 668 | case EVENT_SET_VOICEMAIL_NUMBER_DONE: |
| 669 | handleNullReturnEvent(msg, "setVoicemailNumber"); |
| 670 | break; |
| 671 | |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 672 | case CMD_SET_NETWORK_SELECTION_MODE_AUTOMATIC: |
| 673 | request = (MainThreadRequest) msg.obj; |
| 674 | onCompleted = obtainMessage(EVENT_SET_NETWORK_SELECTION_MODE_AUTOMATIC_DONE, |
| 675 | request); |
| 676 | getPhoneFromRequest(request).setNetworkSelectionModeAutomatic(onCompleted); |
| 677 | break; |
| 678 | |
| 679 | case EVENT_SET_NETWORK_SELECTION_MODE_AUTOMATIC_DONE: |
| 680 | handleNullReturnEvent(msg, "setNetworkSelectionModeAutomatic"); |
| 681 | break; |
| 682 | |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 683 | case CMD_PERFORM_NETWORK_SCAN: |
| 684 | request = (MainThreadRequest) msg.obj; |
| 685 | onCompleted = obtainMessage(EVENT_PERFORM_NETWORK_SCAN_DONE, request); |
| 686 | getPhoneFromRequest(request).getAvailableNetworks(onCompleted); |
| 687 | break; |
| 688 | |
| 689 | case EVENT_PERFORM_NETWORK_SCAN_DONE: |
| 690 | ar = (AsyncResult) msg.obj; |
| 691 | request = (MainThreadRequest) ar.userObj; |
| 692 | CellNetworkScanResult cellScanResult; |
| 693 | if (ar.exception == null && ar.result != null) { |
| 694 | cellScanResult = new CellNetworkScanResult( |
| 695 | CellNetworkScanResult.STATUS_SUCCESS, |
| 696 | (List<OperatorInfo>) ar.result); |
| 697 | } else { |
| 698 | if (ar.result == null) { |
| 699 | loge("getCellNetworkScanResults: Empty response"); |
| 700 | } |
| 701 | if (ar.exception != null) { |
| 702 | loge("getCellNetworkScanResults: Exception: " + ar.exception); |
| 703 | } |
| 704 | int errorCode = CellNetworkScanResult.STATUS_UNKNOWN_ERROR; |
| 705 | if (ar.exception instanceof CommandException) { |
| 706 | CommandException.Error error = |
| 707 | ((CommandException) (ar.exception)).getCommandError(); |
| 708 | if (error == CommandException.Error.RADIO_NOT_AVAILABLE) { |
| 709 | errorCode = CellNetworkScanResult.STATUS_RADIO_NOT_AVAILABLE; |
| 710 | } else if (error == CommandException.Error.GENERIC_FAILURE) { |
| 711 | errorCode = CellNetworkScanResult.STATUS_RADIO_GENERIC_FAILURE; |
| 712 | } |
| 713 | } |
| 714 | cellScanResult = new CellNetworkScanResult(errorCode, null); |
| 715 | } |
| 716 | request.result = cellScanResult; |
| 717 | synchronized (request) { |
| 718 | request.notifyAll(); |
| 719 | } |
| 720 | break; |
| 721 | |
| 722 | case CMD_SET_NETWORK_SELECTION_MODE_MANUAL: |
| 723 | request = (MainThreadRequest) msg.obj; |
Shishir Agrawal | 77ba317 | 2015-09-10 14:50:19 -0700 | [diff] [blame] | 724 | ManualNetworkSelectionArgument selArg = |
| 725 | (ManualNetworkSelectionArgument) request.argument; |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 726 | onCompleted = obtainMessage(EVENT_SET_NETWORK_SELECTION_MODE_MANUAL_DONE, |
| 727 | request); |
Shishir Agrawal | 77ba317 | 2015-09-10 14:50:19 -0700 | [diff] [blame] | 728 | getPhoneFromRequest(request).selectNetworkManually(selArg.operatorInfo, |
| 729 | selArg.persistSelection, onCompleted); |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 730 | break; |
| 731 | |
| 732 | case EVENT_SET_NETWORK_SELECTION_MODE_MANUAL_DONE: |
| 733 | handleNullReturnEvent(msg, "setNetworkSelectionModeManual"); |
| 734 | break; |
| 735 | |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 736 | case CMD_GET_MODEM_ACTIVITY_INFO: |
| 737 | request = (MainThreadRequest) msg.obj; |
| 738 | onCompleted = obtainMessage(EVENT_GET_MODEM_ACTIVITY_INFO_DONE, request); |
Prerepa Viswanadham | 61a60ad | 2015-06-08 18:07:51 -0700 | [diff] [blame] | 739 | mPhone.getModemActivityInfo(onCompleted); |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 740 | break; |
| 741 | |
| 742 | case EVENT_GET_MODEM_ACTIVITY_INFO_DONE: |
| 743 | ar = (AsyncResult) msg.obj; |
| 744 | request = (MainThreadRequest) ar.userObj; |
| 745 | if (ar.exception == null && ar.result != null) { |
| 746 | request.result = ar.result; |
| 747 | } else { |
| 748 | if (ar.result == null) { |
| 749 | loge("queryModemActivityInfo: Empty response"); |
| 750 | } else if (ar.exception instanceof CommandException) { |
| 751 | loge("queryModemActivityInfo: CommandException: " + |
| 752 | ar.exception); |
| 753 | } else { |
| 754 | loge("queryModemActivityInfo: Unknown exception"); |
| 755 | } |
| 756 | } |
Amit Mahajan | d476622 | 2016-01-28 15:28:28 -0800 | [diff] [blame] | 757 | // Result cannot be null. Return ModemActivityInfo with all fields set to 0. |
| 758 | if (request.result == null) { |
| 759 | request.result = new ModemActivityInfo(0, 0, 0, null, 0, 0); |
| 760 | } |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 761 | synchronized (request) { |
| 762 | request.notifyAll(); |
| 763 | } |
| 764 | break; |
| 765 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 766 | default: |
| 767 | Log.w(LOG_TAG, "MainThreadHandler: unexpected message code: " + msg.what); |
| 768 | break; |
| 769 | } |
| 770 | } |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 771 | |
| 772 | private void handleNullReturnEvent(Message msg, String command) { |
| 773 | AsyncResult ar = (AsyncResult) msg.obj; |
| 774 | MainThreadRequest request = (MainThreadRequest) ar.userObj; |
| 775 | if (ar.exception == null) { |
| 776 | request.result = true; |
| 777 | } else { |
| 778 | request.result = false; |
| 779 | if (ar.exception instanceof CommandException) { |
| 780 | loge(command + ": CommandException: " + ar.exception); |
| 781 | } else { |
| 782 | loge(command + ": Unknown exception"); |
| 783 | } |
| 784 | } |
| 785 | synchronized (request) { |
| 786 | request.notifyAll(); |
| 787 | } |
| 788 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | /** |
| 792 | * Posts the specified command to be executed on the main thread, |
| 793 | * waits for the request to complete, and returns the result. |
| 794 | * @see #sendRequestAsync |
| 795 | */ |
| 796 | private Object sendRequest(int command, Object argument) { |
Sanket Padawe | 56e75a3 | 2016-02-08 12:18:19 -0800 | [diff] [blame] | 797 | return sendRequest(command, argument, SubscriptionManager.INVALID_SUBSCRIPTION_ID); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | /** |
| 801 | * Posts the specified command to be executed on the main thread, |
| 802 | * waits for the request to complete, and returns the result. |
| 803 | * @see #sendRequestAsync |
| 804 | */ |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 805 | private Object sendRequest(int command, Object argument, Integer subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 806 | if (Looper.myLooper() == mMainThreadHandler.getLooper()) { |
| 807 | throw new RuntimeException("This method will deadlock if called from the main thread."); |
| 808 | } |
| 809 | |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 810 | MainThreadRequest request = new MainThreadRequest(argument, subId); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 811 | Message msg = mMainThreadHandler.obtainMessage(command, request); |
| 812 | msg.sendToTarget(); |
| 813 | |
| 814 | // Wait for the request to complete |
| 815 | synchronized (request) { |
| 816 | while (request.result == null) { |
| 817 | try { |
| 818 | request.wait(); |
| 819 | } catch (InterruptedException e) { |
| 820 | // Do nothing, go back and wait until the request is complete |
| 821 | } |
| 822 | } |
| 823 | } |
| 824 | return request.result; |
| 825 | } |
| 826 | |
| 827 | /** |
| 828 | * Asynchronous ("fire and forget") version of sendRequest(): |
| 829 | * Posts the specified command to be executed on the main thread, and |
| 830 | * returns immediately. |
| 831 | * @see #sendRequest |
| 832 | */ |
| 833 | private void sendRequestAsync(int command) { |
| 834 | mMainThreadHandler.sendEmptyMessage(command); |
| 835 | } |
| 836 | |
| 837 | /** |
Sailesh Nepal | bd76e4e | 2013-10-27 13:59:44 -0700 | [diff] [blame] | 838 | * Same as {@link #sendRequestAsync(int)} except it takes an argument. |
| 839 | * @see {@link #sendRequest(int,Object)} |
| 840 | */ |
| 841 | private void sendRequestAsync(int command, Object argument) { |
| 842 | MainThreadRequest request = new MainThreadRequest(argument); |
| 843 | Message msg = mMainThreadHandler.obtainMessage(command, request); |
| 844 | msg.sendToTarget(); |
| 845 | } |
| 846 | |
| 847 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 848 | * Initialize the singleton PhoneInterfaceManager instance. |
| 849 | * This is only done once, at startup, from PhoneApp.onCreate(). |
| 850 | */ |
Sailesh Nepal | 194161e | 2014-07-03 08:57:44 -0700 | [diff] [blame] | 851 | /* package */ static PhoneInterfaceManager init(PhoneGlobals app, Phone phone) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 852 | synchronized (PhoneInterfaceManager.class) { |
| 853 | if (sInstance == null) { |
Sailesh Nepal | 194161e | 2014-07-03 08:57:44 -0700 | [diff] [blame] | 854 | sInstance = new PhoneInterfaceManager(app, phone); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 855 | } else { |
| 856 | Log.wtf(LOG_TAG, "init() called multiple times! sInstance = " + sInstance); |
| 857 | } |
| 858 | return sInstance; |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | /** Private constructor; @see init() */ |
Sailesh Nepal | 194161e | 2014-07-03 08:57:44 -0700 | [diff] [blame] | 863 | private PhoneInterfaceManager(PhoneGlobals app, Phone phone) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 864 | mApp = app; |
| 865 | mPhone = phone; |
| 866 | mCM = PhoneGlobals.getInstance().mCM; |
Stuart Scott | 981d858 | 2015-04-21 14:09:50 -0700 | [diff] [blame] | 867 | mUserManager = (UserManager) app.getSystemService(Context.USER_SERVICE); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 868 | mAppOps = (AppOpsManager)app.getSystemService(Context.APP_OPS_SERVICE); |
| 869 | mMainThreadHandler = new MainThreadHandler(); |
Andrew Lee | df14ead | 2014-10-17 14:22:52 -0700 | [diff] [blame] | 870 | mTelephonySharedPreferences = |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 871 | PreferenceManager.getDefaultSharedPreferences(mPhone.getContext()); |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 872 | mSubscriptionController = SubscriptionController.getInstance(); |
Wink Saville | 3ab207e | 2014-11-20 13:07:20 -0800 | [diff] [blame] | 873 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 874 | publish(); |
| 875 | } |
| 876 | |
| 877 | private void publish() { |
| 878 | if (DBG) log("publish: " + this); |
| 879 | |
| 880 | ServiceManager.addService("phone", this); |
| 881 | } |
| 882 | |
Stuart Scott | 584921c | 2015-01-15 17:10:34 -0800 | [diff] [blame] | 883 | private Phone getPhoneFromRequest(MainThreadRequest request) { |
Sanket Padawe | 56e75a3 | 2016-02-08 12:18:19 -0800 | [diff] [blame] | 884 | return (request.subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) |
| 885 | ? mPhone : getPhone(request.subId); |
Stuart Scott | 584921c | 2015-01-15 17:10:34 -0800 | [diff] [blame] | 886 | } |
| 887 | |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 888 | private UiccCard getUiccCardFromRequest(MainThreadRequest request) { |
| 889 | Phone phone = getPhoneFromRequest(request); |
| 890 | return phone == null ? null : |
| 891 | UiccController.getInstance().getUiccCard(phone.getPhoneId()); |
| 892 | } |
| 893 | |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 894 | // returns phone associated with the subId. |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 895 | private Phone getPhone(int subId) { |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 896 | return PhoneFactory.getPhone(mSubscriptionController.getPhoneId(subId)); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 897 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 898 | // |
| 899 | // Implementation of the ITelephony interface. |
| 900 | // |
| 901 | |
| 902 | public void dial(String number) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 903 | dialForSubscriber(getPreferredVoiceSubscription(), number); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 904 | } |
| 905 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 906 | public void dialForSubscriber(int subId, String number) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 907 | if (DBG) log("dial: " + number); |
| 908 | // No permission check needed here: This is just a wrapper around the |
| 909 | // ACTION_DIAL intent, which is available to any app since it puts up |
| 910 | // the UI before it does anything. |
| 911 | |
| 912 | String url = createTelUrl(number); |
| 913 | if (url == null) { |
| 914 | return; |
| 915 | } |
| 916 | |
| 917 | // PENDING: should we just silently fail if phone is offhook or ringing? |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 918 | PhoneConstants.State state = mCM.getState(subId); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 919 | if (state != PhoneConstants.State.OFFHOOK && state != PhoneConstants.State.RINGING) { |
| 920 | Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); |
| 921 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 922 | mApp.startActivity(intent); |
| 923 | } |
| 924 | } |
| 925 | |
| 926 | public void call(String callingPackage, String number) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 927 | callForSubscriber(getPreferredVoiceSubscription(), callingPackage, number); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 928 | } |
| 929 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 930 | public void callForSubscriber(int subId, String callingPackage, String number) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 931 | if (DBG) log("call: " + number); |
| 932 | |
| 933 | // This is just a wrapper around the ACTION_CALL intent, but we still |
| 934 | // need to do a permission check since we're calling startActivity() |
| 935 | // from the context of the phone app. |
| 936 | enforceCallPermission(); |
| 937 | |
| 938 | if (mAppOps.noteOp(AppOpsManager.OP_CALL_PHONE, Binder.getCallingUid(), callingPackage) |
| 939 | != AppOpsManager.MODE_ALLOWED) { |
| 940 | return; |
| 941 | } |
| 942 | |
| 943 | String url = createTelUrl(number); |
| 944 | if (url == null) { |
| 945 | return; |
| 946 | } |
| 947 | |
Wink Saville | 0887461 | 2014-08-31 19:19:58 -0700 | [diff] [blame] | 948 | boolean isValid = false; |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 949 | final List<SubscriptionInfo> slist = getActiveSubscriptionInfoList(); |
Wink Saville | 3ab207e | 2014-11-20 13:07:20 -0800 | [diff] [blame] | 950 | if (slist != null) { |
| 951 | for (SubscriptionInfo subInfoRecord : slist) { |
| 952 | if (subInfoRecord.getSubscriptionId() == subId) { |
| 953 | isValid = true; |
| 954 | break; |
| 955 | } |
Wink Saville | 0887461 | 2014-08-31 19:19:58 -0700 | [diff] [blame] | 956 | } |
| 957 | } |
| 958 | if (isValid == false) { |
| 959 | return; |
| 960 | } |
| 961 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 962 | Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url)); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 963 | intent.putExtra(SUBSCRIPTION_KEY, subId); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 964 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 965 | mApp.startActivity(intent); |
| 966 | } |
| 967 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 968 | /** |
| 969 | * End a call based on call state |
| 970 | * @return true is a call was ended |
| 971 | */ |
| 972 | public boolean endCall() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 973 | return endCallForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | /** |
| 977 | * End a call based on the call state of the subId |
| 978 | * @return true is a call was ended |
| 979 | */ |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 980 | public boolean endCallForSubscriber(int subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 981 | enforceCallPermission(); |
Stuart Scott | 584921c | 2015-01-15 17:10:34 -0800 | [diff] [blame] | 982 | return (Boolean) sendRequest(CMD_END_CALL, null, new Integer(subId)); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 983 | } |
| 984 | |
| 985 | public void answerRingingCall() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 986 | answerRingingCallForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 987 | } |
| 988 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 989 | public void answerRingingCallForSubscriber(int subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 990 | if (DBG) log("answerRingingCall..."); |
| 991 | // TODO: there should eventually be a separate "ANSWER_PHONE" permission, |
| 992 | // but that can probably wait till the big TelephonyManager API overhaul. |
| 993 | // For now, protect this call with the MODIFY_PHONE_STATE permission. |
| 994 | enforceModifyPermission(); |
Stuart Scott | 584921c | 2015-01-15 17:10:34 -0800 | [diff] [blame] | 995 | sendRequest(CMD_ANSWER_RINGING_CALL, null, new Integer(subId)); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 996 | } |
| 997 | |
| 998 | /** |
| 999 | * Make the actual telephony calls to implement answerRingingCall(). |
| 1000 | * This should only be called from the main thread of the Phone app. |
| 1001 | * @see #answerRingingCall |
| 1002 | * |
| 1003 | * TODO: it would be nice to return true if we answered the call, or |
| 1004 | * false if there wasn't actually a ringing incoming call, or some |
| 1005 | * other error occurred. (In other words, pass back the return value |
| 1006 | * from PhoneUtils.answerCall() or PhoneUtils.answerAndEndActive().) |
| 1007 | * But that would require calling this method via sendRequest() rather |
| 1008 | * than sendRequestAsync(), and right now we don't actually *need* that |
| 1009 | * return value, so let's just return void for now. |
| 1010 | */ |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1011 | private void answerRingingCallInternal(int subId) { |
Wink Saville | 0887461 | 2014-08-31 19:19:58 -0700 | [diff] [blame] | 1012 | final boolean hasRingingCall = !getPhone(subId).getRingingCall().isIdle(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1013 | if (hasRingingCall) { |
Wink Saville | 0887461 | 2014-08-31 19:19:58 -0700 | [diff] [blame] | 1014 | final boolean hasActiveCall = !getPhone(subId).getForegroundCall().isIdle(); |
| 1015 | final boolean hasHoldingCall = !getPhone(subId).getBackgroundCall().isIdle(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1016 | if (hasActiveCall && hasHoldingCall) { |
| 1017 | // Both lines are in use! |
| 1018 | // TODO: provide a flag to let the caller specify what |
| 1019 | // policy to use if both lines are in use. (The current |
| 1020 | // behavior is hardwired to "answer incoming, end ongoing", |
| 1021 | // which is how the CALL button is specced to behave.) |
| 1022 | PhoneUtils.answerAndEndActive(mCM, mCM.getFirstActiveRingingCall()); |
| 1023 | return; |
| 1024 | } else { |
| 1025 | // answerCall() will automatically hold the current active |
| 1026 | // call, if there is one. |
| 1027 | PhoneUtils.answerCall(mCM.getFirstActiveRingingCall()); |
| 1028 | return; |
| 1029 | } |
| 1030 | } else { |
| 1031 | // No call was ringing. |
| 1032 | return; |
| 1033 | } |
| 1034 | } |
| 1035 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1036 | /** |
Santos Cordon | 5422a8d | 2014-09-12 04:20:56 -0700 | [diff] [blame] | 1037 | * This method is no longer used and can be removed once TelephonyManager stops referring to it. |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1038 | */ |
Santos Cordon | 5422a8d | 2014-09-12 04:20:56 -0700 | [diff] [blame] | 1039 | public void silenceRinger() { |
| 1040 | Log.e(LOG_TAG, "silenseRinger not supported"); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1041 | } |
| 1042 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1043 | @Override |
| 1044 | public boolean isOffhook(String callingPackage) { |
| 1045 | return isOffhookForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1048 | @Override |
| 1049 | public boolean isOffhookForSubscriber(int subId, String callingPackage) { |
| 1050 | if (!canReadPhoneState(callingPackage, "isOffhookForSubscriber")) { |
| 1051 | return false; |
| 1052 | } |
| 1053 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1054 | final Phone phone = getPhone(subId); |
| 1055 | if (phone != null) { |
| 1056 | return (phone.getState() == PhoneConstants.State.OFFHOOK); |
| 1057 | } else { |
| 1058 | return false; |
| 1059 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1062 | @Override |
| 1063 | public boolean isRinging(String callingPackage) { |
| 1064 | return (isRingingForSubscriber(getDefaultSubscription(), callingPackage)); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1065 | } |
| 1066 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1067 | @Override |
| 1068 | public boolean isRingingForSubscriber(int subId, String callingPackage) { |
| 1069 | if (!canReadPhoneState(callingPackage, "isRingingForSubscriber")) { |
| 1070 | return false; |
| 1071 | } |
| 1072 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1073 | final Phone phone = getPhone(subId); |
| 1074 | if (phone != null) { |
| 1075 | return (phone.getState() == PhoneConstants.State.RINGING); |
| 1076 | } else { |
| 1077 | return false; |
| 1078 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1079 | } |
| 1080 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1081 | @Override |
| 1082 | public boolean isIdle(String callingPackage) { |
| 1083 | return isIdleForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1084 | } |
| 1085 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1086 | @Override |
| 1087 | public boolean isIdleForSubscriber(int subId, String callingPackage) { |
| 1088 | if (!canReadPhoneState(callingPackage, "isIdleForSubscriber")) { |
| 1089 | return false; |
| 1090 | } |
| 1091 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1092 | final Phone phone = getPhone(subId); |
| 1093 | if (phone != null) { |
| 1094 | return (phone.getState() == PhoneConstants.State.IDLE); |
| 1095 | } else { |
| 1096 | return false; |
| 1097 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1098 | } |
| 1099 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1100 | public boolean supplyPin(String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1101 | return supplyPinForSubscriber(getDefaultSubscription(), pin); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1102 | } |
| 1103 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1104 | public boolean supplyPinForSubscriber(int subId, String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1105 | int [] resultArray = supplyPinReportResultForSubscriber(subId, pin); |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1106 | return (resultArray[0] == PhoneConstants.PIN_RESULT_SUCCESS) ? true : false; |
| 1107 | } |
| 1108 | |
| 1109 | public boolean supplyPuk(String puk, String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1110 | return supplyPukForSubscriber(getDefaultSubscription(), puk, pin); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1111 | } |
| 1112 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1113 | public boolean supplyPukForSubscriber(int subId, String puk, String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1114 | int [] resultArray = supplyPukReportResultForSubscriber(subId, puk, pin); |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1115 | return (resultArray[0] == PhoneConstants.PIN_RESULT_SUCCESS) ? true : false; |
| 1116 | } |
| 1117 | |
| 1118 | /** {@hide} */ |
| 1119 | public int[] supplyPinReportResult(String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1120 | return supplyPinReportResultForSubscriber(getDefaultSubscription(), pin); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1121 | } |
| 1122 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1123 | public int[] supplyPinReportResultForSubscriber(int subId, String pin) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1124 | enforceModifyPermission(); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1125 | final UnlockSim checkSimPin = new UnlockSim(getPhone(subId).getIccCard()); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1126 | checkSimPin.start(); |
| 1127 | return checkSimPin.unlockSim(null, pin); |
| 1128 | } |
| 1129 | |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1130 | /** {@hide} */ |
| 1131 | public int[] supplyPukReportResult(String puk, String pin) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1132 | return supplyPukReportResultForSubscriber(getDefaultSubscription(), puk, pin); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1133 | } |
| 1134 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1135 | public int[] supplyPukReportResultForSubscriber(int subId, String puk, String pin) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1136 | enforceModifyPermission(); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1137 | final UnlockSim checkSimPuk = new UnlockSim(getPhone(subId).getIccCard()); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1138 | checkSimPuk.start(); |
| 1139 | return checkSimPuk.unlockSim(puk, pin); |
| 1140 | } |
| 1141 | |
| 1142 | /** |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1143 | * Helper thread to turn async call to SimCard#supplyPin into |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1144 | * a synchronous one. |
| 1145 | */ |
| 1146 | private static class UnlockSim extends Thread { |
| 1147 | |
| 1148 | private final IccCard mSimCard; |
| 1149 | |
| 1150 | private boolean mDone = false; |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1151 | private int mResult = PhoneConstants.PIN_GENERAL_FAILURE; |
| 1152 | private int mRetryCount = -1; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1153 | |
| 1154 | // For replies from SimCard interface |
| 1155 | private Handler mHandler; |
| 1156 | |
| 1157 | // For async handler to identify request type |
| 1158 | private static final int SUPPLY_PIN_COMPLETE = 100; |
| 1159 | |
| 1160 | public UnlockSim(IccCard simCard) { |
| 1161 | mSimCard = simCard; |
| 1162 | } |
| 1163 | |
| 1164 | @Override |
| 1165 | public void run() { |
| 1166 | Looper.prepare(); |
| 1167 | synchronized (UnlockSim.this) { |
| 1168 | mHandler = new Handler() { |
| 1169 | @Override |
| 1170 | public void handleMessage(Message msg) { |
| 1171 | AsyncResult ar = (AsyncResult) msg.obj; |
| 1172 | switch (msg.what) { |
| 1173 | case SUPPLY_PIN_COMPLETE: |
| 1174 | Log.d(LOG_TAG, "SUPPLY_PIN_COMPLETE"); |
| 1175 | synchronized (UnlockSim.this) { |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1176 | mRetryCount = msg.arg1; |
| 1177 | if (ar.exception != null) { |
| 1178 | if (ar.exception instanceof CommandException && |
| 1179 | ((CommandException)(ar.exception)).getCommandError() |
| 1180 | == CommandException.Error.PASSWORD_INCORRECT) { |
| 1181 | mResult = PhoneConstants.PIN_PASSWORD_INCORRECT; |
| 1182 | } else { |
| 1183 | mResult = PhoneConstants.PIN_GENERAL_FAILURE; |
| 1184 | } |
| 1185 | } else { |
| 1186 | mResult = PhoneConstants.PIN_RESULT_SUCCESS; |
| 1187 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1188 | mDone = true; |
| 1189 | UnlockSim.this.notifyAll(); |
| 1190 | } |
| 1191 | break; |
| 1192 | } |
| 1193 | } |
| 1194 | }; |
| 1195 | UnlockSim.this.notifyAll(); |
| 1196 | } |
| 1197 | Looper.loop(); |
| 1198 | } |
| 1199 | |
| 1200 | /* |
| 1201 | * Use PIN or PUK to unlock SIM card |
| 1202 | * |
| 1203 | * If PUK is null, unlock SIM card with PIN |
| 1204 | * |
| 1205 | * If PUK is not null, unlock SIM card with PUK and set PIN code |
| 1206 | */ |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1207 | synchronized int[] unlockSim(String puk, String pin) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1208 | |
| 1209 | while (mHandler == null) { |
| 1210 | try { |
| 1211 | wait(); |
| 1212 | } catch (InterruptedException e) { |
| 1213 | Thread.currentThread().interrupt(); |
| 1214 | } |
| 1215 | } |
| 1216 | Message callback = Message.obtain(mHandler, SUPPLY_PIN_COMPLETE); |
| 1217 | |
| 1218 | if (puk == null) { |
| 1219 | mSimCard.supplyPin(pin, callback); |
| 1220 | } else { |
| 1221 | mSimCard.supplyPuk(puk, pin, callback); |
| 1222 | } |
| 1223 | |
| 1224 | while (!mDone) { |
| 1225 | try { |
| 1226 | Log.d(LOG_TAG, "wait for done"); |
| 1227 | wait(); |
| 1228 | } catch (InterruptedException e) { |
| 1229 | // Restore the interrupted status |
| 1230 | Thread.currentThread().interrupt(); |
| 1231 | } |
| 1232 | } |
| 1233 | Log.d(LOG_TAG, "done"); |
Wink Saville | 9de0f75 | 2013-10-22 19:04:03 -0700 | [diff] [blame] | 1234 | int[] resultArray = new int[2]; |
| 1235 | resultArray[0] = mResult; |
| 1236 | resultArray[1] = mRetryCount; |
| 1237 | return resultArray; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | public void updateServiceLocation() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1242 | updateServiceLocationForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1243 | |
| 1244 | } |
| 1245 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1246 | public void updateServiceLocationForSubscriber(int subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1247 | // No permission check needed here: this call is harmless, and it's |
| 1248 | // needed for the ServiceState.requestStateUpdate() call (which is |
| 1249 | // already intentionally exposed to 3rd parties.) |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1250 | final Phone phone = getPhone(subId); |
| 1251 | if (phone != null) { |
| 1252 | phone.updateServiceLocation(); |
| 1253 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1254 | } |
| 1255 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1256 | @Override |
| 1257 | public boolean isRadioOn(String callingPackage) { |
| 1258 | return isRadioOnForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1259 | } |
| 1260 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1261 | @Override |
| 1262 | public boolean isRadioOnForSubscriber(int subId, String callingPackage) { |
| 1263 | if (!canReadPhoneState(callingPackage, "isRadioOnForSubscriber")) { |
| 1264 | return false; |
| 1265 | } |
| 1266 | return isRadioOnForSubscriber(subId); |
| 1267 | } |
| 1268 | |
| 1269 | private boolean isRadioOnForSubscriber(int subId) { |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1270 | final Phone phone = getPhone(subId); |
| 1271 | if (phone != null) { |
| 1272 | return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF; |
| 1273 | } else { |
| 1274 | return false; |
| 1275 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1276 | } |
| 1277 | |
| 1278 | public void toggleRadioOnOff() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1279 | toggleRadioOnOffForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1280 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1281 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1282 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1283 | public void toggleRadioOnOffForSubscriber(int subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1284 | enforceModifyPermission(); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1285 | final Phone phone = getPhone(subId); |
| 1286 | if (phone != null) { |
| 1287 | phone.setRadioPower(!isRadioOnForSubscriber(subId)); |
| 1288 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1289 | } |
| 1290 | |
| 1291 | public boolean setRadio(boolean turnOn) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1292 | return setRadioForSubscriber(getDefaultSubscription(), turnOn); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1293 | } |
| 1294 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1295 | public boolean setRadioForSubscriber(int subId, boolean turnOn) { |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1296 | enforceModifyPermission(); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1297 | final Phone phone = getPhone(subId); |
| 1298 | if (phone == null) { |
| 1299 | return false; |
| 1300 | } |
| 1301 | if ((phone.getServiceState().getState() != |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1302 | ServiceState.STATE_POWER_OFF) != turnOn) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1303 | toggleRadioOnOffForSubscriber(subId); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1304 | } |
| 1305 | return true; |
| 1306 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1307 | |
Naveen Kalla | 1fd79bd | 2014-08-08 00:48:59 -0700 | [diff] [blame] | 1308 | public boolean needMobileRadioShutdown() { |
| 1309 | /* |
| 1310 | * If any of the Radios are available, it will need to be |
| 1311 | * shutdown. So return true if any Radio is available. |
| 1312 | */ |
| 1313 | for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { |
| 1314 | Phone phone = PhoneFactory.getPhone(i); |
| 1315 | if (phone != null && phone.isRadioAvailable()) return true; |
| 1316 | } |
| 1317 | logv(TelephonyManager.getDefault().getPhoneCount() + " Phones are shutdown."); |
| 1318 | return false; |
| 1319 | } |
| 1320 | |
| 1321 | public void shutdownMobileRadios() { |
| 1322 | for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { |
| 1323 | logv("Shutting down Phone " + i); |
| 1324 | shutdownRadioUsingPhoneId(i); |
| 1325 | } |
| 1326 | } |
| 1327 | |
| 1328 | private void shutdownRadioUsingPhoneId(int phoneId) { |
| 1329 | enforceModifyPermission(); |
| 1330 | Phone phone = PhoneFactory.getPhone(phoneId); |
| 1331 | if (phone != null && phone.isRadioAvailable()) { |
| 1332 | phone.shutdownRadio(); |
| 1333 | } |
| 1334 | } |
| 1335 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1336 | public boolean setRadioPower(boolean turnOn) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1337 | return setRadioPowerForSubscriber(getDefaultSubscription(), turnOn); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1338 | } |
| 1339 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1340 | public boolean setRadioPowerForSubscriber(int subId, boolean turnOn) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1341 | enforceModifyPermission(); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1342 | final Phone phone = getPhone(subId); |
| 1343 | if (phone != null) { |
| 1344 | phone.setRadioPower(turnOn); |
| 1345 | return true; |
| 1346 | } else { |
| 1347 | return false; |
| 1348 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1349 | } |
| 1350 | |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1351 | // FIXME: subId version needed |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1352 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1353 | public boolean enableDataConnectivity() { |
| 1354 | enforceModifyPermission(); |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 1355 | int subId = mSubscriptionController.getDefaultDataSubId(); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1356 | final Phone phone = getPhone(subId); |
| 1357 | if (phone != null) { |
| 1358 | phone.setDataEnabled(true); |
| 1359 | return true; |
| 1360 | } else { |
| 1361 | return false; |
| 1362 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1363 | } |
| 1364 | |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1365 | // FIXME: subId version needed |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1366 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1367 | public boolean disableDataConnectivity() { |
| 1368 | enforceModifyPermission(); |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 1369 | int subId = mSubscriptionController.getDefaultDataSubId(); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1370 | final Phone phone = getPhone(subId); |
| 1371 | if (phone != null) { |
| 1372 | phone.setDataEnabled(false); |
| 1373 | return true; |
| 1374 | } else { |
| 1375 | return false; |
| 1376 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1377 | } |
| 1378 | |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1379 | // FIXME: subId version needed |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1380 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1381 | public boolean isDataConnectivityPossible() { |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 1382 | int subId = mSubscriptionController.getDefaultDataSubId(); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1383 | final Phone phone = getPhone(subId); |
| 1384 | if (phone != null) { |
| 1385 | return phone.isDataConnectivityPossible(); |
| 1386 | } else { |
| 1387 | return false; |
| 1388 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1389 | } |
| 1390 | |
| 1391 | public boolean handlePinMmi(String dialString) { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1392 | return handlePinMmiForSubscriber(getDefaultSubscription(), dialString); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1393 | } |
| 1394 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1395 | public boolean handlePinMmiForSubscriber(int subId, String dialString) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1396 | enforceModifyPermission(); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1397 | if (!SubscriptionManager.isValidSubscriptionId(subId)) { |
| 1398 | return false; |
| 1399 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1400 | return (Boolean) sendRequest(CMD_HANDLE_PIN_MMI, dialString, subId); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1401 | } |
| 1402 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1403 | public int getCallState() { |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 1404 | return getCallStateForSlot(getSlotForDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1405 | } |
| 1406 | |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 1407 | public int getCallStateForSlot(int slotId) { |
| 1408 | Phone phone = PhoneFactory.getPhone(slotId); |
| 1409 | return phone == null ? TelephonyManager.CALL_STATE_IDLE : |
| 1410 | DefaultPhoneNotifier.convertCallState(phone.getState()); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1411 | } |
| 1412 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1413 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1414 | public int getDataState() { |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 1415 | Phone phone = getPhone(mSubscriptionController.getDefaultDataSubId()); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1416 | if (phone != null) { |
| 1417 | return DefaultPhoneNotifier.convertDataState(phone.getDataConnectionState()); |
| 1418 | } else { |
| 1419 | return DefaultPhoneNotifier.convertDataState(PhoneConstants.DataState.DISCONNECTED); |
| 1420 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1421 | } |
| 1422 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1423 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1424 | public int getDataActivity() { |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 1425 | Phone phone = getPhone(mSubscriptionController.getDefaultDataSubId()); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1426 | if (phone != null) { |
| 1427 | return DefaultPhoneNotifier.convertDataActivityState(phone.getDataActivityState()); |
| 1428 | } else { |
| 1429 | return TelephonyManager.DATA_ACTIVITY_NONE; |
| 1430 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1431 | } |
| 1432 | |
| 1433 | @Override |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1434 | public Bundle getCellLocation(String callingPackage) { |
| 1435 | enforceFineOrCoarseLocationPermission("getCellLocation"); |
| 1436 | |
| 1437 | // OP_COARSE_LOCATION controls both fine and coarse location. |
| 1438 | if (mAppOps.noteOp(AppOpsManager.OP_COARSE_LOCATION, Binder.getCallingUid(), |
| 1439 | callingPackage) != AppOpsManager.MODE_ALLOWED) { |
Amit Mahajan | 9acc70d | 2015-06-02 13:17:33 -0700 | [diff] [blame] | 1440 | log("getCellLocation: returning null; mode != allowed"); |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1441 | return null; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1442 | } |
| 1443 | |
Sanket Padawe | ee13a9b | 2016-03-08 17:30:28 -0800 | [diff] [blame] | 1444 | if (checkIfCallerIsSelfOrForegroundUser() || |
| 1445 | checkCallerInteractAcrossUsersFull()) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1446 | if (DBG_LOC) log("getCellLocation: is active user"); |
| 1447 | Bundle data = new Bundle(); |
Legler Wu | 2c01cdf | 2014-12-08 19:00:59 +0800 | [diff] [blame] | 1448 | Phone phone = getPhone(mSubscriptionController.getDefaultDataSubId()); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1449 | if (phone == null) { |
| 1450 | return null; |
| 1451 | } |
Legler Wu | 2c01cdf | 2014-12-08 19:00:59 +0800 | [diff] [blame] | 1452 | phone.getCellLocation().fillInNotifierBundle(data); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1453 | return data; |
| 1454 | } else { |
Amit Mahajan | 9acc70d | 2015-06-02 13:17:33 -0700 | [diff] [blame] | 1455 | log("getCellLocation: suppress non-active user"); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1456 | return null; |
| 1457 | } |
| 1458 | } |
| 1459 | |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1460 | private void enforceFineOrCoarseLocationPermission(String message) { |
| 1461 | try { |
| 1462 | mApp.enforceCallingOrSelfPermission( |
| 1463 | android.Manifest.permission.ACCESS_FINE_LOCATION, null); |
| 1464 | } catch (SecurityException e) { |
| 1465 | // If we have ACCESS_FINE_LOCATION permission, skip the check for ACCESS_COARSE_LOCATION |
| 1466 | // A failure should throw the SecurityException from ACCESS_COARSE_LOCATION since this |
| 1467 | // is the weaker precondition |
| 1468 | mApp.enforceCallingOrSelfPermission( |
| 1469 | android.Manifest.permission.ACCESS_COARSE_LOCATION, message); |
| 1470 | } |
| 1471 | } |
| 1472 | |
| 1473 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1474 | @Override |
| 1475 | public void enableLocationUpdates() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1476 | enableLocationUpdatesForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1477 | } |
| 1478 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1479 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1480 | public void enableLocationUpdatesForSubscriber(int subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1481 | mApp.enforceCallingOrSelfPermission( |
| 1482 | android.Manifest.permission.CONTROL_LOCATION_UPDATES, null); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1483 | final Phone phone = getPhone(subId); |
| 1484 | if (phone != null) { |
| 1485 | phone.enableLocationUpdates(); |
| 1486 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1487 | } |
| 1488 | |
| 1489 | @Override |
| 1490 | public void disableLocationUpdates() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1491 | disableLocationUpdatesForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1492 | } |
| 1493 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1494 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1495 | public void disableLocationUpdatesForSubscriber(int subId) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1496 | mApp.enforceCallingOrSelfPermission( |
| 1497 | android.Manifest.permission.CONTROL_LOCATION_UPDATES, null); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1498 | final Phone phone = getPhone(subId); |
| 1499 | if (phone != null) { |
| 1500 | phone.disableLocationUpdates(); |
| 1501 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1502 | } |
| 1503 | |
| 1504 | @Override |
| 1505 | @SuppressWarnings("unchecked") |
| 1506 | public List<NeighboringCellInfo> getNeighboringCellInfo(String callingPackage) { |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1507 | enforceFineOrCoarseLocationPermission("getNeighboringCellInfo"); |
| 1508 | |
| 1509 | // OP_COARSE_LOCATION controls both fine and coarse location. |
| 1510 | if (mAppOps.noteOp(AppOpsManager.OP_COARSE_LOCATION, Binder.getCallingUid(), |
| 1511 | callingPackage) != AppOpsManager.MODE_ALLOWED) { |
| 1512 | return null; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1513 | } |
| 1514 | |
| 1515 | if (mAppOps.noteOp(AppOpsManager.OP_NEIGHBORING_CELLS, Binder.getCallingUid(), |
| 1516 | callingPackage) != AppOpsManager.MODE_ALLOWED) { |
| 1517 | return null; |
| 1518 | } |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1519 | |
Sanket Padawe | ee13a9b | 2016-03-08 17:30:28 -0800 | [diff] [blame] | 1520 | if (checkIfCallerIsSelfOrForegroundUser() || |
| 1521 | checkCallerInteractAcrossUsersFull()) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1522 | if (DBG_LOC) log("getNeighboringCellInfo: is active user"); |
| 1523 | |
| 1524 | ArrayList<NeighboringCellInfo> cells = null; |
| 1525 | |
| 1526 | try { |
| 1527 | cells = (ArrayList<NeighboringCellInfo>) sendRequest( |
Sanket Padawe | 56e75a3 | 2016-02-08 12:18:19 -0800 | [diff] [blame] | 1528 | CMD_HANDLE_NEIGHBORING_CELL, null, |
| 1529 | SubscriptionManager.INVALID_SUBSCRIPTION_ID); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1530 | } catch (RuntimeException e) { |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1531 | Log.e(LOG_TAG, "getNeighboringCellInfo " + e); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1532 | } |
| 1533 | return cells; |
| 1534 | } else { |
| 1535 | if (DBG_LOC) log("getNeighboringCellInfo: suppress non-active user"); |
| 1536 | return null; |
| 1537 | } |
| 1538 | } |
| 1539 | |
| 1540 | |
| 1541 | @Override |
Svetoslav | 64fad26 | 2015-04-14 14:35:21 -0700 | [diff] [blame] | 1542 | public List<CellInfo> getAllCellInfo(String callingPackage) { |
| 1543 | enforceFineOrCoarseLocationPermission("getAllCellInfo"); |
| 1544 | |
| 1545 | // OP_COARSE_LOCATION controls both fine and coarse location. |
| 1546 | if (mAppOps.noteOp(AppOpsManager.OP_COARSE_LOCATION, Binder.getCallingUid(), |
| 1547 | callingPackage) != AppOpsManager.MODE_ALLOWED) { |
| 1548 | return null; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1549 | } |
| 1550 | |
Sanket Padawe | ee13a9b | 2016-03-08 17:30:28 -0800 | [diff] [blame] | 1551 | if (checkIfCallerIsSelfOrForegroundUser() || |
| 1552 | checkCallerInteractAcrossUsersFull()) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1553 | if (DBG_LOC) log("getAllCellInfo: is active user"); |
Legler Wu | 2c01cdf | 2014-12-08 19:00:59 +0800 | [diff] [blame] | 1554 | List<CellInfo> cellInfos = new ArrayList<CellInfo>(); |
| 1555 | for (Phone phone : PhoneFactory.getPhones()) { |
Robert Greenwalt | d9eb7da | 2015-08-19 12:18:12 -0700 | [diff] [blame] | 1556 | final List<CellInfo> info = phone.getAllCellInfo(); |
| 1557 | if (info != null) cellInfos.addAll(phone.getAllCellInfo()); |
Legler Wu | 2c01cdf | 2014-12-08 19:00:59 +0800 | [diff] [blame] | 1558 | } |
| 1559 | return cellInfos; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1560 | } else { |
| 1561 | if (DBG_LOC) log("getAllCellInfo: suppress non-active user"); |
| 1562 | return null; |
| 1563 | } |
| 1564 | } |
| 1565 | |
Sailesh Nepal | bd76e4e | 2013-10-27 13:59:44 -0700 | [diff] [blame] | 1566 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1567 | public void setCellInfoListRate(int rateInMillis) { |
| 1568 | mPhone.setCellInfoListRate(rateInMillis); |
| 1569 | } |
| 1570 | |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 1571 | @Override |
| 1572 | public String getImeiForSlot(int slotId, String callingPackage) { |
| 1573 | if (!canReadPhoneState(callingPackage, "getImeiForSlot")) { |
| 1574 | return null; |
| 1575 | } |
| 1576 | Phone phone = PhoneFactory.getPhone(slotId); |
| 1577 | return phone == null ? null : phone.getImei(); |
| 1578 | } |
| 1579 | |
| 1580 | @Override |
| 1581 | public String getDeviceSoftwareVersionForSlot(int slotId, String callingPackage) { |
| 1582 | if (!canReadPhoneState(callingPackage, "getDeviceSoftwareVersionForSlot")) { |
| 1583 | return null; |
| 1584 | } |
| 1585 | Phone phone = PhoneFactory.getPhone(slotId); |
| 1586 | return phone == null ? null : phone.getDeviceSvn(); |
| 1587 | } |
| 1588 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1589 | // |
| 1590 | // Internal helper methods. |
| 1591 | // |
| 1592 | |
Sanket Padawe | ee13a9b | 2016-03-08 17:30:28 -0800 | [diff] [blame] | 1593 | /** |
| 1594 | * Returns true if the caller holds INTERACT_ACROSS_USERS_FULL. |
| 1595 | */ |
| 1596 | private boolean checkCallerInteractAcrossUsersFull() { |
| 1597 | return mPhone.getContext().checkCallingOrSelfPermission( |
| 1598 | android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
| 1599 | == PackageManager.PERMISSION_GRANTED; |
| 1600 | } |
| 1601 | |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 1602 | private static boolean checkIfCallerIsSelfOrForegroundUser() { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1603 | boolean ok; |
| 1604 | |
| 1605 | boolean self = Binder.getCallingUid() == Process.myUid(); |
| 1606 | if (!self) { |
| 1607 | // Get the caller's user id then clear the calling identity |
| 1608 | // which will be restored in the finally clause. |
| 1609 | int callingUser = UserHandle.getCallingUserId(); |
| 1610 | long ident = Binder.clearCallingIdentity(); |
| 1611 | |
| 1612 | try { |
| 1613 | // With calling identity cleared the current user is the foreground user. |
| 1614 | int foregroundUser = ActivityManager.getCurrentUser(); |
| 1615 | ok = (foregroundUser == callingUser); |
| 1616 | if (DBG_LOC) { |
| 1617 | log("checkIfCallerIsSelfOrForegoundUser: foregroundUser=" + foregroundUser |
| 1618 | + " callingUser=" + callingUser + " ok=" + ok); |
| 1619 | } |
| 1620 | } catch (Exception ex) { |
| 1621 | if (DBG_LOC) loge("checkIfCallerIsSelfOrForegoundUser: Exception ex=" + ex); |
| 1622 | ok = false; |
| 1623 | } finally { |
| 1624 | Binder.restoreCallingIdentity(ident); |
| 1625 | } |
| 1626 | } else { |
| 1627 | if (DBG_LOC) log("checkIfCallerIsSelfOrForegoundUser: is self"); |
| 1628 | ok = true; |
| 1629 | } |
| 1630 | if (DBG_LOC) log("checkIfCallerIsSelfOrForegoundUser: ret=" + ok); |
| 1631 | return ok; |
| 1632 | } |
| 1633 | |
| 1634 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1635 | * Make sure the caller has the MODIFY_PHONE_STATE permission. |
| 1636 | * |
| 1637 | * @throws SecurityException if the caller does not have the required permission |
| 1638 | */ |
| 1639 | private void enforceModifyPermission() { |
| 1640 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE, null); |
| 1641 | } |
| 1642 | |
| 1643 | /** |
Junda Liu | a2e3601 | 2014-07-09 18:30:01 -0700 | [diff] [blame] | 1644 | * Make sure either system app or the caller has carrier privilege. |
| 1645 | * |
| 1646 | * @throws SecurityException if the caller does not have the required permission/privilege |
| 1647 | */ |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 1648 | private void enforceModifyPermissionOrCarrierPrivilege(int subId) { |
Shishir Agrawal | f1ac4c9 | 2014-07-14 13:54:28 -0700 | [diff] [blame] | 1649 | int permission = mApp.checkCallingOrSelfPermission( |
| 1650 | android.Manifest.permission.MODIFY_PHONE_STATE); |
| 1651 | if (permission == PackageManager.PERMISSION_GRANTED) { |
| 1652 | return; |
| 1653 | } |
| 1654 | |
| 1655 | log("No modify permission, check carrier privilege next."); |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 1656 | enforceCarrierPrivilege(subId); |
Junda Liu | a2e3601 | 2014-07-09 18:30:01 -0700 | [diff] [blame] | 1657 | } |
| 1658 | |
| 1659 | /** |
| 1660 | * Make sure the caller has carrier privilege. |
| 1661 | * |
| 1662 | * @throws SecurityException if the caller does not have the required permission |
| 1663 | */ |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 1664 | private void enforceCarrierPrivilege(int subId) { |
| 1665 | if (getCarrierPrivilegeStatus(subId) != |
| 1666 | TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { |
Shishir Agrawal | f1ac4c9 | 2014-07-14 13:54:28 -0700 | [diff] [blame] | 1667 | loge("No Carrier Privilege."); |
| 1668 | throw new SecurityException("No Carrier Privilege."); |
Junda Liu | a2e3601 | 2014-07-09 18:30:01 -0700 | [diff] [blame] | 1669 | } |
| 1670 | } |
| 1671 | |
| 1672 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1673 | * Make sure the caller has the CALL_PHONE permission. |
| 1674 | * |
| 1675 | * @throws SecurityException if the caller does not have the required permission |
| 1676 | */ |
| 1677 | private void enforceCallPermission() { |
| 1678 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.CALL_PHONE, null); |
| 1679 | } |
| 1680 | |
Stuart Scott | 8eef64f | 2015-04-08 15:13:54 -0700 | [diff] [blame] | 1681 | private void enforceConnectivityInternalPermission() { |
| 1682 | mApp.enforceCallingOrSelfPermission( |
| 1683 | android.Manifest.permission.CONNECTIVITY_INTERNAL, |
| 1684 | "ConnectivityService"); |
| 1685 | } |
| 1686 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1687 | private String createTelUrl(String number) { |
| 1688 | if (TextUtils.isEmpty(number)) { |
| 1689 | return null; |
| 1690 | } |
| 1691 | |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 1692 | return "tel:" + number; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1693 | } |
| 1694 | |
Ihab Awad | f9e9273 | 2013-12-05 18:02:52 -0800 | [diff] [blame] | 1695 | private static void log(String msg) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1696 | Log.d(LOG_TAG, "[PhoneIntfMgr] " + msg); |
| 1697 | } |
| 1698 | |
Naveen Kalla | 1fd79bd | 2014-08-08 00:48:59 -0700 | [diff] [blame] | 1699 | private static void logv(String msg) { |
| 1700 | Log.v(LOG_TAG, "[PhoneIntfMgr] " + msg); |
| 1701 | } |
| 1702 | |
Ihab Awad | f9e9273 | 2013-12-05 18:02:52 -0800 | [diff] [blame] | 1703 | private static void loge(String msg) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1704 | Log.e(LOG_TAG, "[PhoneIntfMgr] " + msg); |
| 1705 | } |
| 1706 | |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1707 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1708 | public int getActivePhoneType() { |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 1709 | return getActivePhoneTypeForSlot(getSlotForDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1710 | } |
| 1711 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1712 | @Override |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 1713 | public int getActivePhoneTypeForSlot(int slotId) { |
| 1714 | final Phone phone = PhoneFactory.getPhone(slotId); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1715 | if (phone == null) { |
| 1716 | return PhoneConstants.PHONE_TYPE_NONE; |
| 1717 | } else { |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 1718 | return phone.getPhoneType(); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1719 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1720 | } |
| 1721 | |
| 1722 | /** |
| 1723 | * Returns the CDMA ERI icon index to display |
| 1724 | */ |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1725 | @Override |
| 1726 | public int getCdmaEriIconIndex(String callingPackage) { |
| 1727 | return getCdmaEriIconIndexForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1728 | } |
| 1729 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1730 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1731 | public int getCdmaEriIconIndexForSubscriber(int subId, String callingPackage) { |
| 1732 | if (!canReadPhoneState(callingPackage, "getCdmaEriIconIndexForSubscriber")) { |
| 1733 | return -1; |
| 1734 | } |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1735 | final Phone phone = getPhone(subId); |
| 1736 | if (phone != null) { |
| 1737 | return phone.getCdmaEriIconIndex(); |
| 1738 | } else { |
| 1739 | return -1; |
| 1740 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1741 | } |
| 1742 | |
| 1743 | /** |
| 1744 | * Returns the CDMA ERI icon mode, |
| 1745 | * 0 - ON |
| 1746 | * 1 - FLASHING |
| 1747 | */ |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1748 | @Override |
| 1749 | public int getCdmaEriIconMode(String callingPackage) { |
| 1750 | return getCdmaEriIconModeForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1751 | } |
| 1752 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1753 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1754 | public int getCdmaEriIconModeForSubscriber(int subId, String callingPackage) { |
| 1755 | if (!canReadPhoneState(callingPackage, "getCdmaEriIconModeForSubscriber")) { |
| 1756 | return -1; |
| 1757 | } |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1758 | final Phone phone = getPhone(subId); |
| 1759 | if (phone != null) { |
| 1760 | return phone.getCdmaEriIconMode(); |
| 1761 | } else { |
| 1762 | return -1; |
| 1763 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1764 | } |
| 1765 | |
| 1766 | /** |
| 1767 | * Returns the CDMA ERI text, |
| 1768 | */ |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1769 | @Override |
| 1770 | public String getCdmaEriText(String callingPackage) { |
| 1771 | return getCdmaEriTextForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1772 | } |
| 1773 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1774 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1775 | public String getCdmaEriTextForSubscriber(int subId, String callingPackage) { |
| 1776 | if (!canReadPhoneState(callingPackage, "getCdmaEriIconTextForSubscriber")) { |
| 1777 | return null; |
| 1778 | } |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1779 | final Phone phone = getPhone(subId); |
| 1780 | if (phone != null) { |
| 1781 | return phone.getCdmaEriText(); |
| 1782 | } else { |
| 1783 | return null; |
| 1784 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1785 | } |
| 1786 | |
| 1787 | /** |
Junda Liu | ca05d5d | 2014-08-14 22:36:34 -0700 | [diff] [blame] | 1788 | * Returns the CDMA MDN. |
| 1789 | */ |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1790 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1791 | public String getCdmaMdn(int subId) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 1792 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1793 | final Phone phone = getPhone(subId); |
| 1794 | if (mPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA && phone != null) { |
| 1795 | return phone.getLine1Number(); |
Junda Liu | ca05d5d | 2014-08-14 22:36:34 -0700 | [diff] [blame] | 1796 | } else { |
| 1797 | return null; |
| 1798 | } |
| 1799 | } |
| 1800 | |
| 1801 | /** |
| 1802 | * Returns the CDMA MIN. |
| 1803 | */ |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1804 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1805 | public String getCdmaMin(int subId) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 1806 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1807 | final Phone phone = getPhone(subId); |
| 1808 | if (phone != null && phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) { |
| 1809 | return phone.getCdmaMin(); |
Junda Liu | ca05d5d | 2014-08-14 22:36:34 -0700 | [diff] [blame] | 1810 | } else { |
| 1811 | return null; |
| 1812 | } |
| 1813 | } |
| 1814 | |
| 1815 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1816 | * Returns true if CDMA provisioning needs to run. |
| 1817 | */ |
| 1818 | public boolean needsOtaServiceProvisioning() { |
| 1819 | return mPhone.needsOtaServiceProvisioning(); |
| 1820 | } |
| 1821 | |
| 1822 | /** |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 1823 | * Sets the voice mail number of a given subId. |
| 1824 | */ |
| 1825 | @Override |
| 1826 | public boolean setVoiceMailNumber(int subId, String alphaTag, String number) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 1827 | enforceCarrierPrivilege(subId); |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 1828 | Boolean success = (Boolean) sendRequest(CMD_SET_VOICEMAIL_NUMBER, |
| 1829 | new Pair<String, String>(alphaTag, number), new Integer(subId)); |
| 1830 | return success; |
| 1831 | } |
| 1832 | |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 1833 | @Override |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame^] | 1834 | public void enableVisualVoicemailSmsFilter(String callingPackage, int subId, |
| 1835 | VisualVoicemailSmsFilterSettings settings) { |
| 1836 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 1837 | VisualVoicemailSmsFilterConfig |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame^] | 1838 | .enableVisualVoicemailSmsFilter(mPhone.getContext(), callingPackage, subId, |
| 1839 | settings); |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 1840 | } |
| 1841 | |
| 1842 | @Override |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame^] | 1843 | public void disableVisualVoicemailSmsFilter(String callingPackage, int subId) { |
| 1844 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 1845 | VisualVoicemailSmsFilterConfig |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame^] | 1846 | .disableVisualVoicemailSmsFilter(mPhone.getContext(), callingPackage, subId); |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 1847 | } |
| 1848 | |
| 1849 | @Override |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame^] | 1850 | public VisualVoicemailSmsFilterSettings getVisualVoicemailSmsFilterSettings( |
| 1851 | String callingPackage, int subId) { |
| 1852 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 1853 | return VisualVoicemailSmsFilterConfig |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame^] | 1854 | .getVisualVoicemailSmsFilterSettings(mPhone.getContext(), callingPackage, subId); |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 1855 | } |
| 1856 | |
| 1857 | @Override |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame^] | 1858 | public VisualVoicemailSmsFilterSettings getSystemVisualVoicemailSmsFilterSettings( |
| 1859 | String packageName, int subId) { |
| 1860 | enforceReadPrivilegedPermission(); |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 1861 | return VisualVoicemailSmsFilterConfig |
Ta-wei Yen | b692960 | 2016-05-24 15:48:27 -0700 | [diff] [blame^] | 1862 | .getVisualVoicemailSmsFilterSettings(mPhone.getContext(), packageName, subId); |
Ta-wei Yen | 87c4984 | 2016-05-13 21:19:52 -0700 | [diff] [blame] | 1863 | } |
Shishir Agrawal | 76d5da9 | 2014-11-09 16:17:25 -0800 | [diff] [blame] | 1864 | /** |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1865 | * Returns the unread count of voicemails |
| 1866 | */ |
| 1867 | public int getVoiceMessageCount() { |
Wink Saville | add7cc5 | 2014-09-08 14:23:09 -0700 | [diff] [blame] | 1868 | return getVoiceMessageCountForSubscriber(getDefaultSubscription()); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1869 | } |
| 1870 | |
| 1871 | /** |
| 1872 | * Returns the unread count of voicemails for a subId |
| 1873 | */ |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1874 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1875 | public int getVoiceMessageCountForSubscriber( int subId) { |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1876 | final Phone phone = getPhone(subId); |
| 1877 | if (phone != null) { |
| 1878 | return phone.getVoiceMessageCount(); |
| 1879 | } else { |
| 1880 | return 0; |
| 1881 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1882 | } |
| 1883 | |
| 1884 | /** |
Robert Greenwalt | a5dcfcb | 2015-07-10 09:06:29 -0700 | [diff] [blame] | 1885 | * Returns the data network type. |
| 1886 | * Legacy call, permission-free. |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1887 | * |
| 1888 | * @Deprecated to be removed Q3 2013 use {@link #getDataNetworkType}. |
| 1889 | */ |
| 1890 | @Override |
Robert Greenwalt | a5dcfcb | 2015-07-10 09:06:29 -0700 | [diff] [blame] | 1891 | public int getNetworkType() { |
| 1892 | final Phone phone = getPhone(getDefaultSubscription()); |
| 1893 | if (phone != null) { |
| 1894 | return phone.getServiceState().getDataNetworkType(); |
| 1895 | } else { |
| 1896 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 1897 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1898 | } |
| 1899 | |
| 1900 | /** |
| 1901 | * Returns the network type for a subId |
| 1902 | */ |
| 1903 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1904 | public int getNetworkTypeForSubscriber(int subId, String callingPackage) { |
| 1905 | if (!canReadPhoneState(callingPackage, "getNetworkTypeForSubscriber")) { |
| 1906 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 1907 | } |
Robert Greenwalt | a5dcfcb | 2015-07-10 09:06:29 -0700 | [diff] [blame] | 1908 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1909 | final Phone phone = getPhone(subId); |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1910 | if (phone != null) { |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1911 | return phone.getServiceState().getDataNetworkType(); |
| 1912 | } else { |
| 1913 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 1914 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1915 | } |
| 1916 | |
| 1917 | /** |
| 1918 | * Returns the data network type |
| 1919 | */ |
| 1920 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1921 | public int getDataNetworkType(String callingPackage) { |
| 1922 | return getDataNetworkTypeForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1923 | } |
| 1924 | |
| 1925 | /** |
| 1926 | * Returns the data network type for a subId |
| 1927 | */ |
| 1928 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1929 | public int getDataNetworkTypeForSubscriber(int subId, String callingPackage) { |
| 1930 | if (!canReadPhoneState(callingPackage, "getDataNetworkTypeForSubscriber")) { |
| 1931 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 1932 | } |
| 1933 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1934 | final Phone phone = getPhone(subId); |
| 1935 | if (phone != null) { |
| 1936 | return phone.getServiceState().getDataNetworkType(); |
| 1937 | } else { |
| 1938 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 1939 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1940 | } |
| 1941 | |
| 1942 | /** |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1943 | * Returns the Voice network type for a subId |
| 1944 | */ |
| 1945 | @Override |
Robert Greenwalt | a5dcfcb | 2015-07-10 09:06:29 -0700 | [diff] [blame] | 1946 | public int getVoiceNetworkTypeForSubscriber(int subId, String callingPackage) { |
| 1947 | if (!canReadPhoneState(callingPackage, "getDataNetworkTypeForSubscriber")) { |
| 1948 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 1949 | } |
| 1950 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1951 | final Phone phone = getPhone(subId); |
| 1952 | if (phone != null) { |
| 1953 | return phone.getServiceState().getVoiceNetworkType(); |
| 1954 | } else { |
| 1955 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 1956 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1957 | } |
| 1958 | |
| 1959 | /** |
| 1960 | * @return true if a ICC card is present |
| 1961 | */ |
| 1962 | public boolean hasIccCard() { |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1963 | // FIXME Make changes to pass defaultSimId of type int |
Amit Mahajan | a6fc2a8 | 2015-01-06 11:53:51 -0800 | [diff] [blame] | 1964 | return hasIccCardUsingSlotId(mSubscriptionController.getSlotId(getDefaultSubscription())); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1965 | } |
| 1966 | |
| 1967 | /** |
| 1968 | * @return true if a ICC card is present for a slotId |
| 1969 | */ |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1970 | @Override |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 1971 | public boolean hasIccCardUsingSlotId(int slotId) { |
Amit Mahajan | a6fc2a8 | 2015-01-06 11:53:51 -0800 | [diff] [blame] | 1972 | int subId[] = mSubscriptionController.getSubIdUsingSlotId(slotId); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1973 | final Phone phone = getPhone(subId[0]); |
| 1974 | if (subId != null && phone != null) { |
| 1975 | return phone.getIccCard().hasIccCard(); |
Amit Mahajan | a6fc2a8 | 2015-01-06 11:53:51 -0800 | [diff] [blame] | 1976 | } else { |
| 1977 | return false; |
| 1978 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1979 | } |
| 1980 | |
| 1981 | /** |
| 1982 | * Return if the current radio is LTE on CDMA. This |
| 1983 | * is a tri-state return value as for a period of time |
| 1984 | * the mode may be unknown. |
| 1985 | * |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1986 | * @param callingPackage the name of the package making the call. |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1987 | * @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] | 1988 | * or {@link Phone#LTE_ON_CDMA_TRUE} |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1989 | */ |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1990 | @Override |
| 1991 | public int getLteOnCdmaMode(String callingPackage) { |
| 1992 | return getLteOnCdmaModeForSubscriber(getDefaultSubscription(), callingPackage); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 1993 | } |
| 1994 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 1995 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 1996 | public int getLteOnCdmaModeForSubscriber(int subId, String callingPackage) { |
| 1997 | if (!canReadPhoneState(callingPackage, "getLteOnCdmaModeForSubscriber")) { |
| 1998 | return PhoneConstants.LTE_ON_CDMA_UNKNOWN; |
| 1999 | } |
| 2000 | |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2001 | final Phone phone = getPhone(subId); |
| 2002 | if (phone == null) { |
| 2003 | return PhoneConstants.LTE_ON_CDMA_UNKNOWN; |
| 2004 | } else { |
| 2005 | return phone.getLteOnCdmaMode(); |
| 2006 | } |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2007 | } |
| 2008 | |
| 2009 | public void setPhone(Phone phone) { |
| 2010 | mPhone = phone; |
| 2011 | } |
| 2012 | |
| 2013 | /** |
| 2014 | * {@hide} |
| 2015 | * Returns Default subId, 0 in the case of single standby. |
| 2016 | */ |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 2017 | private int getDefaultSubscription() { |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 2018 | return mSubscriptionController.getDefaultSubId(); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2019 | } |
| 2020 | |
Shishir Agrawal | a9f3218 | 2016-04-12 12:00:16 -0700 | [diff] [blame] | 2021 | private int getSlotForDefaultSubscription() { |
| 2022 | return mSubscriptionController.getPhoneId(getDefaultSubscription()); |
| 2023 | } |
| 2024 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 2025 | private int getPreferredVoiceSubscription() { |
Wink Saville | ac1bdfd | 2014-11-20 23:04:44 -0800 | [diff] [blame] | 2026 | return mSubscriptionController.getDefaultVoiceSubId(); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 2027 | } |
Ihab Awad | f2177b7 | 2013-11-25 13:33:23 -0800 | [diff] [blame] | 2028 | |
| 2029 | /** |
| 2030 | * @see android.telephony.TelephonyManager.WifiCallingChoices |
| 2031 | */ |
| 2032 | public int getWhenToMakeWifiCalls() { |
Sailesh Nepal | d1e6815 | 2013-12-12 19:08:02 -0800 | [diff] [blame] | 2033 | return Settings.System.getInt(mPhone.getContext().getContentResolver(), |
| 2034 | Settings.System.WHEN_TO_MAKE_WIFI_CALLS, getWhenToMakeWifiCallsDefaultPreference()); |
Ihab Awad | f2177b7 | 2013-11-25 13:33:23 -0800 | [diff] [blame] | 2035 | } |
| 2036 | |
| 2037 | /** |
| 2038 | * @see android.telephony.TelephonyManager.WifiCallingChoices |
| 2039 | */ |
| 2040 | public void setWhenToMakeWifiCalls(int preference) { |
Sailesh Nepal | d1e6815 | 2013-12-12 19:08:02 -0800 | [diff] [blame] | 2041 | if (DBG) log("setWhenToMakeWifiCallsStr, storing setting = " + preference); |
| 2042 | Settings.System.putInt(mPhone.getContext().getContentResolver(), |
| 2043 | Settings.System.WHEN_TO_MAKE_WIFI_CALLS, preference); |
Ihab Awad | f9e9273 | 2013-12-05 18:02:52 -0800 | [diff] [blame] | 2044 | } |
| 2045 | |
Sailesh Nepal | d1e6815 | 2013-12-12 19:08:02 -0800 | [diff] [blame] | 2046 | private static int getWhenToMakeWifiCallsDefaultPreference() { |
Santos Cordon | da120f4 | 2014-08-06 04:44:34 -0700 | [diff] [blame] | 2047 | // TODO: Use a build property to choose this value. |
Evan Charlton | 9829e88 | 2013-12-19 15:30:38 -0800 | [diff] [blame] | 2048 | return TelephonyManager.WifiCallingChoices.ALWAYS_USE; |
Ihab Awad | f2177b7 | 2013-11-25 13:33:23 -0800 | [diff] [blame] | 2049 | } |
Shishir Agrawal | 69f6812 | 2013-12-16 17:25:49 -0800 | [diff] [blame] | 2050 | |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2051 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2052 | public IccOpenLogicalChannelResponse iccOpenLogicalChannel(int subId, String AID) { |
| 2053 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2054 | |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2055 | if (DBG) log("iccOpenLogicalChannel: subId=" + subId + " aid=" + AID); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2056 | IccOpenLogicalChannelResponse response = (IccOpenLogicalChannelResponse)sendRequest( |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2057 | CMD_OPEN_CHANNEL, AID, subId); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2058 | if (DBG) log("iccOpenLogicalChannel: " + response); |
| 2059 | return response; |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2060 | } |
| 2061 | |
| 2062 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2063 | public boolean iccCloseLogicalChannel(int subId, int channel) { |
| 2064 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2065 | |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2066 | if (DBG) log("iccCloseLogicalChannel: subId=" + subId + " chnl=" + channel); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2067 | if (channel < 0) { |
| 2068 | return false; |
| 2069 | } |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2070 | Boolean success = (Boolean)sendRequest(CMD_CLOSE_CHANNEL, channel, subId); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2071 | if (DBG) log("iccCloseLogicalChannel: " + success); |
| 2072 | return success; |
| 2073 | } |
| 2074 | |
| 2075 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2076 | public String iccTransmitApduLogicalChannel(int subId, int channel, int cla, |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2077 | int command, int p1, int p2, int p3, String data) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2078 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2079 | |
| 2080 | if (DBG) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2081 | log("iccTransmitApduLogicalChannel: subId=" + subId + " chnl=" + channel + |
| 2082 | " cla=" + cla + " cmd=" + command + " p1=" + p1 + " p2=" + p2 + " p3=" + p3 + |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2083 | " data=" + data); |
| 2084 | } |
| 2085 | |
| 2086 | if (channel < 0) { |
| 2087 | return ""; |
| 2088 | } |
| 2089 | |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2090 | IccIoResult response = (IccIoResult)sendRequest(CMD_TRANSMIT_APDU_LOGICAL_CHANNEL, |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2091 | new IccAPDUArgument(channel, cla, command, p1, p2, p3, data), subId); |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2092 | if (DBG) log("iccTransmitApduLogicalChannel: " + response); |
| 2093 | |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2094 | // Append the returned status code to the end of the response payload. |
| 2095 | String s = Integer.toHexString( |
| 2096 | (response.sw1 << 8) + response.sw2 + 0x10000).substring(1); |
Shishir Agrawal | 5ec1417 | 2014-08-05 17:05:45 -0700 | [diff] [blame] | 2097 | if (response.payload != null) { |
| 2098 | s = IccUtils.bytesToHexString(response.payload) + s; |
| 2099 | } |
Shishir Agrawal | 566b761 | 2013-10-28 14:41:00 -0700 | [diff] [blame] | 2100 | return s; |
| 2101 | } |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 2102 | |
Evan Charlton | c66da36 | 2014-05-16 14:06:40 -0700 | [diff] [blame] | 2103 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2104 | public String iccTransmitApduBasicChannel(int subId, int cla, int command, int p1, int p2, |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2105 | int p3, String data) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2106 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2107 | |
| 2108 | if (DBG) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2109 | log("iccTransmitApduBasicChannel: subId=" + subId + " cla=" + cla + " cmd=" + command |
| 2110 | + " p1=" + p1 + " p2=" + p2 + " p3=" + p3 + " data=" + data); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2111 | } |
| 2112 | |
| 2113 | IccIoResult response = (IccIoResult)sendRequest(CMD_TRANSMIT_APDU_BASIC_CHANNEL, |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2114 | new IccAPDUArgument(0, cla, command, p1, p2, p3, data), subId); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2115 | if (DBG) log("iccTransmitApduBasicChannel: " + response); |
| 2116 | |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2117 | // Append the returned status code to the end of the response payload. |
| 2118 | String s = Integer.toHexString( |
| 2119 | (response.sw1 << 8) + response.sw2 + 0x10000).substring(1); |
Shishir Agrawal | 5ec1417 | 2014-08-05 17:05:45 -0700 | [diff] [blame] | 2120 | if (response.payload != null) { |
| 2121 | s = IccUtils.bytesToHexString(response.payload) + s; |
| 2122 | } |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2123 | return s; |
| 2124 | } |
| 2125 | |
| 2126 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2127 | 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] | 2128 | String filePath) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2129 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2130 | |
| 2131 | if (DBG) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2132 | log("Exchange SIM_IO " + subId + ":" + fileID + ":" + command + " " + |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2133 | p1 + " " + p2 + " " + p3 + ":" + filePath); |
| 2134 | } |
| 2135 | |
| 2136 | IccIoResult response = |
| 2137 | (IccIoResult)sendRequest(CMD_EXCHANGE_SIM_IO, |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2138 | new IccAPDUArgument(-1, fileID, command, p1, p2, p3, filePath), |
| 2139 | subId); |
Shishir Agrawal | da0bb0d | 2014-07-29 21:18:53 -0700 | [diff] [blame] | 2140 | |
| 2141 | if (DBG) { |
| 2142 | log("Exchange SIM_IO [R]" + response); |
| 2143 | } |
| 2144 | |
| 2145 | byte[] result = null; |
| 2146 | int length = 2; |
| 2147 | if (response.payload != null) { |
| 2148 | length = 2 + response.payload.length; |
| 2149 | result = new byte[length]; |
| 2150 | System.arraycopy(response.payload, 0, result, 0, response.payload.length); |
| 2151 | } else { |
| 2152 | result = new byte[length]; |
| 2153 | } |
| 2154 | |
| 2155 | result[length - 1] = (byte) response.sw2; |
| 2156 | result[length - 2] = (byte) response.sw1; |
| 2157 | return result; |
| 2158 | } |
| 2159 | |
| 2160 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2161 | public String sendEnvelopeWithStatus(int subId, String content) { |
| 2162 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Evan Charlton | c66da36 | 2014-05-16 14:06:40 -0700 | [diff] [blame] | 2163 | |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2164 | IccIoResult response = (IccIoResult)sendRequest(CMD_SEND_ENVELOPE, content, subId); |
Evan Charlton | c66da36 | 2014-05-16 14:06:40 -0700 | [diff] [blame] | 2165 | if (response.payload == null) { |
| 2166 | return ""; |
| 2167 | } |
| 2168 | |
| 2169 | // Append the returned status code to the end of the response payload. |
| 2170 | String s = Integer.toHexString( |
| 2171 | (response.sw1 << 8) + response.sw2 + 0x10000).substring(1); |
| 2172 | s = IccUtils.bytesToHexString(response.payload) + s; |
| 2173 | return s; |
| 2174 | } |
| 2175 | |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 2176 | /** |
| 2177 | * Read one of the NV items defined in {@link com.android.internal.telephony.RadioNVItems} |
| 2178 | * and {@code ril_nv_items.h}. Used for device configuration by some CDMA operators. |
| 2179 | * |
| 2180 | * @param itemID the ID of the item to read |
| 2181 | * @return the NV item as a String, or null on error. |
| 2182 | */ |
| 2183 | @Override |
| 2184 | public String nvReadItem(int itemID) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2185 | enforceModifyPermissionOrCarrierPrivilege(getDefaultSubscription()); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 2186 | if (DBG) log("nvReadItem: item " + itemID); |
| 2187 | String value = (String) sendRequest(CMD_NV_READ_ITEM, itemID); |
| 2188 | if (DBG) log("nvReadItem: item " + itemID + " is \"" + value + '"'); |
| 2189 | return value; |
| 2190 | } |
| 2191 | |
| 2192 | /** |
| 2193 | * Write one of the NV items defined in {@link com.android.internal.telephony.RadioNVItems} |
| 2194 | * and {@code ril_nv_items.h}. Used for device configuration by some CDMA operators. |
| 2195 | * |
| 2196 | * @param itemID the ID of the item to read |
| 2197 | * @param itemValue the value to write, as a String |
| 2198 | * @return true on success; false on any failure |
| 2199 | */ |
| 2200 | @Override |
| 2201 | public boolean nvWriteItem(int itemID, String itemValue) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2202 | enforceModifyPermissionOrCarrierPrivilege(getDefaultSubscription()); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 2203 | if (DBG) log("nvWriteItem: item " + itemID + " value \"" + itemValue + '"'); |
| 2204 | Boolean success = (Boolean) sendRequest(CMD_NV_WRITE_ITEM, |
| 2205 | new Pair<Integer, String>(itemID, itemValue)); |
| 2206 | if (DBG) log("nvWriteItem: item " + itemID + ' ' + (success ? "ok" : "fail")); |
| 2207 | return success; |
| 2208 | } |
| 2209 | |
| 2210 | /** |
| 2211 | * Update the CDMA Preferred Roaming List (PRL) in the radio NV storage. |
| 2212 | * Used for device configuration by some CDMA operators. |
| 2213 | * |
| 2214 | * @param preferredRoamingList byte array containing the new PRL |
| 2215 | * @return true on success; false on any failure |
| 2216 | */ |
| 2217 | @Override |
| 2218 | public boolean nvWriteCdmaPrl(byte[] preferredRoamingList) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2219 | enforceModifyPermissionOrCarrierPrivilege(getDefaultSubscription()); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 2220 | if (DBG) log("nvWriteCdmaPrl: value: " + HexDump.toHexString(preferredRoamingList)); |
| 2221 | Boolean success = (Boolean) sendRequest(CMD_NV_WRITE_CDMA_PRL, preferredRoamingList); |
| 2222 | if (DBG) log("nvWriteCdmaPrl: " + (success ? "ok" : "fail")); |
| 2223 | return success; |
| 2224 | } |
| 2225 | |
| 2226 | /** |
| 2227 | * Perform the specified type of NV config reset. |
| 2228 | * Used for device configuration by some CDMA operators. |
| 2229 | * |
| 2230 | * @param resetType the type of reset to perform (1 == factory reset; 2 == NV-only reset) |
| 2231 | * @return true on success; false on any failure |
| 2232 | */ |
| 2233 | @Override |
| 2234 | public boolean nvResetConfig(int resetType) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2235 | enforceModifyPermissionOrCarrierPrivilege(getDefaultSubscription()); |
Jake Hamby | e994d46 | 2014-02-03 13:10:13 -0800 | [diff] [blame] | 2236 | if (DBG) log("nvResetConfig: type " + resetType); |
| 2237 | Boolean success = (Boolean) sendRequest(CMD_NV_RESET_CONFIG, resetType); |
| 2238 | if (DBG) log("nvResetConfig: type " + resetType + ' ' + (success ? "ok" : "fail")); |
| 2239 | return success; |
| 2240 | } |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 2241 | |
| 2242 | /** |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2243 | * {@hide} |
| 2244 | * Returns Default sim, 0 in the case of single standby. |
| 2245 | */ |
| 2246 | public int getDefaultSim() { |
| 2247 | //TODO Need to get it from Telephony Devcontroller |
| 2248 | return 0; |
| 2249 | } |
| 2250 | |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 2251 | public String[] getPcscfAddress(String apnType, String callingPackage) { |
| 2252 | if (!canReadPhoneState(callingPackage, "getPcscfAddress")) { |
| 2253 | return new String[0]; |
| 2254 | } |
| 2255 | |
| 2256 | |
ram | 87fca6f | 2014-07-18 18:58:44 +0530 | [diff] [blame] | 2257 | return mPhone.getPcscfAddress(apnType); |
Wink Saville | 36469e7 | 2014-06-11 15:17:00 -0700 | [diff] [blame] | 2258 | } |
| 2259 | |
| 2260 | public void setImsRegistrationState(boolean registered) { |
| 2261 | enforceModifyPermission(); |
| 2262 | mPhone.setImsRegistrationState(registered); |
| 2263 | } |
| 2264 | |
| 2265 | /** |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 2266 | * Set the network selection mode to automatic. |
| 2267 | * |
| 2268 | */ |
| 2269 | @Override |
| 2270 | public void setNetworkSelectionModeAutomatic(int subId) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2271 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 2272 | if (DBG) log("setNetworkSelectionModeAutomatic: subId " + subId); |
| 2273 | sendRequest(CMD_SET_NETWORK_SELECTION_MODE_AUTOMATIC, null, subId); |
| 2274 | } |
| 2275 | |
| 2276 | /** |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 2277 | * Set the network selection mode to manual with the selected carrier. |
| 2278 | */ |
| 2279 | @Override |
Shishir Agrawal | 77ba317 | 2015-09-10 14:50:19 -0700 | [diff] [blame] | 2280 | public boolean setNetworkSelectionModeManual(int subId, OperatorInfo operator, |
| 2281 | boolean persistSelection) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2282 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 2283 | if (DBG) log("setNetworkSelectionModeManual: subId:" + subId + " operator:" + operator); |
Shishir Agrawal | 77ba317 | 2015-09-10 14:50:19 -0700 | [diff] [blame] | 2284 | ManualNetworkSelectionArgument arg = new ManualNetworkSelectionArgument(operator, |
| 2285 | persistSelection); |
| 2286 | return (Boolean) sendRequest(CMD_SET_NETWORK_SELECTION_MODE_MANUAL, arg, subId); |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 2287 | } |
| 2288 | |
| 2289 | /** |
| 2290 | * Scans for available networks. |
| 2291 | */ |
| 2292 | @Override |
| 2293 | public CellNetworkScanResult getCellNetworkScanResults(int subId) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2294 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Shishir Agrawal | 302c869 | 2015-06-19 13:49:39 -0700 | [diff] [blame] | 2295 | if (DBG) log("getCellNetworkScanResults: subId " + subId); |
| 2296 | CellNetworkScanResult result = (CellNetworkScanResult) sendRequest( |
| 2297 | CMD_PERFORM_NETWORK_SCAN, null, subId); |
| 2298 | return result; |
| 2299 | } |
| 2300 | |
| 2301 | /** |
Junda Liu | 84d15a2 | 2014-07-02 11:21:04 -0700 | [diff] [blame] | 2302 | * Get the calculated preferred network type. |
| 2303 | * Used for debugging incorrect network type. |
| 2304 | * |
| 2305 | * @return the preferred network type, defined in RILConstants.java. |
| 2306 | */ |
| 2307 | @Override |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 2308 | public int getCalculatedPreferredNetworkType(String callingPackage) { |
| 2309 | if (!canReadPhoneState(callingPackage, "getCalculatedPreferredNetworkType")) { |
| 2310 | return RILConstants.PREFERRED_NETWORK_MODE; |
| 2311 | } |
| 2312 | |
Amit Mahajan | 43330e0 | 2014-11-18 11:54:45 -0800 | [diff] [blame] | 2313 | return PhoneFactory.calculatePreferredNetworkType(mPhone.getContext(), 0); // wink FIXME: need to get SubId from somewhere. |
Junda Liu | 84d15a2 | 2014-07-02 11:21:04 -0700 | [diff] [blame] | 2314 | } |
| 2315 | |
| 2316 | /** |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 2317 | * Get the preferred network type. |
| 2318 | * Used for device configuration by some CDMA operators. |
| 2319 | * |
| 2320 | * @return the preferred network type, defined in RILConstants.java. |
| 2321 | */ |
| 2322 | @Override |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 2323 | public int getPreferredNetworkType(int subId) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2324 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 2325 | if (DBG) log("getPreferredNetworkType"); |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 2326 | int[] result = (int[]) sendRequest(CMD_GET_PREFERRED_NETWORK_TYPE, null, subId); |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 2327 | int networkType = (result != null ? result[0] : -1); |
| 2328 | if (DBG) log("getPreferredNetworkType: " + networkType); |
| 2329 | return networkType; |
| 2330 | } |
| 2331 | |
| 2332 | /** |
| 2333 | * Set the preferred network type. |
| 2334 | * Used for device configuration by some CDMA operators. |
| 2335 | * |
| 2336 | * @param networkType the preferred network type, defined in RILConstants.java. |
| 2337 | * @return true on success; false on any failure. |
| 2338 | */ |
| 2339 | @Override |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 2340 | public boolean setPreferredNetworkType(int subId, int networkType) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2341 | enforceModifyPermissionOrCarrierPrivilege(subId); |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 2342 | if (DBG) log("setPreferredNetworkType: subId " + subId + " type " + networkType); |
| 2343 | Boolean success = (Boolean) sendRequest(CMD_SET_PREFERRED_NETWORK_TYPE, networkType, subId); |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 2344 | if (DBG) log("setPreferredNetworkType: " + (success ? "ok" : "fail")); |
Junda Liu | 80bc0d1 | 2014-07-14 16:36:44 -0700 | [diff] [blame] | 2345 | if (success) { |
| 2346 | Settings.Global.putInt(mPhone.getContext().getContentResolver(), |
Stuart Scott | 5478880 | 2015-03-30 13:18:01 -0700 | [diff] [blame] | 2347 | Settings.Global.PREFERRED_NETWORK_MODE + subId, networkType); |
Junda Liu | 80bc0d1 | 2014-07-14 16:36:44 -0700 | [diff] [blame] | 2348 | } |
Jake Hamby | 7c27be3 | 2014-03-03 13:25:59 -0800 | [diff] [blame] | 2349 | return success; |
| 2350 | } |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 2351 | |
| 2352 | /** |
Junda Liu | 475951f | 2014-11-07 16:45:03 -0800 | [diff] [blame] | 2353 | * Check TETHER_DUN_REQUIRED and TETHER_DUN_APN settings, net.tethering.noprovisioning |
| 2354 | * SystemProperty, and config_tether_apndata to decide whether DUN APN is required for |
| 2355 | * tethering. |
| 2356 | * |
| 2357 | * @return 0: Not required. 1: required. 2: Not set. |
| 2358 | * @hide |
| 2359 | */ |
| 2360 | @Override |
| 2361 | public int getTetherApnRequired() { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2362 | enforceModifyPermission(); |
Junda Liu | 475951f | 2014-11-07 16:45:03 -0800 | [diff] [blame] | 2363 | int dunRequired = Settings.Global.getInt(mPhone.getContext().getContentResolver(), |
| 2364 | Settings.Global.TETHER_DUN_REQUIRED, 2); |
| 2365 | // If not set, check net.tethering.noprovisioning, TETHER_DUN_APN setting and |
| 2366 | // config_tether_apndata. |
| 2367 | if (dunRequired == 2 && mPhone.hasMatchedTetherApnSetting()) { |
| 2368 | dunRequired = 1; |
| 2369 | } |
| 2370 | return dunRequired; |
| 2371 | } |
| 2372 | |
| 2373 | /** |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 2374 | * Set mobile data enabled |
| 2375 | * Used by the user through settings etc to turn on/off mobile data |
| 2376 | * |
| 2377 | * @param enable {@code true} turn turn data on, else {@code false} |
| 2378 | */ |
| 2379 | @Override |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 2380 | public void setDataEnabled(int subId, boolean enable) { |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 2381 | enforceModifyPermission(); |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 2382 | int phoneId = mSubscriptionController.getPhoneId(subId); |
Joe Onorato | a601dd2 | 2016-02-23 13:03:53 -0800 | [diff] [blame] | 2383 | if (DBG) log("getDataEnabled: subId=" + subId + " phoneId=" + phoneId); |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 2384 | Phone phone = PhoneFactory.getPhone(phoneId); |
| 2385 | if (phone != null) { |
Joe Onorato | a601dd2 | 2016-02-23 13:03:53 -0800 | [diff] [blame] | 2386 | if (DBG) log("setDataEnabled: subId=" + subId + " enable=" + enable); |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 2387 | phone.setDataEnabled(enable); |
| 2388 | } else { |
| 2389 | loge("setDataEnabled: no phone for subId=" + subId); |
| 2390 | } |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 2391 | } |
| 2392 | |
| 2393 | /** |
Robert Greenwalt | 646120a | 2014-05-23 11:54:03 -0700 | [diff] [blame] | 2394 | * Get whether mobile data is enabled. |
| 2395 | * |
| 2396 | * Note that this used to be available from ConnectivityService, gated by |
| 2397 | * ACCESS_NETWORK_STATE permission, so this will accept either that or |
| 2398 | * our MODIFY_PHONE_STATE. |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 2399 | * |
| 2400 | * @return {@code true} if data is enabled else {@code false} |
| 2401 | */ |
| 2402 | @Override |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 2403 | public boolean getDataEnabled(int subId) { |
Robert Greenwalt | 646120a | 2014-05-23 11:54:03 -0700 | [diff] [blame] | 2404 | try { |
| 2405 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.ACCESS_NETWORK_STATE, |
| 2406 | null); |
| 2407 | } catch (Exception e) { |
| 2408 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE, |
| 2409 | null); |
| 2410 | } |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 2411 | int phoneId = mSubscriptionController.getPhoneId(subId); |
Joe Onorato | a601dd2 | 2016-02-23 13:03:53 -0800 | [diff] [blame] | 2412 | if (DBG) log("getDataEnabled: subId=" + subId + " phoneId=" + phoneId); |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 2413 | Phone phone = PhoneFactory.getPhone(phoneId); |
| 2414 | if (phone != null) { |
| 2415 | boolean retVal = phone.getDataEnabled(); |
Joe Onorato | a601dd2 | 2016-02-23 13:03:53 -0800 | [diff] [blame] | 2416 | if (DBG) log("getDataEnabled: subId=" + subId + " retVal=" + retVal); |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 2417 | return retVal; |
| 2418 | } else { |
Joe Onorato | a601dd2 | 2016-02-23 13:03:53 -0800 | [diff] [blame] | 2419 | if (DBG) loge("getDataEnabled: no phone subId=" + subId + " retVal=false"); |
Wink Saville | e7353bb | 2014-12-05 14:21:41 -0800 | [diff] [blame] | 2420 | return false; |
| 2421 | } |
Robert Greenwalt | ed86e58 | 2014-05-21 20:03:20 -0700 | [diff] [blame] | 2422 | } |
Shishir Agrawal | 60f9c95 | 2014-06-23 12:00:43 -0700 | [diff] [blame] | 2423 | |
| 2424 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2425 | public int getCarrierPrivilegeStatus(int subId) { |
| 2426 | final Phone phone = getPhone(subId); |
| 2427 | if (phone == null) { |
| 2428 | loge("getCarrierPrivilegeStatus: Invalid subId"); |
| 2429 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS; |
| 2430 | } |
| 2431 | UiccCard card = UiccController.getInstance().getUiccCard(phone.getPhoneId()); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 2432 | if (card == null) { |
Shishir Agrawal | 5e5becd | 2014-11-18 11:38:23 -0800 | [diff] [blame] | 2433 | loge("getCarrierPrivilegeStatus: No UICC"); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 2434 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED; |
| 2435 | } |
| 2436 | return card.getCarrierPrivilegeStatusForCurrentTransaction( |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2437 | phone.getContext().getPackageManager()); |
Shishir Agrawal | 60f9c95 | 2014-06-23 12:00:43 -0700 | [diff] [blame] | 2438 | } |
Junda Liu | 2934034 | 2014-07-10 15:23:27 -0700 | [diff] [blame] | 2439 | |
| 2440 | @Override |
Zach Johnson | 50ecba3 | 2015-05-19 00:24:21 -0700 | [diff] [blame] | 2441 | public int checkCarrierPrivilegesForPackage(String pkgName) { |
Junda Liu | 317d70b | 2016-03-08 09:33:53 -0800 | [diff] [blame] | 2442 | if (TextUtils.isEmpty(pkgName)) |
| 2443 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS; |
Shishir Agrawal | 2140925 | 2015-01-15 23:33:50 -0800 | [diff] [blame] | 2444 | UiccCard card = UiccController.getInstance().getUiccCard(mPhone.getPhoneId()); |
Shishir Agrawal | eb8771e | 2014-07-22 11:24:08 -0700 | [diff] [blame] | 2445 | if (card == null) { |
| 2446 | loge("checkCarrierPrivilegesForPackage: No UICC"); |
| 2447 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED; |
| 2448 | } |
Zach Johnson | 50ecba3 | 2015-05-19 00:24:21 -0700 | [diff] [blame] | 2449 | return card.getCarrierPrivilegeStatus(mPhone.getContext().getPackageManager(), pkgName); |
| 2450 | } |
| 2451 | |
| 2452 | @Override |
| 2453 | public int checkCarrierPrivilegesForPackageAnyPhone(String pkgName) { |
Junda Liu | 317d70b | 2016-03-08 09:33:53 -0800 | [diff] [blame] | 2454 | if (TextUtils.isEmpty(pkgName)) |
| 2455 | return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS; |
Zach Johnson | 50ecba3 | 2015-05-19 00:24:21 -0700 | [diff] [blame] | 2456 | int result = TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED; |
| 2457 | for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { |
| 2458 | UiccCard card = UiccController.getInstance().getUiccCard(i); |
| 2459 | if (card == null) { |
Jonathan Basseri | 7d320df | 2015-06-16 12:17:08 -0700 | [diff] [blame] | 2460 | // No UICC in that slot. |
Zach Johnson | 50ecba3 | 2015-05-19 00:24:21 -0700 | [diff] [blame] | 2461 | continue; |
| 2462 | } |
| 2463 | |
| 2464 | result = card.getCarrierPrivilegeStatus( |
| 2465 | mPhone.getContext().getPackageManager(), pkgName); |
| 2466 | if (result == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { |
| 2467 | break; |
| 2468 | } |
| 2469 | } |
| 2470 | |
| 2471 | return result; |
Junda Liu | 2934034 | 2014-07-10 15:23:27 -0700 | [diff] [blame] | 2472 | } |
Derek Tan | 89e89d4 | 2014-07-08 17:00:10 -0700 | [diff] [blame] | 2473 | |
| 2474 | @Override |
Junda Liu | e64de78 | 2015-04-16 17:19:16 -0700 | [diff] [blame] | 2475 | public List<String> getCarrierPackageNamesForIntentAndPhone(Intent intent, int phoneId) { |
| 2476 | if (!SubscriptionManager.isValidPhoneId(phoneId)) { |
| 2477 | loge("phoneId " + phoneId + " is not valid."); |
| 2478 | return null; |
| 2479 | } |
| 2480 | UiccCard card = UiccController.getInstance().getUiccCard(phoneId); |
Shishir Agrawal | eb6439a | 2014-07-21 13:19:38 -0700 | [diff] [blame] | 2481 | if (card == null) { |
Diego Pontoriero | af74c86 | 2014-08-28 11:51:16 -0700 | [diff] [blame] | 2482 | loge("getCarrierPackageNamesForIntent: No UICC"); |
Shishir Agrawal | eb6439a | 2014-07-21 13:19:38 -0700 | [diff] [blame] | 2483 | return null ; |
| 2484 | } |
Diego Pontoriero | af74c86 | 2014-08-28 11:51:16 -0700 | [diff] [blame] | 2485 | return card.getCarrierPackageNamesForIntent( |
Svetoslav | 483aff7 | 2015-04-21 14:16:07 -0700 | [diff] [blame] | 2486 | mPhone.getContext().getPackageManager(), intent); |
Shishir Agrawal | eb6439a | 2014-07-21 13:19:38 -0700 | [diff] [blame] | 2487 | } |
| 2488 | |
Amith Yamasani | 6e11887 | 2016-02-19 12:53:51 -0800 | [diff] [blame] | 2489 | @Override |
| 2490 | public List<String> getPackagesWithCarrierPrivileges() { |
| 2491 | PackageManager pm = mPhone.getContext().getPackageManager(); |
| 2492 | List<String> privilegedPackages = new ArrayList<>(); |
| 2493 | List<PackageInfo> packages = null; |
| 2494 | for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { |
| 2495 | UiccCard card = UiccController.getInstance().getUiccCard(i); |
| 2496 | if (card == null) { |
| 2497 | // No UICC in that slot. |
| 2498 | continue; |
| 2499 | } |
| 2500 | if (card.hasCarrierPrivilegeRules()) { |
| 2501 | if (packages == null) { |
| 2502 | // Only check packages in user 0 for now |
| 2503 | packages = pm.getInstalledPackagesAsUser( |
| 2504 | PackageManager.MATCH_DISABLED_COMPONENTS |
| 2505 | | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS |
| 2506 | | PackageManager.GET_SIGNATURES, UserHandle.USER_SYSTEM); |
| 2507 | } |
| 2508 | for (int p = packages.size() - 1; p >= 0; p--) { |
| 2509 | PackageInfo pkgInfo = packages.get(p); |
| 2510 | if (pkgInfo != null && pkgInfo.packageName != null |
| 2511 | && card.getCarrierPrivilegeStatus(pkgInfo) |
| 2512 | == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) { |
| 2513 | privilegedPackages.add(pkgInfo.packageName); |
| 2514 | } |
| 2515 | } |
| 2516 | } |
| 2517 | } |
| 2518 | return privilegedPackages; |
| 2519 | } |
| 2520 | |
Wink Saville | b564aae | 2014-10-23 10:18:09 -0700 | [diff] [blame] | 2521 | private String getIccId(int subId) { |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2522 | final Phone phone = getPhone(subId); |
| 2523 | UiccCard card = phone == null ? null : phone.getUiccCard(); |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 2524 | if (card == null) { |
| 2525 | loge("getIccId: No UICC"); |
| 2526 | return null; |
| 2527 | } |
| 2528 | String iccId = card.getIccId(); |
| 2529 | if (TextUtils.isEmpty(iccId)) { |
| 2530 | loge("getIccId: ICC ID is null or empty."); |
| 2531 | return null; |
| 2532 | } |
| 2533 | return iccId; |
| 2534 | } |
| 2535 | |
Shishir Agrawal | eb6439a | 2014-07-21 13:19:38 -0700 | [diff] [blame] | 2536 | @Override |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 2537 | public boolean setLine1NumberForDisplayForSubscriber(int subId, String alphaTag, |
| 2538 | String number) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2539 | enforceCarrierPrivilege(subId); |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 2540 | |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 2541 | final String iccId = getIccId(subId); |
Sanket Padawe | 356d763 | 2015-06-22 14:03:32 -0700 | [diff] [blame] | 2542 | final Phone phone = getPhone(subId); |
| 2543 | if (phone == null) { |
| 2544 | return false; |
| 2545 | } |
| 2546 | final String subscriberId = phone.getSubscriberId(); |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 2547 | |
| 2548 | if (DBG_MERGE) { |
| 2549 | Slog.d(LOG_TAG, "Setting line number for ICC=" + iccId + ", subscriberId=" |
| 2550 | + subscriberId + " to " + number); |
| 2551 | } |
| 2552 | |
Shishir Agrawal | 495d7e1 | 2014-12-01 11:50:28 -0800 | [diff] [blame] | 2553 | if (TextUtils.isEmpty(iccId)) { |
| 2554 | return false; |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 2555 | } |
Shishir Agrawal | 495d7e1 | 2014-12-01 11:50:28 -0800 | [diff] [blame] | 2556 | |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 2557 | final SharedPreferences.Editor editor = mTelephonySharedPreferences.edit(); |
| 2558 | |
| 2559 | final String alphaTagPrefKey = PREF_CARRIERS_ALPHATAG_PREFIX + iccId; |
Shishir Agrawal | 495d7e1 | 2014-12-01 11:50:28 -0800 | [diff] [blame] | 2560 | if (alphaTag == null) { |
| 2561 | editor.remove(alphaTagPrefKey); |
| 2562 | } else { |
| 2563 | editor.putString(alphaTagPrefKey, alphaTag); |
| 2564 | } |
| 2565 | |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 2566 | // Record both the line number and IMSI for this ICCID, since we need to |
| 2567 | // track all merged IMSIs based on line number |
| 2568 | final String numberPrefKey = PREF_CARRIERS_NUMBER_PREFIX + iccId; |
| 2569 | final String subscriberPrefKey = PREF_CARRIERS_SUBSCRIBER_PREFIX + iccId; |
Shishir Agrawal | 495d7e1 | 2014-12-01 11:50:28 -0800 | [diff] [blame] | 2570 | if (number == null) { |
| 2571 | editor.remove(numberPrefKey); |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 2572 | editor.remove(subscriberPrefKey); |
Shishir Agrawal | 495d7e1 | 2014-12-01 11:50:28 -0800 | [diff] [blame] | 2573 | } else { |
| 2574 | editor.putString(numberPrefKey, number); |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 2575 | editor.putString(subscriberPrefKey, subscriberId); |
Shishir Agrawal | 495d7e1 | 2014-12-01 11:50:28 -0800 | [diff] [blame] | 2576 | } |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 2577 | |
Shishir Agrawal | 495d7e1 | 2014-12-01 11:50:28 -0800 | [diff] [blame] | 2578 | editor.commit(); |
| 2579 | return true; |
Derek Tan | 7226c84 | 2014-07-02 17:42:23 -0700 | [diff] [blame] | 2580 | } |
| 2581 | |
| 2582 | @Override |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 2583 | public String getLine1NumberForDisplay(int subId, String callingPackage) { |
Makoto Onuki | fee6934 | 2015-06-29 14:44:50 -0700 | [diff] [blame] | 2584 | // This is open to apps with WRITE_SMS. |
| 2585 | if (!canReadPhoneNumber(callingPackage, "getLine1NumberForDisplay")) { |
Amit Mahajan | 9cf1151 | 2015-11-09 11:40:48 -0800 | [diff] [blame] | 2586 | if (DBG_MERGE) log("getLine1NumberForDisplay returning null due to permission"); |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 2587 | return null; |
| 2588 | } |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 2589 | |
| 2590 | String iccId = getIccId(subId); |
| 2591 | if (iccId != null) { |
| 2592 | String numberPrefKey = PREF_CARRIERS_NUMBER_PREFIX + iccId; |
Amit Mahajan | 9cf1151 | 2015-11-09 11:40:48 -0800 | [diff] [blame] | 2593 | if (DBG_MERGE) { |
| 2594 | log("getLine1NumberForDisplay returning " + |
| 2595 | mTelephonySharedPreferences.getString(numberPrefKey, null)); |
| 2596 | } |
Andrew Lee | df14ead | 2014-10-17 14:22:52 -0700 | [diff] [blame] | 2597 | return mTelephonySharedPreferences.getString(numberPrefKey, null); |
Derek Tan | 7226c84 | 2014-07-02 17:42:23 -0700 | [diff] [blame] | 2598 | } |
Amit Mahajan | 9cf1151 | 2015-11-09 11:40:48 -0800 | [diff] [blame] | 2599 | if (DBG_MERGE) log("getLine1NumberForDisplay returning null as iccId is null"); |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 2600 | return null; |
Derek Tan | 7226c84 | 2014-07-02 17:42:23 -0700 | [diff] [blame] | 2601 | } |
| 2602 | |
| 2603 | @Override |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 2604 | public String getLine1AlphaTagForDisplay(int subId, String callingPackage) { |
| 2605 | if (!canReadPhoneState(callingPackage, "getLine1AlphaTagForDisplay")) { |
| 2606 | return null; |
| 2607 | } |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 2608 | |
| 2609 | String iccId = getIccId(subId); |
| 2610 | if (iccId != null) { |
| 2611 | String alphaTagPrefKey = PREF_CARRIERS_ALPHATAG_PREFIX + iccId; |
Andrew Lee | df14ead | 2014-10-17 14:22:52 -0700 | [diff] [blame] | 2612 | return mTelephonySharedPreferences.getString(alphaTagPrefKey, null); |
Derek Tan | 7226c84 | 2014-07-02 17:42:23 -0700 | [diff] [blame] | 2613 | } |
Derek Tan | 97ebb42 | 2014-09-05 16:55:38 -0700 | [diff] [blame] | 2614 | return null; |
Derek Tan | 7226c84 | 2014-07-02 17:42:23 -0700 | [diff] [blame] | 2615 | } |
Shishir Agrawal | b1ebf8c | 2014-07-17 16:32:41 -0700 | [diff] [blame] | 2616 | |
| 2617 | @Override |
Fyodor Kupolov | 8e53b0b | 2015-06-17 13:17:50 -0700 | [diff] [blame] | 2618 | public String[] getMergedSubscriberIds(String callingPackage) { |
| 2619 | if (!canReadPhoneState(callingPackage, "getMergedSubscriberIds")) { |
| 2620 | return null; |
| 2621 | } |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 2622 | final Context context = mPhone.getContext(); |
| 2623 | final TelephonyManager tele = TelephonyManager.from(context); |
| 2624 | final SubscriptionManager sub = SubscriptionManager.from(context); |
| 2625 | |
| 2626 | // Figure out what subscribers are currently active |
| 2627 | final ArraySet<String> activeSubscriberIds = new ArraySet<>(); |
Fyodor Kupolov | 8e53b0b | 2015-06-17 13:17:50 -0700 | [diff] [blame] | 2628 | // Clear calling identity, when calling TelephonyManager, because callerUid must be |
| 2629 | // the process, where TelephonyManager was instantiated. Otherwise AppOps check will fail. |
| 2630 | final long identity = Binder.clearCallingIdentity(); |
| 2631 | try { |
| 2632 | final int[] subIds = sub.getActiveSubscriptionIdList(); |
| 2633 | for (int subId : subIds) { |
| 2634 | activeSubscriberIds.add(tele.getSubscriberId(subId)); |
| 2635 | } |
| 2636 | } finally { |
| 2637 | Binder.restoreCallingIdentity(identity); |
Jeff Sharkey | 85190e6 | 2014-12-05 09:40:12 -0800 | [diff] [blame] | 2638 | } |
| 2639 | |
| 2640 | // First pass, find a number override for an active subscriber |
| 2641 | String mergeNumber = null; |
| 2642 | final Map<String, ?> prefs = mTelephonySharedPreferences.getAll(); |
| 2643 | for (String key : prefs.keySet()) { |
| 2644 | if (key.startsWith(PREF_CARRIERS_SUBSCRIBER_PREFIX)) { |
| 2645 | final String subscriberId = (String) prefs.get(key); |
| 2646 | if (activeSubscriberIds.contains(subscriberId)) { |
| 2647 | final String iccId = key.substring(PREF_CARRIERS_SUBSCRIBER_PREFIX.length()); |
| 2648 | final String numberKey = PREF_CARRIERS_NUMBER_PREFIX + iccId; |
| 2649 | mergeNumber = (String) prefs.get(numberKey); |
| 2650 | if (DBG_MERGE) { |
| 2651 | Slog.d(LOG_TAG, "Found line number " + mergeNumber |
| 2652 | + " for active subscriber " + subscriberId); |
| 2653 | } |
| 2654 | if (!TextUtils.isEmpty(mergeNumber)) { |
| 2655 | break; |
| 2656 | } |
| 2657 | } |
| 2658 | } |
| 2659 | } |
| 2660 | |
| 2661 | // Shortcut when no active merged subscribers |
| 2662 | if (TextUtils.isEmpty(mergeNumber)) { |
| 2663 | return null; |
| 2664 | } |
| 2665 | |
| 2666 | // Second pass, find all subscribers under that line override |
| 2667 | final ArraySet<String> result = new ArraySet<>(); |
| 2668 | for (String key : prefs.keySet()) { |
| 2669 | if (key.startsWith(PREF_CARRIERS_NUMBER_PREFIX)) { |
| 2670 | final String number = (String) prefs.get(key); |
| 2671 | if (mergeNumber.equals(number)) { |
| 2672 | final String iccId = key.substring(PREF_CARRIERS_NUMBER_PREFIX.length()); |
| 2673 | final String subscriberKey = PREF_CARRIERS_SUBSCRIBER_PREFIX + iccId; |
| 2674 | final String subscriberId = (String) prefs.get(subscriberKey); |
| 2675 | if (!TextUtils.isEmpty(subscriberId)) { |
| 2676 | result.add(subscriberId); |
| 2677 | } |
| 2678 | } |
| 2679 | } |
| 2680 | } |
| 2681 | |
| 2682 | final String[] resultArray = result.toArray(new String[result.size()]); |
| 2683 | Arrays.sort(resultArray); |
| 2684 | if (DBG_MERGE) { |
| 2685 | Slog.d(LOG_TAG, "Found subscribers " + Arrays.toString(resultArray) + " after merge"); |
| 2686 | } |
| 2687 | return resultArray; |
| 2688 | } |
| 2689 | |
| 2690 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2691 | public boolean setOperatorBrandOverride(int subId, String brand) { |
| 2692 | enforceCarrierPrivilege(subId); |
| 2693 | final Phone phone = getPhone(subId); |
| 2694 | return phone == null ? false : phone.setOperatorBrandOverride(brand); |
Shishir Agrawal | b1ebf8c | 2014-07-17 16:32:41 -0700 | [diff] [blame] | 2695 | } |
Steven Liu | 4bf01bc | 2014-07-17 11:05:29 -0500 | [diff] [blame] | 2696 | |
| 2697 | @Override |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2698 | public boolean setRoamingOverride(int subId, List<String> gsmRoamingList, |
Shishir Agrawal | 621a47c | 2014-12-01 10:25:09 -0800 | [diff] [blame] | 2699 | List<String> gsmNonRoamingList, List<String> cdmaRoamingList, |
| 2700 | List<String> cdmaNonRoamingList) { |
Shishir Agrawal | c04d975 | 2016-02-19 10:41:00 -0800 | [diff] [blame] | 2701 | enforceCarrierPrivilege(subId); |
| 2702 | final Phone phone = getPhone(subId); |
| 2703 | if (phone == null) { |
| 2704 | return false; |
| 2705 | } |
| 2706 | return phone.setRoamingOverride(gsmRoamingList, gsmNonRoamingList, cdmaRoamingList, |
Shishir Agrawal | 621a47c | 2014-12-01 10:25:09 -0800 | [diff] [blame] | 2707 | cdmaNonRoamingList); |
| 2708 | } |
| 2709 | |
| 2710 | @Override |
Steven Liu | 4bf01bc | 2014-07-17 11:05:29 -0500 | [diff] [blame] | 2711 | public int invokeOemRilRequestRaw(byte[] oemReq, byte[] oemResp) { |
| 2712 | enforceModifyPermission(); |
| 2713 | |
| 2714 | int returnValue = 0; |
| 2715 | try { |
| 2716 | AsyncResult result = (AsyncResult)sendRequest(CMD_INVOKE_OEM_RIL_REQUEST_RAW, oemReq); |
| 2717 | if(result.exception == null) { |
| 2718 | if (result.result != null) { |
| 2719 | byte[] responseData = (byte[])(result.result); |
| 2720 | if(responseData.length > oemResp.length) { |
| 2721 | Log.w(LOG_TAG, "Buffer to copy response too small: Response length is " + |
| 2722 | responseData.length + "bytes. Buffer Size is " + |
| 2723 | oemResp.length + "bytes."); |
| 2724 | } |
| 2725 | System.arraycopy(responseData, 0, oemResp, 0, responseData.length); |
| 2726 | returnValue = responseData.length; |
| 2727 | } |
| 2728 | } else { |
| 2729 | CommandException ex = (CommandException) result.exception; |
| 2730 | returnValue = ex.getCommandError().ordinal(); |
| 2731 | if(returnValue > 0) returnValue *= -1; |
| 2732 | } |
| 2733 | } catch (RuntimeException e) { |
| 2734 | Log.w(LOG_TAG, "sendOemRilRequestRaw: Runtime Exception"); |
| 2735 | returnValue = (CommandException.Error.GENERIC_FAILURE.ordinal()); |
| 2736 | if(returnValue > 0) returnValue *= -1; |
| 2737 | } |
| 2738 | |
| 2739 | return returnValue; |
| 2740 | } |
Wink Saville | 5d475dd | 2014-10-17 15:00:58 -0700 | [diff] [blame] | 2741 | |
| 2742 | @Override |
| 2743 | public void setRadioCapability(RadioAccessFamily[] rafs) { |
| 2744 | try { |
| 2745 | ProxyController.getInstance().setRadioCapability(rafs); |
| 2746 | } catch (RuntimeException e) { |
| 2747 | Log.w(LOG_TAG, "setRadioCapability: Runtime Exception"); |
| 2748 | } |
| 2749 | } |
| 2750 | |
| 2751 | @Override |
Robert Greenwalt | 36b23af | 2015-07-06 17:59:14 -0700 | [diff] [blame] | 2752 | public int getRadioAccessFamily(int phoneId, String callingPackage) { |
| 2753 | if (!canReadPhoneState(callingPackage, "getRadioAccessFamily")) { |
| 2754 | return RadioAccessFamily.RAF_UNKNOWN; |
| 2755 | } |
| 2756 | |
Wink Saville | 5d475dd | 2014-10-17 15:00:58 -0700 | [diff] [blame] | 2757 | return ProxyController.getInstance().getRadioAccessFamily(phoneId); |
| 2758 | } |
Andrew Lee | df14ead | 2014-10-17 14:22:52 -0700 | [diff] [blame] | 2759 | |
| 2760 | @Override |
| 2761 | public void enableVideoCalling(boolean enable) { |
| 2762 | enforceModifyPermission(); |
Tyler Gunn | fdd69de | 2015-12-04 21:24:38 -0800 | [diff] [blame] | 2763 | ImsManager.setVtSetting(mPhone.getContext(), enable); |
Andrew Lee | df14ead | 2014-10-17 14:22:52 -0700 | [diff] [blame] | 2764 | } |
| 2765 | |
| 2766 | @Override |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 2767 | public boolean isVideoCallingEnabled(String callingPackage) { |
| 2768 | if (!canReadPhoneState(callingPackage, "isVideoCallingEnabled")) { |
| 2769 | return false; |
| 2770 | } |
| 2771 | |
Andrew Lee | 77527ac | 2014-10-21 16:57:39 -0700 | [diff] [blame] | 2772 | // Check the user preference and the system-level IMS setting. Even if the user has |
| 2773 | // enabled video calling, if IMS is disabled we aren't able to support video calling. |
| 2774 | // In the long run, we may instead need to check if there exists a connection service |
| 2775 | // which can support video calling. |
Andrew Lee | 312e817 | 2014-10-23 17:01:36 -0700 | [diff] [blame] | 2776 | return ImsManager.isVtEnabledByPlatform(mPhone.getContext()) |
| 2777 | && ImsManager.isEnhanced4gLteModeSettingEnabledByUser(mPhone.getContext()) |
Tyler Gunn | fdd69de | 2015-12-04 21:24:38 -0800 | [diff] [blame] | 2778 | && ImsManager.isVtEnabledByUser(mPhone.getContext()); |
Andrew Lee | df14ead | 2014-10-17 14:22:52 -0700 | [diff] [blame] | 2779 | } |
Libin.Tang@motorola.com | afe8264 | 2014-12-18 13:27:53 -0600 | [diff] [blame] | 2780 | |
Andrew Lee | a1239f2 | 2015-03-02 17:44:07 -0800 | [diff] [blame] | 2781 | @Override |
| 2782 | public boolean canChangeDtmfToneLength() { |
Jonathan Basseri | 9504c6b | 2015-06-04 14:23:32 -0700 | [diff] [blame] | 2783 | return mApp.getCarrierConfig().getBoolean(CarrierConfigManager.KEY_DTMF_TYPE_ENABLED_BOOL); |
Andrew Lee | a1239f2 | 2015-03-02 17:44:07 -0800 | [diff] [blame] | 2784 | } |
| 2785 | |
| 2786 | @Override |
| 2787 | public boolean isWorldPhone() { |
Jonathan Basseri | 9504c6b | 2015-06-04 14:23:32 -0700 | [diff] [blame] | 2788 | return mApp.getCarrierConfig().getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL); |
Andrew Lee | a1239f2 | 2015-03-02 17:44:07 -0800 | [diff] [blame] | 2789 | } |
| 2790 | |
Andrew Lee | 9431b83 | 2015-03-09 18:46:45 -0700 | [diff] [blame] | 2791 | @Override |
| 2792 | public boolean isTtyModeSupported() { |
| 2793 | TelecomManager telecomManager = TelecomManager.from(mPhone.getContext()); |
| 2794 | TelephonyManager telephonyManager = |
| 2795 | (TelephonyManager) mPhone.getContext().getSystemService(Context.TELEPHONY_SERVICE); |
| 2796 | return !telephonyManager.isMultiSimEnabled() && telecomManager.isTtySupported(); |
| 2797 | } |
| 2798 | |
| 2799 | @Override |
| 2800 | public boolean isHearingAidCompatibilitySupported() { |
| 2801 | return mPhone.getContext().getResources().getBoolean(R.bool.hac_enabled); |
| 2802 | } |
| 2803 | |
Sanket Padawe | 7310cc7 | 2015-01-14 09:53:20 -0800 | [diff] [blame] | 2804 | /** |
| 2805 | * Returns the unique device ID of phone, for example, the IMEI for |
| 2806 | * GSM and the MEID for CDMA phones. Return null if device ID is not available. |
| 2807 | * |
| 2808 | * <p>Requires Permission: |
| 2809 | * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} |
| 2810 | */ |
| 2811 | @Override |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 2812 | public String getDeviceId(String callingPackage) { |
| 2813 | if (!canReadPhoneState(callingPackage, "getDeviceId")) { |
| 2814 | return null; |
| 2815 | } |
| 2816 | |
Sanket Padawe | 7310cc7 | 2015-01-14 09:53:20 -0800 | [diff] [blame] | 2817 | final Phone phone = PhoneFactory.getPhone(0); |
| 2818 | if (phone != null) { |
| 2819 | return phone.getDeviceId(); |
| 2820 | } else { |
| 2821 | return null; |
| 2822 | } |
| 2823 | } |
| 2824 | |
Libin.Tang@motorola.com | afe8264 | 2014-12-18 13:27:53 -0600 | [diff] [blame] | 2825 | /* |
| 2826 | * {@hide} |
| 2827 | * Returns the IMS Registration Status |
| 2828 | */ |
Santos Cordon | 7a1885b | 2015-02-03 11:15:19 -0800 | [diff] [blame] | 2829 | @Override |
Libin.Tang@motorola.com | afe8264 | 2014-12-18 13:27:53 -0600 | [diff] [blame] | 2830 | public boolean isImsRegistered() { |
| 2831 | return mPhone.isImsRegistered(); |
| 2832 | } |
Santos Cordon | 7a1885b | 2015-02-03 11:15:19 -0800 | [diff] [blame] | 2833 | |
| 2834 | @Override |
| 2835 | public int getSubIdForPhoneAccount(PhoneAccount phoneAccount) { |
| 2836 | return PhoneUtils.getSubIdForPhoneAccount(phoneAccount); |
| 2837 | } |
Nathan Harold | dcfc793 | 2015-03-18 10:01:20 -0700 | [diff] [blame] | 2838 | |
Nathan Harold | c55097a | 2015-03-11 18:14:50 -0700 | [diff] [blame] | 2839 | /* |
| 2840 | * {@hide} |
| 2841 | * Returns the IMS Registration Status |
| 2842 | */ |
Etan Cohen | 3b7a1bc | 2015-05-28 15:57:13 -0700 | [diff] [blame] | 2843 | public boolean isWifiCallingAvailable() { |
Nathan Harold | c55097a | 2015-03-11 18:14:50 -0700 | [diff] [blame] | 2844 | return mPhone.isWifiCallingEnabled(); |
| 2845 | } |
| 2846 | |
| 2847 | /* |
| 2848 | * {@hide} |
| 2849 | * Returns the IMS Registration Status |
| 2850 | */ |
Etan Cohen | 3b7a1bc | 2015-05-28 15:57:13 -0700 | [diff] [blame] | 2851 | public boolean isVolteAvailable() { |
Nathan Harold | c55097a | 2015-03-11 18:14:50 -0700 | [diff] [blame] | 2852 | return mPhone.isVolteEnabled(); |
| 2853 | } |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 2854 | |
Etan Cohen | 3b7a1bc | 2015-05-28 15:57:13 -0700 | [diff] [blame] | 2855 | /* |
| 2856 | * {@hide} Returns the IMS Registration Status |
| 2857 | */ |
| 2858 | public boolean isVideoTelephonyAvailable() { |
| 2859 | return mPhone.isVideoEnabled(); |
| 2860 | } |
| 2861 | |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 2862 | private boolean canReadPhoneState(String callingPackage, String message) { |
Etan Cohen | 921655c | 2015-06-24 13:54:50 -0700 | [diff] [blame] | 2863 | try { |
Amit Mahajan | 83ea23b | 2015-07-30 16:05:11 -0700 | [diff] [blame] | 2864 | mApp.enforceCallingOrSelfPermission( |
Etan Cohen | 921655c | 2015-06-24 13:54:50 -0700 | [diff] [blame] | 2865 | android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, message); |
| 2866 | |
Amit Mahajan | 83ea23b | 2015-07-30 16:05:11 -0700 | [diff] [blame] | 2867 | // SKIP checking for run-time permission since caller or self has PRIVILEDGED permission |
Etan Cohen | 921655c | 2015-06-24 13:54:50 -0700 | [diff] [blame] | 2868 | return true; |
Amit Mahajan | 785783f | 2015-06-29 10:36:50 -0700 | [diff] [blame] | 2869 | } catch (SecurityException e) { |
| 2870 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_PHONE_STATE, |
| 2871 | message); |
Etan Cohen | 921655c | 2015-06-24 13:54:50 -0700 | [diff] [blame] | 2872 | } |
Svet Ganov | b320e18 | 2015-04-16 12:30:10 -0700 | [diff] [blame] | 2873 | |
| 2874 | if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(), |
| 2875 | callingPackage) != AppOpsManager.MODE_ALLOWED) { |
| 2876 | return false; |
| 2877 | } |
| 2878 | |
| 2879 | return true; |
| 2880 | } |
Stuart Scott | 8eef64f | 2015-04-08 15:13:54 -0700 | [diff] [blame] | 2881 | |
Makoto Onuki | fee6934 | 2015-06-29 14:44:50 -0700 | [diff] [blame] | 2882 | /** |
Amit Mahajan | b9b4978 | 2015-09-15 18:16:32 -0700 | [diff] [blame] | 2883 | * Besides READ_PHONE_STATE, WRITE_SMS and READ_SMS also allow apps to get phone numbers. |
Makoto Onuki | fee6934 | 2015-06-29 14:44:50 -0700 | [diff] [blame] | 2884 | */ |
| 2885 | private boolean canReadPhoneNumber(String callingPackage, String message) { |
Makoto Onuki | e4072d1 | 2015-08-03 15:12:23 -0700 | [diff] [blame] | 2886 | // Default SMS app can always read it. |
| 2887 | if (mAppOps.noteOp(AppOpsManager.OP_WRITE_SMS, |
| 2888 | Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED) { |
| 2889 | return true; |
| 2890 | } |
| 2891 | try { |
| 2892 | return canReadPhoneState(callingPackage, message); |
Amit Mahajan | b9b4978 | 2015-09-15 18:16:32 -0700 | [diff] [blame] | 2893 | } catch (SecurityException readPhoneStateSecurityException) { |
| 2894 | try { |
| 2895 | // Can be read with READ_SMS too. |
| 2896 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_SMS, message); |
| 2897 | return mAppOps.noteOp(AppOpsManager.OP_READ_SMS, |
| 2898 | Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED; |
| 2899 | } catch (SecurityException readSmsSecurityException) { |
| 2900 | // Throw exception with message including both READ_PHONE_STATE and READ_SMS |
| 2901 | // permissions |
| 2902 | throw new SecurityException(message + ": Neither user " + Binder.getCallingUid() + |
| 2903 | " nor current process has " + android.Manifest.permission.READ_PHONE_STATE + |
| 2904 | " or " + android.Manifest.permission.READ_SMS + "."); |
| 2905 | } |
Makoto Onuki | e4072d1 | 2015-08-03 15:12:23 -0700 | [diff] [blame] | 2906 | } |
Makoto Onuki | fee6934 | 2015-06-29 14:44:50 -0700 | [diff] [blame] | 2907 | } |
| 2908 | |
Stuart Scott | 8eef64f | 2015-04-08 15:13:54 -0700 | [diff] [blame] | 2909 | @Override |
| 2910 | public void factoryReset(int subId) { |
| 2911 | enforceConnectivityInternalPermission(); |
Stuart Scott | 981d858 | 2015-04-21 14:09:50 -0700 | [diff] [blame] | 2912 | if (mUserManager.hasUserRestriction(UserManager.DISALLOW_NETWORK_RESET)) { |
| 2913 | return; |
| 2914 | } |
| 2915 | |
Svet Ganov | cc087f8 | 2015-05-12 20:35:54 -0700 | [diff] [blame] | 2916 | final long identity = Binder.clearCallingIdentity(); |
| 2917 | try { |
Stuart Scott | 981d858 | 2015-04-21 14:09:50 -0700 | [diff] [blame] | 2918 | if (SubscriptionManager.isUsableSubIdValue(subId) && !mUserManager.hasUserRestriction( |
| 2919 | UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) { |
Svet Ganov | cc087f8 | 2015-05-12 20:35:54 -0700 | [diff] [blame] | 2920 | // Enable data |
| 2921 | setDataEnabled(subId, true); |
| 2922 | // Set network selection mode to automatic |
| 2923 | setNetworkSelectionModeAutomatic(subId); |
| 2924 | // Set preferred mobile network type to the best available |
| 2925 | setPreferredNetworkType(subId, Phone.PREFERRED_NT_MODE); |
| 2926 | // Turn off roaming |
| 2927 | SubscriptionManager.from(mApp).setDataRoaming(0, subId); |
| 2928 | } |
| 2929 | } finally { |
| 2930 | Binder.restoreCallingIdentity(identity); |
Stuart Scott | 8eef64f | 2015-04-08 15:13:54 -0700 | [diff] [blame] | 2931 | } |
| 2932 | } |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 2933 | |
| 2934 | @Override |
| 2935 | public String getLocaleFromDefaultSim() { |
| 2936 | // We query all subscriptions instead of just the active ones, because |
| 2937 | // this might be called early on in the provisioning flow when the |
| 2938 | // subscriptions potentially aren't active yet. |
| 2939 | final List<SubscriptionInfo> slist = getAllSubscriptionInfoList(); |
| 2940 | if (slist == null || slist.isEmpty()) { |
| 2941 | return null; |
| 2942 | } |
| 2943 | |
| 2944 | // This function may be called very early, say, from the setup wizard, at |
| 2945 | // which point we won't have a default subscription set. If that's the case |
| 2946 | // we just choose the first, which will be valid in "most cases". |
| 2947 | final int defaultSubId = getDefaultSubscription(); |
| 2948 | SubscriptionInfo info = null; |
| 2949 | if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { |
| 2950 | info = slist.get(0); |
| 2951 | } else { |
| 2952 | for (SubscriptionInfo item : slist) { |
| 2953 | if (item.getSubscriptionId() == defaultSubId) { |
| 2954 | info = item; |
| 2955 | break; |
| 2956 | } |
| 2957 | } |
| 2958 | |
| 2959 | if (info == null) { |
| 2960 | return null; |
| 2961 | } |
| 2962 | } |
| 2963 | |
| 2964 | // Try and fetch the locale from the carrier properties or from the SIM language |
| 2965 | // preferences (EF-PL and EF-LI)... |
Tony Hill | 183b2de | 2015-06-24 14:53:58 +0100 | [diff] [blame] | 2966 | final int mcc = info.getMcc(); |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 2967 | final Phone defaultPhone = getPhone(info.getSubscriptionId()); |
Narayan Kamath | 011676f | 2015-07-29 12:04:08 +0100 | [diff] [blame] | 2968 | String simLanguage = null; |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 2969 | if (defaultPhone != null) { |
| 2970 | final Locale localeFromDefaultSim = defaultPhone.getLocaleFromSimAndCarrierPrefs(); |
| 2971 | if (localeFromDefaultSim != null) { |
Narayan Kamath | 011676f | 2015-07-29 12:04:08 +0100 | [diff] [blame] | 2972 | if (!localeFromDefaultSim.getCountry().isEmpty()) { |
Tony Hill | 183b2de | 2015-06-24 14:53:58 +0100 | [diff] [blame] | 2973 | if (DBG) log("Using locale from default SIM:" + localeFromDefaultSim); |
| 2974 | return localeFromDefaultSim.toLanguageTag(); |
Narayan Kamath | 011676f | 2015-07-29 12:04:08 +0100 | [diff] [blame] | 2975 | } else { |
| 2976 | simLanguage = localeFromDefaultSim.getLanguage(); |
Tony Hill | 183b2de | 2015-06-24 14:53:58 +0100 | [diff] [blame] | 2977 | } |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 2978 | } |
| 2979 | } |
| 2980 | |
Narayan Kamath | 011676f | 2015-07-29 12:04:08 +0100 | [diff] [blame] | 2981 | // The SIM language preferences only store a language (e.g. fr = French), not an |
| 2982 | // exact locale (e.g. fr_FR = French/France). So, if the locale returned from |
| 2983 | // the SIM and carrier preferences does not include a country we add the country |
| 2984 | // determined from the SIM MCC to provide an exact locale. |
| 2985 | final Locale mccLocale = MccTable.getLocaleFromMcc(mPhone.getContext(), mcc, simLanguage); |
Tony Hill | 183b2de | 2015-06-24 14:53:58 +0100 | [diff] [blame] | 2986 | if (mccLocale != null) { |
| 2987 | if (DBG) log("No locale from default SIM, using mcc locale:" + mccLocale); |
| 2988 | return mccLocale.toLanguageTag(); |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 2989 | } |
| 2990 | |
Tony Hill | 183b2de | 2015-06-24 14:53:58 +0100 | [diff] [blame] | 2991 | if (DBG) log("No locale found - returning null"); |
Narayan Kamath | 1c496c2 | 2015-04-16 14:40:19 +0100 | [diff] [blame] | 2992 | return null; |
| 2993 | } |
| 2994 | |
| 2995 | private List<SubscriptionInfo> getAllSubscriptionInfoList() { |
| 2996 | final long identity = Binder.clearCallingIdentity(); |
| 2997 | try { |
| 2998 | return mSubscriptionController.getAllSubInfoList( |
| 2999 | mPhone.getContext().getOpPackageName()); |
| 3000 | } finally { |
| 3001 | Binder.restoreCallingIdentity(identity); |
| 3002 | } |
| 3003 | } |
| 3004 | |
| 3005 | private List<SubscriptionInfo> getActiveSubscriptionInfoList() { |
| 3006 | final long identity = Binder.clearCallingIdentity(); |
| 3007 | try { |
| 3008 | return mSubscriptionController.getActiveSubscriptionInfoList( |
| 3009 | mPhone.getContext().getOpPackageName()); |
| 3010 | } finally { |
| 3011 | Binder.restoreCallingIdentity(identity); |
| 3012 | } |
| 3013 | } |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 3014 | |
| 3015 | /** |
Adam Lesinski | 903a54c | 2016-04-11 14:49:52 -0700 | [diff] [blame] | 3016 | * Responds to the ResultReceiver with the {@link android.telephony.ModemActivityInfo} object |
| 3017 | * representing the state of the modem. |
| 3018 | * |
| 3019 | * NOTE: This clears the modem state, so there should only every be one caller. |
| 3020 | * @hide |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 3021 | */ |
| 3022 | @Override |
Adam Lesinski | 903a54c | 2016-04-11 14:49:52 -0700 | [diff] [blame] | 3023 | public void requestModemActivityInfo(ResultReceiver result) { |
| 3024 | enforceModifyPermission(); |
| 3025 | |
| 3026 | ModemActivityInfo info = (ModemActivityInfo) sendRequest(CMD_GET_MODEM_ACTIVITY_INFO, null); |
| 3027 | Bundle bundle = new Bundle(); |
| 3028 | bundle.putParcelable(TelephonyManager.MODEM_ACTIVITY_RESULT_KEY, info); |
| 3029 | result.send(0, bundle); |
Prerepa Viswanadham | 7fcff69 | 2015-06-03 11:20:55 -0700 | [diff] [blame] | 3030 | } |
Jack Yu | 85bd38a | 2015-11-09 11:34:32 -0800 | [diff] [blame] | 3031 | |
| 3032 | /** |
| 3033 | * {@hide} |
| 3034 | * Returns the service state information on specified subscription. |
| 3035 | */ |
| 3036 | @Override |
| 3037 | public ServiceState getServiceStateForSubscriber(int subId, String callingPackage) { |
| 3038 | |
| 3039 | if (!canReadPhoneState(callingPackage, "getServiceStateForSubscriber")) { |
| 3040 | return null; |
| 3041 | } |
| 3042 | |
| 3043 | final Phone phone = getPhone(subId); |
| 3044 | if (phone == null) { |
| 3045 | return null; |
| 3046 | } |
| 3047 | |
| 3048 | return phone.getServiceState(); |
| 3049 | } |
Nancy Chen | 31f9ba1 | 2016-01-06 11:42:12 -0800 | [diff] [blame] | 3050 | |
| 3051 | /** |
| 3052 | * Returns the URI for the per-account voicemail ringtone set in Phone settings. |
| 3053 | * |
| 3054 | * @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the |
| 3055 | * voicemail ringtone. |
| 3056 | * @return The URI for the ringtone to play when receiving a voicemail from a specific |
| 3057 | * PhoneAccount. |
| 3058 | */ |
| 3059 | @Override |
| 3060 | public Uri getVoicemailRingtoneUri(PhoneAccountHandle accountHandle) { |
| 3061 | final Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(accountHandle); |
| 3062 | if (phone == null) { |
| 3063 | return null; |
| 3064 | } |
| 3065 | |
| 3066 | return VoicemailNotificationSettingsUtil.getRingtoneUri(phone); |
| 3067 | } |
| 3068 | |
| 3069 | /** |
| 3070 | * Returns whether vibration is set for voicemail notification in Phone settings. |
| 3071 | * |
| 3072 | * @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the |
| 3073 | * voicemail vibration setting. |
| 3074 | * @return {@code true} if the vibration is set for this PhoneAccount, {@code false} otherwise. |
| 3075 | */ |
| 3076 | @Override |
| 3077 | public boolean isVoicemailVibrationEnabled(PhoneAccountHandle accountHandle) { |
| 3078 | final Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(accountHandle); |
| 3079 | if (phone == null) { |
| 3080 | return false; |
| 3081 | } |
| 3082 | |
| 3083 | return VoicemailNotificationSettingsUtil.isVibrationEnabled(phone); |
| 3084 | } |
| 3085 | |
Youhan Wang | e64578a | 2016-05-02 15:32:42 -0700 | [diff] [blame] | 3086 | /** |
| 3087 | * Make sure either called from same process as self (phone) or IPC caller has read privilege. |
| 3088 | * |
| 3089 | * @throws SecurityException if the caller does not have the required permission |
| 3090 | */ |
| 3091 | private void enforceReadPrivilegedPermission() { |
| 3092 | mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, |
| 3093 | null); |
| 3094 | } |
| 3095 | |
| 3096 | /** |
| 3097 | * Return the application ID for the app type. |
| 3098 | * |
| 3099 | * @param subId the subscription ID that this request applies to. |
| 3100 | * @param appType the uicc app type. |
| 3101 | * @return Application ID for specificied app type, or null if no uicc. |
| 3102 | */ |
| 3103 | @Override |
| 3104 | public String getAidForAppType(int subId, int appType) { |
| 3105 | enforceReadPrivilegedPermission(); |
| 3106 | Phone phone = getPhone(subId); |
| 3107 | if (phone == null) { |
| 3108 | return null; |
| 3109 | } |
| 3110 | String aid = null; |
| 3111 | try { |
| 3112 | aid = UiccController.getInstance().getUiccCard(phone.getPhoneId()) |
| 3113 | .getApplicationByType(appType).getAid(); |
| 3114 | } catch (Exception e) { |
| 3115 | Log.e(LOG_TAG, "Not getting aid. Exception ex=" + e); |
| 3116 | } |
| 3117 | return aid; |
| 3118 | } |
| 3119 | |
Youhan Wang | 4001d25 | 2016-05-11 10:29:41 -0700 | [diff] [blame] | 3120 | |
| 3121 | /** |
| 3122 | * Return the Electronic Serial Number. |
| 3123 | * |
| 3124 | * @param subId the subscription ID that this request applies to. |
| 3125 | * @return ESN or null if error. |
| 3126 | */ |
| 3127 | @Override |
| 3128 | public String getEsn(int subId) { |
| 3129 | enforceReadPrivilegedPermission(); |
| 3130 | Phone phone = getPhone(subId); |
| 3131 | if (phone == null) { |
| 3132 | return null; |
| 3133 | } |
| 3134 | String esn = null; |
| 3135 | try { |
| 3136 | esn = phone.getEsn(); |
| 3137 | } catch (Exception e) { |
| 3138 | Log.e(LOG_TAG, "Not getting ESN. Exception ex=" + e); |
| 3139 | } |
| 3140 | return esn; |
| 3141 | } |
| 3142 | |
Sanket Padawe | 99ef1e3 | 2016-05-18 16:12:33 -0700 | [diff] [blame] | 3143 | /** |
| 3144 | * Get snapshot of Telephony histograms |
| 3145 | * @return List of Telephony histograms |
| 3146 | * @hide |
| 3147 | */ |
| 3148 | @Override |
| 3149 | public List<TelephonyHistogram> getTelephonyHistograms() { |
| 3150 | enforceModifyPermissionOrCarrierPrivilege(getDefaultSubscription()); |
| 3151 | return RIL.getTelephonyRILTimingHistograms(); |
| 3152 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 3153 | } |