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

Commit 4240a111 authored by Zoey Chen's avatar Zoey Chen
Browse files

[5G] Plumb PhysicalChannelConfig all the way up.

Updates the bottom layer to propagate PhysicalChannelConfig unsols up
through to the PhoneNotifier.

Bug: 162300897
Test: atest PhoneStateListenerTest atest PhysicalChannelConfigTest
Change-Id: I08ffa54f4990c6967ffbeb9f4c667f6ca80e8be2
parent d88f8a6a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.PhoneCapability;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseCallState;
import android.telephony.PreciseDataConnectionState;
import android.telephony.ServiceState;
@@ -255,6 +256,13 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
                barringInfo);
    }

    @Override
    public void notifyPhysicalChannelConfiguration(Phone sender,
                                                   List<PhysicalChannelConfig> configs) {
        int subId = sender.getSubId();
        mTelephonyRegistryMgr.notifyPhysicalChannelConfigurationForSubscriber(subId, configs);
    }

    /**
     * Convert the {@link DataActivityState} enum into the TelephonyManager.DATA_* constants for the
     * public API.
+5 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.PhoneCapability;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseDataConnectionState;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.emergency.EmergencyNumber;
@@ -113,4 +114,8 @@ public interface PhoneNotifier {

    /** Notify barring info has changed */
    void notifyBarringInfoChanged(Phone sender, @NonNull BarringInfo barringInfo);

    /** Notify of change to PhysicalChannelConfiguration. */
    void notifyPhysicalChannelConfiguration(Phone sender, List<PhysicalChannelConfig> configs);

}
+1 −1
Original line number Diff line number Diff line
@@ -2077,7 +2077,7 @@ public class ServiceStateTracker extends Handler {
    }

    private boolean isNrPhysicalChannelConfig(PhysicalChannelConfig config) {
        return config.getRat() == TelephonyManager.NETWORK_TYPE_NR;
        return config.getNetworkType() == TelephonyManager.NETWORK_TYPE_NR;
    }

    /**
+32 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verify;

import android.telephony.PhoneStateListener;
import android.telephony.PhysicalChannelConfig;
import android.telephony.ServiceState;
import android.telephony.emergency.EmergencyNumber;
import android.test.suitebuilder.annotation.SmallTest;
@@ -34,6 +35,8 @@ import org.junit.runner.RunWith;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@@ -43,6 +46,8 @@ public class PhoneStateListenerTest extends TelephonyTest {
    private boolean mUserMobileDataState = false;
    private EmergencyNumber mCalledEmergencyNumber;
    private EmergencyNumber mTextedEmergencyNumber;
    private List<PhysicalChannelConfig> mPhysicalChannelConfigs;


    @Before
    public void setUp() throws Exception {
@@ -70,6 +75,12 @@ public class PhoneStateListenerTest extends TelephonyTest {
                logd("OutgoingSmsEmergencyNumber Changed");
                mTextedEmergencyNumber = emergencyNumber;
            }

            @Override
            public void onPhysicalChannelConfigurationChanged(List<PhysicalChannelConfig> configs) {
                logd("PhysicalChannelConfig Changed");
                mPhysicalChannelConfigs = configs;
            }
        };
        processAllMessages();
    }
@@ -153,4 +164,25 @@ public class PhoneStateListenerTest extends TelephonyTest {

        assertTrue(mTextedEmergencyNumber.equals(emergencyNumber));
    }

    @Test @SmallTest
    public void testTriggerPhysicalChannelConfigurationChanged() throws Exception {
        Field field = PhoneStateListener.class.getDeclaredField("callback");
        field.setAccessible(true);

        assertNull(mPhysicalChannelConfigs);

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

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

        ((IPhoneStateListener) field.get(mPhoneStateListenerUT))
                .onPhysicalChannelConfigurationChanged(configs);
        processAllMessages();

        assertTrue(mPhysicalChannelConfigs.equals(configs));
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public class PhysicalChannelConfigTest {
                .setPhysicalCellId(PHYSICAL_CELL_ID)
                .build();

        assertThat(config.getRat()).isEqualTo(RAT);
        assertThat(config.getNetworkType()).isEqualTo(RAT);
        assertThat(config.getConnectionStatus()).isEqualTo(CONNECTION_STATUS);
        assertThat(config.getCellBandwidthDownlink()).isEqualTo(CELL_BANDWIDTH);
        assertThat(config.getFrequencyRange()).isEqualTo(FREQUENCY_RANGE);