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

Commit 70c62bf1 authored by Sebastian Pickl's avatar Sebastian Pickl Committed by Jack Yu
Browse files

[RESTRICT AUTOMERGE] Revert "Removed IWLAN legacy mode support"

Revert submission 2370228-legacy_iwlan_removal

Reason for revert: try finding the culprit for b/275330844

Reverted changes: /q/submissionid:2370228-legacy_iwlan_removal

Change-Id: Ib20a8567fd468e7d80587d328285d512ddc93f05
parent e86b1c31
Loading
Loading
Loading
Loading
+53 −12
Original line number Diff line number Diff line
@@ -669,7 +669,7 @@ public class ServiceStateTracker extends Handler {

        mAccessNetworksManager = mPhone.getAccessNetworksManager();
        mOutOfServiceSS = new ServiceState();
        mOutOfServiceSS.setOutOfService(false);
        mOutOfServiceSS.setOutOfService(mAccessNetworksManager.isInLegacyMode(), false);

        for (int transportType : mAccessNetworksManager.getAvailableTransports()) {
            mRegStateManagers.append(transportType, new NetworkRegistrationManager(
@@ -771,9 +771,9 @@ public class ServiceStateTracker extends Handler {
        }

        mSS = new ServiceState();
        mSS.setOutOfService(false);
        mSS.setOutOfService(mAccessNetworksManager.isInLegacyMode(), false);
        mNewSS = new ServiceState();
        mNewSS.setOutOfService(false);
        mNewSS.setOutOfService(mAccessNetworksManager.isInLegacyMode(), false);
        mLastCellInfoReqTime = 0;
        mLastCellInfoList = null;
        mStartedGprsRegCheck = false;
@@ -3341,7 +3341,7 @@ public class ServiceStateTracker extends Handler {
                nri = mNewSS.getNetworkRegistrationInfo(
                        NetworkRegistrationInfo.DOMAIN_PS,
                        AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
                mNewSS.setOutOfService(false);
                mNewSS.setOutOfService(mAccessNetworksManager.isInLegacyMode(), false);
                // Add the IWLAN registration info back to service state.
                if (nri != null) {
                    mNewSS.addNetworkRegistrationInfo(nri);
@@ -3358,7 +3358,7 @@ public class ServiceStateTracker extends Handler {
                nri = mNewSS.getNetworkRegistrationInfo(
                        NetworkRegistrationInfo.DOMAIN_PS,
                        AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
                mNewSS.setOutOfService(true);
                mNewSS.setOutOfService(mAccessNetworksManager.isInLegacyMode(), true);
                // Add the IWLAN registration info back to service state.
                if (nri != null) {
                    mNewSS.addNetworkRegistrationInfo(nri);
@@ -3485,10 +3485,14 @@ public class ServiceStateTracker extends Handler {
                mSS.getState() == ServiceState.STATE_POWER_OFF
                        && mNewSS.getState() != ServiceState.STATE_POWER_OFF;

        SparseBooleanArray hasDataAttached = new SparseBooleanArray();
        SparseBooleanArray hasDataDetached = new SparseBooleanArray();
        SparseBooleanArray hasRilDataRadioTechnologyChanged = new SparseBooleanArray();
        SparseBooleanArray hasDataRegStateChanged = new SparseBooleanArray();
        SparseBooleanArray hasDataAttached = new SparseBooleanArray(
                mAccessNetworksManager.getAvailableTransports().length);
        SparseBooleanArray hasDataDetached = new SparseBooleanArray(
                mAccessNetworksManager.getAvailableTransports().length);
        SparseBooleanArray hasRilDataRadioTechnologyChanged = new SparseBooleanArray(
                mAccessNetworksManager.getAvailableTransports().length);
        SparseBooleanArray hasDataRegStateChanged = new SparseBooleanArray(
                mAccessNetworksManager.getAvailableTransports().length);
        boolean anyDataRegChanged = false;
        boolean anyDataRatChanged = false;
        boolean hasAlphaRawChanged =
@@ -3678,7 +3682,7 @@ public class ServiceStateTracker extends Handler {
        ServiceState oldMergedSS = new ServiceState(mPhone.getServiceState());
        mSS = new ServiceState(mNewSS);

        mNewSS.setOutOfService(false);
        mNewSS.setOutOfService(mAccessNetworksManager.isInLegacyMode(), false);

        mCellIdentity = primaryCellIdentity;
        if (mSS.getState() == ServiceState.STATE_IN_SERVICE && primaryCellIdentity != null) {
@@ -5565,7 +5569,8 @@ public class ServiceStateTracker extends Handler {


    /**
     * This method makes some adjustments when the device camps on IWLAN in airplane mode.
     * This method adds IWLAN registration info for legacy mode devices camped on IWLAN. It also
     * makes some adjustments when the device camps on IWLAN in airplane mode.
     */
    private void processIwlanRegistrationInfo() {
        if (mCi.getRadioState() == TelephonyManager.RADIO_POWER_OFF) {
@@ -5579,7 +5584,7 @@ public class ServiceStateTracker extends Handler {
            }
            // operator info should be kept in SS
            String operator = mNewSS.getOperatorAlphaLong();
            mNewSS.setOutOfService(true);
            mNewSS.setOutOfService(mAccessNetworksManager.isInLegacyMode(), true);
            if (resetIwlanRatVal) {
                mNewSS.setDataRegState(ServiceState.STATE_IN_SERVICE);
                NetworkRegistrationInfo nri = new NetworkRegistrationInfo.Builder()
@@ -5589,6 +5594,17 @@ public class ServiceStateTracker extends Handler {
                        .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                        .build();
                mNewSS.addNetworkRegistrationInfo(nri);
                if (mAccessNetworksManager.isInLegacyMode()) {
                    // If in legacy mode, simulate the behavior that IWLAN registration info
                    // is reported through WWAN transport.
                    nri = new NetworkRegistrationInfo.Builder()
                            .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                            .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                            .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)
                            .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                            .build();
                    mNewSS.addNetworkRegistrationInfo(nri);
                }
                mNewSS.setOperatorAlphaLong(operator);
                // Since it's in airplane mode, cellular must be out of service. The only possible
                // transport for data to go through is the IWLAN transport. Setting this to true
@@ -5598,6 +5614,31 @@ public class ServiceStateTracker extends Handler {
            }
            return;
        }

        // If the device operates in legacy mode and camps on IWLAN, modem reports IWLAN as a RAT
        // through WWAN registration info. To be consistent with the behavior with AP-assisted mode,
        // we manually make a WLAN registration info for clients to consume. In this scenario,
        // both WWAN and WLAN registration info are the IWLAN registration info and that's the
        // unfortunate limitation we have when the device operates in legacy mode. In AP-assisted
        // mode, the WWAN registration will correctly report the actual cellular registration info
        // when the device camps on IWLAN.
        if (mAccessNetworksManager.isInLegacyMode()) {
            NetworkRegistrationInfo wwanNri = mNewSS.getNetworkRegistrationInfo(
                    NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
            if (wwanNri != null && wwanNri.getAccessNetworkTechnology()
                    == TelephonyManager.NETWORK_TYPE_IWLAN) {
                NetworkRegistrationInfo wlanNri = new NetworkRegistrationInfo.Builder()
                        .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
                        .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                        .setRegistrationState(wwanNri.getNetworkRegistrationState())
                        .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)
                        .setRejectCause(wwanNri.getRejectCause())
                        .setEmergencyOnly(wwanNri.isEmergencyEnabled())
                        .setAvailableServices(wwanNri.getAvailableServices())
                        .build();
                mNewSS.addNetworkRegistrationInfo(wlanNri);
            }
        }
    }

    /**
+88 −15
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.telephony.data;
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringDef;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -33,6 +34,7 @@ import android.os.PersistableBundle;
import android.os.Registrant;
import android.os.RegistrantList;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
@@ -54,11 +56,14 @@ import android.util.LocalLog;
import android.util.SparseArray;

import com.android.internal.telephony.Phone;
import com.android.internal.telephony.RIL;
import com.android.internal.telephony.SlidingWindowEventCounter;
import com.android.telephony.Rlog;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -76,6 +81,35 @@ import java.util.stream.Collectors;
 */
public class AccessNetworksManager extends Handler {
    private static final boolean DBG = false;
    public static final String SYSTEM_PROPERTIES_IWLAN_OPERATION_MODE =
            "ro.telephony.iwlan_operation_mode";

    @Retention(RetentionPolicy.SOURCE)
    @StringDef(prefix = {"IWLAN_OPERATION_MODE_"},
            value = {
                    IWLAN_OPERATION_MODE_DEFAULT,
                    IWLAN_OPERATION_MODE_LEGACY,
                    IWLAN_OPERATION_MODE_AP_ASSISTED})
    public @interface IwlanOperationMode {}

    /**
     * IWLAN default mode. On device that has IRadio 1.4 or above, it means
     * {@link #IWLAN_OPERATION_MODE_AP_ASSISTED}. On device that has IRadio 1.3 or below, it means
     * {@link #IWLAN_OPERATION_MODE_LEGACY}.
     */
    public static final String IWLAN_OPERATION_MODE_DEFAULT = "default";

    /**
     * IWLAN legacy mode. IWLAN is completely handled by the modem, and when the device is on
     * IWLAN, modem reports IWLAN as a RAT.
     */
    public static final String IWLAN_OPERATION_MODE_LEGACY = "legacy";

    /**
     * IWLAN application processor assisted mode. IWLAN is handled by the bound IWLAN data service
     * and network service separately.
     */
    public static final String IWLAN_OPERATION_MODE_AP_ASSISTED = "AP-assisted";

    /**
     * The counters to detect frequent QNS attempt to change preferred network transport by ApnType.
@@ -332,6 +366,14 @@ public class AccessNetworksManager extends Handler {
                Context.CARRIER_CONFIG_SERVICE);
        mLogTag = "ANM-" + mPhone.getPhoneId();
        mApnTypeToQnsChangeNetworkCounter = new SparseArray<>();

        if (isInLegacyMode()) {
            log("operates in legacy mode.");
            // For legacy mode, WWAN is the only transport to handle all data connections, even
            // the IWLAN ones.
            mAvailableTransports = new int[]{AccessNetworkConstants.TRANSPORT_TYPE_WWAN};
        } else {
            log("operates in AP-assisted mode.");
            mAvailableTransports = new int[]{AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                    AccessNetworkConstants.TRANSPORT_TYPE_WLAN};
            IntentFilter intentFilter = new IntentFilter();
@@ -345,6 +387,7 @@ public class AccessNetworksManager extends Handler {
                loge("Package name not found: ", e);
            }
            bindQualifiedNetworksService();
        }

        // Using post to delay the registering because data retry manager and data config
        // manager instances are created later than access networks manager.
@@ -447,7 +490,8 @@ public class AccessNetworksManager extends Handler {
    /**
     * Get the qualified network service package.
     *
     * @return package name of the qualified networks service package.
     * @return package name of the qualified networks service package. Return empty string when in
     * legacy mode (i.e. Dedicated IWLAN data/network service is not supported).
     */
    private String getQualifiedNetworksServicePackageName() {
        // Read package name from the resource
@@ -524,9 +568,30 @@ public class AccessNetworksManager extends Handler {
    }

    /**
     * @return The available transports.
     * @return {@code true} if the device operates in legacy mode, otherwise {@code false}.
     */
    public @NonNull int[] getAvailableTransports() {
    public boolean isInLegacyMode() {
        // Get IWLAN operation mode from the system property. If the system property is configured
        // to default or not configured, the mode is tied to IRadio version. For 1.4 or above, it's
        // AP-assisted mode, for 1.3 or below, it's legacy mode.
        String mode = SystemProperties.get(SYSTEM_PROPERTIES_IWLAN_OPERATION_MODE);

        if (mode.equals(IWLAN_OPERATION_MODE_AP_ASSISTED)) {
            return false;
        } else if (mode.equals(IWLAN_OPERATION_MODE_LEGACY)) {
            return true;
        }

        return mPhone.getHalVersion().less(RIL.RADIO_HAL_VERSION_1_4);
    }

    /**
     * @return The available transports. Note that on legacy devices, the only available transport
     * would be WWAN only. If the device is configured as AP-assisted mode, the available transport
     * will always be WWAN and WLAN (even if the device is not camped on IWLAN).
     * See {@link #isInLegacyMode()} for mode details.
     */
    public synchronized @NonNull int[] getAvailableTransports() {
        return mAvailableTransports;
    }

@@ -561,6 +626,11 @@ public class AccessNetworksManager extends Handler {
     * @return The preferred transport.
     */
    public @TransportType int getPreferredTransport(@ApnType int apnType) {
        // In legacy mode, always preferred on cellular.
        if (isInLegacyMode()) {
            return AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
        }

        return mPreferredTransports.get(apnType) == null
                ? AccessNetworkConstants.TRANSPORT_TYPE_WWAN : mPreferredTransports.get(apnType);
    }
@@ -663,6 +733,9 @@ public class AccessNetworksManager extends Handler {
        }

        pw.decreaseIndent();
        pw.println("isInLegacy=" + isInLegacyMode());
        pw.println("IWLAN operation mode="
                + SystemProperties.get(SYSTEM_PROPERTIES_IWLAN_OPERATION_MODE));
        pw.println("Local logs=");
        pw.increaseIndent();
        mLocalLog.dump(fd, pw, args);
+2 −3
Original line number Diff line number Diff line
@@ -912,9 +912,8 @@ public class DataNetwork extends StateMachine {
        mDataAllowedReason = dataAllowedReason;
        dataProfile.setLastSetupTimestamp(SystemClock.elapsedRealtime());
        mAttachedNetworkRequestList.addAll(networkRequestList);
        for (int transportType : mAccessNetworksManager.getAvailableTransports()) {
            mCid.put(transportType, INVALID_CID);
        }
        mCid.put(AccessNetworkConstants.TRANSPORT_TYPE_WWAN, INVALID_CID);
        mCid.put(AccessNetworkConstants.TRANSPORT_TYPE_WLAN, INVALID_CID);
        mTelephonyDisplayInfo = mPhone.getDisplayInfoController().getTelephonyDisplayInfo();
        mTcpBufferSizes = mDataConfigManager.getTcpConfigString(mTelephonyDisplayInfo);

+12 −8
Original line number Diff line number Diff line
@@ -779,11 +779,13 @@ public class DataNetworkController extends Handler {
        log("DataNetworkController created.");

        mAccessNetworksManager = phone.getAccessNetworksManager();
        for (int transport : mAccessNetworksManager.getAvailableTransports()) {
            mDataServiceManagers.put(transport, new DataServiceManager(mPhone, looper,
                    AccessNetworkConstants.TRANSPORT_TYPE_WWAN));
        mDataServiceManagers.put(AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                new DataServiceManager(mPhone, looper, AccessNetworkConstants.TRANSPORT_TYPE_WWAN));
        if (!mAccessNetworksManager.isInLegacyMode()) {
            mDataServiceManagers.put(AccessNetworkConstants.TRANSPORT_TYPE_WLAN,
                    new DataServiceManager(mPhone, looper,
                            AccessNetworkConstants.TRANSPORT_TYPE_WLAN));
        }

        mDataConfigManager = new DataConfigManager(mPhone, looper);

        // ========== Anomaly counters ==========
@@ -986,10 +988,12 @@ public class DataNetworkController extends Handler {
        mDataServiceManagers.get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .registerForServiceBindingChanged(this, EVENT_DATA_SERVICE_BINDING_CHANGED);

        if (!mAccessNetworksManager.isInLegacyMode()) {
            mPhone.getServiceStateTracker().registerForServiceStateChanged(this,
                    EVENT_SERVICE_STATE_CHANGED, null);
            mDataServiceManagers.get(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
                    .registerForServiceBindingChanged(this, EVENT_DATA_SERVICE_BINDING_CHANGED);
        }

        mPhone.getContext().getSystemService(TelephonyRegistryManager.class)
                .addOnSubscriptionsChangedListener(new OnSubscriptionsChangedListener() {
+4 −3
Original line number Diff line number Diff line
@@ -958,9 +958,10 @@ public class DataRetryManager extends Handler {
                DataRetryManager.this.onCarrierConfigUpdated();
            }
        });

        for (int transport : mPhone.getAccessNetworksManager().getAvailableTransports()) {
            mDataServiceManagers.get(transport)
        mDataServiceManagers.get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .registerForApnUnthrottled(this, EVENT_DATA_PROFILE_UNTHROTTLED);
        if (!mPhone.getAccessNetworksManager().isInLegacyMode()) {
            mDataServiceManagers.get(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
                    .registerForApnUnthrottled(this, EVENT_DATA_PROFILE_UNTHROTTLED);
        }
        mDataProfileManager.registerCallback(new DataProfileManagerCallback(this::post) {
Loading