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

Commit eb423ffa authored by Nathan Harold's avatar Nathan Harold Committed by android-build-merger
Browse files

Merge "Refactor CellInfo Constructors" am: db6a3000 am: 9660a6e5

am: b50d456f

Change-Id: I2f6f86b0e99de34a4da4743cd26fb806f04f235c
parents a13fc499 b50d456f
Loading
Loading
Loading
Loading
+10 −68
Original line number Original line Diff line number Diff line
@@ -326,9 +326,7 @@ public class CellularNetworkService extends NetworkService {
                    if (cellIdentity.cellIdentityGsm.size() == 1) {
                    if (cellIdentity.cellIdentityGsm.size() == 1) {
                        android.hardware.radio.V1_0.CellIdentityGsm cellIdentityGsm =
                        android.hardware.radio.V1_0.CellIdentityGsm cellIdentityGsm =
                                cellIdentity.cellIdentityGsm.get(0);
                                cellIdentity.cellIdentityGsm.get(0);
                        result = new CellIdentityGsm(cellIdentityGsm.lac, cellIdentityGsm.cid,
                        result = new CellIdentityGsm(cellIdentityGsm);
                                cellIdentityGsm.arfcn, cellIdentityGsm.bsic, cellIdentityGsm.mcc,
                                cellIdentityGsm.mnc, null, null);
                    }
                    }
                    break;
                    break;
                }
                }
@@ -336,9 +334,7 @@ public class CellularNetworkService extends NetworkService {
                    if (cellIdentity.cellIdentityWcdma.size() == 1) {
                    if (cellIdentity.cellIdentityWcdma.size() == 1) {
                        android.hardware.radio.V1_0.CellIdentityWcdma cellIdentityWcdma =
                        android.hardware.radio.V1_0.CellIdentityWcdma cellIdentityWcdma =
                                cellIdentity.cellIdentityWcdma.get(0);
                                cellIdentity.cellIdentityWcdma.get(0);
                        result = new CellIdentityWcdma(cellIdentityWcdma.lac, cellIdentityWcdma.cid,
                        result = new CellIdentityWcdma(cellIdentityWcdma);
                                cellIdentityWcdma.psc, cellIdentityWcdma.uarfcn,
                                cellIdentityWcdma.mcc, cellIdentityWcdma.mnc, null, null);
                    }
                    }
                    break;
                    break;
                }
                }
@@ -346,10 +342,7 @@ public class CellularNetworkService extends NetworkService {
                    if (cellIdentity.cellIdentityTdscdma.size() == 1) {
                    if (cellIdentity.cellIdentityTdscdma.size() == 1) {
                        android.hardware.radio.V1_0.CellIdentityTdscdma cellIdentityTdscdma =
                        android.hardware.radio.V1_0.CellIdentityTdscdma cellIdentityTdscdma =
                                cellIdentity.cellIdentityTdscdma.get(0);
                                cellIdentity.cellIdentityTdscdma.get(0);
                        result = new  CellIdentityTdscdma(cellIdentityTdscdma.mcc,
                        result = new  CellIdentityTdscdma(cellIdentityTdscdma);
                                cellIdentityTdscdma.mnc, cellIdentityTdscdma.lac,
                                cellIdentityTdscdma.cid, cellIdentityTdscdma.cpid,
                                Integer.MAX_VALUE, null, null);
                    }
                    }
                    break;
                    break;
                }
                }
@@ -357,10 +350,7 @@ public class CellularNetworkService extends NetworkService {
                    if (cellIdentity.cellIdentityLte.size() == 1) {
                    if (cellIdentity.cellIdentityLte.size() == 1) {
                        android.hardware.radio.V1_0.CellIdentityLte cellIdentityLte =
                        android.hardware.radio.V1_0.CellIdentityLte cellIdentityLte =
                                cellIdentity.cellIdentityLte.get(0);
                                cellIdentity.cellIdentityLte.get(0);

                        result = new CellIdentityLte(cellIdentityLte);
                        result = new CellIdentityLte(cellIdentityLte.ci, cellIdentityLte.pci,
                                cellIdentityLte.tac, cellIdentityLte.earfcn, Integer.MAX_VALUE,
                                cellIdentityLte.mcc, cellIdentityLte.mnc, null, null);
                    }
                    }
                    break;
                    break;
                }
                }
@@ -368,10 +358,7 @@ public class CellularNetworkService extends NetworkService {
                    if (cellIdentity.cellIdentityCdma.size() == 1) {
                    if (cellIdentity.cellIdentityCdma.size() == 1) {
                        android.hardware.radio.V1_0.CellIdentityCdma cellIdentityCdma =
                        android.hardware.radio.V1_0.CellIdentityCdma cellIdentityCdma =
                                cellIdentity.cellIdentityCdma.get(0);
                                cellIdentity.cellIdentityCdma.get(0);

                        result = new CellIdentityCdma(cellIdentityCdma);
                        result = new CellIdentityCdma(cellIdentityCdma.networkId,
                                cellIdentityCdma.systemId, cellIdentityCdma.baseStationId,
                                cellIdentityCdma.longitude, cellIdentityCdma.latitude);
                    }
                    }
                    break;
                    break;
                }
                }
@@ -395,16 +382,7 @@ public class CellularNetworkService extends NetworkService {
                    if (cellIdentity.cellIdentityGsm.size() == 1) {
                    if (cellIdentity.cellIdentityGsm.size() == 1) {
                        android.hardware.radio.V1_2.CellIdentityGsm cellIdentityGsm =
                        android.hardware.radio.V1_2.CellIdentityGsm cellIdentityGsm =
                                cellIdentity.cellIdentityGsm.get(0);
                                cellIdentity.cellIdentityGsm.get(0);

                        result = new CellIdentityGsm(cellIdentityGsm);
                        result = new CellIdentityGsm(
                                cellIdentityGsm.base.lac,
                                cellIdentityGsm.base.cid,
                                cellIdentityGsm.base.arfcn,
                                cellIdentityGsm.base.bsic,
                                cellIdentityGsm.base.mcc,
                                cellIdentityGsm.base.mnc,
                                cellIdentityGsm.operatorNames.alphaLong,
                                cellIdentityGsm.operatorNames.alphaShort);
                    }
                    }
                    break;
                    break;
                }
                }
@@ -412,16 +390,7 @@ public class CellularNetworkService extends NetworkService {
                    if (cellIdentity.cellIdentityWcdma.size() == 1) {
                    if (cellIdentity.cellIdentityWcdma.size() == 1) {
                        android.hardware.radio.V1_2.CellIdentityWcdma cellIdentityWcdma =
                        android.hardware.radio.V1_2.CellIdentityWcdma cellIdentityWcdma =
                                cellIdentity.cellIdentityWcdma.get(0);
                                cellIdentity.cellIdentityWcdma.get(0);

                        result = new CellIdentityWcdma(cellIdentityWcdma);
                        result = new CellIdentityWcdma(
                                cellIdentityWcdma.base.lac,
                                cellIdentityWcdma.base.cid,
                                cellIdentityWcdma.base.psc,
                                cellIdentityWcdma.base.uarfcn,
                                cellIdentityWcdma.base.mcc,
                                cellIdentityWcdma.base.mnc,
                                cellIdentityWcdma.operatorNames.alphaLong,
                                cellIdentityWcdma.operatorNames.alphaShort);
                    }
                    }
                    break;
                    break;
                }
                }
@@ -429,16 +398,7 @@ public class CellularNetworkService extends NetworkService {
                    if (cellIdentity.cellIdentityTdscdma.size() == 1) {
                    if (cellIdentity.cellIdentityTdscdma.size() == 1) {
                        android.hardware.radio.V1_2.CellIdentityTdscdma cellIdentityTdscdma =
                        android.hardware.radio.V1_2.CellIdentityTdscdma cellIdentityTdscdma =
                                cellIdentity.cellIdentityTdscdma.get(0);
                                cellIdentity.cellIdentityTdscdma.get(0);

                        result = new  CellIdentityTdscdma(cellIdentityTdscdma);
                        result = new  CellIdentityTdscdma(
                                cellIdentityTdscdma.base.mcc,
                                cellIdentityTdscdma.base.mnc,
                                cellIdentityTdscdma.base.lac,
                                cellIdentityTdscdma.base.cid,
                                cellIdentityTdscdma.base.cpid,
                                cellIdentityTdscdma.uarfcn,
                                cellIdentityTdscdma.operatorNames.alphaLong,
                                cellIdentityTdscdma.operatorNames.alphaShort);
                    }
                    }
                    break;
                    break;
                }
                }
@@ -446,17 +406,7 @@ public class CellularNetworkService extends NetworkService {
                    if (cellIdentity.cellIdentityLte.size() == 1) {
                    if (cellIdentity.cellIdentityLte.size() == 1) {
                        android.hardware.radio.V1_2.CellIdentityLte cellIdentityLte =
                        android.hardware.radio.V1_2.CellIdentityLte cellIdentityLte =
                                cellIdentity.cellIdentityLte.get(0);
                                cellIdentity.cellIdentityLte.get(0);

                        result = new CellIdentityLte(cellIdentityLte);
                        result = new CellIdentityLte(
                                cellIdentityLte.base.ci,
                                cellIdentityLte.base.pci,
                                cellIdentityLte.base.tac,
                                cellIdentityLte.base.earfcn,
                                cellIdentityLte.bandwidth,
                                cellIdentityLte.base.mcc,
                                cellIdentityLte.base.mnc,
                                cellIdentityLte.operatorNames.alphaLong,
                                cellIdentityLte.operatorNames.alphaShort);
                    }
                    }
                    break;
                    break;
                }
                }
@@ -464,15 +414,7 @@ public class CellularNetworkService extends NetworkService {
                    if (cellIdentity.cellIdentityCdma.size() == 1) {
                    if (cellIdentity.cellIdentityCdma.size() == 1) {
                        android.hardware.radio.V1_2.CellIdentityCdma cellIdentityCdma =
                        android.hardware.radio.V1_2.CellIdentityCdma cellIdentityCdma =
                                cellIdentity.cellIdentityCdma.get(0);
                                cellIdentity.cellIdentityCdma.get(0);

                        result = new CellIdentityCdma(cellIdentityCdma);
                        result = new CellIdentityCdma(
                                cellIdentityCdma.base.networkId,
                                cellIdentityCdma.base.systemId,
                                cellIdentityCdma.base.baseStationId,
                                cellIdentityCdma.base.longitude,
                                cellIdentityCdma.base.latitude,
                                cellIdentityCdma.operatorNames.alphaLong,
                                cellIdentityCdma.operatorNames.alphaShort);
                    }
                    }
                    break;
                    break;
                }
                }
+2 −305
Original line number Original line Diff line number Diff line
@@ -26,12 +26,6 @@ import android.hardware.radio.V1_0.CdmaBroadcastSmsConfigInfo;
import android.hardware.radio.V1_0.CdmaSmsAck;
import android.hardware.radio.V1_0.CdmaSmsAck;
import android.hardware.radio.V1_0.CdmaSmsMessage;
import android.hardware.radio.V1_0.CdmaSmsMessage;
import android.hardware.radio.V1_0.CdmaSmsWriteArgs;
import android.hardware.radio.V1_0.CdmaSmsWriteArgs;
import android.hardware.radio.V1_0.CellInfoCdma;
import android.hardware.radio.V1_0.CellInfoGsm;
import android.hardware.radio.V1_0.CellInfoLte;
import android.hardware.radio.V1_0.CellInfoTdscdma;
import android.hardware.radio.V1_0.CellInfoType;
import android.hardware.radio.V1_0.CellInfoWcdma;
import android.hardware.radio.V1_0.DataProfileId;
import android.hardware.radio.V1_0.DataProfileId;
import android.hardware.radio.V1_0.Dial;
import android.hardware.radio.V1_0.Dial;
import android.hardware.radio.V1_0.GsmBroadcastSmsConfigInfo;
import android.hardware.radio.V1_0.GsmBroadcastSmsConfigInfo;
@@ -63,7 +57,6 @@ import android.os.Build;
import android.os.Handler;
import android.os.Handler;
import android.os.HwBinder;
import android.os.HwBinder;
import android.os.Message;
import android.os.Message;
import android.os.Parcel;
import android.os.PowerManager;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.PowerManager.WakeLock;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -72,13 +65,7 @@ import android.os.SystemProperties;
import android.os.WorkSource;
import android.os.WorkSource;
import android.service.carrier.CarrierIdentifier;
import android.service.carrier.CarrierIdentifier;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.CellIdentityCdma;
import android.telephony.CellInfo;
import android.telephony.CellInfo;
import android.telephony.CellSignalStrengthCdma;
import android.telephony.CellSignalStrengthGsm;
import android.telephony.CellSignalStrengthLte;
import android.telephony.CellSignalStrengthTdscdma;
import android.telephony.CellSignalStrengthWcdma;
import android.telephony.ClientRequestStats;
import android.telephony.ClientRequestStats;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.ModemActivityInfo;
import android.telephony.ModemActivityInfo;
@@ -5462,89 +5449,6 @@ public class RIL extends BaseCommands implements CommandsInterface {
        return lce;
        return lce;
    }
    }


    // TODO(b/119224773) refactor the converter of CellInfo.
    private static void writeToParcelForGsm(
            Parcel p, int lac, int cid, int arfcn, int bsic, String mcc, String mnc,
            String al, String as, CellSignalStrengthGsm ss) {
        p.writeInt(CellInfo.TYPE_GSM);
        p.writeString(mcc);
        p.writeString(mnc);
        p.writeString(al);
        p.writeString(as);
        p.writeInt(lac);
        p.writeInt(cid);
        p.writeInt(arfcn);
        p.writeInt(bsic);
        ss.writeToParcel(p, 0);
    }

    // TODO(b/119224773) refactor the converter of CellInfo.
    private static void writeToParcelForCdma(
            Parcel p, int ni, int si, int bsi, int lon, int lat, String al, String as,
            CellSignalStrengthCdma ss) {
        new CellIdentityCdma(ni, si, bsi, lon, lat, al, as).writeToParcel(p, 0);
        ss.writeToParcel(p, 0);
    }

    // TODO(b/119224773) refactor the converter of CellInfo.
    private static void writeToParcelForLte(
            Parcel p, int ci, int pci, int tac, int earfcn, int bandwidth, String mcc, String mnc,
            String al, String as, CellSignalStrengthLte ss,
            boolean isEndcAvailable) {

        // General CellInfo
        p.writeInt(CellInfo.TYPE_LTE);
        p.writeString(mcc);
        p.writeString(mnc);
        p.writeString(al);
        p.writeString(as);

        // CellIdentity
        p.writeInt(ci);
        p.writeInt(pci);
        p.writeInt(tac);
        p.writeInt(earfcn);
        p.writeInt(bandwidth);

        // CellSignalStrength
        ss.writeToParcel(p, 0);

        // CellConfigLte
        p.writeBoolean(isEndcAvailable);
    }

    // TODO(b/119224773) refactor the converter of CellInfo.
    private static void writeToParcelForWcdma(
            Parcel p, int lac, int cid, int psc, int uarfcn, String mcc, String mnc,
            String al, String as, CellSignalStrengthWcdma ss) {
        p.writeInt(CellInfo.TYPE_WCDMA);
        p.writeString(mcc);
        p.writeString(mnc);
        p.writeString(al);
        p.writeString(as);
        p.writeInt(lac);
        p.writeInt(cid);
        p.writeInt(psc);
        p.writeInt(uarfcn);
        ss.writeToParcel(p, 0);
    }

    // TODO(b/119224773) refactor the converter of CellInfo.
    private static void writeToParcelForTdscdma(
            Parcel p, int lac, int cid, int cpid, int uarfcn, String mcc, String mnc,
            String al, String as, CellSignalStrengthTdscdma ss) {
        p.writeInt(CellInfo.TYPE_TDSCDMA);
        p.writeString(mcc);
        p.writeString(mnc);
        p.writeString(al);
        p.writeString(as);
        p.writeInt(lac);
        p.writeInt(cid);
        p.writeInt(cpid);
        p.writeInt(uarfcn);
        ss.writeToParcel(p, 0);
    }

    /**
    /**
     * Convert CellInfo defined in 1.0/types.hal to CellInfo type.
     * Convert CellInfo defined in 1.0/types.hal to CellInfo type.
     * @param records List of CellInfo defined in 1.0/types.hal
     * @param records List of CellInfo defined in 1.0/types.hal
@@ -5556,103 +5460,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
        ArrayList<CellInfo> response = new ArrayList<CellInfo>(records.size());
        ArrayList<CellInfo> response = new ArrayList<CellInfo>(records.size());


        for (android.hardware.radio.V1_0.CellInfo record : records) {
        for (android.hardware.radio.V1_0.CellInfo record : records) {
            // first convert RIL CellInfo to Parcel
            response.add(CellInfo.create(record));
            Parcel p = Parcel.obtain();
            p.writeInt(record.cellInfoType);
            p.writeInt(record.registered ? 1 : 0);
            p.writeLong(SystemClock.elapsedRealtimeNanos());
            p.writeInt(CellInfo.CONNECTION_UNKNOWN);
            switch (record.cellInfoType) {
                case CellInfoType.GSM: {
                    CellInfoGsm cellInfoGsm = record.gsm.get(0);
                    writeToParcelForGsm(
                            p,
                            cellInfoGsm.cellIdentityGsm.lac,
                            cellInfoGsm.cellIdentityGsm.cid,
                            cellInfoGsm.cellIdentityGsm.arfcn,
                            Byte.toUnsignedInt(cellInfoGsm.cellIdentityGsm.bsic),
                            cellInfoGsm.cellIdentityGsm.mcc,
                            cellInfoGsm.cellIdentityGsm.mnc,
                            EMPTY_ALPHA_LONG,
                            EMPTY_ALPHA_SHORT,
                            new CellSignalStrengthGsm(cellInfoGsm.signalStrengthGsm));
                    break;
                }

                case CellInfoType.CDMA: {
                    CellInfoCdma cellInfoCdma = record.cdma.get(0);
                    writeToParcelForCdma(
                            p,
                            cellInfoCdma.cellIdentityCdma.networkId,
                            cellInfoCdma.cellIdentityCdma.systemId,
                            cellInfoCdma.cellIdentityCdma.baseStationId,
                            cellInfoCdma.cellIdentityCdma.longitude,
                            cellInfoCdma.cellIdentityCdma.latitude,
                            EMPTY_ALPHA_LONG,
                            EMPTY_ALPHA_SHORT,
                            new CellSignalStrengthCdma(
                                    cellInfoCdma.signalStrengthCdma,
                                    cellInfoCdma.signalStrengthEvdo));
                    break;
                }

                case CellInfoType.LTE: {
                    CellInfoLte cellInfoLte = record.lte.get(0);
                    writeToParcelForLte(
                            p,
                            cellInfoLte.cellIdentityLte.ci,
                            cellInfoLte.cellIdentityLte.pci,
                            cellInfoLte.cellIdentityLte.tac,
                            cellInfoLte.cellIdentityLte.earfcn,
                            Integer.MAX_VALUE,
                            cellInfoLte.cellIdentityLte.mcc,
                            cellInfoLte.cellIdentityLte.mnc,
                            EMPTY_ALPHA_LONG,
                            EMPTY_ALPHA_SHORT,
                            new CellSignalStrengthLte(cellInfoLte.signalStrengthLte),
                            false /* isEndcAvailable */);
                    break;
                }

                case CellInfoType.WCDMA: {
                    CellInfoWcdma cellInfoWcdma = record.wcdma.get(0);
                    writeToParcelForWcdma(
                            p,
                            cellInfoWcdma.cellIdentityWcdma.lac,
                            cellInfoWcdma.cellIdentityWcdma.cid,
                            cellInfoWcdma.cellIdentityWcdma.psc,
                            cellInfoWcdma.cellIdentityWcdma.uarfcn,
                            cellInfoWcdma.cellIdentityWcdma.mcc,
                            cellInfoWcdma.cellIdentityWcdma.mnc,
                            EMPTY_ALPHA_LONG,
                            EMPTY_ALPHA_SHORT,
                            new CellSignalStrengthWcdma(cellInfoWcdma.signalStrengthWcdma));
                    break;
                }

                case CellInfoType.TD_SCDMA: {
                    CellInfoTdscdma cellInfoTdscdma = record.tdscdma.get(0);
                    writeToParcelForTdscdma(
                            p,
                            cellInfoTdscdma.cellIdentityTdscdma.lac,
                            cellInfoTdscdma.cellIdentityTdscdma.cid,
                            cellInfoTdscdma.cellIdentityTdscdma.cpid,
                            Integer.MAX_VALUE,
                            cellInfoTdscdma.cellIdentityTdscdma.mcc,
                            cellInfoTdscdma.cellIdentityTdscdma.mnc,
                            EMPTY_ALPHA_LONG,
                            EMPTY_ALPHA_SHORT,
                            new CellSignalStrengthTdscdma(cellInfoTdscdma.signalStrengthTdscdma));
                    break;
                }
                default:
                    throw new RuntimeException("unexpected cellinfotype: " + record.cellInfoType);
            }

            p.setDataPosition(0);
            CellInfo InfoRec = CellInfo.CREATOR.createFromParcel(p);
            p.recycle();
            response.add(InfoRec);
        }
        }


        return response;
        return response;
@@ -5669,122 +5477,11 @@ public class RIL extends BaseCommands implements CommandsInterface {
        ArrayList<CellInfo> response = new ArrayList<CellInfo>(records.size());
        ArrayList<CellInfo> response = new ArrayList<CellInfo>(records.size());


        for (android.hardware.radio.V1_2.CellInfo record : records) {
        for (android.hardware.radio.V1_2.CellInfo record : records) {
            // first convert RIL CellInfo to Parcel
            response.add(CellInfo.create(record));
            Parcel p = Parcel.obtain();
            p.writeInt(record.cellInfoType);
            p.writeInt(record.registered ? 1 : 0);
            p.writeLong(SystemClock.elapsedRealtimeNanos());
            p.writeInt(record.connectionStatus);
            switch (record.cellInfoType) {
                case CellInfoType.GSM: {
                    android.hardware.radio.V1_2.CellInfoGsm cellInfoGsm = record.gsm.get(0);
                    writeToParcelForGsm(
                            p,
                            cellInfoGsm.cellIdentityGsm.base.lac,
                            cellInfoGsm.cellIdentityGsm.base.cid,
                            cellInfoGsm.cellIdentityGsm.base.arfcn,
                            Byte.toUnsignedInt(cellInfoGsm.cellIdentityGsm.base.bsic),
                            cellInfoGsm.cellIdentityGsm.base.mcc,
                            cellInfoGsm.cellIdentityGsm.base.mnc,
                            cellInfoGsm.cellIdentityGsm.operatorNames.alphaLong,
                            cellInfoGsm.cellIdentityGsm.operatorNames.alphaShort,
                            new CellSignalStrengthGsm(cellInfoGsm.signalStrengthGsm));
                    break;
        }
        }

                case CellInfoType.CDMA: {
                    android.hardware.radio.V1_2.CellInfoCdma cellInfoCdma = record.cdma.get(0);
                    writeToParcelForCdma(
                            p,
                            cellInfoCdma.cellIdentityCdma.base.networkId,
                            cellInfoCdma.cellIdentityCdma.base.systemId,
                            cellInfoCdma.cellIdentityCdma.base.baseStationId,
                            cellInfoCdma.cellIdentityCdma.base.longitude,
                            cellInfoCdma.cellIdentityCdma.base.latitude,
                            cellInfoCdma.cellIdentityCdma.operatorNames.alphaLong,
                            cellInfoCdma.cellIdentityCdma.operatorNames.alphaShort,
                            new CellSignalStrengthCdma(
                                cellInfoCdma.signalStrengthCdma,
                                cellInfoCdma.signalStrengthEvdo));
                    break;
                }

                case CellInfoType.LTE: {
                    android.hardware.radio.V1_2.CellInfoLte cellInfoLte = record.lte.get(0);
                    writeToParcelForLte(
                            p,
                            cellInfoLte.cellIdentityLte.base.ci,
                            cellInfoLte.cellIdentityLte.base.pci,
                            cellInfoLte.cellIdentityLte.base.tac,
                            cellInfoLte.cellIdentityLte.base.earfcn,
                            cellInfoLte.cellIdentityLte.bandwidth,
                            cellInfoLte.cellIdentityLte.base.mcc,
                            cellInfoLte.cellIdentityLte.base.mnc,
                            cellInfoLte.cellIdentityLte.operatorNames.alphaLong,
                            cellInfoLte.cellIdentityLte.operatorNames.alphaShort,
                            new CellSignalStrengthLte(cellInfoLte.signalStrengthLte),
                            false /* isEndcAvailable */);
                    break;
                }

                case CellInfoType.WCDMA: {
                    android.hardware.radio.V1_2.CellInfoWcdma cellInfoWcdma = record.wcdma.get(0);
                    writeToParcelForWcdma(
                            p,
                            cellInfoWcdma.cellIdentityWcdma.base.lac,
                            cellInfoWcdma.cellIdentityWcdma.base.cid,
                            cellInfoWcdma.cellIdentityWcdma.base.psc,
                            cellInfoWcdma.cellIdentityWcdma.base.uarfcn,
                            cellInfoWcdma.cellIdentityWcdma.base.mcc,
                            cellInfoWcdma.cellIdentityWcdma.base.mnc,
                            cellInfoWcdma.cellIdentityWcdma.operatorNames.alphaLong,
                            cellInfoWcdma.cellIdentityWcdma.operatorNames.alphaShort,
                            new CellSignalStrengthWcdma(cellInfoWcdma.signalStrengthWcdma));
                    break;
                }

                case CellInfoType.TD_SCDMA: {
                    android.hardware.radio.V1_2.CellInfoTdscdma cellInfoTdscdma =
                            record.tdscdma.get(0);
                    writeToParcelForTdscdma(
                            p,
                            cellInfoTdscdma.cellIdentityTdscdma.base.lac,
                            cellInfoTdscdma.cellIdentityTdscdma.base.cid,
                            cellInfoTdscdma.cellIdentityTdscdma.base.cpid,
                            cellInfoTdscdma.cellIdentityTdscdma.uarfcn,
                            cellInfoTdscdma.cellIdentityTdscdma.base.mcc,
                            cellInfoTdscdma.cellIdentityTdscdma.base.mnc,
                            cellInfoTdscdma.cellIdentityTdscdma.operatorNames.alphaLong,
                            cellInfoTdscdma.cellIdentityTdscdma.operatorNames.alphaShort,
                            new CellSignalStrengthTdscdma(cellInfoTdscdma.signalStrengthTdscdma));
                    break;
                }

                default:
                    throw new RuntimeException("unexpected cellinfotype: " + record.cellInfoType);
            }

            p.setDataPosition(0);
            CellInfo InfoRec = CellInfo.CREATOR.createFromParcel(p);
            p.recycle();
            response.add(InfoRec);
        }

        return response;
        return response;
    }
    }


    private static int convertTdscdmaRscpTo1_2(int rscp) {
        // The HAL 1.0 range is 25..120; the ASU/ HAL 1.2 range is 0..96;
        // yes, this means the range in 1.0 cannot express -24dBm = 96
        if (rscp >= 25 && rscp <= 120) {
            // First we flip the sign to convert from the HALs -rscp to the actual RSCP value.
            int rscpDbm = -rscp;
            // Then to convert from RSCP to ASU, we apply the offset which aligns 0 ASU to -120dBm.
            return rscpDbm + 120;
        }
        return Integer.MAX_VALUE;
    }

    /**
    /**
     * @return The {@link IwlanOperationMode IWLAN operation mode}
     * @return The {@link IwlanOperationMode IWLAN operation mode}
     */
     */
+2 −37

File changed.

Preview size limit exceeded, changes collapsed.

+2 −36

File changed.

Preview size limit exceeded, changes collapsed.

+5 −2
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.AsyncResult;
import android.os.HandlerThread;
import android.os.HandlerThread;
import android.os.Message;
import android.os.Message;
import android.telephony.CellIdentityGsm;
import android.telephony.CellIdentityGsm;
import android.telephony.CellInfo;
import android.telephony.CellInfoGsm;
import android.telephony.CellInfoGsm;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.SmallTest;
@@ -83,8 +84,10 @@ public class LocaleTrackerTest extends TelephonyTest {
        mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
        mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);


        mCellInfo = new CellInfoGsm();
        mCellInfo = new CellInfoGsm();
        mCellInfo.setCellIdentity(new CellIdentityGsm(Integer.parseInt(US_MCC),
        mCellInfo.setCellIdentity(new CellIdentityGsm(
                Integer.parseInt(FAKE_MNC), 0, 0));
                    CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
                    CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
                    US_MCC, FAKE_MNC, null, null));
        doAnswer(invocation -> {
        doAnswer(invocation -> {
            Message m = invocation.getArgument(1);
            Message m = invocation.getArgument(1);
            AsyncResult.forMessage(m, Arrays.asList(mCellInfo), null);
            AsyncResult.forMessage(m, Arrays.asList(mCellInfo), null);
Loading