Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 3f3d0d4e authored by Joe Kaushal's avatar Joe Kaushal Committed by Anders Frostad Pedersen
Browse files

Avoid setting preferred phone with no phones



PhoneSwitcher#transitionToEmergencyPhone, called in onEvaluate, will set
the preferred data phone to DEFAULT_EMERGENCY_PHONE_ID (0) even when
there are no phones.

This leads onEvaluate to call activate() on the non-existant phone,
causing a NullPointerException in switchPhone as it indexes into the
mPhoneStates array:

Process: com.android.phone, PID: 17125
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
  at <>.telephony.PhoneSwitcher.switchPhone(PhoneSwitcher.java:881)
  at <>.telephony.PhoneSwitcher.activate(PhoneSwitcher.java:872)
  at <>.telephony.PhoneSwitcher.onEvaluate(PhoneSwitcher.java:853)
  at <>.telephony.PhoneSwitcher.onRequestNetwork(PhoneSwitcher.java:666)
  at <>.telephony.PhoneSwitcher.handleMessage(PhoneSwitcher.java:454)
  ...

Fix this by checking that there is at least one phone before setting the
preferred phone variable.

This does not affect the behaviour when there are phones but no SIMs
(and therefore no valid subscriptions): in this case the 0th phone will
still be set as the preferred phone so that it will be available for
emergencies.

Bug: 132047682
Test: manual

Change-Id: Ie000e28b0ffc71d41428b7701c3d290cb63064cb
Signed-off-by: default avatarJoe Kaushal <joe.kaushal@arm.com>
Signed-off-by: default avatarAnders Frostad Pedersen <anders.pedersen@arm.corp-partner.google.com>
parent d89a9311
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment