| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.telephony; |
| 17 |
|
| 18 |
import android.annotation.CallbackExecutor; |
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.annotation.RequiresPermission; |
| 22 |
import android.compat.Compatibility; |
| 23 |
import android.compat.annotation.ChangeId; |
| 24 |
import android.compat.annotation.EnabledAfter; |
| 25 |
import android.content.Context; |
| 26 |
import android.os.Binder; |
| 27 |
import android.os.Build; |
| 28 |
import android.os.RemoteException; |
| 29 |
import android.os.ServiceManager; |
| 30 |
import android.service.carrier.CarrierService; |
| 31 |
import android.telephony.Annotation.CallState; |
| 32 |
import android.telephony.Annotation.DataActivityType; |
| 33 |
import android.telephony.Annotation.DisconnectCauses; |
| 34 |
import android.telephony.Annotation.NetworkType; |
| 35 |
import android.telephony.Annotation.PreciseCallStates; |
| 36 |
import android.telephony.Annotation.PreciseDisconnectCauses; |
| 37 |
import android.telephony.Annotation.RadioPowerState; |
| 38 |
import android.telephony.Annotation.SimActivationState; |
| 39 |
import android.telephony.Annotation.SrvccState; |
| 40 |
import android.telephony.TelephonyManager.CarrierPrivilegesCallback; |
| 41 |
import android.telephony.emergency.EmergencyNumber; |
| 42 |
import android.telephony.ims.ImsReasonInfo; |
| 43 |
import android.util.ArraySet; |
| 44 |
import android.util.Log; |
| 45 |
|
| 46 |
import com.android.internal.annotations.GuardedBy; |
| 47 |
import com.android.internal.listeners.ListenerExecutor; |
| 48 |
import com.android.internal.telephony.ICarrierConfigChangeListener; |
| 49 |
import com.android.internal.telephony.ICarrierPrivilegesCallback; |
| 50 |
import com.android.internal.telephony.IOnSubscriptionsChangedListener; |
| 51 |
import com.android.internal.telephony.ITelephonyRegistry; |
| 52 |
|
| 53 |
import java.lang.ref.WeakReference; |
| 54 |
import java.util.Arrays; |
| 55 |
import java.util.HashMap; |
| 56 |
import java.util.List; |
| 57 |
import java.util.Map; |
| 58 |
import java.util.Objects; |
| 59 |
import java.util.Set; |
| 60 |
import java.util.WeakHashMap; |
| 61 |
import java.util.concurrent.ConcurrentHashMap; |
| 62 |
import java.util.concurrent.Executor; |
| 63 |
import java.util.stream.Collectors; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
public class TelephonyRegistryManager { |
| 76 |
|
| 77 |
private static final String TAG = "TelephonyRegistryManager"; |
| 78 |
private static ITelephonyRegistry sRegistry; |
| 79 |
private final Context mContext; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
private final Map<SubscriptionManager.OnSubscriptionsChangedListener, |
| 86 |
IOnSubscriptionsChangedListener> mSubscriptionChangedListenerMap = new HashMap<>(); |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
private final Map<SubscriptionManager.OnOpportunisticSubscriptionsChangedListener, |
| 92 |
IOnSubscriptionsChangedListener> mOpportunisticSubscriptionChangedListenerMap |
| 93 |
= new HashMap<>(); |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
private final ConcurrentHashMap<CarrierConfigManager.CarrierConfigChangeListener, |
| 100 |
ICarrierConfigChangeListener> |
| 101 |
mCarrierConfigChangeListenerMap = new ConcurrentHashMap<>(); |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
public TelephonyRegistryManager(@NonNull Context context) { |
| 106 |
mContext = context; |
| 107 |
if (sRegistry == null) { |
| 108 |
sRegistry = ITelephonyRegistry.Stub.asInterface( |
| 109 |
ServiceManager.getService("telephony.registry")); |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
public void addOnSubscriptionsChangedListener( |
| 125 |
@NonNull SubscriptionManager.OnSubscriptionsChangedListener listener, |
| 126 |
@NonNull Executor executor) { |
| 127 |
if (mSubscriptionChangedListenerMap.get(listener) != null) { |
| 128 |
Log.d(TAG, "addOnSubscriptionsChangedListener listener already present"); |
| 129 |
return; |
| 130 |
} |
| 131 |
IOnSubscriptionsChangedListener callback = new IOnSubscriptionsChangedListener.Stub() { |
| 132 |
@Override |
| 133 |
public void onSubscriptionsChanged () { |
| 134 |
final long identity = Binder.clearCallingIdentity(); |
| 135 |
try { |
| 136 |
executor.execute(() -> listener.onSubscriptionsChanged()); |
| 137 |
} finally { |
| 138 |
Binder.restoreCallingIdentity(identity); |
| 139 |
} |
| 140 |
} |
| 141 |
}; |
| 142 |
mSubscriptionChangedListenerMap.put(listener, callback); |
| 143 |
try { |
| 144 |
sRegistry.addOnSubscriptionsChangedListener(mContext.getOpPackageName(), |
| 145 |
mContext.getAttributionTag(), callback); |
| 146 |
} catch (RemoteException ex) { |
| 147 |
|
| 148 |
throw ex.rethrowFromSystemServer(); |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
public void removeOnSubscriptionsChangedListener( |
| 160 |
@NonNull SubscriptionManager.OnSubscriptionsChangedListener listener) { |
| 161 |
if (mSubscriptionChangedListenerMap.get(listener) == null) { |
| 162 |
return; |
| 163 |
} |
| 164 |
try { |
| 165 |
sRegistry.removeOnSubscriptionsChangedListener(mContext.getOpPackageName(), |
| 166 |
mSubscriptionChangedListenerMap.get(listener)); |
| 167 |
mSubscriptionChangedListenerMap.remove(listener); |
| 168 |
} catch (RemoteException ex) { |
| 169 |
|
| 170 |
throw ex.rethrowFromSystemServer(); |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
public void addOnOpportunisticSubscriptionsChangedListener( |
| 185 |
@NonNull SubscriptionManager.OnOpportunisticSubscriptionsChangedListener listener, |
| 186 |
@NonNull Executor executor) { |
| 187 |
if (mOpportunisticSubscriptionChangedListenerMap.get(listener) != null) { |
| 188 |
Log.d(TAG, "addOnOpportunisticSubscriptionsChangedListener listener already present"); |
| 189 |
return; |
| 190 |
} |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
IOnSubscriptionsChangedListener callback = new IOnSubscriptionsChangedListener.Stub() { |
| 196 |
@Override |
| 197 |
public void onSubscriptionsChanged() { |
| 198 |
final long identity = Binder.clearCallingIdentity(); |
| 199 |
try { |
| 200 |
Log.d(TAG, "onOpportunisticSubscriptionsChanged callback received."); |
| 201 |
executor.execute(() -> listener.onOpportunisticSubscriptionsChanged()); |
| 202 |
} finally { |
| 203 |
Binder.restoreCallingIdentity(identity); |
| 204 |
} |
| 205 |
} |
| 206 |
}; |
| 207 |
mOpportunisticSubscriptionChangedListenerMap.put(listener, callback); |
| 208 |
try { |
| 209 |
sRegistry.addOnOpportunisticSubscriptionsChangedListener(mContext.getOpPackageName(), |
| 210 |
mContext.getAttributionTag(), callback); |
| 211 |
} catch (RemoteException ex) { |
| 212 |
|
| 213 |
throw ex.rethrowFromSystemServer(); |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
public void removeOnOpportunisticSubscriptionsChangedListener( |
| 226 |
@NonNull SubscriptionManager.OnOpportunisticSubscriptionsChangedListener listener) { |
| 227 |
if (mOpportunisticSubscriptionChangedListenerMap.get(listener) == null) { |
| 228 |
return; |
| 229 |
} |
| 230 |
try { |
| 231 |
sRegistry.removeOnSubscriptionsChangedListener(mContext.getOpPackageName(), |
| 232 |
mOpportunisticSubscriptionChangedListenerMap.get(listener)); |
| 233 |
mOpportunisticSubscriptionChangedListenerMap.remove(listener); |
| 234 |
} catch (RemoteException ex) { |
| 235 |
|
| 236 |
throw ex.rethrowFromSystemServer(); |
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
@ChangeId |
| 244 |
@EnabledAfter(targetSdkVersion = Build.VERSION_CODES.P) |
| 245 |
private static final long LISTEN_CODE_CHANGE = 147600208L; |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
public void listenFromListener(int subId, @NonNull boolean renounceFineLocationAccess, |
| 257 |
@NonNull boolean renounceCoarseLocationAccess, @NonNull String pkg, |
| 258 |
@NonNull String featureId, @NonNull PhoneStateListener listener, |
| 259 |
@NonNull int events, boolean notifyNow) { |
| 260 |
if (listener == null) { |
| 261 |
throw new IllegalStateException("telephony service is null."); |
| 262 |
} |
| 263 |
|
| 264 |
try { |
| 265 |
int[] eventsList = getEventsFromBitmask(events).stream().mapToInt(i -> i).toArray(); |
| 266 |
|
| 267 |
|
| 268 |
if (Compatibility.isChangeEnabled(LISTEN_CODE_CHANGE)) { |
| 269 |
|
| 270 |
|
| 271 |
listener.mSubId = (eventsList.length == 0) |
| 272 |
? SubscriptionManager.INVALID_SUBSCRIPTION_ID : subId; |
| 273 |
} else if (listener.mSubId != null) { |
| 274 |
subId = listener.mSubId; |
| 275 |
} |
| 276 |
sRegistry.listenWithEventList(renounceFineLocationAccess, renounceCoarseLocationAccess, |
| 277 |
subId, pkg, featureId, listener.callback, eventsList, notifyNow); |
| 278 |
} catch (RemoteException e) { |
| 279 |
throw e.rethrowFromSystemServer(); |
| 280 |
} |
| 281 |
} |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
private void listenFromCallback(boolean renounceFineLocationAccess, |
| 293 |
boolean renounceCoarseLocationAccess, int subId, |
| 294 |
@NonNull String pkg, @NonNull String featureId, |
| 295 |
@NonNull TelephonyCallback telephonyCallback, @NonNull int[] events, |
| 296 |
boolean notifyNow) { |
| 297 |
try { |
| 298 |
sRegistry.listenWithEventList(renounceFineLocationAccess, renounceCoarseLocationAccess, |
| 299 |
subId, pkg, featureId, telephonyCallback.callback, events, notifyNow); |
| 300 |
} catch (RemoteException e) { |
| 301 |
throw e.rethrowFromSystemServer(); |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
public void notifyCarrierNetworkChange(boolean active) { |
| 323 |
try { |
| 324 |
sRegistry.notifyCarrierNetworkChange(active); |
| 325 |
} catch (RemoteException ex) { |
| 326 |
|
| 327 |
throw ex.rethrowFromSystemServer(); |
| 328 |
} |
| 329 |
} |
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
public void notifyCarrierNetworkChange(int subscriptionId, boolean active) { |
| 349 |
try { |
| 350 |
sRegistry.notifyCarrierNetworkChangeWithSubId(subscriptionId, active); |
| 351 |
} catch (RemoteException ex) { |
| 352 |
|
| 353 |
throw ex.rethrowFromSystemServer(); |
| 354 |
} |
| 355 |
} |
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
public void notifyCallStateChanged(int slotIndex, int subId, @CallState int state, |
| 367 |
@Nullable String incomingNumber) { |
| 368 |
try { |
| 369 |
sRegistry.notifyCallState(slotIndex, subId, state, incomingNumber); |
| 370 |
} catch (RemoteException ex) { |
| 371 |
|
| 372 |
throw ex.rethrowFromSystemServer(); |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
| 384 |
public void notifyCallStateChangedForAllSubscriptions(@CallState int state, |
| 385 |
@Nullable String incomingNumber) { |
| 386 |
try { |
| 387 |
sRegistry.notifyCallStateForAllSubs(state, incomingNumber); |
| 388 |
} catch (RemoteException ex) { |
| 389 |
|
| 390 |
throw ex.rethrowFromSystemServer(); |
| 391 |
} |
| 392 |
} |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
public void notifySubscriptionInfoChanged() { |
| 399 |
try { |
| 400 |
sRegistry.notifySubscriptionInfoChanged(); |
| 401 |
} catch (RemoteException ex) { |
| 402 |
|
| 403 |
throw ex.rethrowFromSystemServer(); |
| 404 |
} |
| 405 |
} |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
public void notifyOpportunisticSubscriptionInfoChanged() { |
| 412 |
try { |
| 413 |
sRegistry.notifyOpportunisticSubscriptionInfoChanged(); |
| 414 |
} catch (RemoteException ex) { |
| 415 |
|
| 416 |
throw ex.rethrowFromSystemServer(); |
| 417 |
} |
| 418 |
} |
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
public void notifyServiceStateChanged(int slotIndex, int subId, @NonNull ServiceState state) { |
| 429 |
try { |
| 430 |
sRegistry.notifyServiceStateForPhoneId(slotIndex, subId, state); |
| 431 |
} catch (RemoteException ex) { |
| 432 |
|
| 433 |
throw ex.rethrowFromSystemServer(); |
| 434 |
} |
| 435 |
} |
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
public void notifySignalStrengthChanged(int slotIndex, int subId, |
| 446 |
@NonNull SignalStrength signalStrength) { |
| 447 |
try { |
| 448 |
sRegistry.notifySignalStrengthForPhoneId(slotIndex, subId, signalStrength); |
| 449 |
} catch (RemoteException ex) { |
| 450 |
|
| 451 |
throw ex.rethrowFromSystemServer(); |
| 452 |
} |
| 453 |
} |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
public void notifyMessageWaitingChanged(int slotIndex, int subId, boolean msgWaitingInd) { |
| 466 |
try { |
| 467 |
sRegistry.notifyMessageWaitingChangedForPhoneId(slotIndex, subId, msgWaitingInd); |
| 468 |
} catch (RemoteException ex) { |
| 469 |
|
| 470 |
throw ex.rethrowFromSystemServer(); |
| 471 |
} |
| 472 |
} |
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
public void notifyCallForwardingChanged(int subId, boolean callForwardInd) { |
| 482 |
try { |
| 483 |
sRegistry.notifyCallForwardingChangedForSubscriber(subId, callForwardInd); |
| 484 |
} catch (RemoteException ex) { |
| 485 |
|
| 486 |
throw ex.rethrowFromSystemServer(); |
| 487 |
} |
| 488 |
} |
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
public void notifyDataActivityChanged(int subId, @DataActivityType int dataActivityType) { |
| 498 |
try { |
| 499 |
sRegistry.notifyDataActivityForSubscriber(subId, dataActivityType); |
| 500 |
} catch (RemoteException ex) { |
| 501 |
|
| 502 |
throw ex.rethrowFromSystemServer(); |
| 503 |
} |
| 504 |
} |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
public void notifyDataConnectionForSubscriber(int slotIndex, int subId, |
| 518 |
@NonNull PreciseDataConnectionState preciseState) { |
| 519 |
try { |
| 520 |
sRegistry.notifyDataConnectionForSubscriber( |
| 521 |
slotIndex, subId, preciseState); |
| 522 |
} catch (RemoteException ex) { |
| 523 |
|
| 524 |
throw ex.rethrowFromSystemServer(); |
| 525 |
} |
| 526 |
} |
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
public void notifyCallQualityChanged(int slotIndex, int subId, @NonNull CallQuality callQuality, |
| 538 |
@NetworkType int networkType) { |
| 539 |
try { |
| 540 |
sRegistry.notifyCallQualityChanged(callQuality, slotIndex, subId, networkType); |
| 541 |
} catch (RemoteException ex) { |
| 542 |
|
| 543 |
throw ex.rethrowFromSystemServer(); |
| 544 |
} |
| 545 |
} |
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
public void notifyEmergencyNumberList( int slotIndex, int subId) { |
| 555 |
try { |
| 556 |
sRegistry.notifyEmergencyNumberList(slotIndex, subId); |
| 557 |
} catch (RemoteException ex) { |
| 558 |
|
| 559 |
throw ex.rethrowFromSystemServer(); |
| 560 |
} |
| 561 |
} |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
public void notifyOutgoingEmergencyCall(int phoneId, int subId, |
| 570 |
@NonNull EmergencyNumber emergencyNumber) { |
| 571 |
try { |
| 572 |
sRegistry.notifyOutgoingEmergencyCall(phoneId, subId, emergencyNumber); |
| 573 |
} catch (RemoteException ex) { |
| 574 |
|
| 575 |
throw ex.rethrowFromSystemServer(); |
| 576 |
} |
| 577 |
} |
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
public void notifyOutgoingEmergencySms(int phoneId, int subId, |
| 586 |
@NonNull EmergencyNumber emergencyNumber) { |
| 587 |
try { |
| 588 |
sRegistry.notifyOutgoingEmergencySms(phoneId, subId, emergencyNumber); |
| 589 |
} catch (RemoteException ex) { |
| 590 |
|
| 591 |
throw ex.rethrowFromSystemServer(); |
| 592 |
} |
| 593 |
} |
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
public void notifyRadioPowerStateChanged(int slotIndex, int subId, |
| 604 |
@RadioPowerState int radioPowerState) { |
| 605 |
try { |
| 606 |
sRegistry.notifyRadioPowerStateChanged(slotIndex, subId, radioPowerState); |
| 607 |
} catch (RemoteException ex) { |
| 608 |
|
| 609 |
throw ex.rethrowFromSystemServer(); |
| 610 |
} |
| 611 |
} |
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
public void notifyPhoneCapabilityChanged(@NonNull PhoneCapability phoneCapability) { |
| 619 |
try { |
| 620 |
sRegistry.notifyPhoneCapabilityChanged(phoneCapability); |
| 621 |
} catch (RemoteException ex) { |
| 622 |
|
| 623 |
throw ex.rethrowFromSystemServer(); |
| 624 |
} |
| 625 |
} |
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
public static final int SIM_ACTIVATION_TYPE_VOICE = 0; |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
public static final int SIM_ACTIVATION_TYPE_DATA = 1; |
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
public void notifyDataActivationStateChanged(int slotIndex, int subId, |
| 650 |
@SimActivationState int activationState) { |
| 651 |
try { |
| 652 |
sRegistry.notifySimActivationStateChangedForPhoneId(slotIndex, subId, |
| 653 |
SIM_ACTIVATION_TYPE_DATA, activationState); |
| 654 |
} catch (RemoteException ex) { |
| 655 |
|
| 656 |
throw ex.rethrowFromSystemServer(); |
| 657 |
} |
| 658 |
} |
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
public void notifyVoiceActivationStateChanged(int slotIndex, int subId, |
| 670 |
@SimActivationState int activationState) { |
| 671 |
try { |
| 672 |
sRegistry.notifySimActivationStateChangedForPhoneId(slotIndex, subId, |
| 673 |
SIM_ACTIVATION_TYPE_VOICE, activationState); |
| 674 |
} catch (RemoteException ex) { |
| 675 |
|
| 676 |
throw ex.rethrowFromSystemServer(); |
| 677 |
} |
| 678 |
} |
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
public void notifyUserMobileDataStateChanged(int slotIndex, int subId, boolean state) { |
| 690 |
try { |
| 691 |
sRegistry.notifyUserMobileDataStateChangedForPhoneId(slotIndex, subId, state); |
| 692 |
} catch (RemoteException ex) { |
| 693 |
|
| 694 |
throw ex.rethrowFromSystemServer(); |
| 695 |
} |
| 696 |
} |
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
public void notifyDisplayInfoChanged(int slotIndex, int subscriptionId, |
| 708 |
@NonNull TelephonyDisplayInfo telephonyDisplayInfo) { |
| 709 |
try { |
| 710 |
sRegistry.notifyDisplayInfoChanged(slotIndex, subscriptionId, telephonyDisplayInfo); |
| 711 |
} catch (RemoteException ex) { |
| 712 |
|
| 713 |
throw ex.rethrowFromSystemServer(); |
| 714 |
} |
| 715 |
} |
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
public void notifyImsDisconnectCause(int subId, @NonNull ImsReasonInfo imsReasonInfo) { |
| 724 |
try { |
| 725 |
sRegistry.notifyImsDisconnectCause(subId, imsReasonInfo); |
| 726 |
} catch (RemoteException ex) { |
| 727 |
|
| 728 |
throw ex.rethrowFromSystemServer(); |
| 729 |
} |
| 730 |
} |
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
public void notifySrvccStateChanged(int subId, @SrvccState int state) { |
| 740 |
try { |
| 741 |
sRegistry.notifySrvccStateChanged(subId, state); |
| 742 |
} catch (RemoteException ex) { |
| 743 |
|
| 744 |
throw ex.rethrowFromSystemServer(); |
| 745 |
} |
| 746 |
} |
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
public void notifyPreciseCallState(int slotIndex, int subId, |
| 760 |
@PreciseCallStates int ringCallPreciseState, |
| 761 |
@PreciseCallStates int foregroundCallPreciseState, |
| 762 |
@PreciseCallStates int backgroundCallPreciseState) { |
| 763 |
try { |
| 764 |
sRegistry.notifyPreciseCallState(slotIndex, subId, ringCallPreciseState, |
| 765 |
foregroundCallPreciseState, backgroundCallPreciseState); |
| 766 |
} catch (RemoteException ex) { |
| 767 |
|
| 768 |
throw ex.rethrowFromSystemServer(); |
| 769 |
} |
| 770 |
} |
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
public void notifyDisconnectCause(int slotIndex, int subId, @DisconnectCauses int cause, |
| 784 |
@PreciseDisconnectCauses int preciseCause) { |
| 785 |
try { |
| 786 |
sRegistry.notifyDisconnectCause(slotIndex, subId, cause, preciseCause); |
| 787 |
} catch (RemoteException ex) { |
| 788 |
|
| 789 |
throw ex.rethrowFromSystemServer(); |
| 790 |
} |
| 791 |
} |
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
public void notifyCellLocation(int subId, @NonNull CellIdentity cellLocation) { |
| 800 |
try { |
| 801 |
sRegistry.notifyCellLocationForSubscriber(subId, cellLocation); |
| 802 |
} catch (RemoteException ex) { |
| 803 |
|
| 804 |
throw ex.rethrowFromSystemServer(); |
| 805 |
} |
| 806 |
} |
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
public void notifyCellInfoChanged(int subId, @NonNull List<CellInfo> cellInfo) { |
| 816 |
try { |
| 817 |
sRegistry.notifyCellInfoForSubscriber(subId, cellInfo); |
| 818 |
} catch (RemoteException ex) { |
| 819 |
throw ex.rethrowFromSystemServer(); |
| 820 |
} |
| 821 |
} |
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
public void notifyActiveDataSubIdChanged(int activeDataSubId) { |
| 828 |
try { |
| 829 |
sRegistry.notifyActiveDataSubIdChanged(activeDataSubId); |
| 830 |
} catch (RemoteException ex) { |
| 831 |
throw ex.rethrowFromSystemServer(); |
| 832 |
} |
| 833 |
} |
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
public void notifyRegistrationFailed(int slotIndex, int subId, |
| 858 |
@NonNull CellIdentity cellIdentity, @NonNull String chosenPlmn, |
| 859 |
int domain, int causeCode, int additionalCauseCode) { |
| 860 |
try { |
| 861 |
sRegistry.notifyRegistrationFailed(slotIndex, subId, cellIdentity, |
| 862 |
chosenPlmn, domain, causeCode, additionalCauseCode); |
| 863 |
} catch (RemoteException ex) { |
| 864 |
throw ex.rethrowFromSystemServer(); |
| 865 |
} |
| 866 |
} |
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
public void notifyBarringInfoChanged( |
| 876 |
int slotIndex, int subId, @NonNull BarringInfo barringInfo) { |
| 877 |
try { |
| 878 |
sRegistry.notifyBarringInfoChanged(slotIndex, subId, barringInfo); |
| 879 |
} catch (RemoteException ex) { |
| 880 |
|
| 881 |
throw ex.rethrowFromSystemServer(); |
| 882 |
} |
| 883 |
} |
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
public void notifyPhysicalChannelConfigForSubscriber(int slotIndex, int subId, |
| 893 |
List<PhysicalChannelConfig> configs) { |
| 894 |
try { |
| 895 |
sRegistry.notifyPhysicalChannelConfigForSubscriber(slotIndex, subId, configs); |
| 896 |
} catch (RemoteException ex) { |
| 897 |
|
| 898 |
throw ex.rethrowFromSystemServer(); |
| 899 |
} |
| 900 |
} |
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
public void notifyDataEnabled(int slotIndex, int subId, boolean enabled, |
| 910 |
@TelephonyManager.DataEnabledReason int reason) { |
| 911 |
try { |
| 912 |
sRegistry.notifyDataEnabled(slotIndex, subId, enabled, reason); |
| 913 |
} catch (RemoteException ex) { |
| 914 |
|
| 915 |
throw ex.rethrowFromSystemServer(); |
| 916 |
} |
| 917 |
} |
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
public void notifyAllowedNetworkTypesChanged(int slotIndex, int subId, |
| 928 |
int reason, long allowedNetworkType) { |
| 929 |
try { |
| 930 |
sRegistry.notifyAllowedNetworkTypesChanged(slotIndex, subId, reason, |
| 931 |
allowedNetworkType); |
| 932 |
} catch (RemoteException ex) { |
| 933 |
|
| 934 |
throw ex.rethrowFromSystemServer(); |
| 935 |
} |
| 936 |
} |
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
public void notifyLinkCapacityEstimateChanged(int slotIndex, int subId, |
| 945 |
List<LinkCapacityEstimate> linkCapacityEstimateList) { |
| 946 |
try { |
| 947 |
sRegistry.notifyLinkCapacityEstimateChanged(slotIndex, subId, linkCapacityEstimateList); |
| 948 |
} catch (RemoteException ex) { |
| 949 |
|
| 950 |
throw ex.rethrowFromSystemServer(); |
| 951 |
} |
| 952 |
} |
| 953 |
|
| 954 |
public @NonNull Set<Integer> getEventsFromCallback( |
| 955 |
@NonNull TelephonyCallback telephonyCallback) { |
| 956 |
Set<Integer> eventList = new ArraySet<>(); |
| 957 |
|
| 958 |
if (telephonyCallback instanceof TelephonyCallback.ServiceStateListener) { |
| 959 |
eventList.add(TelephonyCallback.EVENT_SERVICE_STATE_CHANGED); |
| 960 |
} |
| 961 |
|
| 962 |
if (telephonyCallback instanceof TelephonyCallback.MessageWaitingIndicatorListener) { |
| 963 |
eventList.add(TelephonyCallback.EVENT_MESSAGE_WAITING_INDICATOR_CHANGED); |
| 964 |
} |
| 965 |
|
| 966 |
if (telephonyCallback instanceof TelephonyCallback.CallForwardingIndicatorListener) { |
| 967 |
eventList.add(TelephonyCallback.EVENT_CALL_FORWARDING_INDICATOR_CHANGED); |
| 968 |
} |
| 969 |
|
| 970 |
if (telephonyCallback instanceof TelephonyCallback.CellLocationListener) { |
| 971 |
eventList.add(TelephonyCallback.EVENT_CELL_LOCATION_CHANGED); |
| 972 |
} |
| 973 |
|
| 974 |
|
| 975 |
if (telephonyCallback instanceof TelephonyCallback.CallStateListener) { |
| 976 |
eventList.add(TelephonyCallback.EVENT_CALL_STATE_CHANGED); |
| 977 |
} |
| 978 |
|
| 979 |
if (telephonyCallback instanceof TelephonyCallback.DataConnectionStateListener) { |
| 980 |
eventList.add(TelephonyCallback.EVENT_DATA_CONNECTION_STATE_CHANGED); |
| 981 |
} |
| 982 |
|
| 983 |
if (telephonyCallback instanceof TelephonyCallback.DataActivityListener) { |
| 984 |
eventList.add(TelephonyCallback.EVENT_DATA_ACTIVITY_CHANGED); |
| 985 |
} |
| 986 |
|
| 987 |
if (telephonyCallback instanceof TelephonyCallback.SignalStrengthsListener) { |
| 988 |
eventList.add(TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED); |
| 989 |
} |
| 990 |
|
| 991 |
if (telephonyCallback instanceof TelephonyCallback.CellInfoListener) { |
| 992 |
eventList.add(TelephonyCallback.EVENT_CELL_INFO_CHANGED); |
| 993 |
} |
| 994 |
|
| 995 |
if (telephonyCallback instanceof TelephonyCallback.PreciseCallStateListener) { |
| 996 |
eventList.add(TelephonyCallback.EVENT_PRECISE_CALL_STATE_CHANGED); |
| 997 |
} |
| 998 |
|
| 999 |
if (telephonyCallback instanceof TelephonyCallback.CallDisconnectCauseListener) { |
| 1000 |
eventList.add(TelephonyCallback.EVENT_CALL_DISCONNECT_CAUSE_CHANGED); |
| 1001 |
} |
| 1002 |
|
| 1003 |
if (telephonyCallback instanceof TelephonyCallback.ImsCallDisconnectCauseListener) { |
| 1004 |
eventList.add(TelephonyCallback.EVENT_IMS_CALL_DISCONNECT_CAUSE_CHANGED); |
| 1005 |
} |
| 1006 |
|
| 1007 |
if (telephonyCallback instanceof TelephonyCallback.PreciseDataConnectionStateListener) { |
| 1008 |
eventList.add(TelephonyCallback.EVENT_PRECISE_DATA_CONNECTION_STATE_CHANGED); |
| 1009 |
} |
| 1010 |
|
| 1011 |
if (telephonyCallback instanceof TelephonyCallback.SrvccStateListener) { |
| 1012 |
eventList.add(TelephonyCallback.EVENT_SRVCC_STATE_CHANGED); |
| 1013 |
} |
| 1014 |
|
| 1015 |
if (telephonyCallback instanceof TelephonyCallback.VoiceActivationStateListener) { |
| 1016 |
eventList.add(TelephonyCallback.EVENT_VOICE_ACTIVATION_STATE_CHANGED); |
| 1017 |
} |
| 1018 |
|
| 1019 |
if (telephonyCallback instanceof TelephonyCallback.DataActivationStateListener) { |
| 1020 |
eventList.add(TelephonyCallback.EVENT_DATA_ACTIVATION_STATE_CHANGED); |
| 1021 |
} |
| 1022 |
|
| 1023 |
if (telephonyCallback instanceof TelephonyCallback.UserMobileDataStateListener) { |
| 1024 |
eventList.add(TelephonyCallback.EVENT_USER_MOBILE_DATA_STATE_CHANGED); |
| 1025 |
} |
| 1026 |
|
| 1027 |
if (telephonyCallback instanceof TelephonyCallback.DisplayInfoListener) { |
| 1028 |
eventList.add(TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED); |
| 1029 |
} |
| 1030 |
|
| 1031 |
if (telephonyCallback instanceof TelephonyCallback.EmergencyNumberListListener) { |
| 1032 |
eventList.add(TelephonyCallback.EVENT_EMERGENCY_NUMBER_LIST_CHANGED); |
| 1033 |
} |
| 1034 |
|
| 1035 |
if (telephonyCallback instanceof TelephonyCallback.OutgoingEmergencyCallListener) { |
| 1036 |
eventList.add(TelephonyCallback.EVENT_OUTGOING_EMERGENCY_CALL); |
| 1037 |
} |
| 1038 |
|
| 1039 |
if (telephonyCallback instanceof TelephonyCallback.OutgoingEmergencySmsListener) { |
| 1040 |
eventList.add(TelephonyCallback.EVENT_OUTGOING_EMERGENCY_SMS); |
| 1041 |
} |
| 1042 |
|
| 1043 |
if (telephonyCallback instanceof TelephonyCallback.PhoneCapabilityListener) { |
| 1044 |
eventList.add(TelephonyCallback.EVENT_PHONE_CAPABILITY_CHANGED); |
| 1045 |
} |
| 1046 |
|
| 1047 |
if (telephonyCallback instanceof TelephonyCallback.ActiveDataSubscriptionIdListener) { |
| 1048 |
eventList.add(TelephonyCallback.EVENT_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGED); |
| 1049 |
} |
| 1050 |
|
| 1051 |
if (telephonyCallback instanceof TelephonyCallback.RadioPowerStateListener) { |
| 1052 |
eventList.add(TelephonyCallback.EVENT_RADIO_POWER_STATE_CHANGED); |
| 1053 |
} |
| 1054 |
|
| 1055 |
if (telephonyCallback instanceof TelephonyCallback.CarrierNetworkListener) { |
| 1056 |
eventList.add(TelephonyCallback.EVENT_CARRIER_NETWORK_CHANGED); |
| 1057 |
} |
| 1058 |
|
| 1059 |
if (telephonyCallback instanceof TelephonyCallback.RegistrationFailedListener) { |
| 1060 |
eventList.add(TelephonyCallback.EVENT_REGISTRATION_FAILURE); |
| 1061 |
} |
| 1062 |
|
| 1063 |
if (telephonyCallback instanceof TelephonyCallback.CallAttributesListener) { |
| 1064 |
eventList.add(TelephonyCallback.EVENT_CALL_ATTRIBUTES_CHANGED); |
| 1065 |
} |
| 1066 |
|
| 1067 |
if (telephonyCallback instanceof TelephonyCallback.BarringInfoListener) { |
| 1068 |
eventList.add(TelephonyCallback.EVENT_BARRING_INFO_CHANGED); |
| 1069 |
} |
| 1070 |
|
| 1071 |
if (telephonyCallback instanceof TelephonyCallback.PhysicalChannelConfigListener) { |
| 1072 |
eventList.add(TelephonyCallback.EVENT_PHYSICAL_CHANNEL_CONFIG_CHANGED); |
| 1073 |
} |
| 1074 |
|
| 1075 |
if (telephonyCallback instanceof TelephonyCallback.DataEnabledListener) { |
| 1076 |
eventList.add(TelephonyCallback.EVENT_DATA_ENABLED_CHANGED); |
| 1077 |
} |
| 1078 |
|
| 1079 |
if (telephonyCallback instanceof TelephonyCallback.AllowedNetworkTypesListener) { |
| 1080 |
eventList.add(TelephonyCallback.EVENT_ALLOWED_NETWORK_TYPE_LIST_CHANGED); |
| 1081 |
} |
| 1082 |
|
| 1083 |
if (telephonyCallback instanceof TelephonyCallback.LinkCapacityEstimateChangedListener) { |
| 1084 |
eventList.add(TelephonyCallback.EVENT_LINK_CAPACITY_ESTIMATE_CHANGED); |
| 1085 |
} |
| 1086 |
|
| 1087 |
return eventList; |
| 1088 |
} |
| 1089 |
|
| 1090 |
private @NonNull Set<Integer> getEventsFromBitmask(int eventMask) { |
| 1091 |
|
| 1092 |
Set<Integer> eventList = new ArraySet<>(); |
| 1093 |
|
| 1094 |
if ((eventMask & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) { |
| 1095 |
eventList.add(TelephonyCallback.EVENT_SERVICE_STATE_CHANGED); |
| 1096 |
} |
| 1097 |
|
| 1098 |
if ((eventMask & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) { |
| 1099 |
eventList.add(TelephonyCallback.EVENT_SIGNAL_STRENGTH_CHANGED); |
| 1100 |
} |
| 1101 |
|
| 1102 |
if ((eventMask & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { |
| 1103 |
eventList.add(TelephonyCallback.EVENT_MESSAGE_WAITING_INDICATOR_CHANGED); |
| 1104 |
} |
| 1105 |
|
| 1106 |
if ((eventMask & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) { |
| 1107 |
eventList.add(TelephonyCallback.EVENT_CALL_FORWARDING_INDICATOR_CHANGED); |
| 1108 |
} |
| 1109 |
|
| 1110 |
if ((eventMask & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) { |
| 1111 |
eventList.add(TelephonyCallback.EVENT_CELL_LOCATION_CHANGED); |
| 1112 |
} |
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
if ((eventMask & PhoneStateListener.LISTEN_CALL_STATE) != 0) { |
| 1117 |
eventList.add(TelephonyCallback.EVENT_LEGACY_CALL_STATE_CHANGED); |
| 1118 |
} |
| 1119 |
|
| 1120 |
if ((eventMask & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) { |
| 1121 |
eventList.add(TelephonyCallback.EVENT_DATA_CONNECTION_STATE_CHANGED); |
| 1122 |
} |
| 1123 |
|
| 1124 |
if ((eventMask & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) { |
| 1125 |
eventList.add(TelephonyCallback.EVENT_DATA_ACTIVITY_CHANGED); |
| 1126 |
} |
| 1127 |
|
| 1128 |
if ((eventMask & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { |
| 1129 |
eventList.add(TelephonyCallback.EVENT_SIGNAL_STRENGTHS_CHANGED); |
| 1130 |
} |
| 1131 |
|
| 1132 |
if ((eventMask & PhoneStateListener.LISTEN_CELL_INFO) != 0) { |
| 1133 |
eventList.add(TelephonyCallback.EVENT_CELL_INFO_CHANGED); |
| 1134 |
} |
| 1135 |
|
| 1136 |
if ((eventMask & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { |
| 1137 |
eventList.add(TelephonyCallback.EVENT_PRECISE_CALL_STATE_CHANGED); |
| 1138 |
} |
| 1139 |
|
| 1140 |
if ((eventMask & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 1141 |
eventList.add(TelephonyCallback.EVENT_PRECISE_DATA_CONNECTION_STATE_CHANGED); |
| 1142 |
} |
| 1143 |
|
| 1144 |
if ((eventMask & PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO) != 0) { |
| 1145 |
eventList.add(TelephonyCallback.EVENT_DATA_CONNECTION_REAL_TIME_INFO_CHANGED); |
| 1146 |
} |
| 1147 |
|
| 1148 |
if ((eventMask & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) { |
| 1149 |
eventList.add(TelephonyCallback.EVENT_OEM_HOOK_RAW); |
| 1150 |
} |
| 1151 |
|
| 1152 |
if ((eventMask & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) { |
| 1153 |
eventList.add(TelephonyCallback.EVENT_SRVCC_STATE_CHANGED); |
| 1154 |
} |
| 1155 |
|
| 1156 |
if ((eventMask & PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) != 0) { |
| 1157 |
eventList.add(TelephonyCallback.EVENT_CARRIER_NETWORK_CHANGED); |
| 1158 |
} |
| 1159 |
|
| 1160 |
if ((eventMask & PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) != 0) { |
| 1161 |
eventList.add(TelephonyCallback.EVENT_VOICE_ACTIVATION_STATE_CHANGED); |
| 1162 |
} |
| 1163 |
|
| 1164 |
if ((eventMask & PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE) != 0) { |
| 1165 |
eventList.add(TelephonyCallback.EVENT_DATA_ACTIVATION_STATE_CHANGED); |
| 1166 |
} |
| 1167 |
|
| 1168 |
if ((eventMask & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) { |
| 1169 |
eventList.add(TelephonyCallback.EVENT_USER_MOBILE_DATA_STATE_CHANGED); |
| 1170 |
} |
| 1171 |
|
| 1172 |
if ((eventMask & PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED) != 0) { |
| 1173 |
eventList.add(TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED); |
| 1174 |
} |
| 1175 |
|
| 1176 |
if ((eventMask & PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE) != 0) { |
| 1177 |
eventList.add(TelephonyCallback.EVENT_PHONE_CAPABILITY_CHANGED); |
| 1178 |
} |
| 1179 |
|
| 1180 |
if ((eventMask & PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE) != 0) { |
| 1181 |
eventList.add(TelephonyCallback.EVENT_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGED); |
| 1182 |
} |
| 1183 |
|
| 1184 |
if ((eventMask & PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED) != 0) { |
| 1185 |
eventList.add(TelephonyCallback.EVENT_RADIO_POWER_STATE_CHANGED); |
| 1186 |
} |
| 1187 |
|
| 1188 |
if ((eventMask & PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST) != 0) { |
| 1189 |
eventList.add(TelephonyCallback.EVENT_EMERGENCY_NUMBER_LIST_CHANGED); |
| 1190 |
} |
| 1191 |
|
| 1192 |
if ((eventMask & PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES) != 0) { |
| 1193 |
eventList.add(TelephonyCallback.EVENT_CALL_DISCONNECT_CAUSE_CHANGED); |
| 1194 |
} |
| 1195 |
|
| 1196 |
if ((eventMask & PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED) != 0) { |
| 1197 |
eventList.add(TelephonyCallback.EVENT_CALL_ATTRIBUTES_CHANGED); |
| 1198 |
} |
| 1199 |
|
| 1200 |
if ((eventMask & PhoneStateListener.LISTEN_IMS_CALL_DISCONNECT_CAUSES) != 0) { |
| 1201 |
eventList.add(TelephonyCallback.EVENT_IMS_CALL_DISCONNECT_CAUSE_CHANGED); |
| 1202 |
} |
| 1203 |
|
| 1204 |
if ((eventMask & PhoneStateListener.LISTEN_OUTGOING_EMERGENCY_CALL) != 0) { |
| 1205 |
eventList.add(TelephonyCallback.EVENT_OUTGOING_EMERGENCY_CALL); |
| 1206 |
} |
| 1207 |
|
| 1208 |
if ((eventMask & PhoneStateListener.LISTEN_OUTGOING_EMERGENCY_SMS) != 0) { |
| 1209 |
eventList.add(TelephonyCallback.EVENT_OUTGOING_EMERGENCY_SMS); |
| 1210 |
} |
| 1211 |
|
| 1212 |
if ((eventMask & PhoneStateListener.LISTEN_REGISTRATION_FAILURE) != 0) { |
| 1213 |
eventList.add(TelephonyCallback.EVENT_REGISTRATION_FAILURE); |
| 1214 |
} |
| 1215 |
|
| 1216 |
if ((eventMask & PhoneStateListener.LISTEN_BARRING_INFO) != 0) { |
| 1217 |
eventList.add(TelephonyCallback.EVENT_BARRING_INFO_CHANGED); |
| 1218 |
} |
| 1219 |
return eventList; |
| 1220 |
|
| 1221 |
} |
| 1222 |
|
| 1223 |
|
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
|
| 1233 |
|
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
public void registerTelephonyCallback(boolean renounceFineLocationAccess, |
| 1253 |
boolean renounceCoarseLocationAccess, |
| 1254 |
@NonNull @CallbackExecutor Executor executor, |
| 1255 |
int subId, String pkgName, String attributionTag, @NonNull TelephonyCallback callback, |
| 1256 |
boolean notifyNow) { |
| 1257 |
if (callback == null) { |
| 1258 |
throw new IllegalStateException("telephony service is null."); |
| 1259 |
} |
| 1260 |
callback.init(executor); |
| 1261 |
listenFromCallback(renounceFineLocationAccess, renounceCoarseLocationAccess, subId, |
| 1262 |
pkgName, attributionTag, callback, |
| 1263 |
getEventsFromCallback(callback).stream().mapToInt(i -> i).toArray(), notifyNow); |
| 1264 |
} |
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
public void unregisterTelephonyCallback(int subId, String pkgName, String attributionTag, |
| 1272 |
@NonNull TelephonyCallback callback, boolean notifyNow) { |
| 1273 |
listenFromCallback(false, false, subId, |
| 1274 |
pkgName, attributionTag, callback, new int[0], notifyNow); |
| 1275 |
} |
| 1276 |
|
| 1277 |
private static class CarrierPrivilegesCallbackWrapper extends ICarrierPrivilegesCallback.Stub |
| 1278 |
implements ListenerExecutor { |
| 1279 |
@NonNull private final WeakReference<CarrierPrivilegesCallback> mCallback; |
| 1280 |
@NonNull private final Executor mExecutor; |
| 1281 |
|
| 1282 |
CarrierPrivilegesCallbackWrapper( |
| 1283 |
@NonNull CarrierPrivilegesCallback callback, @NonNull Executor executor) { |
| 1284 |
mCallback = new WeakReference<>(callback); |
| 1285 |
mExecutor = executor; |
| 1286 |
} |
| 1287 |
|
| 1288 |
@Override |
| 1289 |
public void onCarrierPrivilegesChanged( |
| 1290 |
@NonNull List<String> privilegedPackageNames, @NonNull int[] privilegedUids) { |
| 1291 |
|
| 1292 |
Set<String> privilegedPkgNamesSet = Set.copyOf(privilegedPackageNames); |
| 1293 |
Set<Integer> privilegedUidsSet = Arrays.stream(privilegedUids).boxed().collect( |
| 1294 |
Collectors.toSet()); |
| 1295 |
Binder.withCleanCallingIdentity( |
| 1296 |
() -> |
| 1297 |
executeSafely( |
| 1298 |
mExecutor, |
| 1299 |
mCallback::get, |
| 1300 |
cpc -> |
| 1301 |
cpc.onCarrierPrivilegesChanged( |
| 1302 |
privilegedPkgNamesSet, privilegedUidsSet))); |
| 1303 |
} |
| 1304 |
|
| 1305 |
@Override |
| 1306 |
public void onCarrierServiceChanged(@Nullable String packageName, int uid) { |
| 1307 |
Binder.withCleanCallingIdentity( |
| 1308 |
() -> |
| 1309 |
executeSafely( |
| 1310 |
mExecutor, |
| 1311 |
mCallback::get, |
| 1312 |
cpc -> cpc.onCarrierServiceChanged(packageName, uid))); |
| 1313 |
} |
| 1314 |
} |
| 1315 |
|
| 1316 |
@NonNull |
| 1317 |
@GuardedBy("sCarrierPrivilegeCallbacks") |
| 1318 |
private static final WeakHashMap<CarrierPrivilegesCallback, |
| 1319 |
WeakReference<CarrierPrivilegesCallbackWrapper>> |
| 1320 |
sCarrierPrivilegeCallbacks = new WeakHashMap<>(); |
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
public void addCarrierPrivilegesCallback( |
| 1332 |
int logicalSlotIndex, |
| 1333 |
@NonNull @CallbackExecutor Executor executor, |
| 1334 |
@NonNull CarrierPrivilegesCallback callback) { |
| 1335 |
if (callback == null || executor == null) { |
| 1336 |
throw new IllegalArgumentException("callback and executor must be non-null"); |
| 1337 |
} |
| 1338 |
synchronized (sCarrierPrivilegeCallbacks) { |
| 1339 |
WeakReference<CarrierPrivilegesCallbackWrapper> existing = |
| 1340 |
sCarrierPrivilegeCallbacks.get(callback); |
| 1341 |
if (existing != null && existing.get() != null) { |
| 1342 |
Log.d(TAG, "addCarrierPrivilegesCallback: callback already registered"); |
| 1343 |
return; |
| 1344 |
} |
| 1345 |
CarrierPrivilegesCallbackWrapper wrapper = |
| 1346 |
new CarrierPrivilegesCallbackWrapper(callback, executor); |
| 1347 |
sCarrierPrivilegeCallbacks.put(callback, new WeakReference<>(wrapper)); |
| 1348 |
try { |
| 1349 |
sRegistry.addCarrierPrivilegesCallback( |
| 1350 |
logicalSlotIndex, |
| 1351 |
wrapper, |
| 1352 |
mContext.getOpPackageName(), |
| 1353 |
mContext.getAttributionTag()); |
| 1354 |
} catch (RemoteException e) { |
| 1355 |
throw e.rethrowFromSystemServer(); |
| 1356 |
} |
| 1357 |
} |
| 1358 |
} |
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
public void removeCarrierPrivilegesCallback(@NonNull CarrierPrivilegesCallback callback) { |
| 1366 |
if (callback == null) { |
| 1367 |
throw new IllegalArgumentException("listener must be non-null"); |
| 1368 |
} |
| 1369 |
synchronized (sCarrierPrivilegeCallbacks) { |
| 1370 |
WeakReference<CarrierPrivilegesCallbackWrapper> ref = |
| 1371 |
sCarrierPrivilegeCallbacks.remove(callback); |
| 1372 |
if (ref == null) return; |
| 1373 |
CarrierPrivilegesCallbackWrapper wrapper = ref.get(); |
| 1374 |
if (wrapper == null) return; |
| 1375 |
try { |
| 1376 |
sRegistry.removeCarrierPrivilegesCallback(wrapper, mContext.getOpPackageName()); |
| 1377 |
} catch (RemoteException e) { |
| 1378 |
throw e.rethrowFromSystemServer(); |
| 1379 |
} |
| 1380 |
} |
| 1381 |
} |
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
public void notifyCarrierPrivilegesChanged( |
| 1391 |
int logicalSlotIndex, |
| 1392 |
@NonNull Set<String> privilegedPackageNames, |
| 1393 |
@NonNull Set<Integer> privilegedUids) { |
| 1394 |
if (privilegedPackageNames == null || privilegedUids == null) { |
| 1395 |
throw new IllegalArgumentException( |
| 1396 |
"privilegedPackageNames and privilegedUids must be non-null"); |
| 1397 |
} |
| 1398 |
try { |
| 1399 |
|
| 1400 |
List<String> pkgList = List.copyOf(privilegedPackageNames); |
| 1401 |
int[] uids = privilegedUids.stream().mapToInt(Number::intValue).toArray(); |
| 1402 |
sRegistry.notifyCarrierPrivilegesChanged(logicalSlotIndex, pkgList, uids); |
| 1403 |
} catch (RemoteException e) { |
| 1404 |
throw e.rethrowFromSystemServer(); |
| 1405 |
} |
| 1406 |
} |
| 1407 |
|
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
public void notifyCarrierServiceChanged(int logicalSlotIndex, @Nullable String packageName, |
| 1416 |
int uid) { |
| 1417 |
try { |
| 1418 |
sRegistry.notifyCarrierServiceChanged(logicalSlotIndex, packageName, uid); |
| 1419 |
} catch (RemoteException e) { |
| 1420 |
throw e.rethrowFromSystemServer(); |
| 1421 |
} |
| 1422 |
} |
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
|
| 1431 |
public void addCarrierConfigChangedListener( |
| 1432 |
@NonNull @CallbackExecutor Executor executor, |
| 1433 |
@NonNull CarrierConfigManager.CarrierConfigChangeListener listener) { |
| 1434 |
Objects.requireNonNull(executor, "Executor should be non-null."); |
| 1435 |
Objects.requireNonNull(listener, "Listener should be non-null."); |
| 1436 |
if (mCarrierConfigChangeListenerMap.get(listener) != null) { |
| 1437 |
Log.e(TAG, "registerCarrierConfigChangeListener: listener already present"); |
| 1438 |
return; |
| 1439 |
} |
| 1440 |
|
| 1441 |
ICarrierConfigChangeListener callback = new ICarrierConfigChangeListener.Stub() { |
| 1442 |
@Override |
| 1443 |
public void onCarrierConfigChanged(int slotIndex, int subId, int carrierId, |
| 1444 |
int specificCarrierId) { |
| 1445 |
Log.d(TAG, "onCarrierConfigChanged call in ICarrierConfigChangeListener callback"); |
| 1446 |
final long identify = Binder.clearCallingIdentity(); |
| 1447 |
try { |
| 1448 |
executor.execute(() -> listener.onCarrierConfigChanged(slotIndex, subId, |
| 1449 |
carrierId, specificCarrierId)); |
| 1450 |
} finally { |
| 1451 |
Binder.restoreCallingIdentity(identify); |
| 1452 |
} |
| 1453 |
} |
| 1454 |
}; |
| 1455 |
|
| 1456 |
try { |
| 1457 |
sRegistry.addCarrierConfigChangeListener(callback, |
| 1458 |
mContext.getOpPackageName(), mContext.getAttributionTag()); |
| 1459 |
mCarrierConfigChangeListenerMap.put(listener, callback); |
| 1460 |
} catch (RemoteException re) { |
| 1461 |
|
| 1462 |
throw re.rethrowFromSystemServer(); |
| 1463 |
} |
| 1464 |
} |
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
|
| 1471 |
public void removeCarrierConfigChangedListener( |
| 1472 |
@NonNull CarrierConfigManager.CarrierConfigChangeListener listener) { |
| 1473 |
Objects.requireNonNull(listener, "Listener should be non-null."); |
| 1474 |
if (mCarrierConfigChangeListenerMap.get(listener) == null) { |
| 1475 |
Log.e(TAG, "removeCarrierConfigChangedListener: listener was not present"); |
| 1476 |
return; |
| 1477 |
} |
| 1478 |
|
| 1479 |
try { |
| 1480 |
sRegistry.removeCarrierConfigChangeListener( |
| 1481 |
mCarrierConfigChangeListenerMap.get(listener), mContext.getOpPackageName()); |
| 1482 |
mCarrierConfigChangeListenerMap.remove(listener); |
| 1483 |
} catch (RemoteException re) { |
| 1484 |
|
| 1485 |
throw re.rethrowFromSystemServer(); |
| 1486 |
} |
| 1487 |
} |
| 1488 |
|
| 1489 |
|
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
public void notifyCarrierConfigChanged(int slotIndex, int subId, int carrierId, |
| 1501 |
int specificCarrierId) { |
| 1502 |
|
| 1503 |
if (!SubscriptionManager.isValidPhoneId(slotIndex)) { |
| 1504 |
Log.e(TAG, "notifyCarrierConfigChanged, ignored: invalid slotIndex " + slotIndex); |
| 1505 |
return; |
| 1506 |
} |
| 1507 |
try { |
| 1508 |
sRegistry.notifyCarrierConfigChanged(slotIndex, subId, carrierId, specificCarrierId); |
| 1509 |
} catch (RemoteException re) { |
| 1510 |
throw re.rethrowFromSystemServer(); |
| 1511 |
} |
| 1512 |
} |
| 1513 |
} |