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

Commit 11594514 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11200327 from 218e04b0 to 24Q1-release

Change-Id: I298ef7e270d01b20608c1743b5ba63f2a887dd37
parents f67e0fee 218e04b0
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -34,3 +34,10 @@ flag {
    description: "This flag is for adding suggested actions related to RAT to ims registration"
    bug:"290573256"
}

flag {
    name: "terminate_active_video_call_when_accepting_second_video_call_as_audio_only"
    namespace: "telephony"
    description: "This flag terminates active video call instead holding when accepting 2nd incoming video call as audio only"
    bug:"309548300"
}
+41 −6
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.PatternSyntaxException;

/**
@@ -101,6 +102,7 @@ public class SignalStrengthController extends Handler {
    private static final int EVENT_POLL_SIGNAL_STRENGTH                     = 7;
    private static final int EVENT_SIGNAL_STRENGTH_UPDATE                   = 8;
    private static final int EVENT_POLL_SIGNAL_STRENGTH_DONE                = 9;
    private static final int EVENT_SERVICE_STATE_CHANGED                    = 10;

    @NonNull
    private final Phone mPhone;
@@ -146,6 +148,8 @@ public class SignalStrengthController extends Handler {
    @NonNull
    private final LocalLog mLocalLog = new LocalLog(64);

    private final AtomicBoolean mNTNConnected = new AtomicBoolean(false);

    public SignalStrengthController(@NonNull Phone phone) {
        mPhone = phone;
        mCi = mPhone.mCi;
@@ -161,6 +165,8 @@ public class SignalStrengthController extends Handler {
        ccm.registerCarrierConfigChangeListener(this::post,
                (slotIndex, subId, carrierId, specificCarrierId) ->
                        onCarrierConfigurationChanged(slotIndex));

        mPhone.registerForServiceStateChanged(this, EVENT_SERVICE_STATE_CHANGED, null);
    }

    @Override
@@ -273,6 +279,11 @@ public class SignalStrengthController extends Handler {
                break;
            }

            case EVENT_SERVICE_STATE_CHANGED: {
                onServiceStateChanged((ServiceState) ((AsyncResult) msg.obj).result);
                break;
            }

            default:
                log("Unhandled message with number: " + msg.what);
                break;
@@ -406,10 +417,13 @@ public class SignalStrengthController extends Handler {
                            true));
        }

        int lteMeasurementEnabled = mCarrierConfig.getInt(CarrierConfigManager
                .KEY_PARAMETERS_USED_FOR_LTE_SIGNAL_BAR_INT, CellSignalStrengthLte.USE_RSRP);
        int[] lteRsrpThresholds = mCarrierConfig.getIntArray(
                CarrierConfigManager.KEY_LTE_RSRP_THRESHOLDS_INT_ARRAY);
        int lteMeasurementEnabled = mCarrierConfig.getInt(isUsingNonTerrestrialNetwork()
                        ? CarrierConfigManager.KEY_PARAMETERS_USED_FOR_NTN_LTE_SIGNAL_BAR_INT
                        : CarrierConfigManager.KEY_PARAMETERS_USED_FOR_LTE_SIGNAL_BAR_INT,
                CellSignalStrengthLte.USE_RSRP);
        int[] lteRsrpThresholds = mCarrierConfig.getIntArray(isUsingNonTerrestrialNetwork()
                ? CarrierConfigManager.KEY_NTN_LTE_RSRP_THRESHOLDS_INT_ARRAY
                : CarrierConfigManager.KEY_LTE_RSRP_THRESHOLDS_INT_ARRAY);
        if (lteRsrpThresholds != null) {
            signalThresholdInfos.add(
                    validateAndCreateSignalThresholdInfo(
@@ -421,7 +435,8 @@ public class SignalStrengthController extends Handler {
        }

        if (mPhone.getHalVersion(HAL_SERVICE_NETWORK).greaterOrEqual(RIL.RADIO_HAL_VERSION_1_5)) {
            int[] lteRsrqThresholds = mCarrierConfig.getIntArray(
            int[] lteRsrqThresholds = mCarrierConfig.getIntArray(isUsingNonTerrestrialNetwork()
                    ? CarrierConfigManager.KEY_NTN_LTE_RSRQ_THRESHOLDS_INT_ARRAY :
                    CarrierConfigManager.KEY_LTE_RSRQ_THRESHOLDS_INT_ARRAY);
            if (lteRsrqThresholds != null) {
                signalThresholdInfos.add(
@@ -433,7 +448,8 @@ public class SignalStrengthController extends Handler {
                                (lteMeasurementEnabled & CellSignalStrengthLte.USE_RSRQ) != 0));
            }

            int[] lteRssnrThresholds = mCarrierConfig.getIntArray(
            int[] lteRssnrThresholds = mCarrierConfig.getIntArray(isUsingNonTerrestrialNetwork()
                    ? CarrierConfigManager.KEY_NTN_LTE_RSSNR_THRESHOLDS_INT_ARRAY :
                    CarrierConfigManager.KEY_LTE_RSSNR_THRESHOLDS_INT_ARRAY);
            if (lteRssnrThresholds != null) {
                signalThresholdInfos.add(
@@ -1322,6 +1338,25 @@ public class SignalStrengthController extends Handler {
        };
    }

    private void onServiceStateChanged(ServiceState state) {
        if (state.getState() != ServiceState.STATE_IN_SERVICE) {
            return;
        }

        if (mNTNConnected.get() != state.isUsingNonTerrestrialNetwork()) {
            log("onServiceStateChanged: update it to " + state.isUsingNonTerrestrialNetwork());
            updateReportingCriteria();
            mNTNConnected.set(state.isUsingNonTerrestrialNetwork());
        }
    }

    private boolean isUsingNonTerrestrialNetwork() {
        if (mPhone.getServiceState() == null) {
            return false;
        }
        return mPhone.getServiceState().isUsingNonTerrestrialNetwork();
    }

    private static void log(String msg) {
        if (DBG) Rlog.d(TAG, msg);
    }
+16 −4
Original line number Diff line number Diff line
@@ -311,8 +311,11 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                        // activeCall could be null if the foreground call is in a disconnected
                        // state.  If either of the calls is null there is no need to check if
                        // one will be disconnected on answer.
                        // Use VideoProfile.STATE_BIDIRECTIONAL to not affect existing
                        // implementation. Video state of user response is handled in acceptCall().
                        boolean answeringWillDisconnect =
                                shouldDisconnectActiveCallOnAnswer(activeCall, imsCall);
                                shouldDisconnectActiveCallOnAnswer(activeCall, imsCall,
                                        VideoProfile.STATE_BIDIRECTIONAL);
                        conn.setActiveCallDisconnectedOnAnswer(answeringWillDisconnect);
                    }
                }
@@ -2215,7 +2218,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            ImsCall ringingCall = mRingingCall.getImsCall();
            if (mForegroundCall.hasConnections() && mRingingCall.hasConnections()) {
                answeringWillDisconnect =
                        shouldDisconnectActiveCallOnAnswer(activeCall, ringingCall);
                        shouldDisconnectActiveCallOnAnswer(activeCall, ringingCall, videoState);
            }

            // Cache video state for pending MT call.
@@ -5499,11 +5502,13 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
     *
     * @param activeCall The active call.
     * @param incomingCall The incoming call.
     * @param incomingCallVideoState The media type of incoming call acceptance.
     *                              {@link VideoProfile.VideoState}
     * @return {@code true} if answering the incoming call will cause the active call to be
     *      disconnected, {@code false} otherwise.
     */
    private boolean shouldDisconnectActiveCallOnAnswer(ImsCall activeCall,
            ImsCall incomingCall) {
            ImsCall incomingCall, int incomingCallVideoState) {

        if (activeCall == null || incomingCall == null) {
            return false;
@@ -5518,7 +5523,14 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        boolean isActiveCallOnWifi = activeCall.isWifiCall();
        boolean isVoWifiEnabled = mImsManager.isWfcEnabledByPlatform()
                && mImsManager.isWfcEnabledByUser();
        boolean isIncomingCallAudio = !incomingCall.isVideoCall();
        boolean isIncomingCallAudio = true;
        if (!mFeatureFlags.terminateActiveVideoCallWhenAcceptingSecondVideoCallAsAudioOnly()) {
            isIncomingCallAudio = !incomingCall.isVideoCall();
        } else {
            isIncomingCallAudio = !incomingCall.isVideoCall()
                    || incomingCallVideoState == VideoProfile.STATE_AUDIO_ONLY;
        }

        log("shouldDisconnectActiveCallOnAnswer : isActiveCallVideo=" + isActiveCallVideo +
                " isActiveCallOnWifi=" + isActiveCallOnWifi + " isIncomingCallAudio=" +
                isIncomingCallAudio + " isVowifiEnabled=" + isVoWifiEnabled);
+240 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.internal.telephony;

import static android.telephony.ServiceState.STATE_IN_SERVICE;
import static android.telephony.ServiceState.STATE_OUT_OF_SERVICE;
import static android.telephony.ServiceState.STATE_POWER_OFF;
import static android.telephony.SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP;
import static android.telephony.SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI;
import static android.telephony.SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP;
@@ -27,14 +30,19 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.content.Context;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
import android.os.PersistableBundle;
@@ -1269,6 +1277,238 @@ public class SignalStrengthControllerTest extends TelephonyTest {
        sendCarrierConfigUpdate();
    }

    @Test
    public void testInvalidCarrierConfig_NTN_LTE_RSRP_thresholdIsTooSmall() {
        // 4 threshold integers must be within the boundaries [-140, -44]
        mBundle.putIntArray(CarrierConfigManager.KEY_NTN_LTE_RSRP_THRESHOLDS_INT_ARRAY,
                new int[]{
                        -141, /* SIGNAL_STRENGTH_POOR */
                        -118, /* SIGNAL_STRENGTH_MODERATE */
                        -108, /* SIGNAL_STRENGTH_GOOD */
                        -98  /* SIGNAL_STRENGTH_GREAT */
                });
        sendCarrierConfigUpdate();
    }


    @Test
    public void testInvalidCarrierConfig_NTN_LTE_RSRP_thresholdIsTooLarge() {
        // 4 threshold integers must be within the boundaries [-140, -44]
        mBundle.putIntArray(CarrierConfigManager.KEY_NTN_LTE_RSRQ_THRESHOLDS_INT_ARRAY,
                new int[]{
                        -128, /* SIGNAL_STRENGTH_POOR */
                        -118, /* SIGNAL_STRENGTH_MODERATE */
                        -108, /* SIGNAL_STRENGTH_GOOD */
                        -43,  /* SIGNAL_STRENGTH_GREAT */
                });
        sendCarrierConfigUpdate();
    }

    @Test
    public void testInvalidCarrierConfig_NTN_LTE_RSRQ_thresholdIsTooSmall() {
        // 4 threshold integers must be within the boundaries [-34, 3]
        mBundle.putIntArray(CarrierConfigManager.KEY_NTN_LTE_RSRQ_THRESHOLDS_INT_ARRAY,
                new int[]{
                        -35, /* SIGNAL_STRENGTH_POOR */
                        -17, /* SIGNAL_STRENGTH_MODERATE */
                        -14, /* SIGNAL_STRENGTH_GOOD */
                        -11  /* SIGNAL_STRENGTH_GREAT */
                });
        sendCarrierConfigUpdate();
    }


    @Test
    public void testInvalidCarrierConfig_NTN_LTE_RSRQ_thresholdIsTooLarge() {
        // 4 threshold integers must be within the boundaries [-34, 3]
        mBundle.putIntArray(CarrierConfigManager.KEY_NTN_LTE_RSRQ_THRESHOLDS_INT_ARRAY,
                new int[]{
                        -20, /* SIGNAL_STRENGTH_POOR */
                        -17, /* SIGNAL_STRENGTH_MODERATE */
                        -14, /* SIGNAL_STRENGTH_GOOD */
                        4  /* SIGNAL_STRENGTH_GREAT */
                });
        sendCarrierConfigUpdate();
    }

    @Test
    public void testInvalidCarrierConfig_NTN_LTE_RSSNR_thresholdIsTooSmall() {
        // 4 threshold integers must be within the boundaries [-20, 30]
        mBundle.putIntArray(CarrierConfigManager.KEY_NTN_LTE_RSSNR_THRESHOLDS_INT_ARRAY,
                new int[]{
                        -21, /* SIGNAL_STRENGTH_POOR */
                        1,  /* SIGNAL_STRENGTH_MODERATE */
                        5,  /* SIGNAL_STRENGTH_GOOD */
                        13  /* SIGNAL_STRENGTH_GREAT */
                });
        sendCarrierConfigUpdate();
    }

    @Test
    public void testInvalidCarrierConfig_NTN_LTE_RSSNR_thresholdIsTooLarge() {
        // 4 threshold integers must be within the boundaries [-20, 30]
        mBundle.putIntArray(CarrierConfigManager.KEY_NTN_LTE_RSSNR_THRESHOLDS_INT_ARRAY,
                new int[]{
                        -3, /* SIGNAL_STRENGTH_POOR */
                        1,  /* SIGNAL_STRENGTH_MODERATE */
                        5,  /* SIGNAL_STRENGTH_GOOD */
                        31  /* SIGNAL_STRENGTH_GREAT */
                });
        sendCarrierConfigUpdate();
    }

    @Test
    public void testLteSignalStrengthReportingCriteriaWhenServiceStateChanged() {
        SignalStrength ss = new SignalStrength(
                new CellSignalStrengthCdma(),
                new CellSignalStrengthGsm(),
                new CellSignalStrengthWcdma(),
                new CellSignalStrengthTdscdma(),
                new CellSignalStrengthLte(
                        -110, /* rssi */
                        -114, /* rsrp */
                        -5, /* rsrq */
                        0, /* rssnr */
                        SignalStrength.INVALID, /* cqi */
                        SignalStrength.INVALID /* ta */),
                new CellSignalStrengthNr());

        // RSRP NTN_LTE threshold set to Good and LTE threshold set to poor.
        mBundle.putInt(CarrierConfigManager.KEY_PARAMETERS_USED_FOR_NTN_LTE_SIGNAL_BAR_INT,
                CellSignalStrengthLte.USE_RSRP);
        mBundle.putIntArray(CarrierConfigManager.KEY_NTN_LTE_RSRP_THRESHOLDS_INT_ARRAY,
                new int[]{-125 /* SIGNAL_STRENGTH_POOR */, -120 /* SIGNAL_STRENGTH_MODERATE */,
                        -115 /* SIGNAL_STRENGTH_GOOD */, -110/* SIGNAL_STRENGTH_GREAT */});
        mBundle.putIntArray(CarrierConfigManager.KEY_LTE_RSRP_THRESHOLDS_INT_ARRAY,
                new int[]{-114, /* SIGNAL_STRENGTH_POOR */ -110, /* SIGNAL_STRENGTH_MODERATE */
                        -105, /* SIGNAL_STRENGTH_GOOD */ -100, /* SIGNAL_STRENGTH_GREAT */});
        CarrierConfigManager mockConfigManager = Mockito.mock(CarrierConfigManager.class);
        when(mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE))
                .thenReturn(mockConfigManager);
        when(mockConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);

        // When NTN is connected, check the signal strength is GOOD
        AsyncResult asyncResult = mock(AsyncResult.class);
        asyncResult.result = mServiceState;
        doReturn(true).when(mServiceState).isUsingNonTerrestrialNetwork();
        mSsc.handleMessage(mSsc.obtainMessage(10/*EVENT_SERVICE_STATE_CHANGED*/, asyncResult));
        processAllMessages();

        mSimulatedCommands.setSignalStrength(ss);
        mSimulatedCommands.notifySignalStrength();
        processAllMessages();
        assertEquals(CellSignalStrength.SIGNAL_STRENGTH_GOOD, mSsc.getSignalStrength().getLevel());

        // When TN connected, check the signal strength is POOR
        doReturn(false).when(mServiceState).isUsingNonTerrestrialNetwork();
        mSsc.handleMessage(mSsc.obtainMessage(10/*EVENT_SERVICE_STATE_CHANGED*/, asyncResult));
        processAllMessages();

        mSimulatedCommands.setSignalStrength(ss);
        mSimulatedCommands.notifySignalStrength();
        processAllMessages();
        assertEquals(CellSignalStrength.SIGNAL_STRENGTH_POOR, mSsc.getSignalStrength().getLevel());

        // RSRP NTN_LTE threshold set to Moderate and LTE threshold set to poor.
        // When TN connected, check the signal strength is POOR.
        mBundle.putIntArray(CarrierConfigManager.KEY_NTN_LTE_RSRP_THRESHOLDS_INT_ARRAY,
                new int[]{-130 /* SIGNAL_STRENGTH_POOR */, -120 /* SIGNAL_STRENGTH_MODERATE */,
                        -110 /* SIGNAL_STRENGTH_GOOD */, -100/* SIGNAL_STRENGTH_GREAT */});
        mSsc.handleMessage(mSsc.obtainMessage(10/*EVENT_SERVICE_STATE_CHANGED*/, asyncResult));
        processAllMessages();

        mSimulatedCommands.setSignalStrength(ss);
        mSimulatedCommands.notifySignalStrength();
        processAllMessages();
        assertEquals(CellSignalStrength.SIGNAL_STRENGTH_POOR, mSsc.getSignalStrength().getLevel());

        // Service State Changed with OUT_OF_SERVICE, then no update
        // SignalStrengthReportingCriteria.
        reset(mSimulatedCommandsVerifier);
        doReturn(STATE_OUT_OF_SERVICE).when(mServiceState).getState();
        mSsc.handleMessage(mSsc.obtainMessage(10/*EVENT_SERVICE_STATE_CHANGED*/, asyncResult));
        processAllMessages();

        mSimulatedCommands.setSignalStrength(ss);
        mSimulatedCommands.notifySignalStrength();
        processAllMessages();
        assertEquals(CellSignalStrength.SIGNAL_STRENGTH_POOR, mSsc.getSignalStrength().getLevel());
        verify(mSimulatedCommandsVerifier, never()).setSignalStrengthReportingCriteria(anyList(),
                isNull());

        // Service State Changed with POWER_OFF, then no update SignalStrengthReportingCriteria.
        reset(mSimulatedCommandsVerifier);
        doReturn(STATE_POWER_OFF).when(mServiceState).getState();
        mSsc.handleMessage(mSsc.obtainMessage(10/*EVENT_SERVICE_STATE_CHANGED*/, asyncResult));
        processAllMessages();

        mSimulatedCommands.setSignalStrength(ss);
        mSimulatedCommands.notifySignalStrength();
        processAllMessages();
        assertEquals(CellSignalStrength.SIGNAL_STRENGTH_POOR, mSsc.getSignalStrength().getLevel());
        verify(mSimulatedCommandsVerifier, never()).setSignalStrengthReportingCriteria(anyList(),
                isNull());

        // Service State Changed with IN_SERVICE, then update SignalStrengthReportingCriteria.
        // When NTN is connected, check the signal strength is MODERATE
        reset(mSimulatedCommandsVerifier);
        doReturn(true).when(mServiceState).isUsingNonTerrestrialNetwork();
        doReturn(STATE_IN_SERVICE).when(mServiceState).getState();
        mSsc.handleMessage(mSsc.obtainMessage(10/*EVENT_SERVICE_STATE_CHANGED*/, asyncResult));
        processAllMessages();

        mSimulatedCommands.setSignalStrength(ss);
        mSimulatedCommands.notifySignalStrength();
        processAllMessages();
        assertEquals(CellSignalStrength.SIGNAL_STRENGTH_MODERATE,
                mSsc.getSignalStrength().getLevel());
        verify(mSimulatedCommandsVerifier).setSignalStrengthReportingCriteria(anyList(), isNull());

        // Service State Changed with IN_SERVICE and still NTN is connected,
        // verify not update SignalStrengthReportingCriteria and the signal strength is MODERATE.
        reset(mSimulatedCommandsVerifier);
        mSsc.handleMessage(mSsc.obtainMessage(10/*EVENT_SERVICE_STATE_CHANGED*/, asyncResult));
        processAllMessages();

        mSimulatedCommands.setSignalStrength(ss);
        mSimulatedCommands.notifySignalStrength();
        processAllMessages();
        assertEquals(CellSignalStrength.SIGNAL_STRENGTH_MODERATE,
                mSsc.getSignalStrength().getLevel());
        verify(mSimulatedCommandsVerifier, never()).setSignalStrengthReportingCriteria(anyList(),
                isNull());

        // Service State Changed with IN_SERVICE, then update SignalStrengthReportingCriteria.
        // When TN is connected, check the signal strength is POOR.
        reset(mSimulatedCommandsVerifier);
        doReturn(false).when(mServiceState).isUsingNonTerrestrialNetwork();
        mSsc.handleMessage(mSsc.obtainMessage(10/*EVENT_SERVICE_STATE_CHANGED*/, asyncResult));
        processAllMessages();

        mSimulatedCommands.setSignalStrength(ss);
        mSimulatedCommands.notifySignalStrength();
        processAllMessages();
        assertEquals(CellSignalStrength.SIGNAL_STRENGTH_POOR,
                mSsc.getSignalStrength().getLevel());
        verify(mSimulatedCommandsVerifier).setSignalStrengthReportingCriteria(anyList(), isNull());

        // Service State Changed with IN_SERVICE and still TN is connected,
        // verify not update SignalStrengthReportingCriteria and the signal strength is POOR.
        reset(mSimulatedCommandsVerifier);
        mSsc.handleMessage(mSsc.obtainMessage(10/*EVENT_SERVICE_STATE_CHANGED*/, asyncResult));
        processAllMessages();

        mSimulatedCommands.setSignalStrength(ss);
        mSimulatedCommands.notifySignalStrength();
        processAllMessages();
        assertEquals(CellSignalStrength.SIGNAL_STRENGTH_POOR,
                mSsc.getSignalStrength().getLevel());
        verify(mSimulatedCommandsVerifier, never()).setSignalStrengthReportingCriteria(anyList(),
                isNull());

        reset(mSimulatedCommandsVerifier);
    }

    private void verifyAllEmptyThresholdAreDisabledWhenSetSignalStrengthReportingCriteria(
            int expectedNonEmptyThreshold) {
        ArgumentCaptor<List<SignalThresholdInfo>> signalThresholdInfoCaptor =
+532 −0

File changed.

Preview size limit exceeded, changes collapsed.