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:Joe Kaushal <joe.kaushal@arm.com> Signed-off-by:
Anders Frostad Pedersen <anders.pedersen@arm.corp-partner.google.com>
Loading
Please register or sign in to comment