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

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

Snap for 13362916 from d304a07e to 25Q3-release

Change-Id: I6531806de271d4b4ee190f03de8537b03b4d344a
parents ad73c5aa d304a07e
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -298,10 +298,13 @@ public class NetworkTypeController extends StateMachine {

    private void updateBandwidthConstrainedStatus(NetworkCapabilities capabilities) {
        if (capabilities != null) {
            mIsSatelliteConstrainedData
                    = isBandwidthConstrainedCapabilitySupported(capabilities);
            log("satellite constrained data status : " + mIsSatelliteConstrainedData);
            boolean isConstrained = isBandwidthConstrainedCapabilitySupported(capabilities);
            if (isConstrained != mIsSatelliteConstrainedData) {
                mIsSatelliteConstrainedData = isConstrained;
                log("Update network type because satellite constrained data status changed to "
                        + mIsSatelliteConstrainedData);
                mDisplayInfoController.updateTelephonyDisplayInfo();
            }
        } else {
            log("capabilities is null");
        }
+32 −18
Original line number Diff line number Diff line
@@ -674,7 +674,7 @@ public class AutoDataSwitchController extends Handler {
            TelephonyDisplayInfo displayInfo = phone.getDisplayInfoController()
                    .getTelephonyDisplayInfo();
            mPhonesSignalStatus[phoneId].mDisplayInfo = displayInfo;
            if (getHigherScoreCandidatePhoneId() != mSelectedTargetPhoneId) {
            if (getBetterCandidatePhoneIdBasedOnScore() != mSelectedTargetPhoneId) {
                log("onDisplayInfoChanged: phone " + phoneId + " " + displayInfo);
                evaluateAutoDataSwitch(EVALUATION_REASON_DISPLAY_INFO_CHANGED);
            }
@@ -694,7 +694,7 @@ public class AutoDataSwitchController extends Handler {
            SignalStrength oldSignalStrength = mPhonesSignalStatus[phoneId].mSignalStrength;
            if (oldSignalStrength.getLevel() != newSignalStrength.getLevel()) {
                mPhonesSignalStatus[phoneId].mSignalStrength = newSignalStrength;
                if (getHigherScoreCandidatePhoneId() != mSelectedTargetPhoneId) {
                if (getBetterCandidatePhoneIdBasedOnScore() != mSelectedTargetPhoneId) {
                    log("onSignalStrengthChanged: phone " + phoneId + " "
                            + oldSignalStrength.getLevel() + "->" + newSignalStrength.getLevel());
                    evaluateAutoDataSwitch(EVALUATION_REASON_SIGNAL_STRENGTH_CHANGED);
@@ -706,31 +706,45 @@ public class AutoDataSwitchController extends Handler {
    }

    /**
     * Called as a preliminary check for the frequent signal/display info change.
     * @return The phone Id if found a candidate phone with higher signal score, or the DDS has
     * an equal score.
     * Checks for a better data phone candidate based on signal strength.Compares the preferred data
     * phone and DDS, potentially switching to another active phone with a significantly better
     * signal or reverting to DDS if the preferred phone isn't significantly better.
     *
     * @return A better candidate phone ID, the DDS phone ID,
     * or {@link android.telephony.SubscriptionManager#INVALID_PHONE_INDEX}.
     */
    private int getHigherScoreCandidatePhoneId() {
    private int getBetterCandidatePhoneIdBasedOnScore() {
        int preferredPhoneId = mPhoneSwitcher.getPreferredDataPhoneId();
        int ddsPhoneId = mSubscriptionManagerService.getPhoneId(
                mSubscriptionManagerService.getDefaultDataSubId());
        if (isActiveModemPhone(preferredPhoneId) && isActiveModemPhone(ddsPhoneId)) {
            int currentScore = mPhonesSignalStatus[preferredPhoneId].getRatSignalScore();
            for (int phoneId = 0; phoneId < mPhonesSignalStatus.length; phoneId++) {
                if (phoneId == preferredPhoneId) continue;
                PhoneSignalStatus candidateStatus = mPhonesSignalStatus[phoneId];
                // Ignore non-home phone.
                if (candidateStatus.getUsableState() != PhoneSignalStatus.UsableState.HOME) {

        if (!isActiveModemPhone(preferredPhoneId) || !isActiveModemPhone(ddsPhoneId)) {
            return INVALID_PHONE_INDEX;
        }

        int defaultScore = mPhonesSignalStatus[ddsPhoneId].getRatSignalScore();
        int preferredScore = mPhonesSignalStatus[preferredPhoneId].getRatSignalScore();

        // Currently on default data subscription
        if (ddsPhoneId == preferredPhoneId) {
            // Find any candidate with significantly better score
            for (int backupId = 0; backupId < mPhonesSignalStatus.length; backupId++) {
                // Skip current phone and non-home phones
                if (backupId == preferredPhoneId
                        || !isHomeService(mPhonesSignalStatus[backupId].mDataRegState)) {
                    continue;
                }
                int candidateScore = candidateStatus.getRatSignalScore();
                if ((candidateScore - currentScore) > mScoreTolerance
                        // Also reevaluate if DDS has the same score as the current phone.
                        || (candidateScore >= currentScore && phoneId == ddsPhoneId)) {
                    return phoneId;

                int candidateScore = mPhonesSignalStatus[backupId].getRatSignalScore();
                if (candidateScore - defaultScore > mScoreTolerance) {
                    return backupId;
                }
            }
        } else if (preferredScore - defaultScore <= mScoreTolerance) { // Currently on backup
            // Switch back to dds if preferred isn't significantly better
            return ddsPhoneId;
        }

        return INVALID_PHONE_INDEX;
    }

+25 −0
Original line number Diff line number Diff line
@@ -325,6 +325,7 @@ public class SatelliteController extends Handler {
    private static final int CMD_GET_SATELLITE_ENABLED_FOR_CARRIER = 64;
    private static final int EVENT_GET_SATELLITE_ENABLED_FOR_CARRIER_DONE = 65;
    private static final int REQUEST_SATELLITE_ENABLED = 66;
    private static final int REQUEST_IS_SATELLITE_ENABLED = 67;

    @NonNull private static SatelliteController sInstance;
    @NonNull private final Context mContext;
@@ -2337,6 +2338,18 @@ public class SatelliteController extends Handler {
                break;
            }

            case REQUEST_IS_SATELLITE_ENABLED: {
                plogd("REQUEST_IS_SATELLITE_ENABLED");
                SomeArgs args = (SomeArgs) msg.obj;
                ResultReceiver result = (ResultReceiver) args.arg1;
                try {
                    handleRequestIsSatelliteEnabled(result);
                } finally {
                    args.recycle();
                }
                break;
            }

            default:
                Log.w(TAG, "SatelliteControllerHandler: unexpected message code: " +
                        msg.what);
@@ -2719,6 +2732,18 @@ public class SatelliteController extends Handler {
     *               if the request is successful or an error code if the request failed.
     */
    public void requestIsSatelliteEnabled(@NonNull ResultReceiver result) {
        if (mFeatureFlags.satelliteImproveMultiThreadDesign()) {
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = result;
            sendMessage(obtainMessage(REQUEST_IS_SATELLITE_ENABLED, args));
            return;
        }

        handleRequestIsSatelliteEnabled(result);
    }

    private void handleRequestIsSatelliteEnabled(@NonNull ResultReceiver result) {
        plogd("handleRequestIsSatelliteEnabled");
        int error = evaluateOemSatelliteRequestAllowed(false);
        if (error != SATELLITE_RESULT_SUCCESS) {
            result.send(error, null);
+28 −1
Original line number Diff line number Diff line
@@ -420,6 +420,7 @@ public class AutoDataSwitchControllerTest extends TelephonyTest {

        // 4.1.2 Display info and signal strength on secondary phone became bad,
        // but primary become service, then don't switch.
        logd("4.1.2 Display info and signal strength on secondary became bad, don't switch.");
        prepareIdealUsesNonDdsCondition();
        processAllFutureMessages();
        clearInvocations(mMockedPhoneSwitcherCallback, mMockedAlarmManager);
@@ -433,6 +434,7 @@ public class AutoDataSwitchControllerTest extends TelephonyTest {
                EVENT_STABILITY_CHECK_PASSED));

        // 4.2 Display info on default phone became good just as the secondary
        logd("4.2 Display info on default phone became good just as the secondary.");
        prepareIdealUsesNonDdsCondition();
        processAllFutureMessages();
        clearInvocations(mMockedPhoneSwitcherCallback, mMockedAlarmManager);
@@ -445,6 +447,7 @@ public class AutoDataSwitchControllerTest extends TelephonyTest {
                EVENT_STABILITY_CHECK_PASSED));

        // 4.3 Signal strength on default phone became just as good as the secondary
        logd("4.3 Signal strength on default phone became just as good as the secondary.");
        prepareIdealUsesNonDdsCondition();
        processAllFutureMessages();
        clearInvocations(mMockedPhoneSwitcherCallback, mMockedAlarmManager);
@@ -906,7 +909,7 @@ public class AutoDataSwitchControllerTest extends TelephonyTest {

    @Test
    public void testRatSignalStrengthSkipEvaluation() {
        // Verify the secondary phone is OOS and its score(0) is too low to justify the evaluation
        // Score NOT significantly better to justify the evaluation
        clearInvocations(mMockedPhoneSwitcherCallback);
        displayInfoChanged(PHONE_2, mBadTelephonyDisplayInfo);
        processAllFutureMessages();
@@ -915,6 +918,30 @@ public class AutoDataSwitchControllerTest extends TelephonyTest {
        verify(mMockedPhoneSwitcherCallback, never()).onRequireValidation(anyInt(), anyBoolean());
    }

    /**
     * Scenario 2: On Default, Candidate score IS better, BUT Candidate is NOT HOME.
     */
    @Test
    public void testBetterCandidate_onDefault_nonHome_scoreHigh_noEval() {
        doReturn(PHONE_1).when(mPhoneSwitcher).getPreferredDataPhoneId();

        // Setup state: Low score for default, high score for backup
        displayInfoChanged(PHONE_1, mBadTelephonyDisplayInfo);
        signalStrengthChanged(PHONE_1, SignalStrength.SIGNAL_STRENGTH_POOR);
        displayInfoChanged(PHONE_2, mGoodTelephonyDisplayInfo); // High score inputs
        signalStrengthChanged(PHONE_2, SignalStrength.SIGNAL_STRENGTH_GREAT);
        serviceStateChanged(PHONE_2, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING);
        processAllMessages();

        // Trigger internal call via another display info change
        displayInfoChanged(PHONE_2, mGoodTelephonyDisplayInfo);
        processAllMessages();

        // Verify no evaluation scheduled (skipped because not HOME)
        assertThat(mAutoDataSwitchControllerUT.hasMessages(EVENT_EVALUATE_AUTO_SWITCH)).isFalse();
        mAutoDataSwitchControllerUT.removeMessages(EVENT_EVALUATE_AUTO_SWITCH);
    }

    /**
     * Trigger conditions
     * 1. service state changes