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

Commit 129ef2a7 authored by Amit Mahajan's avatar Amit Mahajan Committed by android-build-merger
Browse files

Merge "Remove delay before getService() call for IRadio service." am: 0db505ee am: d5ef1ce0

am: 2c4bc732

Change-Id: Iedb85e2708b1917bc55cb78bc462caeb1bcf900d
parents d877c238 2c4bc732
Loading
Loading
Loading
Loading
+6 −26
Original line number Original line Diff line number Diff line
@@ -285,10 +285,6 @@ public class RIL extends BaseCommands implements CommandsInterface {
                            " mRadioProxyCookie = " + mRadioProxyCookie.get());
                            " mRadioProxyCookie = " + mRadioProxyCookie.get());
                    if ((long) msg.obj == mRadioProxyCookie.get()) {
                    if ((long) msg.obj == mRadioProxyCookie.get()) {
                        resetProxyAndRequestList();
                        resetProxyAndRequestList();

                        // todo: rild should be back up since message was sent with a delay. this is
                        // a hack.
                        getRadioProxy(null);
                    }
                    }
                    break;
                    break;
            }
            }
@@ -323,11 +319,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
        public void serviceDied(long cookie) {
        public void serviceDied(long cookie) {
            // Deal with service going away
            // Deal with service going away
            riljLog("serviceDied");
            riljLog("serviceDied");
            // todo: temp hack to send delayed message so that rild is back up by then
            mRilHandler.sendMessage(mRilHandler.obtainMessage(EVENT_RADIO_PROXY_DEAD, cookie));
            //mRilHandler.sendMessage(mRilHandler.obtainMessage(EVENT_RADIO_PROXY_DEAD, cookie));
            mRilHandler.sendMessageDelayed(
                    mRilHandler.obtainMessage(EVENT_RADIO_PROXY_DEAD, cookie),
                    IRADIO_GET_SERVICE_DELAY_MILLIS);
        }
        }
    }
    }


@@ -343,9 +335,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
        // Clear request list on close
        // Clear request list on close
        clearRequestList(RADIO_NOT_AVAILABLE, false);
        clearRequestList(RADIO_NOT_AVAILABLE, false);


        // todo: need to get service right away so setResponseFunctions() can be called for
        getRadioProxy(null);
        // unsolicited indications. getService() is not a blocking call, so it doesn't help to call
        // it here. Current hack is to call getService() on death notification after a delay.
    }
    }


    /** Returns a {@link IRadio} instance or null if the service is not available. */
    /** Returns a {@link IRadio} instance or null if the service is not available. */
@@ -366,7 +356,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
        }
        }


        try {
        try {
            mRadioProxy = IRadio.getService(HIDL_SERVICE_NAME[mPhoneId == null ? 0 : mPhoneId]);
            mRadioProxy = IRadio.getService(HIDL_SERVICE_NAME[mPhoneId == null ? 0 : mPhoneId],
                    true);
            if (mRadioProxy != null) {
            if (mRadioProxy != null) {
                mRadioProxy.linkToDeath(mRadioProxyDeathRecipient,
                mRadioProxy.linkToDeath(mRadioProxyDeathRecipient,
                        mRadioProxyCookie.incrementAndGet());
                        mRadioProxyCookie.incrementAndGet());
@@ -380,17 +371,13 @@ public class RIL extends BaseCommands implements CommandsInterface {
        }
        }


        if (mRadioProxy == null) {
        if (mRadioProxy == null) {
            // getService() is a blocking call, so this should never happen
            riljLoge("getRadioProxy: mRadioProxy == null");
            if (result != null) {
            if (result != null) {
                AsyncResult.forMessage(result, null,
                AsyncResult.forMessage(result, null,
                        CommandException.fromRilErrno(RADIO_NOT_AVAILABLE));
                        CommandException.fromRilErrno(RADIO_NOT_AVAILABLE));
                result.sendToTarget();
                result.sendToTarget();
            }
            }

            // if service is not up, treat it like death notification to try to get service again
            mRilHandler.sendMessageDelayed(
                    mRilHandler.obtainMessage(EVENT_RADIO_PROXY_DEAD,
                            mRadioProxyCookie.incrementAndGet()),
                    IRADIO_GET_SERVICE_DELAY_MILLIS);
        }
        }


        return mRadioProxy;
        return mRadioProxy;
@@ -475,13 +462,6 @@ public class RIL extends BaseCommands implements CommandsInterface {
    private void handleRadioProxyExceptionForRR(RILRequest rr, String caller, Exception e) {
    private void handleRadioProxyExceptionForRR(RILRequest rr, String caller, Exception e) {
        riljLoge(caller + ": " + e);
        riljLoge(caller + ": " + e);
        resetProxyAndRequestList();
        resetProxyAndRequestList();

        // service most likely died, handle exception like death notification to try to get service
        // again
        mRilHandler.sendMessageDelayed(
                mRilHandler.obtainMessage(EVENT_RADIO_PROXY_DEAD,
                        mRadioProxyCookie.incrementAndGet()),
                IRADIO_GET_SERVICE_DELAY_MILLIS);
    }
    }


    private String convertNullToEmptyString(String string) {
    private String convertNullToEmptyString(String string) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -166,7 +166,7 @@ public class RadioConfig extends Handler {
        }
        }


        try {
        try {
            mRadioConfigProxy = IRadioConfig.getService(RADIO_CONFIG_SERVICE_NAME);
            mRadioConfigProxy = IRadioConfig.getService(RADIO_CONFIG_SERVICE_NAME, true);
            if (mRadioConfigProxy != null) {
            if (mRadioConfigProxy != null) {
                mRadioConfigProxy.linkToDeath(mServiceDeathRecipient,
                mRadioConfigProxy.linkToDeath(mServiceDeathRecipient,
                        mRadioConfigProxyCookie.incrementAndGet());
                        mRadioConfigProxyCookie.incrementAndGet());
@@ -177,7 +177,7 @@ public class RadioConfig extends Handler {
            }
            }
        } catch (RemoteException | RuntimeException e) {
        } catch (RemoteException | RuntimeException e) {
            mRadioConfigProxy = null;
            mRadioConfigProxy = null;
            loge("getRadioConfigProxy: RadioProxy getService/setResponseFunctions: " + e);
            loge("getRadioConfigProxy: RadioConfigProxy getService/setResponseFunctions: " + e);
        }
        }


        if (mRadioConfigProxy == null) {
        if (mRadioConfigProxy == null) {