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

Commit b50e6cee authored by Mingming Cai's avatar Mingming Cai Committed by Gerrit Code Review
Browse files

Merge "Migrate convertHalCellIdentityToCellIdentity()"

parents 546e10a7 7481a2f0
Loading
Loading
Loading
Loading
+5 −126
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package com.android.internal.telephony;
package com.android.internal.telephony;


import android.hardware.radio.V1_0.CellInfoType;
import android.hardware.radio.V1_0.RegState;
import android.hardware.radio.V1_0.RegState;
import android.hardware.radio.V1_4.DataRegStateResult.VopsInfo.hidl_discriminator;
import android.hardware.radio.V1_4.DataRegStateResult.VopsInfo.hidl_discriminator;
import android.os.AsyncResult;
import android.os.AsyncResult;
@@ -27,11 +26,6 @@ import android.os.Message;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.CellIdentity;
import android.telephony.CellIdentity;
import android.telephony.CellIdentityCdma;
import android.telephony.CellIdentityGsm;
import android.telephony.CellIdentityLte;
import android.telephony.CellIdentityTdscdma;
import android.telephony.CellIdentityWcdma;
import android.telephony.LteVopsSupportInfo;
import android.telephony.LteVopsSupportInfo;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.NetworkService;
import android.telephony.NetworkService;
@@ -228,8 +222,7 @@ public class CellularNetworkService extends NetworkService {
                int defaultRoamingIndicator = voiceRegState.defaultRoamingIndicator;
                int defaultRoamingIndicator = voiceRegState.defaultRoamingIndicator;
                List<Integer> availableServices = getAvailableServices(
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity =
                CellIdentity cellIdentity = CellIdentity.create(voiceRegState.cellIdentity);
                        convertHalCellIdentityToCellIdentity(voiceRegState.cellIdentity);


                return new NetworkRegistrationInfo(domain, transportType, regState,
                return new NetworkRegistrationInfo(domain, transportType, regState,
                        networkType, reasonForDenial, emergencyOnly, availableServices,
                        networkType, reasonForDenial, emergencyOnly, availableServices,
@@ -251,8 +244,7 @@ public class CellularNetworkService extends NetworkService {
                int defaultRoamingIndicator = voiceRegState.defaultRoamingIndicator;
                int defaultRoamingIndicator = voiceRegState.defaultRoamingIndicator;
                List<Integer> availableServices = getAvailableServices(
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity =
                CellIdentity cellIdentity = CellIdentity.create(voiceRegState.cellIdentity);
                        convertHalCellIdentityToCellIdentity(voiceRegState.cellIdentity);


                return new NetworkRegistrationInfo(domain, transportType, regState,
                return new NetworkRegistrationInfo(domain, transportType, regState,
                        networkType, reasonForDenial, emergencyOnly, availableServices,
                        networkType, reasonForDenial, emergencyOnly, availableServices,
@@ -289,8 +281,7 @@ public class CellularNetworkService extends NetworkService {
                reasonForDenial = dataRegState.reasonDataDenied;
                reasonForDenial = dataRegState.reasonDataDenied;
                emergencyOnly = isEmergencyOnly(dataRegState.regState);
                emergencyOnly = isEmergencyOnly(dataRegState.regState);
                maxDataCalls = dataRegState.maxDataCalls;
                maxDataCalls = dataRegState.maxDataCalls;

                cellIdentity = CellIdentity.create(dataRegState.cellIdentity);
                cellIdentity = convertHalCellIdentityToCellIdentity(dataRegState.cellIdentity);
            } else if (result instanceof android.hardware.radio.V1_2.DataRegStateResult) {
            } else if (result instanceof android.hardware.radio.V1_2.DataRegStateResult) {
                android.hardware.radio.V1_2.DataRegStateResult dataRegState =
                android.hardware.radio.V1_2.DataRegStateResult dataRegState =
                        (android.hardware.radio.V1_2.DataRegStateResult) result;
                        (android.hardware.radio.V1_2.DataRegStateResult) result;
@@ -299,7 +290,7 @@ public class CellularNetworkService extends NetworkService {
                reasonForDenial = dataRegState.reasonDataDenied;
                reasonForDenial = dataRegState.reasonDataDenied;
                emergencyOnly = isEmergencyOnly(dataRegState.regState);
                emergencyOnly = isEmergencyOnly(dataRegState.regState);
                maxDataCalls = dataRegState.maxDataCalls;
                maxDataCalls = dataRegState.maxDataCalls;
                cellIdentity = convertHalCellIdentityToCellIdentity(dataRegState.cellIdentity);
                cellIdentity = CellIdentity.create(dataRegState.cellIdentity);
            } else if (result instanceof android.hardware.radio.V1_4.DataRegStateResult) {
            } else if (result instanceof android.hardware.radio.V1_4.DataRegStateResult) {
                android.hardware.radio.V1_4.DataRegStateResult dataRegState =
                android.hardware.radio.V1_4.DataRegStateResult dataRegState =
                        (android.hardware.radio.V1_4.DataRegStateResult) result;
                        (android.hardware.radio.V1_4.DataRegStateResult) result;
@@ -309,7 +300,7 @@ public class CellularNetworkService extends NetworkService {
                reasonForDenial = dataRegState.base.reasonDataDenied;
                reasonForDenial = dataRegState.base.reasonDataDenied;
                emergencyOnly = isEmergencyOnly(dataRegState.base.regState);
                emergencyOnly = isEmergencyOnly(dataRegState.base.regState);
                maxDataCalls = dataRegState.base.maxDataCalls;
                maxDataCalls = dataRegState.base.maxDataCalls;
                cellIdentity = convertHalCellIdentityToCellIdentity(dataRegState.base.cellIdentity);
                cellIdentity = CellIdentity.create(dataRegState.base.cellIdentity);
                android.hardware.radio.V1_4.NrIndicators nrIndicators = dataRegState.nrIndicators;
                android.hardware.radio.V1_4.NrIndicators nrIndicators = dataRegState.nrIndicators;


                // Check for lteVopsInfo only if its initialized and RAT is EUTRAN
                // Check for lteVopsInfo only if its initialized and RAT is EUTRAN
@@ -362,118 +353,6 @@ public class CellularNetworkService extends NetworkService {
            return new LteVopsSupportInfo(vops, emergency);
            return new LteVopsSupportInfo(vops, emergency);
        }
        }


        private CellIdentity convertHalCellIdentityToCellIdentity(
                android.hardware.radio.V1_0.CellIdentity cellIdentity) {
            if (cellIdentity == null) {
                return null;
            }

            CellIdentity result = null;
            switch(cellIdentity.cellInfoType) {
                case CellInfoType.GSM: {
                    if (cellIdentity.cellIdentityGsm.size() == 1) {
                        android.hardware.radio.V1_0.CellIdentityGsm cellIdentityGsm =
                                cellIdentity.cellIdentityGsm.get(0);
                        result = new CellIdentityGsm(cellIdentityGsm);
                    }
                    break;
                }
                case CellInfoType.WCDMA: {
                    if (cellIdentity.cellIdentityWcdma.size() == 1) {
                        android.hardware.radio.V1_0.CellIdentityWcdma cellIdentityWcdma =
                                cellIdentity.cellIdentityWcdma.get(0);
                        result = new CellIdentityWcdma(cellIdentityWcdma);
                    }
                    break;
                }
                case CellInfoType.TD_SCDMA: {
                    if (cellIdentity.cellIdentityTdscdma.size() == 1) {
                        android.hardware.radio.V1_0.CellIdentityTdscdma cellIdentityTdscdma =
                                cellIdentity.cellIdentityTdscdma.get(0);
                        result = new  CellIdentityTdscdma(cellIdentityTdscdma);
                    }
                    break;
                }
                case CellInfoType.LTE: {
                    if (cellIdentity.cellIdentityLte.size() == 1) {
                        android.hardware.radio.V1_0.CellIdentityLte cellIdentityLte =
                                cellIdentity.cellIdentityLte.get(0);
                        result = new CellIdentityLte(cellIdentityLte);
                    }
                    break;
                }
                case CellInfoType.CDMA: {
                    if (cellIdentity.cellIdentityCdma.size() == 1) {
                        android.hardware.radio.V1_0.CellIdentityCdma cellIdentityCdma =
                                cellIdentity.cellIdentityCdma.get(0);
                        result = new CellIdentityCdma(cellIdentityCdma);
                    }
                    break;
                }
                case CellInfoType.NONE:
                default:
                    break;
            }

            return result;
        }

        private CellIdentity convertHalCellIdentityToCellIdentity(
                android.hardware.radio.V1_2.CellIdentity cellIdentity) {
            if (cellIdentity == null) {
                return null;
            }

            CellIdentity result = null;
            switch(cellIdentity.cellInfoType) {
                case CellInfoType.GSM: {
                    if (cellIdentity.cellIdentityGsm.size() == 1) {
                        android.hardware.radio.V1_2.CellIdentityGsm cellIdentityGsm =
                                cellIdentity.cellIdentityGsm.get(0);
                        result = new CellIdentityGsm(cellIdentityGsm);
                    }
                    break;
                }
                case CellInfoType.WCDMA: {
                    if (cellIdentity.cellIdentityWcdma.size() == 1) {
                        android.hardware.radio.V1_2.CellIdentityWcdma cellIdentityWcdma =
                                cellIdentity.cellIdentityWcdma.get(0);
                        result = new CellIdentityWcdma(cellIdentityWcdma);
                    }
                    break;
                }
                case CellInfoType.TD_SCDMA: {
                    if (cellIdentity.cellIdentityTdscdma.size() == 1) {
                        android.hardware.radio.V1_2.CellIdentityTdscdma cellIdentityTdscdma =
                                cellIdentity.cellIdentityTdscdma.get(0);
                        result = new  CellIdentityTdscdma(cellIdentityTdscdma);
                    }
                    break;
                }
                case CellInfoType.LTE: {
                    if (cellIdentity.cellIdentityLte.size() == 1) {
                        android.hardware.radio.V1_2.CellIdentityLte cellIdentityLte =
                                cellIdentity.cellIdentityLte.get(0);
                        result = new CellIdentityLte(cellIdentityLte);
                    }
                    break;
                }
                case CellInfoType.CDMA: {
                    if (cellIdentity.cellIdentityCdma.size() == 1) {
                        android.hardware.radio.V1_2.CellIdentityCdma cellIdentityCdma =
                                cellIdentity.cellIdentityCdma.get(0);
                        result = new CellIdentityCdma(cellIdentityCdma);
                    }
                    break;
                }
                case CellInfoType.NONE:
                default:
                    break;
            }

            return result;
        }

        @Override
        @Override
        public void requestNetworkRegistrationInfo(int domain, NetworkServiceCallback callback) {
        public void requestNetworkRegistrationInfo(int domain, NetworkServiceCallback callback) {
            if (DBG) log("requestNetworkRegistrationInfo for domain " + domain);
            if (DBG) log("requestNetworkRegistrationInfo for domain " + domain);