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

Commit 45ce096b authored by Daniel Bright's avatar Daniel Bright
Browse files

Add CAPABILITY_ALLOWED_NETWORK_TYPES_USED

* Made the HAL version available to radio interface capabilities
* With version 1.6 of the Radio HAL, a new function was added to enforce
the user network types preference (setAllowedNetworkTypeBitmap).
Depending on the version implemented by the modem the
setPreferredNetworkType and setAllowedNetworkTypes TelephonyManager API
methods may use this new HAL method or rely on the previous method
(setPreferredNetworkType). This new capability enum value can be used by
TelephonyManager consumers to know which HAL function is effectively
backing up their calls.

Bug: 163168917
Test: checked logs, created RadioConfigCapabilitiesResponseTest
Change-Id: I0fe8534b341da3419faf2f782715bbfc101d192c
parent 536c1c50
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2151,6 +2151,13 @@ public interface CommandsInterface {
     */
    int getRilVersion();

    /**
     * @return the radio hal version
     */
    default HalVersion getHalVersion() {
        return HalVersion.UNKNOWN;
    }

   /**
     * Sets user selected subscription at Modem.
     *
+10 −9
Original line number Diff line number Diff line
@@ -31,9 +31,9 @@ import android.os.RegistrantList;
import android.os.storage.StorageManager;
import android.sysprop.TelephonyProperties;
import android.telephony.PhoneCapability;
import android.telephony.RadioInterfaceCapabilities;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.ArraySet;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
@@ -42,6 +42,7 @@ import com.android.telephony.Rlog;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

/**
 * This class manages phone's configuration which defines the potential capability (static) of the
@@ -73,7 +74,7 @@ public class PhoneConfigurationManager {
    private MockableInterface mMi = new MockableInterface();
    private TelephonyManager mTelephonyManager;
    private static final RegistrantList sMultiSimConfigChangeRegistrants = new RegistrantList();
    private RadioInterfaceCapabilities mRadioInterfaceCapabilities;
    private Set<String> mRadioInterfaceCapabilities;
    private final Object mLockRadioInterfaceCapabilities = new Object();

    /**
@@ -101,7 +102,7 @@ public class PhoneConfigurationManager {
        mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        //initialize with default, it'll get updated when RADIO is ON/AVAILABLE
        mStaticCapability = getDefaultCapability();
        mRadioConfig = RadioConfig.getInstance(mContext);
        mRadioConfig = RadioConfig.getInstance();
        mHandler = new ConfigManagerHandler();
        mPhoneStatusMap = new HashMap<>();

@@ -318,7 +319,7 @@ public class PhoneConfigurationManager {
     * Gets the radio interface capabilities for the device
     */
    @NonNull
    public synchronized RadioInterfaceCapabilities getRadioInterfaceCapabilities() {
    public synchronized Set<String> getRadioInterfaceCapabilities() {
        if (mRadioInterfaceCapabilities == null) {
            // Only incur cost of synchronization block if mRadioInterfaceCapabilities isn't null
            synchronized (mLockRadioInterfaceCapabilities) {
@@ -338,8 +339,9 @@ public class PhoneConfigurationManager {
                }
            }
        }
        if (mRadioInterfaceCapabilities == null) return new RadioInterfaceCapabilities();
        else return mRadioInterfaceCapabilities;

        if (mRadioInterfaceCapabilities == null) return new ArraySet<>();
        return mRadioInterfaceCapabilities;
    }

    private void setupRadioInterfaceCapabilities(@NonNull AsyncResult ar) {
@@ -351,8 +353,7 @@ public class PhoneConfigurationManager {
                    }
                    log("setupRadioInterfaceCapabilities: "
                            + "mRadioInterfaceCapabilities now setup");

                    mRadioInterfaceCapabilities = (RadioInterfaceCapabilities) ar.result;
                    mRadioInterfaceCapabilities = (Set<String>) ar.result;
                }
                mLockRadioInterfaceCapabilities.notify();
            }
+4 −0
Original line number Diff line number Diff line
@@ -175,6 +175,10 @@ public class PhoneFactory {
                            RadioAccessFamily.getRafFromNetworkType(networkModes[i]),
                            cdmaSubscription, i);
                }
                HalVersion radioHalVersion;
                if (numPhones > 0) radioHalVersion = sCommandsInterfaces[0].getHalVersion();
                else radioHalVersion = HalVersion.UNKNOWN;
                RadioConfig.make(context, radioHalVersion);

                // Instantiate UiccController so that all other classes can just
                // call getInstance()
+1 −1
Original line number Diff line number Diff line
@@ -399,7 +399,7 @@ public class PhoneSwitcher extends Handler {
        mLocalLog = new LocalLog(MAX_LOCAL_LOG_LINES);

        mSubscriptionController = SubscriptionController.getInstance();
        mRadioConfig = RadioConfig.getInstance(mContext);
        mRadioConfig = RadioConfig.getInstance();
        mValidator = CellularNetworkValidator.getInstance();

        mActivePhoneRegistrants = new RegistrantList();
+28 −10
Original line number Diff line number Diff line
@@ -25,8 +25,7 @@ import static com.android.internal.telephony.RILConstants.REQUEST_NOT_SUPPORTED;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_HAL_DEVICE_CAPABILITIES;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_PHONE_CAPABILITY;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SLOT_STATUS;
import static com.android.internal.telephony.RILConstants
        .RIL_REQUEST_SET_LOGICAL_TO_PHYSICAL_SLOT_MAPPING;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_LOGICAL_TO_PHYSICAL_SLOT_MAPPING;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_PREFERRED_DATA_MODEM;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SWITCH_DUAL_SIM_CONFIG;

@@ -43,7 +42,6 @@ import android.os.Message;
import android.os.Registrant;
import android.os.RemoteException;
import android.os.WorkSource;
import android.telephony.RadioInterfaceCapabilities;
import android.util.SparseArray;

import com.android.internal.telephony.uicc.IccSlotStatus;
@@ -85,6 +83,7 @@ public class RadioConfig extends Handler {
    private final WorkSource mDefaultWorkSource;
    private final int mDeviceNrCapability;
    private static RadioConfig sRadioConfig;
    private static final Object sLock = new Object();

    protected Registrant mSimSlotStatusRegistrant;

@@ -97,12 +96,12 @@ public class RadioConfig extends Handler {
        }
    }

    private RadioConfig(Context context) {
    private RadioConfig(Context context, HalVersion radioHalVersion) {
        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(
                Context.CONNECTIVITY_SERVICE);
        mIsMobileNetworkSupported = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);

        mRadioConfigResponse = new RadioConfigResponse(this);
        mRadioConfigResponse = new RadioConfigResponse(this, radioHalVersion);
        mRadioConfigIndication = new RadioConfigIndication(this);
        mServiceDeathRecipient = new ServiceDeathRecipient();

@@ -121,12 +120,28 @@ public class RadioConfig extends Handler {
    /**
     * Returns the singleton static instance of RadioConfig
     */
    public static RadioConfig getInstance(Context context) {
    public static RadioConfig getInstance() {
        synchronized (sLock) {
            if (sRadioConfig == null) {
            sRadioConfig = new RadioConfig(context);
                throw new RuntimeException(
                        "RadioConfig.getInstance can't be called before make()");
            }
            return sRadioConfig;
        }
    }

    /**
     * Makes the radio config based on the context and the radio hal version passed in
     */
    public static RadioConfig make(Context c, HalVersion radioHalVersion) {
        synchronized (sLock) {
            if (sRadioConfig != null) {
                throw new RuntimeException("RadioConfig.make() should only be called once");
            }
            sRadioConfig = new RadioConfig(c, radioHalVersion);
            return sRadioConfig;
        }
    }

    @Override
    public void handleMessage(Message message) {
@@ -540,7 +555,10 @@ public class RadioConfig extends Handler {
                if (DBG) {
                    logd("RIL_REQUEST_GET_HAL_DEVICE_CAPABILITIES > REQUEST_NOT_SUPPORTED");
                }
                AsyncResult.forMessage(result, new RadioInterfaceCapabilities() /* send empty */,
                AsyncResult.forMessage(result,
                        /* Send response such that all capabilities are supported (depending on
                           the hal version of course.) */
                        mRadioConfigResponse.createFullCapabilitySet(),
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                result.sendToTarget();
            } else {
Loading