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

Commit 2b82c304 authored by terrycrhuang's avatar terrycrhuang Committed by jimsun
Browse files

Fix phone crash by NullPointerException

As Binder die, no cookie is returned. Add an new message without cookie
for the binder die case.

Bug: 203241555
Test: no phone crash as switching mock modem and live modem

Change-Id: Ic6beeea4fd05b448a49c6d2351f752e61205349b
Merged-In: Ic6beeea4fd05b448a49c6d2351f752e61205349b
parent 237e9e96
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -57,7 +57,8 @@ public class RadioConfig extends Handler {
    private static final boolean VDBG = false; //STOPSHIP if true
    private static final Object sLock = new Object();

    static final int EVENT_SERVICE_DEAD = 1;
    static final int EVENT_HIDL_SERVICE_DEAD = 1;
    static final int EVENT_AIDL_SERVICE_DEAD = 2;
    static final HalVersion RADIO_CONFIG_HAL_VERSION_UNKNOWN = new HalVersion(-1, -1);
    static final HalVersion RADIO_CONFIG_HAL_VERSION_1_0 = new HalVersion(1, 0);
    static final HalVersion RADIO_CONFIG_HAL_VERSION_1_1 = new HalVersion(1, 1);
@@ -137,12 +138,16 @@ public class RadioConfig extends Handler {

    @Override
    public void handleMessage(Message message) {
        if (message.what == EVENT_SERVICE_DEAD) {
            logd("handleMessage: EVENT_SERVICE_DEAD cookie = " + message.obj
        if (message.what == EVENT_HIDL_SERVICE_DEAD) {
            logd("handleMessage: EVENT_HIDL_SERVICE_DEAD cookie = " + message.obj
                    + " mRadioConfigProxyCookie = " + mRadioConfigProxyCookie.get());
            if ((long) message.obj == mRadioConfigProxyCookie.get()) {
                resetProxyAndRequestList("EVENT_SERVICE_DEAD", null);
                resetProxyAndRequestList("EVENT_HIDL_SERVICE_DEAD", null);
            }
        } else if (message.what == EVENT_AIDL_SERVICE_DEAD) {
            logd("handleMessage: EVENT_AIDL_SERVICE_DEAD mRadioConfigProxyCookie = "
                    + mRadioConfigProxyCookie.get());
            resetProxyAndRequestList("EVENT_AIDL_SERVICE_DEAD", null);
        }
    }

@@ -259,7 +264,7 @@ public class RadioConfig extends Handler {
                serviceBound = false;
            }

            if (serviceBound) resetProxyAndRequestList("EVENT_SERVICE_DEAD", null);
            if (serviceBound) resetProxyAndRequestList("EVENT_HIDL_SERVICE_DEAD", null);
        }

        if ((serviceName == null) || (!serviceBound)) {
+3 −2
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ public class RadioConfigProxy {
            // Deal with service going away
            Rlog.e(TAG, "serviceDied");
            mRadioConfig.sendMessage(
                    mRadioConfig.obtainMessage(RadioConfig.EVENT_SERVICE_DEAD, cookie));
                    mRadioConfig.obtainMessage(RadioConfig.EVENT_HIDL_SERVICE_DEAD, cookie));
        }
    }

@@ -329,7 +329,8 @@ public class RadioConfigProxy {
        public void binderDied() {
            Rlog.e(TAG, "service died.");
            unlinkToDeath();
            mRadioConfig.sendMessage(mRadioConfig.obtainMessage(RadioConfig.EVENT_SERVICE_DEAD));
            mRadioConfig.sendMessage(
                    mRadioConfig.obtainMessage(RadioConfig.EVENT_AIDL_SERVICE_DEAD));
        }
    }
}