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

Commit 76104c6d authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes Idf14d782,If6bb738d am: ab6b67ea

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1937678

Change-Id: Ic5502c313ad0325edd4525b2c411b47425873f19
parents f6040c85 ab6b67ea
Loading
Loading
Loading
Loading
+36 −7
Original line number Diff line number Diff line
@@ -580,6 +580,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
    /** Returns a {@link IRadio} instance or null if the service is not available. */
    @VisibleForTesting
    public synchronized IRadio getRadioProxy(Message result) {
        if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_2_0)) return null;
        if (!SubscriptionManager.isValidPhoneId(mPhoneId)) return null;
        if (!mIsCellularSupported) {
            if (RILJ_LOGV) riljLog("getRadioProxy: Not calling getService(): wifi-only");
@@ -838,7 +839,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                        break;
                }

                if (serviceProxy.isEmpty()) {
                if (serviceProxy.isEmpty() && mRadioVersion.less(RADIO_HAL_VERSION_2_0)) {
                    try {
                        mRadioVersion = RADIO_HAL_VERSION_1_6;
                        serviceProxy.setHidl(mRadioVersion,
@@ -848,7 +849,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                    }
                }

                if (serviceProxy.isEmpty()) {
                if (serviceProxy.isEmpty() && mRadioVersion.less(RADIO_HAL_VERSION_2_0)) {
                    try {
                        mRadioVersion = RADIO_HAL_VERSION_1_5;
                        serviceProxy.setHidl(mRadioVersion,
@@ -858,7 +859,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                    }
                }

                if (serviceProxy.isEmpty()) {
                if (serviceProxy.isEmpty() && mRadioVersion.less(RADIO_HAL_VERSION_2_0)) {
                    try {
                        mRadioVersion = RADIO_HAL_VERSION_1_4;
                        serviceProxy.setHidl(mRadioVersion,
@@ -868,7 +869,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                    }
                }

                if (serviceProxy.isEmpty()) {
                if (serviceProxy.isEmpty() && mRadioVersion.less(RADIO_HAL_VERSION_2_0)) {
                    try {
                        mRadioVersion = RADIO_HAL_VERSION_1_3;
                        serviceProxy.setHidl(mRadioVersion,
@@ -878,7 +879,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                    }
                }

                if (serviceProxy.isEmpty()) {
                if (serviceProxy.isEmpty() && mRadioVersion.less(RADIO_HAL_VERSION_2_0)) {
                    try {
                        mRadioVersion = RADIO_HAL_VERSION_1_2;
                        serviceProxy.setHidl(mRadioVersion,
@@ -888,7 +889,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                    }
                }

                if (serviceProxy.isEmpty()) {
                if (serviceProxy.isEmpty() && mRadioVersion.less(RADIO_HAL_VERSION_2_0)) {
                    try {
                        mRadioVersion = RADIO_HAL_VERSION_1_1;
                        serviceProxy.setHidl(mRadioVersion,
@@ -898,7 +899,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                    }
                }

                if (serviceProxy.isEmpty()) {
                if (serviceProxy.isEmpty() && mRadioVersion.less(RADIO_HAL_VERSION_2_0)) {
                    try {
                        mRadioVersion = RADIO_HAL_VERSION_1_0;
                        serviceProxy.setHidl(mRadioVersion,
@@ -949,6 +950,9 @@ public class RIL extends BaseCommands implements CommandsInterface {
                                break;
                        }
                    } else {
                        if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_2_0)) {
                            throw new AssertionError("serviceProxy shouldn't be HIDL with HAL 2.0");
                        }
                        serviceProxy.getHidl().linkToDeath(mRadioProxyDeathRecipient,
                                mServiceCookies.get(service).incrementAndGet());
                        serviceProxy.getHidl().setResponseFunctions(
@@ -1023,6 +1027,14 @@ public class RIL extends BaseCommands implements CommandsInterface {
        if (isRadioBugDetectionEnabled()) {
            mRadioBugDetector = new RadioBugDetector(context, mPhoneId);
        }
        try {
            if (isRadioVersion2_0()) mRadioVersion = RADIO_HAL_VERSION_2_0;
        } catch (SecurityException ex) {
            /* TODO(b/211920208): instead of the following workaround (guessing if we're in a test
             * based on proxies being populated), mock ServiceManager to not throw
             * SecurityException and return correct value based on what HAL we're testing. */
            if (proxies == null) throw ex;
        }

        TelephonyManager tm = (TelephonyManager) context.getSystemService(
                Context.TELEPHONY_SERVICE);
@@ -1101,6 +1113,23 @@ public class RIL extends BaseCommands implements CommandsInterface {
        }
    }

    private boolean isRadioVersion2_0() {
        final String[] serviceNames = new String[] {
            android.hardware.radio.data.IRadioData.DESCRIPTOR,
            android.hardware.radio.messaging.IRadioMessaging.DESCRIPTOR,
            android.hardware.radio.modem.IRadioModem.DESCRIPTOR,
            android.hardware.radio.network.IRadioNetwork.DESCRIPTOR,
            android.hardware.radio.sim.IRadioSim.DESCRIPTOR,
            android.hardware.radio.voice.IRadioVoice.DESCRIPTOR,
        };
        for (String serviceName : serviceNames) {
            if (ServiceManager.isDeclared(serviceName + '/' + HIDL_SERVICE_NAME[mPhoneId])) {
                return true;
            }
        }
        return false;
    }

    private boolean isRadioBugDetectionEnabled() {
        return Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.ENABLE_RADIO_BUG_DETECTION, 1) != 0;