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

Commit 80bd0262 authored by Pavel Zhamaitsiak's avatar Pavel Zhamaitsiak
Browse files

Fix race in dafault phone creation

ImsPhone might be created when we are starting monitoring IMS service.
When we are creating ImsPhone, we are opening IMS service.
When IMS service is being opened, it might request default phone (which
might not be ready yet).

Bug: 24130556
Change-Id: I7677b3131b15c78f6c6ac008f0cbb06b1a427b5d
parent b6dfcea9
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -157,11 +157,9 @@ public class PhoneFactory {
                    if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
                        phone = new GSMPhone(context,
                                sCommandsInterfaces[i], sPhoneNotifier, i);
                        phone.startMonitoringImsService();
                    } else if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
                        phone = new CDMALTEPhone(context,
                                sCommandsInterfaces[i], sPhoneNotifier, i);
                        phone.startMonitoringImsService();
                    }
                    Rlog.i(LOG_TAG, "Creating Phone with type = " + phoneType + " sub = " + i);

@@ -195,6 +193,13 @@ public class PhoneFactory {
                sSubInfoRecordUpdater = new SubscriptionInfoUpdater(context,
                        sProxyPhones, sCommandsInterfaces);
                SubscriptionController.getInstance().updatePhonesAvailability(sProxyPhones);

                // Start monitoring after defaults have been made.
                // Default phone must be ready before ImsPhone is created
                // because ImsService might need it when it is being opened.
                for (int i = 0; i < numPhones; i++) {
                    sProxyPhones[i].startMonitoringImsService();
                }
            }
        }
    }
+5 −1
Original line number Diff line number Diff line
@@ -1504,7 +1504,11 @@ public class PhoneProxy extends Handler implements Phone {
    public ImsPhone relinquishOwnershipOfImsPhone() { return null; }

    @Override
    public void startMonitoringImsService() {}
    public void startMonitoringImsService() {
        if (mActivePhone != null) {
            mActivePhone.startMonitoringImsService();
        }
    }

    @Override
    public void acquireOwnershipOfImsPhone(ImsPhone imsPhone) { }