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

Commit c5d3256e authored by nharold's avatar nharold Committed by Gerrit Code Review
Browse files

Merge changes from topics "cdma-null-island", "cdma-signal-strength"

* changes:
  Test Invalid Lat/Long Values for CellIdentityCdma
  Replace Manual Parceling for CellInfoCdma
parents 0555c815 7b6cdc9e
Loading
Loading
Loading
Loading
+4 −15
Original line number Original line Diff line number Diff line
@@ -69,7 +69,9 @@ 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.CellIdentity;
import android.telephony.CellIdentity;
import android.telephony.CellIdentityCdma;
import android.telephony.CellInfo;
import android.telephony.CellInfo;
import android.telephony.CellSignalStrengthCdma;
import android.telephony.ClientRequestStats;
import android.telephony.ClientRequestStats;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.ModemActivityInfo;
import android.telephony.ModemActivityInfo;
@@ -5022,21 +5024,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
    private static void writeToParcelForCdma(
    private static void writeToParcelForCdma(
            Parcel p, int ni, int si, int bsi, int lon, int lat, String al, String as,
            Parcel p, int ni, int si, int bsi, int lon, int lat, String al, String as,
            int dbm, int ecio, int eDbm, int eEcio, int eSnr) {
            int dbm, int ecio, int eDbm, int eEcio, int eSnr) {
        p.writeInt(CellIdentity.TYPE_CDMA);
        new CellIdentityCdma(ni, si, bsi, lon, lat, al, as).writeToParcel(p, 0);
        p.writeString(null);
        new CellSignalStrengthCdma(dbm, ecio, eDbm, eEcio, eSnr).writeToParcel(p, 0);
        p.writeString(null);
        p.writeInt(ni);
        p.writeInt(si);
        p.writeInt(bsi);
        p.writeInt(lon);
        p.writeInt(lat);
        p.writeString(al);
        p.writeString(as);
        p.writeInt(dbm);
        p.writeInt(ecio);
        p.writeInt(eDbm);
        p.writeInt(eEcio);
        p.writeInt(eSnr);
    }
    }


    private static void writeToParcelForLte(
    private static void writeToParcelForLte(
+11 −0
Original line number Original line Diff line number Diff line
@@ -48,10 +48,21 @@ public class CellIdentityCdmaTest extends AndroidTestCase {


        assertEquals(NETWORK_ID, ci.getNetworkId());
        assertEquals(NETWORK_ID, ci.getNetworkId());
        assertEquals(LATITUDE, ci.getLatitude());
        assertEquals(LATITUDE, ci.getLatitude());
        assertEquals(LONGITUDE, ci.getLongitude());
        assertEquals(ALPHA_LONG, ci.getOperatorAlphaLong());
        assertEquals(ALPHA_LONG, ci.getOperatorAlphaLong());
        assertEquals(ALPHA_SHORT, ci.getOperatorAlphaShort());
        assertEquals(ALPHA_SHORT, ci.getOperatorAlphaShort());
    }
    }


    @SmallTest
    public void testNullIsland() {
        CellIdentityCdma  ci =
                new CellIdentityCdma(NETWORK_ID, SYSTEM_ID, BASESTATION_ID, -1, 0,
                        ALPHA_LONG, ALPHA_SHORT);

        assertEquals(Integer.MAX_VALUE, ci.getLatitude());
        assertEquals(Integer.MAX_VALUE, ci.getLongitude());
    }

    @SmallTest
    @SmallTest
    public void testEquals() {
    public void testEquals() {
        CellIdentityCdma  ciA =
        CellIdentityCdma  ciA =
+92 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.os.Parcel;
import android.telephony.CellSignalStrengthCdma;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;

/** Unit tests for {@link CellSignalStrengthCdma}. */

public class CellSignalStrengthCdmaTest extends AndroidTestCase {

    private static final int CDMA_DBM = 74;
    private static final int CDMA_ECIO = 124;
    private static final int EVDO_DBM = 23;
    private static final int EVDO_ECIO = 108;
    private static final int EVDO_SNR = 7;

    @SmallTest
    public void testConstructor() {
        CellSignalStrengthCdma css = new CellSignalStrengthCdma(
                CDMA_DBM, CDMA_ECIO, EVDO_DBM, EVDO_ECIO, EVDO_SNR);
        assertEquals(-CDMA_DBM, css.getCdmaDbm());
        assertEquals(-CDMA_ECIO, css.getCdmaEcio());
        assertEquals(-EVDO_DBM, css.getEvdoDbm());
        assertEquals(-EVDO_ECIO, css.getEvdoEcio());
        assertEquals(EVDO_SNR, css.getEvdoSnr());
    }

    @SmallTest
    public void testInvalidConstructor() {
        CellSignalStrengthCdma css = new CellSignalStrengthCdma(-1, -1, -1, -1, -1);
        assertEquals(Integer.MAX_VALUE, css.getCdmaDbm());
        assertEquals(Integer.MAX_VALUE, css.getCdmaEcio());
        assertEquals(Integer.MAX_VALUE, css.getEvdoDbm());
        assertEquals(Integer.MAX_VALUE, css.getEvdoEcio());
        assertEquals(Integer.MAX_VALUE, css.getEvdoSnr());
    }

    @SmallTest
    public void testDefaultConstructor() {
        CellSignalStrengthCdma css = new CellSignalStrengthCdma();
        assertEquals(Integer.MAX_VALUE, css.getCdmaDbm());
        assertEquals(Integer.MAX_VALUE, css.getCdmaEcio());
        assertEquals(Integer.MAX_VALUE, css.getEvdoDbm());
        assertEquals(Integer.MAX_VALUE, css.getEvdoEcio());
        assertEquals(Integer.MAX_VALUE, css.getEvdoSnr());
    }

    @SmallTest
    public void testEquals() {
        assertTrue(new CellSignalStrengthCdma(
                CDMA_DBM, CDMA_ECIO, EVDO_DBM, EVDO_ECIO, EVDO_SNR).equals(
                        new CellSignalStrengthCdma(
                                CDMA_DBM, CDMA_ECIO, EVDO_DBM, EVDO_ECIO, EVDO_SNR)));
        assertFalse(new CellSignalStrengthCdma(
                CDMA_DBM, CDMA_ECIO, EVDO_DBM, EVDO_ECIO, EVDO_SNR).equals(
                    new CellSignalStrengthCdma(CDMA_DBM, CDMA_ECIO, -1, EVDO_ECIO, EVDO_SNR)));
    }

    @SmallTest
    public void testParcel() {
        CellSignalStrengthCdma css = new CellSignalStrengthCdma(
                CDMA_DBM, CDMA_ECIO, EVDO_DBM, EVDO_ECIO, EVDO_SNR);

        Parcel p = Parcel.obtain();
        css.writeToParcel(p, 0);
        p.setDataPosition(0);

        CellSignalStrengthCdma newCss = CellSignalStrengthCdma.CREATOR.createFromParcel(p);
        assertEquals(css, newCss);
    }
}
+7 −7
Original line number Original line Diff line number Diff line
@@ -188,7 +188,7 @@ public class RILTest extends TelephonyTest {
    private static final int RSSNR = 2147483647;
    private static final int RSSNR = 2147483647;
    private static final int RSRP = 96;
    private static final int RSRP = 96;
    private static final int RSRQ = 10;
    private static final int RSRQ = 10;
    private static final int SIGNAL_NOICE_RATIO = 6;
    private static final int SIGNAL_NOISE_RATIO = 6;
    private static final int SIGNAL_STRENGTH = 24;
    private static final int SIGNAL_STRENGTH = 24;
    private static final int SYSTEM_ID = 65533;
    private static final int SYSTEM_ID = 65533;
    private static final int TAC = 65535;
    private static final int TAC = 65535;
@@ -1159,7 +1159,7 @@ public class RILTest extends TelephonyTest {
        cellinfo.signalStrengthCdma.ecio = ECIO;
        cellinfo.signalStrengthCdma.ecio = ECIO;
        cellinfo.signalStrengthEvdo.dbm = DBM;
        cellinfo.signalStrengthEvdo.dbm = DBM;
        cellinfo.signalStrengthEvdo.ecio = ECIO;
        cellinfo.signalStrengthEvdo.ecio = ECIO;
        cellinfo.signalStrengthEvdo.signalNoiseRatio = SIGNAL_NOICE_RATIO;
        cellinfo.signalStrengthEvdo.signalNoiseRatio = SIGNAL_NOISE_RATIO;
        android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo();
        android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo();
        record.cellInfoType = TYPE_CDMA;
        record.cellInfoType = TYPE_CDMA;
        record.registered = false;
        record.registered = false;
@@ -1182,7 +1182,7 @@ public class RILTest extends TelephonyTest {
                NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
                EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
        CellSignalStrengthCdma cs = new CellSignalStrengthCdma(
        CellSignalStrengthCdma cs = new CellSignalStrengthCdma(
                -DBM, -ECIO, -DBM, -ECIO, SIGNAL_NOICE_RATIO);
                DBM, ECIO, DBM, ECIO, SIGNAL_NOISE_RATIO);
        expected.setCellIdentity(ci);
        expected.setCellIdentity(ci);
        expected.setCellSignalStrength(cs);
        expected.setCellSignalStrength(cs);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_UNKNOWN);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_UNKNOWN);
@@ -1393,7 +1393,7 @@ public class RILTest extends TelephonyTest {
                NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                ALPHA_LONG, ALPHA_SHORT);
                ALPHA_LONG, ALPHA_SHORT);
        CellSignalStrengthCdma cs = new CellSignalStrengthCdma(
        CellSignalStrengthCdma cs = new CellSignalStrengthCdma(
                -DBM, -ECIO, -DBM, -ECIO, SIGNAL_NOICE_RATIO);
                DBM, ECIO, DBM, ECIO, SIGNAL_NOISE_RATIO);
        expected.setCellIdentity(ci);
        expected.setCellIdentity(ci);
        expected.setCellSignalStrength(cs);
        expected.setCellSignalStrength(cs);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
@@ -1401,7 +1401,7 @@ public class RILTest extends TelephonyTest {
    }
    }


    @Test
    @Test
    public void testConvertHalCellInfoList_1_2ForCdmaWithEmptyOperatorInfd() throws Exception {
    public void testConvertHalCellInfoList_1_2ForCdmaWithEmptyOperatorInfo() throws Exception {
        ArrayList<CellInfo> ret = getCellInfoListForCdma(EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
        ArrayList<CellInfo> ret = getCellInfoListForCdma(EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);


        assertEquals(1, ret.size());
        assertEquals(1, ret.size());
@@ -1414,7 +1414,7 @@ public class RILTest extends TelephonyTest {
                NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE,
                EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
                EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
        CellSignalStrengthCdma cs = new CellSignalStrengthCdma(
        CellSignalStrengthCdma cs = new CellSignalStrengthCdma(
                -DBM, -ECIO, -DBM, -ECIO, SIGNAL_NOICE_RATIO);
                DBM, ECIO, DBM, ECIO, SIGNAL_NOISE_RATIO);
        expected.setCellIdentity(ci);
        expected.setCellIdentity(ci);
        expected.setCellSignalStrength(cs);
        expected.setCellSignalStrength(cs);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
        expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
@@ -1525,7 +1525,7 @@ public class RILTest extends TelephonyTest {
        cellinfo.signalStrengthCdma.ecio = ECIO;
        cellinfo.signalStrengthCdma.ecio = ECIO;
        cellinfo.signalStrengthEvdo.dbm = DBM;
        cellinfo.signalStrengthEvdo.dbm = DBM;
        cellinfo.signalStrengthEvdo.ecio = ECIO;
        cellinfo.signalStrengthEvdo.ecio = ECIO;
        cellinfo.signalStrengthEvdo.signalNoiseRatio = SIGNAL_NOICE_RATIO;
        cellinfo.signalStrengthEvdo.signalNoiseRatio = SIGNAL_NOISE_RATIO;
        android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo();
        android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo();
        record.cellInfoType = TYPE_CDMA;
        record.cellInfoType = TYPE_CDMA;
        record.registered = false;
        record.registered = false;