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

Commit 4acbe295 authored by Sewook Seo's avatar Sewook Seo
Browse files

Adding QNS API reconnectQualifiedNetworkType

Provide a new API reconnectQualifiedNetworkType to trigger a clean initial connection
instead of handover to the transport type.

Bug: 319520561
Test: Device test b/325650467
Change-Id: Ibf56d8feeb44809b08ef78000f26c1aa62b9785a
parent e932b949
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26,4 +26,5 @@ oneway interface IQualifiedNetworksServiceCallback
{
    void onQualifiedNetworkTypesChanged(int apnTypes, in int[] qualifiedNetworkTypes);
    void onNetworkValidationRequested(int networkCapability, IIntegerConsumer callback);
    void onReconnectQualifedNetworkType(int apnTypes, int qualifiedNetworkType);
}
+55 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.Annotation.ApnType;
import android.telephony.Annotation.NetCapability;
import android.telephony.PreciseDataConnectionState;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.SparseArray;

@@ -82,6 +83,7 @@ public abstract class QualifiedNetworksService extends Service {
    private static final int QNS_APN_THROTTLE_STATUS_CHANGED                        = 5;
    private static final int QNS_EMERGENCY_DATA_NETWORK_PREFERRED_TRANSPORT_CHANGED = 6;
    private static final int QNS_REQUEST_NETWORK_VALIDATION                         = 7;
    private static final int QNS_RECONNECT_QUALIFIED_NETWORK                        = 8;

    /** Feature flags */
    private static final FeatureFlags sFeatureFlag = new FeatureFlagsImpl();
@@ -186,8 +188,42 @@ public abstract class QualifiedNetworksService extends Service {
                    qualifiedNetworkTypesArray).sendToTarget();
        }

        private void onUpdateQualifiedNetworkTypes(@ApnType int apnTypes,
                                                   int[] qualifiedNetworkTypes) {
        /**
         * Request to make a clean initial connection instead of handover to a transport type mapped
         * to the {@code qualifiedNetworkType} for the {@code apnTypes}. This will update the
         * preferred network type like {@link #updateQualifiedNetworkTypes(int, List)}, however if
         * the data network for the {@code apnTypes} is not in the state {@link TelephonyManager
         * #DATA_CONNECTED} or it's already connected on the transport type mapped to the
         * qualified network type, forced reconnection will be ignored.
         *
         * <p>This will tear down current data network even though target transport type mapped to
         * the {@code qualifiedNetworkType} is not available, and the data network will be connected
         * to the transport type when it becomes available.
         *
         * <p>This is one shot request and does not mean further handover is not allowed to the
         * qualified network type for this APN type.
         *
         * @param apnTypes APN type(s) of the qualified networks. This must be a bitmask combination
         * of {@link ApnType}. The same qualified networks will be applicable to all APN types
         * specified here.
         * @param qualifiedNetworkType Access network types which are qualified for data connection
         * setup for {@link ApnType}. Empty list means QNS has no suggestion to the frameworks, and
         * for that APN type frameworks will route the corresponding network requests to
         * {@link AccessNetworkConstants#TRANSPORT_TYPE_WWAN}.
         *
         * <p> If one of the element is invalid, for example, {@link AccessNetworkType#UNKNOWN},
         * then this operation becomes a no-op.
         *
         * @hide
         */
        public final void reconnectQualifiedNetworkType(@ApnType int apnTypes,
                @AccessNetworkConstants.RadioAccessNetworkType int qualifiedNetworkType) {
            mHandler.obtainMessage(QNS_RECONNECT_QUALIFIED_NETWORK, mSlotIndex, apnTypes,
                    new Integer(qualifiedNetworkType)).sendToTarget();
        }

        private void onUpdateQualifiedNetworkTypes(
                @ApnType int apnTypes, int[] qualifiedNetworkTypes) {
            mQualifiedNetworkTypesList.put(apnTypes, qualifiedNetworkTypes);
            if (mCallback != null) {
                try {
@@ -198,6 +234,17 @@ public abstract class QualifiedNetworksService extends Service {
            }
        }

        private void onReconnectQualifiedNetworkType(@ApnType int apnTypes,
                @AccessNetworkConstants.RadioAccessNetworkType int qualifiedNetworkType) {
            if (mCallback != null) {
                try {
                    mCallback.onReconnectQualifedNetworkType(apnTypes, qualifiedNetworkType);
                } catch (RemoteException e) {
                    loge("Failed to call onReconnectQualifiedNetworkType. " + e);
                }
            }
        }

        /**
         * The framework calls this method when the throttle status of an APN changes.
         *
@@ -366,6 +413,12 @@ public abstract class QualifiedNetworksService extends Service {
                case QNS_REQUEST_NETWORK_VALIDATION:
                    if (provider == null) break;
                    provider.onRequestNetworkValidation((NetworkValidationRequestData) message.obj);
                    break;

                case QNS_RECONNECT_QUALIFIED_NETWORK:
                    if (provider == null) break;
                    provider.onReconnectQualifiedNetworkType(message.arg2, (Integer) message.obj);
                    break;
            }
        }
    }