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

Commit 1a3bb293 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "[IRadioConfig] Fix memory linkToDeath memory leak"

parents 78416bd0 f3285525
Loading
Loading
Loading
Loading
+69 −282
Original line number Original line Diff line number Diff line
@@ -31,7 +31,6 @@ import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SWITCH_DUA
import android.content.Context;
import android.content.Context;
import android.os.AsyncResult;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Handler;
import android.os.HwBinder;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Message;
import android.os.Message;
import android.os.Registrant;
import android.os.Registrant;
@@ -56,9 +55,9 @@ public class RadioConfig extends Handler {
    private static final String TAG = "RadioConfig";
    private static final String TAG = "RadioConfig";
    private static final boolean DBG = true;
    private static final boolean DBG = true;
    private static final boolean VDBG = false; //STOPSHIP if true
    private static final boolean VDBG = false; //STOPSHIP if true
    private static final int EVENT_SERVICE_DEAD = 1;
    private static final Object sLock = new Object();
    private static final Object sLock = new Object();


    static final int EVENT_SERVICE_DEAD = 1;
    static final HalVersion RADIO_CONFIG_HAL_VERSION_UNKNOWN = new HalVersion(-1, -1);
    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_0 = new HalVersion(1, 0);
    static final HalVersion RADIO_CONFIG_HAL_VERSION_1_1 = new HalVersion(1, 1);
    static final HalVersion RADIO_CONFIG_HAL_VERSION_1_1 = new HalVersion(1, 1);
@@ -66,212 +65,17 @@ public class RadioConfig extends Handler {
    static final HalVersion RADIO_CONFIG_HAL_VERSION_2_0 = new HalVersion(2, 0);
    static final HalVersion RADIO_CONFIG_HAL_VERSION_2_0 = new HalVersion(2, 0);


    private final boolean mIsMobileNetworkSupported;
    private final boolean mIsMobileNetworkSupported;
    private final HwServiceDeathRecipient mHwServiceDeathRecipient;
    private final RadioConfigBinderServiceDeathRecipient mBinderServiceDeathRecipient;
    private final RadioConfigResponse mRadioConfigResponse;
    private final RadioConfigIndication mRadioConfigIndication;
    private final SparseArray<RILRequest> mRequestList = new SparseArray<>();
    private final SparseArray<RILRequest> mRequestList = new SparseArray<>();
    /* default work source which will blame phone process */
    /* default work source which will blame phone process */
    private final WorkSource mDefaultWorkSource;
    private final WorkSource mDefaultWorkSource;
    private final int[] mDeviceNrCapabilities;
    private final int[] mDeviceNrCapabilities;
    private final AtomicLong mRadioConfigProxyCookie = new AtomicLong(0);
    private final AtomicLong mRadioConfigProxyCookie = new AtomicLong(0);
    private final RadioConfigProxy mRadioConfigProxy;


    private static RadioConfig sRadioConfig;
    private static RadioConfig sRadioConfig;


    private final RadioConfigProxy mRadioConfigProxy = new RadioConfigProxy();

    protected Registrant mSimSlotStatusRegistrant;
    protected Registrant mSimSlotStatusRegistrant;


    final class HwServiceDeathRecipient implements HwBinder.DeathRecipient {
        @Override
        public void serviceDied(long cookie) {
            // Deal with service going away
            logd("serviceDied");
            sendMessage(obtainMessage(EVENT_SERVICE_DEAD, cookie));
        }
    }

    final class RadioConfigBinderServiceDeathRecipient implements IBinder.DeathRecipient {
        private IBinder mBinder;

        public void linkToDeath(IBinder service) throws RemoteException {
            if (service != null) {
                mBinder = service;
                mBinder.linkToDeath(this, (int) mRadioConfigProxyCookie.incrementAndGet());
            }
        }

        public synchronized void unlinkToDeath() {
            if (mBinder != null) {
                mBinder.unlinkToDeath(this, 0);
                mBinder = null;
            }
        }

        @Override
        public void binderDied() {
            logd("RadioConfigService has died.");
            unlinkToDeath();
        }

    }

    private final class RadioConfigProxy {
        private boolean mIsAidl;

        private volatile android.hardware.radio.config.V1_0.IRadioConfig mRadioConfigProxyV1 = null;
        private volatile android.hardware.radio.config.IRadioConfig mRadioConfigProxyV2 = null;
        private HalVersion mHalVersion = RADIO_CONFIG_HAL_VERSION_UNKNOWN;

        public boolean isV2OrHigher() {
            return mIsAidl;
        }

        public void setV1(
                HalVersion halVersion, android.hardware.radio.config.V1_0.IRadioConfig config) {
            mHalVersion = halVersion;
            mRadioConfigProxyV1 = config;
            mIsAidl = false;
        }

        public android.hardware.radio.config.V1_0.IRadioConfig getV1() {
            return mRadioConfigProxyV1;
        }

        public void setV2(
                HalVersion halVersion, android.hardware.radio.config.IRadioConfig config) {
            mHalVersion = halVersion;
            mRadioConfigProxyV2 = config;
            mIsAidl = true;
        }

        public android.hardware.radio.config.IRadioConfig getV2() {
            return mRadioConfigProxyV2;
        }

        public void clear() {
            mHalVersion = RADIO_CONFIG_HAL_VERSION_UNKNOWN;
            mRadioConfigProxyV1 = null;
            mRadioConfigProxyV2 = null;
        }

        public boolean isEmpty() {
            return mRadioConfigProxyV1 == null && mRadioConfigProxyV2 == null;
        }

        public void linkToDeath() {
            if (isEmpty()) return;

            if (isV2OrHigher()) {
                try {
                    // Link to death
                    mBinderServiceDeathRecipient.linkToDeath(mRadioConfigProxyV2.asBinder());

                    // Set response. If fails, set proxy to null and return.
                    mRadioConfigProxyV2.setResponseFunctions(
                            mRadioConfigResponse.getV2(), mRadioConfigIndication.getV2());
                } catch (RemoteException | RuntimeException e) {
                    mRadioConfigProxyV2 = null;
                    loge("getRadioConfigProxyV2: RadioConfigProxy setResponseFunctions: " + e);
                }
            } else {
                try {
                    // Link to death recipient and set response.
                    // If fails, set proxy to null and return.
                    mRadioConfigProxyV1.linkToDeath(
                            mHwServiceDeathRecipient, mRadioConfigProxyCookie.incrementAndGet());
                    mRadioConfigProxyV1.setResponseFunctions(
                            mRadioConfigResponse.getV1(), mRadioConfigIndication.getV1());
                } catch (RemoteException | RuntimeException e) {
                    mRadioConfigProxyV1 = null;
                    loge("getRadioConfigProxyV1: RadioConfigProxy setResponseFunctions: " + e);
                }
            }
        }

        public void getPhoneCapability(int serial) throws RemoteException {
            if (isEmpty()) return;
            if (mHalVersion.less(RADIO_CONFIG_HAL_VERSION_1_1)) return;

            if (isV2OrHigher()) {
                mRadioConfigProxyV2.getPhoneCapability(serial);
            } else {
                ((android.hardware.radio.config.V1_1.IRadioConfig) mRadioConfigProxyV1)
                        .getPhoneCapability(serial);
            }
        }

        public void getSimSlotsStatus(int serial) throws RemoteException {
            if (isEmpty()) return;

            if (isV2OrHigher()) {
                mRadioConfigProxyV2.getSimSlotsStatus(serial);
            } else {
                mRadioConfigProxyV1.getSimSlotsStatus(serial);
            }
        }

        public void setPreferredDataModem(int serial, byte modemId) throws RemoteException {
            if (isEmpty()) return;
            if (mHalVersion.less(RADIO_CONFIG_HAL_VERSION_1_1)) return;

            if (isV2OrHigher()) {
                mRadioConfigProxyV2.setPreferredDataModem(serial, modemId);
            } else {
                ((android.hardware.radio.config.V1_1.IRadioConfig) mRadioConfigProxyV1)
                        .setPreferredDataModem(serial, modemId);
            }
        }

        public void setSimSlotsMapping(int serial, int[] list)
                throws RemoteException {
            if (isEmpty()) return;

            if (isV2OrHigher()) {
                mRadioConfigProxyV2.setSimSlotsMapping(serial,
                        RILUtils.convertSimSlotsMapping(list));
            } else {
                mRadioConfigProxyV1.setSimSlotsMapping(serial,
                        RILUtils.primitiveArrayToArrayList(list));
            }
        }

        public void setModemsConfig(
                int serial,
                android.hardware.radio.config.V1_1.ModemsConfig modemsConfig)
                throws RemoteException {
            if (isEmpty()) return;
            if (mHalVersion.less(RADIO_CONFIG_HAL_VERSION_1_1)) return;
            if (mHalVersion.greaterOrEqual(RADIO_CONFIG_HAL_VERSION_2_0)) return;

            ((android.hardware.radio.config.V1_1.IRadioConfig) mRadioConfigProxyV1)
                    .setModemsConfig(serial, modemsConfig);
        }

        public void setNumOfLiveModems(int serial, byte numOfLiveModems) throws RemoteException {
            if (isEmpty()) return;
            if (mHalVersion.less(RADIO_CONFIG_HAL_VERSION_2_0)) return;

            mRadioConfigProxyV2.setNumOfLiveModems(serial, numOfLiveModems);
        }

        public HalVersion getVersion() {
            return mHalVersion;
        }

        public void getHalDeviceCapabilities(int serial) throws RemoteException {
            if (isEmpty()) return;
            if (mHalVersion.less(RADIO_CONFIG_HAL_VERSION_1_3)) return;

            if (isV2OrHigher()) {
                mRadioConfigProxyV2.getHalDeviceCapabilities(serial);
            } else {
                ((android.hardware.radio.config.V1_3.IRadioConfig) mRadioConfigProxyV1)
                        .getHalDeviceCapabilities(serial);
            }
        }
    }

    private boolean isMobileDataCapable(Context context) {
    private boolean isMobileDataCapable(Context context) {
        final TelephonyManager tm = context.getSystemService(TelephonyManager.class);
        final TelephonyManager tm = context.getSystemService(TelephonyManager.class);
        return tm != null && tm.isDataCapable();
        return tm != null && tm.isDataCapable();
@@ -279,13 +83,9 @@ public class RadioConfig extends Handler {


    private RadioConfig(Context context, HalVersion radioHalVersion) {
    private RadioConfig(Context context, HalVersion radioHalVersion) {
        mIsMobileNetworkSupported = isMobileDataCapable(context);
        mIsMobileNetworkSupported = isMobileDataCapable(context);

        mRadioConfigProxy = new RadioConfigProxy(this, radioHalVersion);
        mRadioConfigResponse = new RadioConfigResponse(this, radioHalVersion);
        mDefaultWorkSource = new WorkSource(context.getApplicationInfo().uid,
        mRadioConfigIndication = new RadioConfigIndication(this, radioHalVersion);
                context.getPackageName());
        mHwServiceDeathRecipient = new HwServiceDeathRecipient();
        mBinderServiceDeathRecipient = new RadioConfigBinderServiceDeathRecipient();
        mDefaultWorkSource = new WorkSource(
                context.getApplicationInfo().uid, context.getPackageName());


        boolean is5gStandalone = context.getResources().getBoolean(
        boolean is5gStandalone = context.getResources().getBoolean(
                com.android.internal.R.bool.config_telephony5gStandalone);
                com.android.internal.R.bool.config_telephony5gStandalone);
@@ -396,7 +196,8 @@ public class RadioConfig extends Handler {
                        CommandException.fromRilErrno(RADIO_NOT_AVAILABLE));
                        CommandException.fromRilErrno(RADIO_NOT_AVAILABLE));
                result.sendToTarget();
                result.sendToTarget();
            }
            }
            return null;
            mRadioConfigProxy.clear();
            return mRadioConfigProxy;
        }
        }


        if (!mRadioConfigProxy.isEmpty()) {
        if (!mRadioConfigProxy.isEmpty()) {
@@ -404,7 +205,6 @@ public class RadioConfig extends Handler {
        }
        }


        updateRadioConfigProxy();
        updateRadioConfigProxy();
        mRadioConfigProxy.linkToDeath();


        if (mRadioConfigProxy.isEmpty() && result != null) {
        if (mRadioConfigProxy.isEmpty() && result != null) {
            AsyncResult.forMessage(
            AsyncResult.forMessage(
@@ -416,48 +216,57 @@ public class RadioConfig extends Handler {
    }
    }


    private void updateRadioConfigProxy() {
    private void updateRadioConfigProxy() {
        // Try to get service from different versions.

        // Try to get AIDL variant first
        IBinder service = ServiceManager.waitForDeclaredService(
        IBinder service = ServiceManager.waitForDeclaredService(
                android.hardware.radio.config.IRadioConfig.DESCRIPTOR + "/default");
                android.hardware.radio.config.IRadioConfig.DESCRIPTOR + "/default");


        if (service != null) {
        if (service != null) {
            mRadioConfigProxy.setV2(
            mRadioConfigProxy.setAidl(
                    RADIO_CONFIG_HAL_VERSION_2_0,
                    RADIO_CONFIG_HAL_VERSION_2_0,
                    android.hardware.radio.config.IRadioConfig.Stub.asInterface(service));
                    android.hardware.radio.config.IRadioConfig.Stub.asInterface(service));
            return;
        }
        }


        // Now HIDL 1.3
        if (mRadioConfigProxy.isEmpty()) {
            try {
            try {
            mRadioConfigProxy.setV1(
                mRadioConfigProxy.setHidl(RADIO_CONFIG_HAL_VERSION_1_3,
                    RADIO_CONFIG_HAL_VERSION_1_3,
                        android.hardware.radio.config.V1_3.IRadioConfig.getService(true));
                        android.hardware.radio.config.V1_3.IRadioConfig.getService(true));
            return;
            } catch (RemoteException | NoSuchElementException e) {
        } catch (NoSuchElementException | RemoteException ignored) {
                mRadioConfigProxy.clear();
                loge("getHidlRadioConfigProxy1_3: RadioConfigProxy getService: " + e);
            }
        }
        }


        // HIDL 1.1
        if (mRadioConfigProxy.isEmpty()) {
            try {
            try {
            mRadioConfigProxy.setV1(
                mRadioConfigProxy.setHidl(RADIO_CONFIG_HAL_VERSION_1_1,
                    RADIO_CONFIG_HAL_VERSION_1_1,
                        android.hardware.radio.config.V1_1.IRadioConfig.getService(true));
                        android.hardware.radio.config.V1_1.IRadioConfig.getService(true));
            return;
            } catch (RemoteException | NoSuchElementException e) {
        } catch (NoSuchElementException | RemoteException ignored) {
                mRadioConfigProxy.clear();
                loge("getHidlRadioConfigProxy1_1: RadioConfigProxy getService | linkToDeath: " + e);
            }
        }
        }


        // HIDL 1.0
        if (mRadioConfigProxy.isEmpty()) {
            try {
            try {
            mRadioConfigProxy.setV1(
                mRadioConfigProxy.setHidl(RADIO_CONFIG_HAL_VERSION_1_0,
                    RADIO_CONFIG_HAL_VERSION_1_0,
                        android.hardware.radio.config.V1_0.IRadioConfig.getService(true));
                        android.hardware.radio.config.V1_0.IRadioConfig.getService(true));
            } catch (RemoteException | NoSuchElementException e) {
                mRadioConfigProxy.clear();
                loge("getHidlRadioConfigProxy1_0: RadioConfigProxy getService | linkToDeath: " + e);
            }
        }

        if (!mRadioConfigProxy.isEmpty()) {
            try {
                mRadioConfigProxy.linkToDeath(mRadioConfigProxyCookie.incrementAndGet());
                mRadioConfigProxy.setResponseFunctions(this);
                return;
                return;
        } catch (NoSuchElementException | RemoteException ignored) {
            } catch (RemoteException e) {
                mRadioConfigProxy.clear();
                loge("RadioConfigProxy: failed to linkToDeath() or setResponseFunction()");
            }
        }
        }


        // Couldn't bind to anything!
        loge("getRadioConfigProxy: mRadioConfigProxy == null");
        loge("getRadioConfigProxy: mRadioConfigProxyHolder == null");
    }
    }


    private RILRequest obtainRequest(int request, Message result, WorkSource workSource) {
    private RILRequest obtainRequest(int request, Message result, WorkSource workSource) {
@@ -557,21 +366,18 @@ public class RadioConfig extends Handler {
     */
     */
    public void getSimSlotsStatus(Message result) {
    public void getSimSlotsStatus(Message result) {
        RadioConfigProxy proxy = getRadioConfigProxy(result);
        RadioConfigProxy proxy = getRadioConfigProxy(result);
        if (proxy.isEmpty()) return;


        if (!proxy.isEmpty()) {
        RILRequest rr = obtainRequest(RIL_REQUEST_GET_SLOT_STATUS, result, mDefaultWorkSource);
        RILRequest rr = obtainRequest(RIL_REQUEST_GET_SLOT_STATUS, result, mDefaultWorkSource);

        if (DBG) {
        if (DBG) {
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
        }
        }

        try {
        try {
                proxy.getSimSlotsStatus(rr.mSerial);
            proxy.getSimSlotStatus(rr.mSerial);
        } catch (RemoteException | RuntimeException e) {
        } catch (RemoteException | RuntimeException e) {
            resetProxyAndRequestList("getSimSlotsStatus", e);
            resetProxyAndRequestList("getSimSlotsStatus", e);
        }
        }
    }
    }
    }


    /**
    /**
     * Wrapper function for IRadioConfig.setPreferredDataModem(int modemId).
     * Wrapper function for IRadioConfig.setPreferredDataModem(int modemId).
@@ -592,9 +398,8 @@ public class RadioConfig extends Handler {
        if (DBG) {
        if (DBG) {
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
        }
        }

        try {
        try {
            proxy.setPreferredDataModem(rr.mSerial, (byte) modemId);
            proxy.setPreferredDataModem(rr.mSerial, modemId);
        } catch (RemoteException | RuntimeException e) {
        } catch (RemoteException | RuntimeException e) {
            resetProxyAndRequestList("setPreferredDataModem", e);
            resetProxyAndRequestList("setPreferredDataModem", e);
        }
        }
@@ -615,11 +420,9 @@ public class RadioConfig extends Handler {
        }
        }


        RILRequest rr = obtainRequest(RIL_REQUEST_GET_PHONE_CAPABILITY, result, mDefaultWorkSource);
        RILRequest rr = obtainRequest(RIL_REQUEST_GET_PHONE_CAPABILITY, result, mDefaultWorkSource);

        if (DBG) {
        if (DBG) {
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
        }
        }

        try {
        try {
            proxy.getPhoneCapability(rr.mSerial);
            proxy.getPhoneCapability(rr.mSerial);
        } catch (RemoteException | RuntimeException e) {
        } catch (RemoteException | RuntimeException e) {
@@ -640,27 +443,23 @@ public class RadioConfig extends Handler {


    /**
    /**
     * Wrapper function for IRadioConfig.setSimSlotsMapping(int32_t serial, vec<uint32_t> slotMap).
     * Wrapper function for IRadioConfig.setSimSlotsMapping(int32_t serial, vec<uint32_t> slotMap).
     * TODO(ag/15898089): Interface for setSimSlotsMapping was changes but underlying implementation
     *                    was not provided. Need to update this with proper implementation.
     */
     */
    public void setSimSlotsMapping(int[] physicalSlots, Message result) {
    public void setSimSlotsMapping(int[] physicalSlots, Message result) {
        RadioConfigProxy proxy = getRadioConfigProxy(result);
        RadioConfigProxy proxy = getRadioConfigProxy(result);
        if (!proxy.isEmpty()) {
        if (proxy.isEmpty()) return;

        RILRequest rr = obtainRequest(RIL_REQUEST_SET_LOGICAL_TO_PHYSICAL_SLOT_MAPPING, result,
        RILRequest rr = obtainRequest(RIL_REQUEST_SET_LOGICAL_TO_PHYSICAL_SLOT_MAPPING, result,
                mDefaultWorkSource);
                mDefaultWorkSource);

        if (DBG) {
        if (DBG) {
                logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest)
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest) + " "
                        + " " + Arrays.toString(physicalSlots));
                    + Arrays.toString(physicalSlots));
        }
        }

        try {
        try {
            proxy.setSimSlotsMapping(rr.mSerial, physicalSlots);
            proxy.setSimSlotsMapping(rr.mSerial, physicalSlots);
        } catch (RemoteException | RuntimeException e) {
        } catch (RemoteException | RuntimeException e) {
            resetProxyAndRequestList("setSimSlotsMapping", e);
            resetProxyAndRequestList("setSimSlotsMapping", e);
        }
        }
    }
    }
    }


    /**
    /**
     * Wrapper function for using IRadioConfig.setNumOfLiveModems(int32_t serial,
     * Wrapper function for using IRadioConfig.setNumOfLiveModems(int32_t serial,
@@ -679,25 +478,15 @@ public class RadioConfig extends Handler {


        RILRequest rr = obtainRequest(RIL_REQUEST_SWITCH_DUAL_SIM_CONFIG,
        RILRequest rr = obtainRequest(RIL_REQUEST_SWITCH_DUAL_SIM_CONFIG,
                result, mDefaultWorkSource);
                result, mDefaultWorkSource);

        if (DBG) {
        if (DBG) {
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest)
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest)
                    + ", numOfLiveModems = " + numOfLiveModems);
                    + ", numOfLiveModems = " + numOfLiveModems);
        }
        }

        try {
        try {
            if (proxy.getVersion().greaterOrEqual(RADIO_CONFIG_HAL_VERSION_2_0)) {
            proxy.setNumOfLiveModems(rr.mSerial, numOfLiveModems);
                proxy.setNumOfLiveModems(rr.mSerial, (byte) numOfLiveModems);
            } else {
                android.hardware.radio.config.V1_1.ModemsConfig modemsConfig =
                        new android.hardware.radio.config.V1_1.ModemsConfig();
                modemsConfig.numOfLiveModems = (byte) numOfLiveModems;
                proxy.setModemsConfig(rr.mSerial, modemsConfig);
            }
        } catch (RemoteException | RuntimeException e) {
        } catch (RemoteException | RuntimeException e) {
            resetProxyAndRequestList("setModemsConfig", e);
            resetProxyAndRequestList("setNumOfLiveModems", e);
        }
        }

    }
    }


    /**
    /**
@@ -730,7 +519,7 @@ public class RadioConfig extends Handler {
                AsyncResult.forMessage(result,
                AsyncResult.forMessage(result,
                        /* Send response such that all capabilities are supported (depending on
                        /* Send response such that all capabilities are supported (depending on
                           the hal version of course.) */
                           the hal version of course.) */
                        mRadioConfigResponse.getFullCapabilitySet(),
                        proxy.getFullCapabilitySet(),
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                result.sendToTarget();
                result.sendToTarget();
            } else {
            } else {
@@ -744,11 +533,9 @@ public class RadioConfig extends Handler {


        RILRequest rr = obtainRequest(RIL_REQUEST_GET_HAL_DEVICE_CAPABILITIES,
        RILRequest rr = obtainRequest(RIL_REQUEST_GET_HAL_DEVICE_CAPABILITIES,
                result, mDefaultWorkSource);
                result, mDefaultWorkSource);

        if (DBG) {
        if (DBG) {
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
            logd(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
        }
        }

        try {
        try {
            proxy.getHalDeviceCapabilities(rr.mSerial);
            proxy.getHalDeviceCapabilities(rr.mSerial);
        } catch (RemoteException | RuntimeException e) {
        } catch (RemoteException | RuntimeException e) {
+0 −41
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

/**
 * This class is the implementation of IRadioConfigIndication interface.
 */
public class RadioConfigIndication {
    private RadioConfigIndicationHidl mRadioConfigIndicationHidl;
    private RadioConfigIndicationAidl mRadioConfigIndicationAidl;

    public RadioConfigIndication(RadioConfig radioConfig, HalVersion halVersion) {
        if (halVersion.greaterOrEqual(RIL.RADIO_HAL_VERSION_2_0)) {
            mRadioConfigIndicationAidl = new RadioConfigIndicationAidl(radioConfig);
        } else {
            mRadioConfigIndicationHidl = new RadioConfigIndicationHidl(radioConfig);
        }
    }

    public android.hardware.radio.config.V1_2.IRadioConfigIndication getV1() {
        return mRadioConfigIndicationHidl;
    }

    public android.hardware.radio.config.IRadioConfigIndication getV2() {
        return mRadioConfigIndicationAidl;
    }
}
+335 −0

File added.

Preview size limit exceeded, changes collapsed.

+0 −63
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

import android.telephony.TelephonyManager;

import java.util.Set;

/**
 * This class is the implementation of IRadioConfigResponse interface.
 */
public class RadioConfigResponse {
    private static final String TAG = "RadioConfigResponse";

    private final HalVersion mHalVersion;

    private RadioConfigResponseAidl mRadioConfigResponseAidl = null;
    private RadioConfigResponseHidl mRadioConfigResponseHidl = null;

    public RadioConfigResponse(RadioConfig radioConfig, HalVersion halVersion) {
        mHalVersion = halVersion;

        if (mHalVersion.greaterOrEqual(RIL.RADIO_HAL_VERSION_2_0)) {
            mRadioConfigResponseAidl = new RadioConfigResponseAidl(radioConfig, halVersion);
        } else {
            mRadioConfigResponseHidl = new RadioConfigResponseHidl(radioConfig, halVersion);
        }
    }

    public android.hardware.radio.config.V1_3.IRadioConfigResponse getV1() {
        return mRadioConfigResponseHidl;
    }

    public android.hardware.radio.config.IRadioConfigResponse getV2() {
        return mRadioConfigResponseAidl;
    }

    /**
     * Returns all capabilities supported in the most recent radio hal version.
     * <p/>
     * Used in the {@link RILConstants.REQUEST_NOT_SUPPORTED} case.
     *
     * @return all capabilities
     */
    @TelephonyManager.RadioInterfaceCapability
    public Set<String> getFullCapabilitySet() {
        return RILUtils.getCaps(mHalVersion, false);
    }
}