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

Commit c31929f5 authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Revert "Revert "[eSIM BootStrap Support] Support esim bootstrap ..."" into main

parents f0c211c9 e9ff24a4
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
package: "com.android.internal.telephony.flags"

flag {
    name: "esim_bootstrap_provisioning_flag"
    namespace: "telephony"
    description: "This flag controls eSIM Bootstrap provisioning feature support."
    bug:"298567545"
}
flag {
    name: "imsi_key_retry_download_on_phone_unlock"
    namespace: "telephony"
+6 −1
Original line number Diff line number Diff line
@@ -2290,6 +2290,10 @@ public class DataNetwork extends StateMachine {
            }
        }

        if (mDataNetworkController.isEsimBootStrapProvisioningActivated()) {
            builder.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
        }

        // If one of the capabilities are for special use, for example, IMS, CBS, then this
        // network should be restricted, regardless data is enabled or not.
        if (NetworkCapabilitiesUtils.inferRestrictedCapability(builder.build())
@@ -3318,7 +3322,8 @@ public class DataNetwork extends StateMachine {
            TelephonyNetworkRequest networkRequest = mAttachedNetworkRequestList.get(0);
            DataProfile dataProfile = mDataNetworkController.getDataProfileManager()
                    .getDataProfileForNetworkRequest(networkRequest, targetNetworkType,
                            mPhone.getServiceState().isUsingNonTerrestrialNetwork(), false);
                            mPhone.getServiceState().isUsingNonTerrestrialNetwork(),
                            mDataNetworkController.isEsimBootStrapProvisioningActivated(), false);
            // Some carriers have different profiles between cellular and IWLAN. We need to
            // dynamically switch profile, but only when those profiles have same APN name.
            if (dataProfile != null && dataProfile.getApnSetting() != null
+22 −1
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@ import com.android.internal.telephony.data.DataStallRecoveryManager.DataStallRec
import com.android.internal.telephony.data.LinkBandwidthEstimator.LinkBandwidthEstimatorCallback;
import com.android.internal.telephony.flags.FeatureFlags;
import com.android.internal.telephony.ims.ImsResolver;
import com.android.internal.telephony.subscription.SubscriptionInfoInternal;
import com.android.internal.telephony.subscription.SubscriptionManagerService;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.telephony.Rlog;

@@ -1330,6 +1332,7 @@ public class DataNetworkController extends Handler {
                        .getDataProfileForNetworkRequest(requestList.getFirst(),
                                TelephonyManager.NETWORK_TYPE_IWLAN,
                                mServiceState.isUsingNonTerrestrialNetwork(),
                                isEsimBootStrapProvisioningActivated(),
                                false/*ignorePermanentFailure*/);
                if (candidate != null && !dataNetwork.getDataProfile().equals(candidate)) {
                    logv("But skipped because found better data profile " + candidate
@@ -1494,7 +1497,8 @@ public class DataNetworkController extends Handler {
            evaluation.addDataAllowedReason(DataAllowedReason.EMERGENCY_REQUEST);
            evaluation.setCandidateDataProfile(mDataProfileManager.getDataProfileForNetworkRequest(
                    networkRequest, getDataNetworkType(transport),
                    mServiceState.isUsingNonTerrestrialNetwork(), true));
                    mServiceState.isUsingNonTerrestrialNetwork(),
                    isEsimBootStrapProvisioningActivated(), true));
            networkRequest.setEvaluation(evaluation);
            log(evaluation.toString());
            return evaluation;
@@ -1653,6 +1657,7 @@ public class DataNetworkController extends Handler {
        DataProfile dataProfile = mDataProfileManager
                .getDataProfileForNetworkRequest(networkRequest, networkType,
                        mServiceState.isUsingNonTerrestrialNetwork(),
                        isEsimBootStrapProvisioningActivated(),
                        // If the evaluation is due to environmental changes, then we should ignore
                        // the permanent failure reached earlier.
                        reason.isConditionBased());
@@ -2271,6 +2276,22 @@ public class DataNetworkController extends Handler {
                .orElse(null);
    }

    /**
     * Check if the device is in eSIM bootstrap provisioning state.
     *
     * @return {@code true} if the device is under eSIM bootstrap provisioning.
     */
    public boolean isEsimBootStrapProvisioningActivated() {
        if (!mFeatureFlags.esimBootstrapProvisioningFlag()) {
            return false;
        }

        SubscriptionInfoInternal subInfo = SubscriptionManagerService.getInstance()
                .getSubscriptionInfoInternal(mPhone.getSubId());
        return subInfo != null
                && subInfo.getProfileClass() == SubscriptionManager.PROFILE_CLASS_PROVISIONING;
    }

    /**
     * Register for IMS feature registration state.
     *
+52 −37
Original line number Diff line number Diff line
@@ -255,6 +255,7 @@ public class DataProfileManager extends Handler {
        cursor.close();
        return dataProfile;
    }

    /**
     * Update all data profiles, including preferred data profile, and initial attach data profile.
     * Also send those profiles down to the modem if needed.
@@ -640,12 +641,12 @@ public class DataProfileManager extends Handler {
     */
    public @Nullable DataProfile getDataProfileForNetworkRequest(
            @NonNull TelephonyNetworkRequest networkRequest, @NetworkType int networkType,
            boolean isNtn, boolean ignorePermanentFailure) {
            boolean isNtn, boolean isEsimBootstrapProvisioning, boolean ignorePermanentFailure) {
        ApnSetting apnSetting = null;
        if (networkRequest.hasAttribute(TelephonyNetworkRequest
                .CAPABILITY_ATTRIBUTE_APN_SETTING)) {
            apnSetting = getApnSettingForNetworkRequest(networkRequest, networkType, isNtn,
                    ignorePermanentFailure);
                    isEsimBootstrapProvisioning, ignorePermanentFailure);
        }

        TrafficDescriptor.Builder trafficDescriptorBuilder = new TrafficDescriptor.Builder();
@@ -711,17 +712,19 @@ public class DataProfileManager extends Handler {
     */
    private @Nullable ApnSetting getApnSettingForNetworkRequest(
            @NonNull TelephonyNetworkRequest networkRequest, @NetworkType int networkType,
            boolean isNtn, boolean ignorePermanentFailure) {
            boolean isNtn, boolean isEsimBootStrapProvisioning, boolean ignorePermanentFailure) {
        if (!networkRequest.hasAttribute(
                TelephonyNetworkRequest.CAPABILITY_ATTRIBUTE_APN_SETTING)) {
            loge("Network request does not have APN setting attribute.");
            return null;
        }

        // if esim bootstrap provisioning in progress, do not apply preferred data profile
        if (!isEsimBootStrapProvisioning) {
            if (mFeatureFlags.carrierEnabledSatelliteFlag()) {
                // If the preferred data profile can be used, always use it if it can satisfy the
            // network request with current network type (even though it's been marked as permanent
            // failed.)
                // network request with current network type (even though it's been marked as
                // permanent failed.)
                if (mPreferredDataProfile != null
                        && networkRequest.canBeSatisfiedBy(mPreferredDataProfile)
                        && mPreferredDataProfile.getApnSetting() != null
@@ -740,12 +743,13 @@ public class DataProfileManager extends Handler {
                }
            } else {
                // If the preferred data profile can be used, always use it if it can satisfy the
            // network request with current network type (even though it's been marked as permanent
            // failed.)
                // network request with current network type (even though it's been marked as
                // permanent failed.)
                if (mPreferredDataProfile != null
                        && networkRequest.canBeSatisfiedBy(mPreferredDataProfile)
                        && mPreferredDataProfile.getApnSetting() != null
                    && mPreferredDataProfile.getApnSetting().canSupportNetworkType(networkType)) {
                        && mPreferredDataProfile.getApnSetting()
                        .canSupportNetworkType(networkType)) {
                    if (ignorePermanentFailure || !mPreferredDataProfile.getApnSetting()
                            .getPermanentFailed()) {
                        return mPreferredDataProfile.getApnSetting();
@@ -755,6 +759,7 @@ public class DataProfileManager extends Handler {
                    return null;
                }
            }
        }

        // Filter out the data profile that can't satisfy the request.
        // Preferred data profile should be returned in the top of the list.
@@ -778,6 +783,8 @@ public class DataProfileManager extends Handler {
                .filter((dp) -> {
                    if (dp.getApnSetting() == null) return false;
                    if (!dp.getApnSetting().canSupportNetworkType(networkType)) return false;
                    if (isEsimBootStrapProvisioning
                            != dp.getApnSetting().isEsimBootstrapProvisioning()) return false;
                    if (mFeatureFlags.carrierEnabledSatelliteFlag()) {
                        if (isNtn && !dp.getApnSetting().isForInfrastructure(
                                ApnSetting.INFRASTRUCTURE_SATELLITE)) {
@@ -820,6 +827,10 @@ public class DataProfileManager extends Handler {
            return null;
        }

        if (isEsimBootStrapProvisioning) {
            log("Found esim bootstrap provisioning data profile for network request: "
                    + dataProfiles.get(0).getApnSetting());
        }
        return dataProfiles.get(0).getApnSetting();
    }

@@ -865,7 +876,9 @@ public class DataProfileManager extends Handler {
                        .addCapability(NetworkCapabilities.NET_CAPABILITY_DUN)
                        .build(), mPhone);
        return getDataProfileForNetworkRequest(networkRequest, networkType,
                mPhone.getServiceState().isUsingNonTerrestrialNetwork(), true) != null;
                mPhone.getServiceState().isUsingNonTerrestrialNetwork(),
                mDataNetworkController.isEsimBootStrapProvisioningActivated(),
                true) != null;
    }

    /**
@@ -1040,6 +1053,8 @@ public class DataProfileManager extends Handler {
        apnBuilder.setCarrierId(apn1.getCarrierId());
        apnBuilder.setSkip464Xlat(apn1.getSkip464Xlat());
        apnBuilder.setAlwaysOn(apn1.isAlwaysOn());
        apnBuilder.setInfrastructureBitmask(apn1.getInfrastructureBitmask());
        apnBuilder.setEsimBootstrapProvisioning(apn1.isEsimBootstrapProvisioning());

        return new DataProfile.Builder()
                .setApnSetting(apnBuilder.build())
Loading