blob: 0d072a77a4b0090e05e7c5b17aa06243167792de [file] [log] [blame]
Paul Keithb18c7bf2018-05-09 02:21:19 +02001/*
2 * Copyright (C) 2018 The LineageOS 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
17package com.qualcomm.qti.internal.telephony;
18
19import android.content.Context;
Paul Keith01b8f282018-05-09 15:32:27 +020020import android.content.Intent;
21import android.os.AsyncResult;
22import android.os.Handler;
23import android.os.Message;
Paul Keithb18c7bf2018-05-09 02:21:19 +020024import android.os.ServiceManager;
LuK13376374c2a2018-05-09 21:37:16 +020025import android.telecom.PhoneAccount;
26import android.telecom.PhoneAccountHandle;
27import android.telecom.TelecomManager;
Paul Keithb18c7bf2018-05-09 02:21:19 +020028import android.telephony.PhoneNumberUtils;
LuK13376374c2a2018-05-09 21:37:16 +020029import android.telephony.SubscriptionManager;
30import android.telephony.TelephonyManager;
Paul Keithb18c7bf2018-05-09 02:21:19 +020031
Paul Keith01b8f282018-05-09 15:32:27 +020032import com.android.internal.telephony.CommandsInterface;
33import com.android.internal.telephony.Phone;
34import com.android.internal.telephony.PhoneConstants;
35import com.android.internal.telephony.uicc.IccCardStatus.CardState;
36import com.android.internal.telephony.uicc.UiccCard;
37import com.android.internal.telephony.uicc.UiccController;
38
LuK13374db93482018-12-05 03:19:19 +010039import org.codeaurora.internal.Client;
Paul Keithb18c7bf2018-05-09 02:21:19 +020040import org.codeaurora.internal.IDepersoResCallback;
41import org.codeaurora.internal.IDsda;
42import org.codeaurora.internal.IExtTelephony;
LuK13374db93482018-12-05 03:19:19 +010043import org.codeaurora.internal.INetworkCallback;
44import org.codeaurora.internal.Token;
Paul Keithb18c7bf2018-05-09 02:21:19 +020045
LuK13376374c2a2018-05-09 21:37:16 +020046import java.util.Iterator;
47
48import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
49
Paul Keith01b8f282018-05-09 15:32:27 +020050import static android.telephony.TelephonyManager.SIM_ACTIVATION_STATE_ACTIVATED;
51import static android.telephony.TelephonyManager.SIM_ACTIVATION_STATE_DEACTIVATED;
52
Paul Keith27c445e2018-07-11 18:20:23 +020053import static android.telephony.TelephonyManager.MultiSimVariants.DSDA;
54
Paul Keith01b8f282018-05-09 15:32:27 +020055import static com.android.internal.telephony.uicc.IccCardStatus.CardState.CARDSTATE_PRESENT;
56
Paul Keithb18c7bf2018-05-09 02:21:19 +020057public class LineageExtTelephony extends IExtTelephony.Stub {
58
Paul Keithb8e14622018-05-20 18:46:30 +020059 class UiccStatus {
60
61 boolean mProvisioned;
62 int mStatus;
63
64 UiccStatus(int status) {
65 mProvisioned = true;
66 mStatus = status;
67 }
68
69 }
70
Paul Keithb18c7bf2018-05-09 02:21:19 +020071 // Service name
72 private static final String EXT_TELEPHONY_SERVICE_NAME = "extphone";
73
74 // Intents (+ extras) to broadcast
75 private static final String ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED =
76 "org.codeaurora.intent.action.ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED";
77 private static final String EXTRA_NEW_PROVISION_STATE = "newProvisionState";
78
79 // UICC States
80 private static final int PROVISIONED = 1;
81 private static final int NOT_PROVISIONED = 0;
82 private static final int INVALID_STATE = -1;
83 private static final int CARD_NOT_PRESENT = -2;
84
85 // Error codes
86 private static final int SUCCESS = 0;
87 private static final int GENERIC_FAILURE = -1;
88 private static final int INVALID_INPUT = -2;
89 private static final int BUSY = -3;
90
Paul Keith01b8f282018-05-09 15:32:27 +020091 // From IccCardProxy.java
92 private static final int EVENT_ICC_CHANGED = 3;
93
Paul Keithb18c7bf2018-05-09 02:21:19 +020094 private static LineageExtTelephony sInstance;
95
Paul Keith0f1392f2018-07-15 23:36:35 +020096 private CommandsInterface[] mCommandsInterfaces;
97 private Context mContext;
Paul Keith01b8f282018-05-09 15:32:27 +020098 private Handler mHandler;
Paul Keith0f1392f2018-07-15 23:36:35 +020099 private Phone[] mPhones;
100 private SubscriptionManager mSubscriptionManager;
101 private TelecomManager mTelecomManager;
102 private TelephonyManager mTelephonyManager;
Paul Keith01b8f282018-05-09 15:32:27 +0200103 private UiccController mUiccController;
Paul Keith0f1392f2018-07-15 23:36:35 +0200104 private UiccStatus mUiccStatus[];
105 private boolean mBusy;
Paul Keith01b8f282018-05-09 15:32:27 +0200106
Paul Keith01b8f282018-05-09 15:32:27 +0200107
Paul Keith0f1392f2018-07-15 23:36:35 +0200108 public static void init(Context context, Phone[] phones,
109 CommandsInterface[] commandsInterfaces) {
110 sInstance = getInstance(context, phones, commandsInterfaces);
Paul Keithb18c7bf2018-05-09 02:21:19 +0200111 }
112
Paul Keith0f1392f2018-07-15 23:36:35 +0200113 public static LineageExtTelephony getInstance(Context context, Phone[] phones,
114 CommandsInterface[] commandsInterfaces) {
Paul Keithb18c7bf2018-05-09 02:21:19 +0200115 if (sInstance == null) {
Paul Keith0f1392f2018-07-15 23:36:35 +0200116 sInstance = new LineageExtTelephony(context, phones, commandsInterfaces);
Paul Keithb18c7bf2018-05-09 02:21:19 +0200117 }
118
119 return sInstance;
120 }
121
Paul Keith0f1392f2018-07-15 23:36:35 +0200122 private LineageExtTelephony(Context context, Phone[] phones,
123 CommandsInterface[] commandsInterfaces) {
Paul Keithb18c7bf2018-05-09 02:21:19 +0200124 if (ServiceManager.getService(EXT_TELEPHONY_SERVICE_NAME) == null) {
125 ServiceManager.addService(EXT_TELEPHONY_SERVICE_NAME, this);
126 }
Paul Keith01b8f282018-05-09 15:32:27 +0200127
Paul Keith0f1392f2018-07-15 23:36:35 +0200128 mCommandsInterfaces = commandsInterfaces;
129
130 mContext = context;
Paul Keithb8e14622018-05-20 18:46:30 +0200131
132 // Keep track of ICC state changes
Paul Keith01b8f282018-05-09 15:32:27 +0200133 mHandler = new Handler() {
134 @Override
135 public void handleMessage(Message msg) {
136 AsyncResult ar;
137
138 if (msg.what == EVENT_ICC_CHANGED) {
139 ar = (AsyncResult) msg.obj;
140 if (ar != null && ar.result != null) {
141 iccStatusChanged((Integer) ar.result);
142 }
143 }
144 }
145 };
Paul Keith0f1392f2018-07-15 23:36:35 +0200146
147 mPhones = phones;
148
149 mSubscriptionManager = (SubscriptionManager) mContext.getSystemService(
150 Context.TELEPHONY_SUBSCRIPTION_SERVICE);
151
152 mTelecomManager = TelecomManager.from(context);
153
154 mTelephonyManager = TelephonyManager.from(context);
155
156 // Assume everything present is provisioned by default
157 mUiccStatus = new UiccStatus[mPhones.length];
158 for (int i = 0; i < mPhones.length; i++) {
159 if (mPhones[i] == null) {
160 mUiccStatus[i] = null;
161 } else if (mPhones[i].getUiccCard() == null) {
162 mUiccStatus[i] = new UiccStatus(CARD_NOT_PRESENT);
163 } else {
164 mUiccStatus[i] = new UiccStatus(mPhones[i].getUiccCard().getCardState()
165 == CARDSTATE_PRESENT ? PROVISIONED : CARD_NOT_PRESENT);
166 }
167 }
168
169 mBusy = false;
170
Paul Keith01b8f282018-05-09 15:32:27 +0200171 mUiccController = UiccController.getInstance();
172 mUiccController.registerForIccChanged(mHandler, EVENT_ICC_CHANGED, null);
173 }
174
Paul Keith208646f2018-05-11 03:05:54 +0200175 private synchronized void iccStatusChanged(int slotId) {
Paul Keith0f1392f2018-07-15 23:36:35 +0200176 if (slotId >= mPhones.length || mPhones[slotId] == null) {
Paul Keith01b8f282018-05-09 15:32:27 +0200177 return;
178 }
179
Paul Keith0f1392f2018-07-15 23:36:35 +0200180 UiccCard card = mPhones[slotId].getUiccCard();
Paul Keith01b8f282018-05-09 15:32:27 +0200181
Paul Keithb8e14622018-05-20 18:46:30 +0200182 if (card == null || card.getCardState() != CARDSTATE_PRESENT) {
Paul Keith0f1392f2018-07-15 23:36:35 +0200183 mUiccStatus[slotId].mStatus = CARD_NOT_PRESENT;
Paul Keithb8e14622018-05-20 18:46:30 +0200184 } else {
Paul Keith0f1392f2018-07-15 23:36:35 +0200185 if (mUiccStatus[slotId].mProvisioned &&
186 mUiccStatus[slotId].mStatus != PROVISIONED) {
187 mUiccStatus[slotId].mStatus = NOT_PROVISIONED;
LuK13378fe9d762018-05-11 00:09:00 +0200188 activateUiccCard(slotId);
Paul Keith0f1392f2018-07-15 23:36:35 +0200189 } else if (!mUiccStatus[slotId].mProvisioned &&
190 mUiccStatus[slotId].mStatus != NOT_PROVISIONED) {
191 mUiccStatus[slotId].mStatus = PROVISIONED;
Paul Keithb8e14622018-05-20 18:46:30 +0200192 deactivateUiccCard(slotId);
LuK13378fe9d762018-05-11 00:09:00 +0200193 }
LuK13376374c2a2018-05-09 21:37:16 +0200194 }
195
Paul Keith01b8f282018-05-09 15:32:27 +0200196 broadcastUiccActivation(slotId);
197 }
198
199 private void setUiccActivation(int slotId, boolean activate) {
Paul Keith0f1392f2018-07-15 23:36:35 +0200200 UiccCard card = mPhones[slotId].getUiccCard();
Paul Keith01b8f282018-05-09 15:32:27 +0200201
202 int numApps = card.getNumApplications();
203
Paul Keith0f1392f2018-07-15 23:36:35 +0200204 mUiccStatus[slotId].mProvisioned = activate;
Paul Keithb8e14622018-05-20 18:46:30 +0200205
Paul Keith01b8f282018-05-09 15:32:27 +0200206 for (int i = 0; i < numApps; i++) {
207 if (card.getApplicationIndex(i) == null) {
208 continue;
209 }
210
Paul Keith0f1392f2018-07-15 23:36:35 +0200211 mCommandsInterfaces[slotId].setUiccSubscription(i, activate, null);
Paul Keith01b8f282018-05-09 15:32:27 +0200212 }
213 }
214
215 private void broadcastUiccActivation(int slotId) {
216 Intent intent = new Intent(ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED);
217 intent.putExtra(PhoneConstants.PHONE_KEY, slotId);
Paul Keith0f1392f2018-07-15 23:36:35 +0200218 intent.putExtra(EXTRA_NEW_PROVISION_STATE, mUiccStatus[slotId].mStatus);
219 mContext.sendBroadcast(intent);
Paul Keithb18c7bf2018-05-09 02:21:19 +0200220 }
221
222 @Override
223 public int getCurrentUiccCardProvisioningStatus(int slotId) {
Paul Keith0f1392f2018-07-15 23:36:35 +0200224 if (slotId >= mUiccStatus.length || mUiccStatus[slotId] == null) {
Paul Keith01b8f282018-05-09 15:32:27 +0200225 return INVALID_INPUT;
226 }
227
Paul Keith0f1392f2018-07-15 23:36:35 +0200228 return mUiccStatus[slotId].mStatus;
Paul Keithb18c7bf2018-05-09 02:21:19 +0200229 }
230
231 @Override
232 public int getUiccCardProvisioningUserPreference(int slotId) {
Paul Keith0f1392f2018-07-15 23:36:35 +0200233 if (slotId >= mUiccStatus.length || mUiccStatus[slotId] == null) {
Paul Keithb8e14622018-05-20 18:46:30 +0200234 return INVALID_INPUT;
235 }
236
Paul Keith0f1392f2018-07-15 23:36:35 +0200237 return mUiccStatus[slotId].mProvisioned ? PROVISIONED : NOT_PROVISIONED;
Paul Keithb18c7bf2018-05-09 02:21:19 +0200238 }
239
240 @Override
241 public int activateUiccCard(int slotId) {
Paul Keith0f1392f2018-07-15 23:36:35 +0200242 if (slotId >= mPhones.length || mPhones[slotId] == null ||
243 slotId >= mCommandsInterfaces.length || mCommandsInterfaces[slotId] == null) {
Paul Keith01b8f282018-05-09 15:32:27 +0200244 return INVALID_INPUT;
245 }
246
Paul Keith0f1392f2018-07-15 23:36:35 +0200247 if (mBusy) {
Paul Keith208646f2018-05-11 03:05:54 +0200248 return BUSY;
249 }
250
Paul Keith0f1392f2018-07-15 23:36:35 +0200251 if (mUiccStatus[slotId].mStatus == PROVISIONED) {
Paul Keith01b8f282018-05-09 15:32:27 +0200252 return SUCCESS;
253 }
254
Paul Keith0f1392f2018-07-15 23:36:35 +0200255 if (mUiccStatus[slotId].mStatus != NOT_PROVISIONED) {
Paul Keith01b8f282018-05-09 15:32:27 +0200256 return INVALID_INPUT;
257 }
258
Paul Keith0f1392f2018-07-15 23:36:35 +0200259 mBusy = true;
Paul Keith208646f2018-05-11 03:05:54 +0200260
Paul Keith0f1392f2018-07-15 23:36:35 +0200261 mUiccStatus[slotId].mStatus = PROVISIONED;
Paul Keithb8e14622018-05-20 18:46:30 +0200262
Paul Keith01b8f282018-05-09 15:32:27 +0200263 setUiccActivation(slotId, true);
Paul Keith0f1392f2018-07-15 23:36:35 +0200264 mPhones[slotId].setVoiceActivationState(SIM_ACTIVATION_STATE_ACTIVATED);
265 mPhones[slotId].setDataActivationState(SIM_ACTIVATION_STATE_ACTIVATED);
Paul Keith01b8f282018-05-09 15:32:27 +0200266
Paul Keith0f1392f2018-07-15 23:36:35 +0200267 mBusy = false;
Paul Keith208646f2018-05-11 03:05:54 +0200268
Paul Keith01b8f282018-05-09 15:32:27 +0200269 broadcastUiccActivation(slotId);
270
Paul Keithb18c7bf2018-05-09 02:21:19 +0200271 return SUCCESS;
272 }
273
274 @Override
275 public int deactivateUiccCard(int slotId) {
Paul Keith0f1392f2018-07-15 23:36:35 +0200276 if (slotId >= mPhones.length || mPhones[slotId] == null ||
277 slotId >= mCommandsInterfaces.length || mCommandsInterfaces[slotId] == null) {
Paul Keith01b8f282018-05-09 15:32:27 +0200278 return INVALID_INPUT;
279 }
280
Paul Keith0f1392f2018-07-15 23:36:35 +0200281 if (mBusy) {
Paul Keith208646f2018-05-11 03:05:54 +0200282 return BUSY;
283 }
284
Paul Keith0f1392f2018-07-15 23:36:35 +0200285 if (mUiccStatus[slotId].mStatus == NOT_PROVISIONED) {
Paul Keith01b8f282018-05-09 15:32:27 +0200286 return SUCCESS;
287 }
288
Paul Keith0f1392f2018-07-15 23:36:35 +0200289 if (mUiccStatus[slotId].mStatus != PROVISIONED) {
Paul Keith01b8f282018-05-09 15:32:27 +0200290 return INVALID_INPUT;
291 }
292
Paul Keith0f1392f2018-07-15 23:36:35 +0200293 mBusy = true;
Paul Keith208646f2018-05-11 03:05:54 +0200294
Paul Keith0f1392f2018-07-15 23:36:35 +0200295 int subIdToDeactivate = mPhones[slotId].getSubId();
LuK13376374c2a2018-05-09 21:37:16 +0200296 int subIdToMakeDefault = INVALID_SUBSCRIPTION_ID;
297
Paul Keith0f1392f2018-07-15 23:36:35 +0200298 mUiccStatus[slotId].mStatus = NOT_PROVISIONED;
Paul Keithb8e14622018-05-20 18:46:30 +0200299
LuK13376374c2a2018-05-09 21:37:16 +0200300 // Find first provisioned sub that isn't what we're deactivating
Paul Keith0f1392f2018-07-15 23:36:35 +0200301 for (int i = 0; i < mPhones.length; i++) {
302 if (mUiccStatus[i].mStatus == PROVISIONED) {
303 subIdToMakeDefault = mPhones[i].getSubId();
LuK13376374c2a2018-05-09 21:37:16 +0200304 break;
305 }
306 }
307
308 // Make sure defaults are now sane
Paul Keith0f1392f2018-07-15 23:36:35 +0200309 PhoneAccountHandle accountHandle = mTelecomManager.getUserSelectedOutgoingPhoneAccount();
310 PhoneAccount account = mTelecomManager.getPhoneAccount(accountHandle);
LuK13376374c2a2018-05-09 21:37:16 +0200311
Paul Keith0f1392f2018-07-15 23:36:35 +0200312 if (mSubscriptionManager.getDefaultSmsSubscriptionId() == subIdToDeactivate) {
313 mSubscriptionManager.setDefaultSmsSubId(subIdToMakeDefault);
LuK13376374c2a2018-05-09 21:37:16 +0200314 }
315
Paul Keith0f1392f2018-07-15 23:36:35 +0200316 if (mSubscriptionManager.getDefaultDataSubscriptionId() == subIdToDeactivate) {
317 mSubscriptionManager.setDefaultDataSubId(subIdToMakeDefault);
LuK13376374c2a2018-05-09 21:37:16 +0200318 }
319
Paul Keith0f1392f2018-07-15 23:36:35 +0200320 if (mTelephonyManager.getSubIdForPhoneAccount(account) == subIdToDeactivate) {
321 mTelecomManager.setUserSelectedOutgoingPhoneAccount(
LuK13376374c2a2018-05-09 21:37:16 +0200322 subscriptionIdToPhoneAccountHandle(subIdToMakeDefault));
323 }
324
Paul Keith0f1392f2018-07-15 23:36:35 +0200325 mPhones[slotId].setVoiceActivationState(SIM_ACTIVATION_STATE_DEACTIVATED);
326 mPhones[slotId].setDataActivationState(SIM_ACTIVATION_STATE_DEACTIVATED);
Paul Keith01b8f282018-05-09 15:32:27 +0200327 setUiccActivation(slotId, false);
328
Paul Keith0f1392f2018-07-15 23:36:35 +0200329 mBusy = false;
Paul Keith208646f2018-05-11 03:05:54 +0200330
Paul Keith01b8f282018-05-09 15:32:27 +0200331 broadcastUiccActivation(slotId);
332
333 return SUCCESS;
Paul Keithb18c7bf2018-05-09 02:21:19 +0200334 }
335
336 @Override
337 public boolean isSMSPromptEnabled() {
338 // I hope we don't use this
339 return false;
340 }
341
342 @Override
343 public void setSMSPromptEnabled(boolean enabled) {
344 // I hope we don't use this
345 }
346
347 @Override
348 public int getPhoneIdForECall() {
349 // I hope we don't use this
350 return -1;
351 }
352
353 @Override
354 public void setPrimaryCardOnSlot(int slotId) {
355 // I hope we don't use this
356 }
357
358 @Override
359 public boolean isFdnEnabled() {
360 // I hope we don't use this
361 return false;
362 }
363
364 @Override
365 public int getPrimaryStackPhoneId() {
366 // I hope we don't use this
367 return -1;
368 }
369
370 @Override
371 public boolean isEmergencyNumber(String number) {
372 // This is lame...
373 return PhoneNumberUtils.isEmergencyNumber(number);
374 }
375
376 @Override
377 public boolean isLocalEmergencyNumber(String number) {
378 // This is lame...
Paul Keith0f1392f2018-07-15 23:36:35 +0200379 return PhoneNumberUtils.isLocalEmergencyNumber(mContext, number);
Paul Keithb18c7bf2018-05-09 02:21:19 +0200380 }
381
382 @Override
383 public boolean isPotentialEmergencyNumber(String number) {
384 // This is lame...
385 return PhoneNumberUtils.isPotentialEmergencyNumber(number);
386 }
387
388 @Override
389 public boolean isPotentialLocalEmergencyNumber(String number) {
390 // This is lame...
Paul Keith0f1392f2018-07-15 23:36:35 +0200391 return PhoneNumberUtils.isPotentialLocalEmergencyNumber(mContext, number);
Paul Keithb18c7bf2018-05-09 02:21:19 +0200392 }
393
394 @Override
395 public boolean isDeviceInSingleStandby() {
396 // I hope we don't use this
397 return false;
398 }
399
400 @Override
401 public boolean setLocalCallHold(int subId, boolean enable) {
402 // TODO: Do something here
403 return false;
404 }
405
406 @Override
407 public void switchToActiveSub(int subId) {
408 // I hope we don't use this
409 }
410
411 @Override
412 public void setDsdaAdapter(IDsda dsdaAdapter) {
413 // I hope we don't use this
414 }
415
416 @Override
417 public int getActiveSubscription() {
418 // I hope we don't use this
419 return -1;
420 }
421
422 @Override
423 public boolean isDsdaEnabled() {
Paul Keith0f1392f2018-07-15 23:36:35 +0200424 return mTelephonyManager.getMultiSimConfiguration() == DSDA;
Paul Keithb18c7bf2018-05-09 02:21:19 +0200425 }
426
427 @Override
428 public void supplyIccDepersonalization(String netpin, String type, IDepersoResCallback callback,
429 int phoneId) {
430 // I hope we don't use this
431 }
432
433 @Override
434 public int getPrimaryCarrierSlotId() {
435 // I hope we don't use this
436 return -1;
437 }
438
439 @Override
440 public boolean isPrimaryCarrierSlotId(int slotId) {
441 // I hope we don't use this
442 return false;
443 }
444
445 @Override
446 public boolean setSmscAddress(int slotId, String smsc) {
447 // I hope we don't use this
448 return false;
449 }
450
451 @Override
452 public String getSmscAddress(int slotId) {
453 // I hope we don't use this
454 return null;
455 }
456
457 @Override
458 public boolean isVendorApkAvailable(String packageName) {
459 // I hope we don't use this
460 return false;
461 }
462
463 @Override
464 public int getCurrentPrimaryCardSlotId() {
465 // I hope we don't use this
466 return -1;
467 }
468
LuK13374db93482018-12-05 03:19:19 +0100469 @Override
470 public Token enable5g(int slotId, Client client) {
471 // I hope we don't use this
472 return new Token(-1);
473 }
474
475 @Override
476 public Token disable5g(int slotId, Client client) {
477 // I hope we don't use this
478 return new Token(-1);
479 }
480
481 @Override
482 public Token enable5gOnly(int slotId, Client client) {
483 // I hope we don't use this
484 return new Token(-1);
485 }
486
487 @Override
488 public Token query5gStatus(int slotId, Client client) {
489 // I hope we don't use this
490 return new Token(-1);
491 }
492
493 @Override
494 public Token queryNrDcParam(int slotId, Client client) {
495 // I hope we don't use this
496 return new Token(-1);
497 }
498
499 @Override
500 public Token queryNrBearerAllocation(int slotId, Client client) {
501 // I hope we don't use this
502 return new Token(-1);
503 }
504
505 @Override
506 public Token queryNrSignalStrength(int slotId, Client client) {
507 // I hope we don't use this
508 return new Token(-1);
509 }
510
511 @Override
512 public Client registerCallback(String packageName, INetworkCallback callback) {
513 // I hope we don't use this
514 return new Client(-1, -1, packageName, callback);
515 }
516
517 @Override
518 public void unRegisterCallback(INetworkCallback callback) {
519 // I hope we don't use this
520 }
521
LuK13376374c2a2018-05-09 21:37:16 +0200522 private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) {
523 final Iterator<PhoneAccountHandle> phoneAccounts =
Paul Keith0f1392f2018-07-15 23:36:35 +0200524 mTelecomManager.getCallCapablePhoneAccounts().listIterator();
LuK13376374c2a2018-05-09 21:37:16 +0200525
526 while (phoneAccounts.hasNext()) {
527 final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();
Paul Keith0f1392f2018-07-15 23:36:35 +0200528 final PhoneAccount phoneAccount = mTelecomManager.getPhoneAccount(phoneAccountHandle);
529 if (subId == mTelephonyManager.getSubIdForPhoneAccount(phoneAccount)) {
LuK13376374c2a2018-05-09 21:37:16 +0200530 return phoneAccountHandle;
531 }
532 }
533
534 return null;
535 }
536
Paul Keithb18c7bf2018-05-09 02:21:19 +0200537}