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

Commit fef30c21 authored by Xin Li's avatar Xin Li
Browse files

Merge 24Q3 (ab/AP3A.240905.001) to aosp-main-future

Bug: 347831320
Merged-In: I4662939fa98b66fec77ff257ff33128580e1959e
Change-Id: I3310efd6d85cb35c763577eb257b0576121c8d22
parents a33c5553 585f1a81
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1502,6 +1502,14 @@ public class DataConfigManager extends Handler {
                .collect(Collectors.toSet());
    }

    /**
     * {@code True} enables mms to be attempted on iwlan if possible, even if existing cellular
     *  networks already supports iwlan.
     */
    public boolean isForceIwlanMmsFeatureEnabled() {
        return mResources.getBoolean(com.android.internal.R.bool.force_iwlan_mms_feature_enabled);
    }

    /**
     * Log debug messages.
     * @param s debug messages
+5 −3
Original line number Diff line number Diff line
@@ -1263,7 +1263,7 @@ public class DataNetwork extends StateMachine {
                        getHandler(), EVENT_VOICE_CALL_ENDED, null);
            }

            if (mFlags.forceIwlanMms()) {
            if (mFlags.forceIwlanMms() && mDataConfigManager.isForceIwlanMmsFeatureEnabled()) {
                if (mDataProfile.canSatisfy(NetworkCapabilities.NET_CAPABILITY_MMS)) {
                    mAccessNetworksManagerCallback = new AccessNetworksManagerCallback(
                            getHandler()::post) {
@@ -1289,7 +1289,8 @@ public class DataNetwork extends StateMachine {
        @Override
        public void exit() {
            logv("Unregistering all events.");
            if (mFlags.forceIwlanMms() && mAccessNetworksManagerCallback != null) {
            if (mFlags.forceIwlanMms() && mAccessNetworksManagerCallback != null
                    && mDataConfigManager.isForceIwlanMmsFeatureEnabled()) {
                mAccessNetworksManager.unregisterCallback(mAccessNetworksManagerCallback);
            }

@@ -2488,7 +2489,8 @@ public class DataNetwork extends StateMachine {
        // will be attempted on IWLAN if possible, even if existing cellular networks already
        // supports IWLAN.
        if (mFlags.forceIwlanMms() && builder.build()
                .hasCapability(NetworkCapabilities.NET_CAPABILITY_MMS)) {
                .hasCapability(NetworkCapabilities.NET_CAPABILITY_MMS)
                && mDataConfigManager.isForceIwlanMmsFeatureEnabled()) {
            // If QNS sets MMS preferred on IWLAN, and it is possible to setup an MMS network on
            // IWLAN, then we need to remove the MMS capability on the cellular network. This will
            // allow the new MMS network to be brought up on IWLAN when MMS network request arrives.
+64 −0
Original line number Diff line number Diff line
@@ -564,6 +564,11 @@ public class EmergencyStateTracker {
        Rlog.i(TAG, "startEmergencyCall: phoneId=" + phone.getPhoneId()
                + ", callId=" + c.getTelecomCallId());

        if (needToSwitchPhone(phone)) {
            Rlog.e(TAG, "startEmergencyCall failed. need to switch stacks.");
            return CompletableFuture.completedFuture(DisconnectCause.EMERGENCY_PERM_FAILURE);
        }

        if (mPhone != null) {
            // Create new future to return as to not interfere with any uncompleted futures.
            // Case1) When 2nd emergency call is initiated during an active call on the same phone.
@@ -2105,4 +2110,63 @@ public class EmergencyStateTracker {
            endNormalRoutingEmergencyCall(c);
        }
    }

    /**
     * Determines whether switching stacks is needed or not.
     *
     * @param phone the {@code Phone} on which to process the emergency call.
     * @return true if switching stacks is needed.
     */
    @VisibleForTesting
    public boolean needToSwitchPhone(Phone phone) {
        int subId = phone.getSubId();
        int phoneId = phone.getPhoneId();

        if (isSimReady(phoneId, subId)) return false;

        boolean switchPhone = false;
        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
            Rlog.i(TAG, "needToSwitchPhone SIM absent");
            if (phoneId != 0 || isThereOtherPhone(phoneId, true)) {
                // Prefer default Phone or other Phone with a SIM regardless of lock state.
                switchPhone = true;
            }
        } else {
            Rlog.i(TAG, "needToSwitchPhone SIM not ready");
            if ((phoneId == 0 && isThereOtherPhone(phoneId, false))
                    || (phoneId != 0 && isThereOtherPhone(phoneId, true))) {
                // If there is another one with a SIM ready, switch Phones.
                // Otherwise, prefer default Phone if both SIMs are locked.
                switchPhone = true;
            }
        }
        Rlog.i(TAG, "needToSwitchPhone " + switchPhone);
        return switchPhone;
    }

    private boolean isThereOtherPhone(int skipPhoneId, boolean ignoreLockState) {
        for (Phone phone : mPhoneFactoryProxy.getPhones()) {
            int phoneId = phone.getPhoneId();
            if (phoneId == skipPhoneId) {
                continue;
            }

            int subId = phone.getSubId();
            if (!SubscriptionManager.isValidSubscriptionId(subId)) {
                Rlog.i(TAG, "isThereOtherPhone phoneId=" + phoneId + ", subId=" + subId);
                continue;
            }
            int simState = mTelephonyManagerProxy.getSimState(phoneId);
            if ((simState == TelephonyManager.SIM_STATE_READY) || (ignoreLockState
                    && simState != TelephonyManager.SIM_STATE_ABSENT
                    && simState != TelephonyManager.SIM_STATE_NOT_READY)) {
                Rlog.i(TAG, "isThereOtherPhone found, ignoreLockState=" + ignoreLockState
                        + ", phoneId=" + phoneId + ", simState=" + simState);
                return true;
            }
            Rlog.i(TAG, "isThereOtherPhone phoneId=" + phoneId + ", simState=" + simState);
        }

        return false;
    }
}
+11 −5
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony.satellite;

import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
import static android.telephony.ServiceState.STATE_EMERGENCY_ONLY;
import static android.telephony.ServiceState.STATE_IN_SERVICE;
import static android.telephony.ServiceState.STATE_OUT_OF_SERVICE;
@@ -29,6 +30,7 @@ import static com.android.internal.telephony.satellite.SatelliteController.INVAL

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
@@ -251,10 +253,11 @@ public class SatelliteSOSMessageRecommender extends Handler {

        selectEmergencyCallWaitForConnectionTimeoutDuration();
        if (mEmergencyConnection == null) {
            handleStateChangedEventForHysteresisTimer();
            registerForInterestedStateChangedEvents();
        }
        mEmergencyConnection = connection;
        handleStateChangedEventForHysteresisTimer();

        synchronized (mLock) {
            mCheckingAccessRestrictionInProgress = false;
            mIsSatelliteAllowedForCurrentLocation = false;
@@ -413,7 +416,6 @@ public class SatelliteSOSMessageRecommender extends Handler {
        for (Phone phone : PhoneFactory.getPhones()) {
            phone.registerForServiceStateChanged(
                    this, EVENT_SERVICE_STATE_CHANGED, null);
            registerForImsRegistrationStateChanged(phone);
        }
    }

@@ -433,7 +435,6 @@ public class SatelliteSOSMessageRecommender extends Handler {
                SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mISatelliteProvisionStateCallback);
        for (Phone phone : PhoneFactory.getPhones()) {
            phone.unregisterForServiceStateChanged(this);
            unregisterForImsRegistrationStateChanged(phone);
        }
    }

@@ -525,7 +526,7 @@ public class SatelliteSOSMessageRecommender extends Handler {
    }

    private synchronized void handleStateChangedEventForHysteresisTimer() {
        if (!isCellularAvailable()) {
        if (!isCellularAvailable() && mEmergencyConnection != null) {
            startTimer();
        } else {
            logv("handleStateChangedEventForHysteresisTimer stopTimer");
@@ -701,10 +702,15 @@ public class SatelliteSOSMessageRecommender extends Handler {
            intent = new Intent(Intent.ACTION_SENDTO, uri);
        } else {
            intent = new Intent(action);
            intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP);
        }
        Bundle activityOptions = ActivityOptions.makeBasic()
                .setPendingIntentBackgroundActivityStartMode(
                        ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED)
                .toBundle();
        intent.setComponent(new ComponentName(packageName, className));
        return PendingIntent.getActivity(mContext, 0, intent,
                PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
                PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE, activityOptions);
    }

    private boolean isEmergencyCallToSatelliteHandoverTypeT911Enforced() {
+1 −0
Original line number Diff line number Diff line
@@ -2419,6 +2419,7 @@ public class DataNetworkTest extends TelephonyTest {
    @Test
    public void testMmsCapabilityRemovedWhenMmsPreferredOnIwlan() throws Exception {
        doReturn(true).when(mFeatureFlags).forceIwlanMms();
        doReturn(true).when(mDataConfigManager).isForceIwlanMmsFeatureEnabled();
        setupDataNetwork();

        assertThat(mDataNetworkUT.getNetworkCapabilities()
Loading