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

Commit 6bd48a24 authored by Jack Yu's avatar Jack Yu
Browse files

Fixed IWLAN related APIs issue

Fixed APIs that not meeting API review requirement.
1. Changed createXxxServiceProvider to onCreateXxxServiceProvider
2. Added builder for NetworkRegistrationState

Test: Manual
Bug: 126552434

Change-Id: Idb2411a47caf61e83fe26b98e393fa851ac1759d
parent 5461b1d2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -42727,7 +42727,7 @@ package android.telephony {
  public class ServiceState implements android.os.Parcelable {
    ctor public ServiceState();
    ctor public ServiceState(android.telephony.ServiceState);
    ctor public ServiceState(android.os.Parcel);
    ctor @Deprecated public ServiceState(android.os.Parcel);
    method protected void copyFrom(android.telephony.ServiceState);
    method public int describeContents();
    method public int getCdmaNetworkId();
+23 −7
Original line number Diff line number Diff line
@@ -6030,11 +6030,10 @@ package android.telephony {
  }
  public class NetworkRegistrationState implements android.os.Parcelable {
    ctor public NetworkRegistrationState(int, int, int, int, int, boolean, int[], @Nullable android.telephony.CellIdentity);
    ctor protected NetworkRegistrationState(android.os.Parcel);
    ctor public NetworkRegistrationState(int, int, int, int, int, boolean, @NonNull int[], @Nullable android.telephony.CellIdentity);
    method public int describeContents();
    method public int getAccessNetworkTechnology();
    method public int[] getAvailableServices();
    method @NonNull public int[] getAvailableServices();
    method public android.telephony.CellIdentity getCellIdentity();
    method @Nullable public android.telephony.DataSpecificRegistrationStates getDataSpecificStates();
    method public int getDomain();
@@ -6061,9 +6060,25 @@ package android.telephony {
    field public static final int SERVICE_TYPE_VOICE = 1; // 0x1
  }
  public static class NetworkRegistrationState.Builder {
    ctor public NetworkRegistrationState.Builder();
    method @NonNull public android.telephony.NetworkRegistrationState build();
    method @NonNull public android.telephony.NetworkRegistrationState.Builder setAccessNetworkTechnology(int);
    method @NonNull public android.telephony.NetworkRegistrationState.Builder setAvailableServices(@NonNull int[]);
    method @NonNull public android.telephony.NetworkRegistrationState.Builder setCellIdentity(@Nullable android.telephony.CellIdentity);
    method @NonNull public android.telephony.NetworkRegistrationState.Builder setDomain(int);
    method @NonNull public android.telephony.NetworkRegistrationState.Builder setEmergencyOnly(boolean);
    method @NonNull public android.telephony.NetworkRegistrationState.Builder setNrStatus(int);
    method @NonNull public android.telephony.NetworkRegistrationState.Builder setRegState(int);
    method @NonNull public android.telephony.NetworkRegistrationState.Builder setRejectCause(int);
    method @NonNull public android.telephony.NetworkRegistrationState.Builder setRoamingType(int);
    method @NonNull public android.telephony.NetworkRegistrationState.Builder setTransportType(int);
  }
  public abstract class NetworkService extends android.app.Service {
    ctor public NetworkService();
    method protected abstract android.telephony.NetworkService.NetworkServiceProvider createNetworkServiceProvider(int);
    method public android.os.IBinder onBind(android.content.Intent);
    method public abstract android.telephony.NetworkService.NetworkServiceProvider onCreateNetworkServiceProvider(int);
    field public static final String NETWORK_SERVICE_INTERFACE = "android.telephony.NetworkService";
  }
@@ -6071,7 +6086,7 @@ package android.telephony {
    ctor public NetworkService.NetworkServiceProvider(int);
    method public abstract void close();
    method public void getNetworkRegistrationState(int, @NonNull android.telephony.NetworkServiceCallback);
    method public final int getSlotId();
    method public final int getSlotIndex();
    method public final void notifyNetworkRegistrationStateChanged();
  }
@@ -6549,7 +6564,8 @@ package android.telephony.data {
  public abstract class DataService extends android.app.Service {
    ctor public DataService();
    method public abstract android.telephony.data.DataService.DataServiceProvider createDataServiceProvider(int);
    method public android.os.IBinder onBind(android.content.Intent);
    method public abstract android.telephony.data.DataService.DataServiceProvider onCreateDataServiceProvider(int);
    field public static final String DATA_SERVICE_INTERFACE = "android.telephony.data.DataService";
    field public static final int REQUEST_REASON_HANDOVER = 3; // 0x3
    field public static final int REQUEST_REASON_NORMAL = 1; // 0x1
@@ -6561,7 +6577,7 @@ package android.telephony.data {
    method public abstract void close();
    method public void deactivateDataCall(int, int, @Nullable android.telephony.data.DataServiceCallback);
    method public void getDataCallList(@NonNull android.telephony.data.DataServiceCallback);
    method public final int getSlotId();
    method public final int getSlotIndex();
    method public final void notifyDataCallListChanged(java.util.List<android.telephony.data.DataCallResponse>);
    method public void setDataProfile(@NonNull java.util.List<android.telephony.data.DataProfile>, boolean, @Nullable android.telephony.data.DataServiceCallback);
    method public void setInitialAttachApn(@NonNull android.telephony.data.DataProfile, boolean, @Nullable android.telephony.data.DataServiceCallback);
+207 −11
Original line number Diff line number Diff line
@@ -17,11 +17,13 @@
package android.telephony;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.TelephonyManager.NetworkType;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -140,6 +142,7 @@ public class NetworkRegistrationState implements Parcelable {
    @ServiceState.RoamingType
    private int mRoamingType;

    @NetworkType
    private int mAccessNetworkTechnology;

    @NRStatus
@@ -149,6 +152,7 @@ public class NetworkRegistrationState implements Parcelable {

    private final boolean mEmergencyOnly;

    @ServiceType
    private final int[] mAvailableServices;

    @Nullable
@@ -167,9 +171,8 @@ public class NetworkRegistrationState implements Parcelable {
     * @param regState Network registration state. Must be one of the {@link RegState}. For
     * {@link TransportType#WLAN} transport, only {@link #REG_STATE_HOME} and
     * {@link #REG_STATE_NOT_REG_NOT_SEARCHING} are valid states.
     * @param accessNetworkTechnology Access network technology. Must be one of TelephonyManager
     * NETWORK_TYPE_XXXX. For {@link TransportType#WLAN} transport, set to
     * {@link TelephonyManager#NETWORK_TYPE_IWLAN}.
     * @param accessNetworkTechnology Access network technology.For {@link TransportType#WLAN}
     * transport, set to {@link TelephonyManager#NETWORK_TYPE_IWLAN}.
     * @param rejectCause Reason for denial if the registration state is {@link #REG_STATE_DENIED}.
     * Depending on {@code accessNetworkTechnology}, the values are defined in 3GPP TS 24.008
     * 10.5.3.6 for UMTS, 3GPP TS 24.301 9.9.3.9 for LTE, and 3GPP2 A.S0001 6.2.2.44 for CDMA. If
@@ -182,8 +185,9 @@ public class NetworkRegistrationState implements Parcelable {
     * information is not available.
     */
    public NetworkRegistrationState(@Domain int domain, int transportType, @RegState int regState,
                                    int accessNetworkTechnology, int rejectCause,
                                    boolean emergencyOnly, int[] availableServices,
                                    @NetworkType int accessNetworkTechnology, int rejectCause,
                                    boolean emergencyOnly,
                                    @NonNull @ServiceType int[] availableServices,
                                    @Nullable CellIdentity cellIdentity) {
        mDomain = domain;
        mTransportType = transportType;
@@ -230,7 +234,7 @@ public class NetworkRegistrationState implements Parcelable {
        updateNrStatus(mDataSpecificStates);
    }

    protected NetworkRegistrationState(Parcel source) {
    private NetworkRegistrationState(Parcel source) {
        mDomain = source.readInt();
        mTransportType = source.readInt();
        mRegState = source.readInt();
@@ -309,25 +313,29 @@ public class NetworkRegistrationState implements Parcelable {
    /**
     * @return List of available service types.
     */
    @NonNull
    @ServiceType
    public int[] getAvailableServices() { return mAvailableServices; }

    /**
     * @return The access network technology {@link TelephonyManager.NetworkType}.
     * @return The access network technology {@link NetworkType}.
     */
    public @TelephonyManager.NetworkType int getAccessNetworkTechnology() {
    public @NetworkType int getAccessNetworkTechnology() {
        return mAccessNetworkTechnology;
    }

    /**
     * override the access network technology {@link TelephonyManager.NetworkType} e.g, rat ratchet.
     * override the access network technology {@link NetworkType} e.g, rat ratchet.
     * @hide
     */
    public void setAccessNetworkTechnology(@TelephonyManager.NetworkType int tech) {
    public void setAccessNetworkTechnology(@NetworkType int tech) {
        mAccessNetworkTechnology = tech;
    }

    /**
     * @return Network reject cause
     * @return Reason for denial if the registration state is {@link #REG_STATE_DENIED}.
     * Depending on {@code accessNetworkTechnology}, the values are defined in 3GPP TS 24.008
     * 10.5.3.6 for UMTS, 3GPP TS 24.301 9.9.3.9 for LTE, and 3GPP2 A.S0001 6.2.2.44 for CDMA
     */
    public int getRejectCause() {
        return mRejectCause;
@@ -539,4 +547,192 @@ public class NetworkRegistrationState implements Parcelable {
        p.recycle();
        return result;
    }

    /**
     * Provides a convenient way to set the fields of a {@link NetworkRegistrationState} when
     * creating a new instance.
     *
     * <p>The example below shows how you might create a new {@code NetworkRegistrationState}:
     *
     * <pre><code>
     *
     * NetworkRegistrationState nrs = new NetworkRegistrationState.Builder()
     *     .setApnTypeBitmask(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS)
     *     .setApnName("apn.example.com")
     *     .setEntryName("Example Carrier APN")
     *     .setMmsc(Uri.parse("http://mms.example.com:8002"))
     *     .setMmsProxyAddress(mmsProxy)
     *     .setMmsProxyPort(8799)
     *     .build();
     * </code></pre>
     */
    public static class Builder{
        @Domain
        private int mDomain;

        private int mTransportType;

        @RegState
        private int mRegState;

        @ServiceState.RoamingType
        private int mRoamingType;

        @NetworkType
        private int mAccessNetworkTechnology;

        @NRStatus
        private int mNrStatus;

        private int mRejectCause;

        private boolean mEmergencyOnly;

        @ServiceType
        private int[] mAvailableServices;

        @Nullable
        private CellIdentity mCellIdentity;

        /**
         * Default constructor for Builder.
         */
        public Builder() {}

        /**
         * Set the network domain.
         *
         * @param domain Network domain.
         *
         * @return The same instance of the builder.
         */
        public @NonNull Builder setDomain(@Domain int domain) {
            mDomain = domain;
            return this;
        }

        /**
         * Set the transport type.
         *
         * @param transportType Transport type.
         *
         * @return The same instance of the builder.
         */
        public @NonNull Builder setTransportType(int transportType) {
            mTransportType = transportType;
            return this;
        }

        /**
         * Set the registration state.
         *
         * @param regState The registration state.
         *
         * @return The same instance of the builder.
         */
        public @NonNull Builder setRegState(@RegState int regState) {
            mRegState = regState;
            return this;
        }

        /**
         * Set the roaming type.
         *
         * @param roamingType Roaming type.
         *
         * @return The same instance of the builder.
         */
        public @NonNull Builder setRoamingType(@ServiceState.RoamingType int roamingType) {
            mRoamingType = roamingType;
            return this;
        }

        /**
         * Set tne access network technology.
         *
         * @return The same instance of the builder.
         *
         * @param accessNetworkTechnology The access network technology
         */
        public @NonNull Builder setAccessNetworkTechnology(
                @NetworkType int accessNetworkTechnology) {
            mAccessNetworkTechnology = accessNetworkTechnology;
            return this;
        }

        /**
         * Set the 5G NR connection status.
         *
         * @param nrStatus 5G NR connection status.
         *
         * @return The same instance of the builder.
         */
        public @NonNull Builder setNrStatus(@NRStatus int nrStatus) {
            mNrStatus = nrStatus;
            return this;
        }

        /**
         * Set the network reject cause.
         *
         * @param rejectCause Reason for denial if the registration state is
         * {@link #REG_STATE_DENIED}.Depending on {@code accessNetworkTechnology}, the values are
         * defined in 3GPP TS 24.008 10.5.3.6 for UMTS, 3GPP TS 24.301 9.9.3.9 for LTE, and 3GPP2
         * A.S0001 6.2.2.44 for CDMA. If the reject cause is not supported or unknown, set it to 0.
         *
         * @return The same instance of the builder.
         */
        public @NonNull Builder setRejectCause(int rejectCause) {
            mRejectCause = rejectCause;
            return this;
        }

        /**
         * Set emergency only.
         *
         * @param emergencyOnly True if this network registration is for emergency use only.
         *
         * @return The same instance of the builder.
         */
        public @NonNull Builder setEmergencyOnly(boolean emergencyOnly) {
            mEmergencyOnly = emergencyOnly;
            return this;
        }

        /**
         * Set the available services.
         *
         * @param availableServices Available services.
         *
         * @return The same instance of the builder.
         */
        public @NonNull Builder setAvailableServices(
                @NonNull @ServiceType int[] availableServices) {
            mAvailableServices = availableServices;
            return this;
        }

        /**
         * Set the cell identity.
         *
         * @param cellIdentity The cell identity.
         *
         * @return The same instance of the builder.
         */
        public @NonNull Builder setCellIdentity(@Nullable CellIdentity cellIdentity) {
            mCellIdentity = cellIdentity;
            return this;
        }

        /**
         * Build the NetworkRegistrationState.
         *
         * @return the NetworkRegistrationState object.
         */
        public @NonNull NetworkRegistrationState build() {
            return new NetworkRegistrationState(mDomain, mTransportType, mRegState,
                    mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices,
                    mCellIdentity);
        }
    }
}
+31 −26
Original line number Diff line number Diff line
@@ -82,27 +82,30 @@ public abstract class NetworkService extends Service {
     * service is associated with one physical SIM slot.
     */
    public abstract class NetworkServiceProvider implements AutoCloseable {
        private final int mSlotId;
        private final int mSlotIndex;

        private final List<INetworkServiceCallback>
                mNetworkRegistrationStateChangedCallbacks = new ArrayList<>();

        public NetworkServiceProvider(int slotId) {
            mSlotId = slotId;
        /**
         * Constructor
         * @param slotIndex SIM slot id the data service provider associated with.
         */
        public NetworkServiceProvider(int slotIndex) {
            mSlotIndex = slotIndex;
        }

        /**
         * @return SIM slot id the network service associated with.
         * @return SIM slot index the network service associated with.
         */
        public final int getSlotId() {
            return mSlotId;
        public final int getSlotIndex() {
            return mSlotIndex;
        }

        /**
         * API to get network registration state. The result will be passed to the callback.
         * @param domain Network domain
         * @param callback The callback for reporting network registration state
         * @return SIM slot id the network service associated with.
         */
        public void getNetworkRegistrationState(@Domain int domain,
                                                @NonNull NetworkServiceCallback callback) {
@@ -110,9 +113,12 @@ public abstract class NetworkService extends Service {
                    NetworkServiceCallback.RESULT_ERROR_UNSUPPORTED, null);
        }

        /**
         * Notify the system that network registration state is changed.
         */
        public final void notifyNetworkRegistrationStateChanged() {
            mHandler.obtainMessage(NETWORK_SERVICE_INDICATION_NETWORK_STATE_CHANGED,
                    mSlotId, 0, null).sendToTarget();
                    mSlotIndex, 0, null).sendToTarget();
        }

        private void registerForStateChanged(@NonNull INetworkServiceCallback callback) {
@@ -154,23 +160,23 @@ public abstract class NetworkService extends Service {

        @Override
        public void handleMessage(Message message) {
            final int slotId = message.arg1;
            final int slotIndex = message.arg1;
            final INetworkServiceCallback callback = (INetworkServiceCallback) message.obj;

            NetworkServiceProvider serviceProvider = mServiceMap.get(slotId);
            NetworkServiceProvider serviceProvider = mServiceMap.get(slotIndex);

            switch (message.what) {
                case NETWORK_SERVICE_CREATE_NETWORK_SERVICE_PROVIDER:
                    // If the service provider doesn't exist yet, we try to create it.
                    if (serviceProvider == null) {
                        mServiceMap.put(slotId, createNetworkServiceProvider(slotId));
                        mServiceMap.put(slotIndex, onCreateNetworkServiceProvider(slotIndex));
                    }
                    break;
                case NETWORK_SERVICE_REMOVE_NETWORK_SERVICE_PROVIDER:
                    // If the service provider doesn't exist yet, we try to create it.
                    if (serviceProvider != null) {
                        serviceProvider.close();
                        mServiceMap.remove(slotId);
                        mServiceMap.remove(slotIndex);
                    }
                    break;
                case NETWORK_SERVICE_REMOVE_ALL_NETWORK_SERVICE_PROVIDERS:
@@ -223,12 +229,11 @@ public abstract class NetworkService extends Service {
     * this method to facilitate the creation of {@link NetworkServiceProvider} instances. The system
     * will call this method after binding the network service for each active SIM slot id.
     *
     * @param slotId SIM slot id the network service associated with.
     * @param slotIndex SIM slot id the network service associated with.
     * @return Network service object
     */
    protected abstract NetworkServiceProvider createNetworkServiceProvider(int slotId);
    public abstract NetworkServiceProvider onCreateNetworkServiceProvider(int slotIndex);

    /** @hide */
    @Override
    public IBinder onBind(Intent intent) {
        if (intent == null || !NETWORK_SERVICE_INTERFACE.equals(intent.getAction())) {
@@ -239,7 +244,6 @@ public abstract class NetworkService extends Service {
        return mBinder;
    }

    /** @hide */
    @Override
    public boolean onUnbind(Intent intent) {
        mHandler.obtainMessage(NETWORK_SERVICE_REMOVE_ALL_NETWORK_SERVICE_PROVIDERS, 0,
@@ -252,6 +256,7 @@ public abstract class NetworkService extends Service {
    @Override
    public void onDestroy() {
        mHandlerThread.quit();
        super.onDestroy();
    }

    /**
@@ -261,35 +266,35 @@ public abstract class NetworkService extends Service {
    private class INetworkServiceWrapper extends INetworkService.Stub {

        @Override
        public void createNetworkServiceProvider(int slotId) {
            mHandler.obtainMessage(NETWORK_SERVICE_CREATE_NETWORK_SERVICE_PROVIDER, slotId,
        public void createNetworkServiceProvider(int slotIndex) {
            mHandler.obtainMessage(NETWORK_SERVICE_CREATE_NETWORK_SERVICE_PROVIDER, slotIndex,
                    0, null).sendToTarget();
        }

        @Override
        public void removeNetworkServiceProvider(int slotId) {
            mHandler.obtainMessage(NETWORK_SERVICE_REMOVE_NETWORK_SERVICE_PROVIDER, slotId,
        public void removeNetworkServiceProvider(int slotIndex) {
            mHandler.obtainMessage(NETWORK_SERVICE_REMOVE_NETWORK_SERVICE_PROVIDER, slotIndex,
                    0, null).sendToTarget();
        }

        @Override
        public void getNetworkRegistrationState(
                int slotId, int domain, INetworkServiceCallback callback) {
            mHandler.obtainMessage(NETWORK_SERVICE_GET_REGISTRATION_STATE, slotId,
                int slotIndex, int domain, INetworkServiceCallback callback) {
            mHandler.obtainMessage(NETWORK_SERVICE_GET_REGISTRATION_STATE, slotIndex,
                    domain, callback).sendToTarget();
        }

        @Override
        public void registerForNetworkRegistrationStateChanged(
                int slotId, INetworkServiceCallback callback) {
            mHandler.obtainMessage(NETWORK_SERVICE_REGISTER_FOR_STATE_CHANGE, slotId,
                int slotIndex, INetworkServiceCallback callback) {
            mHandler.obtainMessage(NETWORK_SERVICE_REGISTER_FOR_STATE_CHANGE, slotIndex,
                    0, callback).sendToTarget();
        }

        @Override
        public void unregisterForNetworkRegistrationStateChanged(
                int slotId,INetworkServiceCallback callback) {
            mHandler.obtainMessage(NETWORK_SERVICE_UNREGISTER_FOR_STATE_CHANGE, slotId,
                int slotIndex, INetworkServiceCallback callback) {
            mHandler.obtainMessage(NETWORK_SERVICE_UNREGISTER_FOR_STATE_CHANGE, slotIndex,
                    0, callback).sendToTarget();
        }
    }
+4 −0
Original line number Diff line number Diff line
@@ -438,7 +438,11 @@ public class ServiceState implements Parcelable {

    /**
     * Construct a ServiceState object from the given parcel.
     *
     * @deprecated The constructor takes parcel should not be public at the beginning. Use
     * {@link #ServiceState()} instead.
     */
    @Deprecated
    public ServiceState(Parcel in) {
        mVoiceRegState = in.readInt();
        mDataRegState = in.readInt();
Loading