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

Commit 8e1e5e0d authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge "Added slot id in the internal API" am: 045ff781 am: 5674b8e1 am: da1f3a56"

parents d2e16289 01d2e132
Loading
Loading
Loading
Loading
+73 −102
Original line number Original line Diff line number Diff line
@@ -86,15 +86,17 @@ public abstract class DataService extends Service {
    /** The reason of the data request is IWLAN handover */
    /** The reason of the data request is IWLAN handover */
    public static final int REQUEST_REASON_HANDOVER = 3;
    public static final int REQUEST_REASON_HANDOVER = 3;


    private static final int DATA_SERVICE_INTERNAL_REQUEST_INITIALIZE_SERVICE          = 1;
    private static final int DATA_SERVICE_CREATE_DATA_SERVICE_PROVIDER                 = 1;
    private static final int DATA_SERVICE_REQUEST_SETUP_DATA_CALL                      = 2;
    private static final int DATA_SERVICE_REMOVE_DATA_SERVICE_PROVIDER                 = 2;
    private static final int DATA_SERVICE_REQUEST_DEACTIVATE_DATA_CALL                 = 3;
    private static final int DATA_SERVICE_REMOVE_ALL_DATA_SERVICE_PROVIDERS            = 3;
    private static final int DATA_SERVICE_REQUEST_SET_INITIAL_ATTACH_APN               = 4;
    private static final int DATA_SERVICE_REQUEST_SETUP_DATA_CALL                      = 4;
    private static final int DATA_SERVICE_REQUEST_SET_DATA_PROFILE                     = 5;
    private static final int DATA_SERVICE_REQUEST_DEACTIVATE_DATA_CALL                 = 5;
    private static final int DATA_SERVICE_REQUEST_GET_DATA_CALL_LIST                   = 6;
    private static final int DATA_SERVICE_REQUEST_SET_INITIAL_ATTACH_APN               = 6;
    private static final int DATA_SERVICE_REQUEST_REGISTER_DATA_CALL_LIST_CHANGED      = 7;
    private static final int DATA_SERVICE_REQUEST_SET_DATA_PROFILE                     = 7;
    private static final int DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED    = 8;
    private static final int DATA_SERVICE_REQUEST_GET_DATA_CALL_LIST                   = 8;
    private static final int DATA_SERVICE_INDICATION_DATA_CALL_LIST_CHANGED            = 9;
    private static final int DATA_SERVICE_REQUEST_REGISTER_DATA_CALL_LIST_CHANGED      = 9;
    private static final int DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED    = 10;
    private static final int DATA_SERVICE_INDICATION_DATA_CALL_LIST_CHANGED            = 11;


    private final HandlerThread mHandlerThread;
    private final HandlerThread mHandlerThread;


@@ -102,7 +104,7 @@ public abstract class DataService extends Service {


    private final SparseArray<DataServiceProvider> mServiceMap = new SparseArray<>();
    private final SparseArray<DataServiceProvider> mServiceMap = new SparseArray<>();


    private final SparseArray<IDataServiceWrapper> mBinderMap = new SparseArray<>();
    private final IBinder mBinder = new IDataServiceWrapper();


    /**
    /**
     * The abstract class of the actual data service implementation. The data service provider
     * The abstract class of the actual data service implementation. The data service provider
@@ -321,23 +323,34 @@ public abstract class DataService extends Service {
        public void handleMessage(Message message) {
        public void handleMessage(Message message) {
            IDataServiceCallback callback;
            IDataServiceCallback callback;
            final int slotId = message.arg1;
            final int slotId = message.arg1;
            DataServiceProvider service;
            DataServiceProvider serviceProvider = mServiceMap.get(slotId);

            synchronized (mServiceMap) {
                service = mServiceMap.get(slotId);
            }


            switch (message.what) {
            switch (message.what) {
                case DATA_SERVICE_INTERNAL_REQUEST_INITIALIZE_SERVICE:
                case DATA_SERVICE_CREATE_DATA_SERVICE_PROVIDER:
                    service = createDataServiceProvider(message.arg1);
                    serviceProvider = createDataServiceProvider(message.arg1);
                    if (service != null) {
                    if (serviceProvider != null) {
                        mServiceMap.put(slotId, service);
                        mServiceMap.put(slotId, serviceProvider);
                    }
                    break;
                case DATA_SERVICE_REMOVE_DATA_SERVICE_PROVIDER:
                    if (serviceProvider != null) {
                        serviceProvider.onDestroy();
                        mServiceMap.remove(slotId);
                    }
                    }
                    break;
                    break;
                case DATA_SERVICE_REMOVE_ALL_DATA_SERVICE_PROVIDERS:
                    for (int i = 0; i < mServiceMap.size(); i++) {
                        serviceProvider = mServiceMap.get(i);
                        if (serviceProvider != null) {
                            serviceProvider.onDestroy();
                        }
                    }
                    mServiceMap.clear();
                    break;
                case DATA_SERVICE_REQUEST_SETUP_DATA_CALL:
                case DATA_SERVICE_REQUEST_SETUP_DATA_CALL:
                    if (service == null) break;
                    if (serviceProvider == null) break;
                    SetupDataCallRequest setupDataCallRequest = (SetupDataCallRequest) message.obj;
                    SetupDataCallRequest setupDataCallRequest = (SetupDataCallRequest) message.obj;
                    service.setupDataCall(setupDataCallRequest.accessNetworkType,
                    serviceProvider.setupDataCall(setupDataCallRequest.accessNetworkType,
                            setupDataCallRequest.dataProfile, setupDataCallRequest.isRoaming,
                            setupDataCallRequest.dataProfile, setupDataCallRequest.isRoaming,
                            setupDataCallRequest.allowRoaming, setupDataCallRequest.reason,
                            setupDataCallRequest.allowRoaming, setupDataCallRequest.reason,
                            setupDataCallRequest.linkProperties,
                            setupDataCallRequest.linkProperties,
@@ -345,46 +358,46 @@ public abstract class DataService extends Service {


                    break;
                    break;
                case DATA_SERVICE_REQUEST_DEACTIVATE_DATA_CALL:
                case DATA_SERVICE_REQUEST_DEACTIVATE_DATA_CALL:
                    if (service == null) break;
                    if (serviceProvider == null) break;
                    DeactivateDataCallRequest deactivateDataCallRequest =
                    DeactivateDataCallRequest deactivateDataCallRequest =
                            (DeactivateDataCallRequest) message.obj;
                            (DeactivateDataCallRequest) message.obj;
                    service.deactivateDataCall(deactivateDataCallRequest.cid,
                    serviceProvider.deactivateDataCall(deactivateDataCallRequest.cid,
                            deactivateDataCallRequest.reason,
                            deactivateDataCallRequest.reason,
                            new DataServiceCallback(deactivateDataCallRequest.callback));
                            new DataServiceCallback(deactivateDataCallRequest.callback));
                    break;
                    break;
                case DATA_SERVICE_REQUEST_SET_INITIAL_ATTACH_APN:
                case DATA_SERVICE_REQUEST_SET_INITIAL_ATTACH_APN:
                    if (service == null) break;
                    if (serviceProvider == null) break;
                    SetInitialAttachApnRequest setInitialAttachApnRequest =
                    SetInitialAttachApnRequest setInitialAttachApnRequest =
                            (SetInitialAttachApnRequest) message.obj;
                            (SetInitialAttachApnRequest) message.obj;
                    service.setInitialAttachApn(setInitialAttachApnRequest.dataProfile,
                    serviceProvider.setInitialAttachApn(setInitialAttachApnRequest.dataProfile,
                            setInitialAttachApnRequest.isRoaming,
                            setInitialAttachApnRequest.isRoaming,
                            new DataServiceCallback(setInitialAttachApnRequest.callback));
                            new DataServiceCallback(setInitialAttachApnRequest.callback));
                    break;
                    break;
                case DATA_SERVICE_REQUEST_SET_DATA_PROFILE:
                case DATA_SERVICE_REQUEST_SET_DATA_PROFILE:
                    if (service == null) break;
                    if (serviceProvider == null) break;
                    SetDataProfileRequest setDataProfileRequest =
                    SetDataProfileRequest setDataProfileRequest =
                            (SetDataProfileRequest) message.obj;
                            (SetDataProfileRequest) message.obj;
                    service.setDataProfile(setDataProfileRequest.dps,
                    serviceProvider.setDataProfile(setDataProfileRequest.dps,
                            setDataProfileRequest.isRoaming,
                            setDataProfileRequest.isRoaming,
                            new DataServiceCallback(setDataProfileRequest.callback));
                            new DataServiceCallback(setDataProfileRequest.callback));
                    break;
                    break;
                case DATA_SERVICE_REQUEST_GET_DATA_CALL_LIST:
                case DATA_SERVICE_REQUEST_GET_DATA_CALL_LIST:
                    if (service == null) break;
                    if (serviceProvider == null) break;


                    service.getDataCallList(new DataServiceCallback(
                    serviceProvider.getDataCallList(new DataServiceCallback(
                            (IDataServiceCallback) message.obj));
                            (IDataServiceCallback) message.obj));
                    break;
                    break;
                case DATA_SERVICE_REQUEST_REGISTER_DATA_CALL_LIST_CHANGED:
                case DATA_SERVICE_REQUEST_REGISTER_DATA_CALL_LIST_CHANGED:
                    if (service == null) break;
                    if (serviceProvider == null) break;
                    service.registerForDataCallListChanged((IDataServiceCallback) message.obj);
                    serviceProvider.registerForDataCallListChanged((IDataServiceCallback) message.obj);
                    break;
                    break;
                case DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED:
                case DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED:
                    if (service == null) break;
                    if (serviceProvider == null) break;
                    callback = (IDataServiceCallback) message.obj;
                    callback = (IDataServiceCallback) message.obj;
                    service.unregisterForDataCallListChanged(callback);
                    serviceProvider.unregisterForDataCallListChanged(callback);
                    break;
                    break;
                case DATA_SERVICE_INDICATION_DATA_CALL_LIST_CHANGED:
                case DATA_SERVICE_INDICATION_DATA_CALL_LIST_CHANGED:
                    if (service == null) break;
                    if (serviceProvider == null) break;
                    DataCallListChangedIndication indication =
                    DataCallListChangedIndication indication =
                            (DataCallListChangedIndication) message.obj;
                            (DataCallListChangedIndication) message.obj;
                    try {
                    try {
@@ -423,67 +436,19 @@ public abstract class DataService extends Service {
            loge("Unexpected intent " + intent);
            loge("Unexpected intent " + intent);
            return null;
            return null;
        }
        }

        return mBinder;
        int slotId = intent.getIntExtra(
                DATA_SERVICE_EXTRA_SLOT_ID, SubscriptionManager.INVALID_SIM_SLOT_INDEX);

        if (!SubscriptionManager.isValidSlotIndex(slotId)) {
            loge("Invalid slot id " + slotId);
            return null;
        }

        log("onBind: slot id=" + slotId);

        IDataServiceWrapper binder = mBinderMap.get(slotId);
        if (binder == null) {
            Message msg = mHandler.obtainMessage(DATA_SERVICE_INTERNAL_REQUEST_INITIALIZE_SERVICE);
            msg.arg1 = slotId;
            msg.sendToTarget();

            binder = new IDataServiceWrapper(slotId);
            mBinderMap.put(slotId, binder);
        }

        return binder;
    }
    }


    /** @hide */
    /** @hide */
    @Override
    @Override
    public boolean onUnbind(Intent intent) {
    public boolean onUnbind(Intent intent) {
        int slotId = intent.getIntExtra(DATA_SERVICE_EXTRA_SLOT_ID,
        mHandler.obtainMessage(DATA_SERVICE_REMOVE_ALL_DATA_SERVICE_PROVIDERS).sendToTarget();
                SubscriptionManager.INVALID_SIM_SLOT_INDEX);
        if (mBinderMap.get(slotId) != null) {
            DataServiceProvider serviceImpl;
            synchronized (mServiceMap) {
                serviceImpl = mServiceMap.get(slotId);
            }
            if (serviceImpl != null) {
                serviceImpl.onDestroy();
            }
            mBinderMap.remove(slotId);
        }

        // If all clients unbinds, quit the handler thread
        if (mBinderMap.size() == 0) {
            mHandlerThread.quit();
        }

        return false;
        return false;
    }
    }


    /** @hide */
    /** @hide */
    @Override
    @Override
    public void onDestroy() {
    public void onDestroy() {
        synchronized (mServiceMap) {
            for (int i = 0; i < mServiceMap.size(); i++) {
                DataServiceProvider serviceImpl = mServiceMap.get(i);
                if (serviceImpl != null) {
                    serviceImpl.onDestroy();
                }
            }
            mServiceMap.clear();
        }

        mHandlerThread.quit();
        mHandlerThread.quit();
    }
    }


@@ -491,68 +456,74 @@ public abstract class DataService extends Service {
     * A wrapper around IDataService that forwards calls to implementations of {@link DataService}.
     * A wrapper around IDataService that forwards calls to implementations of {@link DataService}.
     */
     */
    private class IDataServiceWrapper extends IDataService.Stub {
    private class IDataServiceWrapper extends IDataService.Stub {
        @Override
        public void createDataServiceProvider(int slotId) {
            mHandler.obtainMessage(DATA_SERVICE_CREATE_DATA_SERVICE_PROVIDER, slotId, 0)
                    .sendToTarget();
        }


        private final int mSlotId;
        @Override

        public void removeDataServiceProvider(int slotId) {
        IDataServiceWrapper(int slotId) {
            mHandler.obtainMessage(DATA_SERVICE_REMOVE_DATA_SERVICE_PROVIDER, slotId, 0)
            mSlotId = slotId;
                    .sendToTarget();
        }
        }


        @Override
        @Override
        public void setupDataCall(int accessNetworkType, DataProfile dataProfile,
        public void setupDataCall(int slotId, int accessNetworkType, DataProfile dataProfile,
                                  boolean isRoaming, boolean allowRoaming, int reason,
                                  boolean isRoaming, boolean allowRoaming, int reason,
                                  LinkProperties linkProperties, IDataServiceCallback callback) {
                                  LinkProperties linkProperties, IDataServiceCallback callback) {
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_SETUP_DATA_CALL, mSlotId, 0,
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_SETUP_DATA_CALL, slotId, 0,
                    new SetupDataCallRequest(accessNetworkType, dataProfile, isRoaming,
                    new SetupDataCallRequest(accessNetworkType, dataProfile, isRoaming,
                            allowRoaming, reason, linkProperties, callback))
                            allowRoaming, reason, linkProperties, callback))
                    .sendToTarget();
                    .sendToTarget();
        }
        }


        @Override
        @Override
        public void deactivateDataCall(int cid, int reason, IDataServiceCallback callback) {
        public void deactivateDataCall(int slotId, int cid, int reason,
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_DEACTIVATE_DATA_CALL, mSlotId, 0,
                                       IDataServiceCallback callback) {
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_DEACTIVATE_DATA_CALL, slotId, 0,
                    new DeactivateDataCallRequest(cid, reason, callback))
                    new DeactivateDataCallRequest(cid, reason, callback))
                    .sendToTarget();
                    .sendToTarget();
        }
        }


        @Override
        @Override
        public void setInitialAttachApn(DataProfile dataProfile, boolean isRoaming,
        public void setInitialAttachApn(int slotId, DataProfile dataProfile, boolean isRoaming,
                                        IDataServiceCallback callback) {
                                        IDataServiceCallback callback) {
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_SET_INITIAL_ATTACH_APN, mSlotId, 0,
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_SET_INITIAL_ATTACH_APN, slotId, 0,
                    new SetInitialAttachApnRequest(dataProfile, isRoaming, callback))
                    new SetInitialAttachApnRequest(dataProfile, isRoaming, callback))
                    .sendToTarget();
                    .sendToTarget();
        }
        }


        @Override
        @Override
        public void setDataProfile(List<DataProfile> dps, boolean isRoaming,
        public void setDataProfile(int slotId, List<DataProfile> dps, boolean isRoaming,
                                   IDataServiceCallback callback) {
                                   IDataServiceCallback callback) {
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_SET_DATA_PROFILE, mSlotId, 0,
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_SET_DATA_PROFILE, slotId, 0,
                    new SetDataProfileRequest(dps, isRoaming, callback)).sendToTarget();
                    new SetDataProfileRequest(dps, isRoaming, callback)).sendToTarget();
        }
        }


        @Override
        @Override
        public void getDataCallList(IDataServiceCallback callback) {
        public void getDataCallList(int slotId, IDataServiceCallback callback) {
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_GET_DATA_CALL_LIST, mSlotId, 0,
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_GET_DATA_CALL_LIST, slotId, 0,
                    callback).sendToTarget();
                    callback).sendToTarget();
        }
        }


        @Override
        @Override
        public void registerForDataCallListChanged(IDataServiceCallback callback) {
        public void registerForDataCallListChanged(int slotId, IDataServiceCallback callback) {
            if (callback == null) {
            if (callback == null) {
                loge("Callback is null");
                loge("Callback is null");
                return;
                return;
            }
            }
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_REGISTER_DATA_CALL_LIST_CHANGED, mSlotId,
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_REGISTER_DATA_CALL_LIST_CHANGED, slotId,
                    0, callback).sendToTarget();
                    0, callback).sendToTarget();
        }
        }


        @Override
        @Override
        public void unregisterForDataCallListChanged(IDataServiceCallback callback) {
        public void unregisterForDataCallListChanged(int slotId, IDataServiceCallback callback) {
            if (callback == null) {
            if (callback == null) {
                loge("Callback is null");
                loge("Callback is null");
                return;
                return;
            }
            }
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED, mSlotId,
            mHandler.obtainMessage(DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED, slotId,
                    0, callback).sendToTarget();
                    0, callback).sendToTarget();
        }
        }
    }
    }
+10 −7
Original line number Original line Diff line number Diff line
@@ -25,14 +25,17 @@ import android.telephony.data.IDataServiceCallback;
 */
 */
oneway interface IDataService
oneway interface IDataService
{
{
    void setupDataCall(int accessNetwork, in DataProfile dataProfile, boolean isRoaming,
    void createDataServiceProvider(int slotId);
    void removeDataServiceProvider(int slotId);
    void setupDataCall(int slotId, int accessNetwork, in DataProfile dataProfile, boolean isRoaming,
                       boolean allowRoaming, int reason, in LinkProperties linkProperties,
                       boolean allowRoaming, int reason, in LinkProperties linkProperties,
                       IDataServiceCallback callback);
                       IDataServiceCallback callback);
    void deactivateDataCall(int cid, int reason, IDataServiceCallback callback);
    void deactivateDataCall(int slotId, int cid, int reason, IDataServiceCallback callback);
    void setInitialAttachApn(in DataProfile dataProfile, boolean isRoaming,
    void setInitialAttachApn(int slotId, in DataProfile dataProfile, boolean isRoaming,
                             IDataServiceCallback callback);
                             IDataServiceCallback callback);
    void setDataProfile(in List<DataProfile> dps, boolean isRoaming, IDataServiceCallback callback);
    void setDataProfile(int slotId, in List<DataProfile> dps, boolean isRoaming,
    void getDataCallList(IDataServiceCallback callback);
                        IDataServiceCallback callback);
    void registerForDataCallListChanged(IDataServiceCallback callback);
    void getDataCallList(int slotId, IDataServiceCallback callback);
    void unregisterForDataCallListChanged(IDataServiceCallback callback);
    void registerForDataCallListChanged(int slotId, IDataServiceCallback callback);
    void unregisterForDataCallListChanged(int slotId, IDataServiceCallback callback);
}
}