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

Commit 68fb6dbf authored by Shuo Qian's avatar Shuo Qian Committed by android-build-merger
Browse files

Merge "Introduce sets to record disabled hal services" am: 51856bff

am: 64fab1d7

Change-Id: I3604ea6b60f2e2407656fd161d6e2e50b4a1797d
parents d51ad164 64fab1d7
Loading
Loading
Loading
Loading
+57 −27
Original line number Diff line number Diff line
@@ -115,7 +115,10 @@ import java.net.Inet6Address;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;

@@ -175,6 +178,18 @@ public class RIL extends BaseCommands implements CommandsInterface {

    final Integer mPhoneId;

    /**
     * A set that records if radio service is disabled in hal for
     * a specific phone id slot to avoid further getService request.
     */
    Set<Integer> mDisabledRadioServices = new HashSet();

    /**
     * A set that records if oem hook service is disabled in hal for
     * a specific phone id slot to avoid further getService request.
     */
    Set<Integer> mDisabledOemHookServices = new HashSet();

    /* default work source which will blame phone process */
    private WorkSource mRILDefaultWorkSource;

@@ -350,7 +365,7 @@ public class RIL extends BaseCommands implements CommandsInterface {

    /** Returns a {@link IRadio} instance or null if the service is not available. */
    @VisibleForTesting
    public IRadio getRadioProxy(Message result) {
    public synchronized IRadio getRadioProxy(Message result) {
        if (!mIsMobileNetworkSupported) {
            if (RILJ_LOGV) riljLog("getRadioProxy: Not calling getService(): wifi-only");
            if (result != null) {
@@ -366,16 +381,26 @@ public class RIL extends BaseCommands implements CommandsInterface {
        }

        try {
            mRadioProxy = IRadio.getService(HIDL_SERVICE_NAME[mPhoneId == null ? 0 : mPhoneId],
            if (mDisabledRadioServices.contains(mPhoneId)) {
                riljLoge("getRadioProxy: mRadioProxy for " + HIDL_SERVICE_NAME[mPhoneId]
                        + " is disabled");
            } else {
                mRadioProxy = IRadio.getService(HIDL_SERVICE_NAME[mPhoneId],
                        true);
                if (mRadioProxy != null) {
                    mRadioProxy.linkToDeath(mRadioProxyDeathRecipient,
                            mRadioProxyCookie.incrementAndGet());
                    mRadioProxy.setResponseFunctions(mRadioResponse, mRadioIndication);
                } else {
                riljLoge("getRadioProxy: mRadioProxy == null");
                    mDisabledRadioServices.add(mPhoneId);
                    riljLoge("getRadioProxy: mRadioProxy for "
                            + HIDL_SERVICE_NAME[mPhoneId] + " is disabled");
                }
        } catch (RemoteException | RuntimeException e) {
            }
        } catch (NoSuchElementException e) {
            mRadioProxy = null;
            riljLoge("IRadio service is not on the device HAL: " + e);
        } catch (RemoteException e) {
            mRadioProxy = null;
            riljLoge("RadioProxy getService/setResponseFunctions: " + e);
        }
@@ -395,7 +420,7 @@ public class RIL extends BaseCommands implements CommandsInterface {

    /** Returns an {@link IOemHook} instance or null if the service is not available. */
    @VisibleForTesting
    public IOemHook getOemHookProxy(Message result) {
    public synchronized IOemHook getOemHookProxy(Message result) {
        if (!mIsMobileNetworkSupported) {
            if (RILJ_LOGV) riljLog("getOemHookProxy: Not calling getService(): wifi-only");
            if (result != null) {
@@ -411,16 +436,25 @@ public class RIL extends BaseCommands implements CommandsInterface {
        }

        try {
            mOemHookProxy = IOemHook.getService(
                    HIDL_SERVICE_NAME[mPhoneId == null ? 0 : mPhoneId], true);
            if (mDisabledOemHookServices.contains(mPhoneId)) {
                riljLoge("getOemHookProxy: mOemHookProxy for " + HIDL_SERVICE_NAME[mPhoneId]
                        + " is disabled");
            } else {
                mOemHookProxy = IOemHook.getService(HIDL_SERVICE_NAME[mPhoneId], true);
                if (mOemHookProxy != null) {
                    // not calling linkToDeath() as ril service runs in the same process and death
                    // notification for that should be sufficient
                    mOemHookProxy.setResponseFunctions(mOemHookResponse, mOemHookIndication);
                } else {
                riljLoge("getOemHookProxy: mOemHookProxy == null");
                    mDisabledOemHookServices.add(mPhoneId);
                    riljLoge("getOemHookProxy: mOemHookProxy for " + HIDL_SERVICE_NAME[mPhoneId]
                            + " is disabled");
                }
        } catch (RemoteException | RuntimeException e) {
            }
        } catch (NoSuchElementException e) {
            mRadioProxy = null;
            riljLoge("IOemHook service is not on the device HAL: " + e);
        }  catch (RemoteException e) {
            mOemHookProxy = null;
            riljLoge("OemHookProxy getService/setResponseFunctions: " + e);
        }
@@ -454,7 +488,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
        mCdmaSubscription  = cdmaSubscription;
        mPreferredNetworkType = preferredNetworkType;
        mPhoneType = RILConstants.NO_PHONE;
        mPhoneId = instanceId;
        mPhoneId = instanceId == null ? 0 : instanceId;

        ConnectivityManager cm = (ConnectivityManager)context.getSystemService(
                Context.CONNECTIVITY_SERVICE);
@@ -5016,23 +5050,19 @@ public class RIL extends BaseCommands implements CommandsInterface {
    }

    void riljLog(String msg) {
        Rlog.d(RILJ_LOG_TAG, msg
                + (mPhoneId != null ? (" [SUB" + mPhoneId + "]") : ""));
        Rlog.d(RILJ_LOG_TAG, msg + (" [SUB" + mPhoneId + "]"));
    }

    void riljLoge(String msg) {
        Rlog.e(RILJ_LOG_TAG, msg
                + (mPhoneId != null ? (" [SUB" + mPhoneId + "]") : ""));
        Rlog.e(RILJ_LOG_TAG, msg + (" [SUB" + mPhoneId + "]"));
    }

    void riljLoge(String msg, Exception e) {
        Rlog.e(RILJ_LOG_TAG, msg
                + (mPhoneId != null ? (" [SUB" + mPhoneId + "]") : ""), e);
        Rlog.e(RILJ_LOG_TAG, msg + (" [SUB" + mPhoneId + "]"), e);
    }

    void riljLogv(String msg) {
        Rlog.v(RILJ_LOG_TAG, msg
                + (mPhoneId != null ? (" [SUB" + mPhoneId + "]") : ""));
        Rlog.v(RILJ_LOG_TAG, msg + (" [SUB" + mPhoneId + "]"));
    }

    void unsljLog(int response) {