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

Commit f12667ef authored by Pengquan Meng's avatar Pengquan Meng Committed by Gerrit Code Review
Browse files

Merge "Implement PhysicalChannelConfig"

parents b8607bbc 4e5d53c6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -294,7 +294,10 @@ public class RadioIndication extends IRadioIndication.Stub {
                    break;
            }

            response.add(new PhysicalChannelConfig(status, config.cellBandwidthDownlink));
            response.add(new PhysicalChannelConfig.Builder()
                    .setCellConnectionStatus(status)
                    .setCellBandwidthDownlinkKhz(config.cellBandwidthDownlink)
                    .build());
        }

        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_PHYSICAL_CHANNEL_CONFIG, response);
+4 −2
Original line number Diff line number Diff line
@@ -114,8 +114,10 @@ public class PhoneStateListenerExecutorTest extends TelephonyTest {

        assertNull(mPhysicalChannelConfigs);

        PhysicalChannelConfig config = new PhysicalChannelConfig(
                PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING, 20000 /* bandwidth */);
        PhysicalChannelConfig config = new PhysicalChannelConfig.Builder()
                .setCellConnectionStatus(PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING)
                .setCellBandwidthDownlinkKhz(2000 /* bandwidth */)
                .build();

        List<PhysicalChannelConfig> configs = Collections.singletonList(config);

+4 −2
Original line number Diff line number Diff line
@@ -128,8 +128,10 @@ public class PhoneStateListenerTest extends TelephonyTest {

        assertNull(mPhysicalChannelConfigs);

        PhysicalChannelConfig config = new PhysicalChannelConfig(
                PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING, 20000 /* bandwidth */);
        PhysicalChannelConfig config = new PhysicalChannelConfig.Builder()
                .setCellConnectionStatus(PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING)
                .setCellBandwidthDownlinkKhz(20000 /* bandwidth */)
                .build();

        List<PhysicalChannelConfig> configs = Collections.singletonList(config);

+79 −0
Original line number 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 com.google.common.truth.Truth.assertThat;

import android.os.Parcel;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PhysicalChannelConfig.Builder;
import android.telephony.ServiceState;

import org.junit.Test;

/** Unit test for {@link android.telephony.PhysicalChannelConfig}. */
public class PhysicalChannelConfigTest {

    private static final int RAT = ServiceState.RIL_RADIO_TECHNOLOGY_LTE;
    private static final int CONNECTION_STATUS = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING;
    private static final int CELL_BANDWIDTH = 12345;
    private static final int FREQUENCY_RANGE = 1;
    private static final int CHANNEL_NUMBER = 1234;
    private static final int[] CONTEXT_IDS = new int[] {123, 555, 1, 0};
    private static final int PHYSICAL_CELL_ID = 502;

    @Test
    public void testBuilder() {
        PhysicalChannelConfig config = new Builder()
                .setRat(RAT)
                .setCellConnectionStatus(CONNECTION_STATUS)
                .setCellBandwidthDownlinkKhz(CELL_BANDWIDTH)
                .setFrequencyRange(FREQUENCY_RANGE)
                .setChannelNumber(CHANNEL_NUMBER)
                .setContextIds(CONTEXT_IDS)
                .setPhysicalCellId(PHYSICAL_CELL_ID)
                .build();

        assertThat(config.getRat()).isEqualTo(RAT);
        assertThat(config.getConnectionStatus()).isEqualTo(CONNECTION_STATUS);
        assertThat(config.getCellBandwidthDownlink()).isEqualTo(CELL_BANDWIDTH);
        assertThat(config.getFrequencyRange()).isEqualTo(FREQUENCY_RANGE);
        assertThat(config.getChannelNumber()).isEqualTo(CHANNEL_NUMBER);
        assertThat(config.getContextIds()).isEqualTo(CONTEXT_IDS);
        assertThat(config.getPhysicalCellId()).isEqualTo(PHYSICAL_CELL_ID);
    }

    @Test
    public void testParcel() {
        PhysicalChannelConfig config = new Builder()
                .setRat(RAT)
                .setCellConnectionStatus(CONNECTION_STATUS)
                .setCellBandwidthDownlinkKhz(CELL_BANDWIDTH)
                .setFrequencyRange(FREQUENCY_RANGE)
                .setChannelNumber(CHANNEL_NUMBER)
                .setContextIds(CONTEXT_IDS)
                .setPhysicalCellId(PHYSICAL_CELL_ID)
                .build();

        Parcel parcel = Parcel.obtain();
        config.writeToParcel(parcel, 0 /* flags */);
        parcel.setDataPosition(0);

        PhysicalChannelConfig fromParcel = PhysicalChannelConfig.CREATOR.createFromParcel(parcel);

        assertThat(fromParcel).isEqualTo(config);
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -1729,7 +1729,10 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        ArrayList<PhysicalChannelConfig> pc = new ArrayList<>();
        int ssType = PhysicalChannelConfig.CONNECTION_PRIMARY_SERVING;
        for (int bw : bandwidths) {
            pc.add(new PhysicalChannelConfig(ssType, bw));
            pc.add(new PhysicalChannelConfig.Builder()
                    .setCellConnectionStatus(ssType)
                    .setCellBandwidthDownlinkKhz(bw)
                    .build());

            // All cells after the first are secondary serving cells.
            ssType = PhysicalChannelConfig.CONNECTION_SECONDARY_SERVING;