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

Commit 4b5d7329 authored by Jordan Liu's avatar Jordan Liu
Browse files

Add null guard and wtf log to getSubId

This method causes crashes when SubscriptionController#getInstance
returns null (which it shouldn't but go figure). These crashes haven't
been seen in the wild but they can cause presubmit flakiness.

Bug: 79215402
Bug: 78359408
Test: atest FrameworksTelephonyTests # unit tests pass
(this is not sufficient to know that flakiness is gone)
Change-Id: I60dad9f348c441405890d0a1bdc20e0d5e440c8c
Merged-In: I60dad9f348c441405890d0a1bdc20e0d5e440c8c
parent ad228a6d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -3134,6 +3134,13 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * Returns the subscription id.
     */
    public int getSubId() {
        if (SubscriptionController.getInstance() == null) {
            // TODO b/78359408 getInstance sometimes returns null in Treehugger tests, which causes
            // flakiness. Even though we haven't seen this crash in the wild we should keep this
            // check in until we've figured out the root cause.
            Rlog.e(LOG_TAG, "SubscriptionController.getInstance = null! Returning default subId");
            return SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
        }
        return SubscriptionController.getInstance().getSubIdUsingPhoneId(mPhoneId);
    }