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

Commit d1963130 authored by Nazanin Bakhshi's avatar Nazanin Bakhshi Committed by Android (Google) Code Review
Browse files

Merge "Make sure data is enabled on the non-primary sub's voice call only if...

Merge "Make sure data is enabled on the non-primary sub's voice call only if the primary's data is on" into qt-r1-dev
parents 018912c0 dfbad4ce
Loading
Loading
Loading
Loading
+43 −2
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.internal.telephony.dataconnection;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting;
import android.telephony.data.ApnSetting.ApnType;
import android.text.TextUtils;
@@ -26,6 +28,7 @@ import android.util.ArrayMap;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.dataconnection.DataEnabledOverride.OverrideConditions.Condition;

@@ -52,7 +55,9 @@ public class DataEnabledOverride {
     */
    private static final OverrideRule OVERRIDE_RULE_ALLOW_DATA_DURING_VOICE_CALL =
            new OverrideRule(ApnSetting.TYPE_ALL, OverrideConditions.CONDITION_IN_VOICE_CALL
                    | OverrideConditions.CONDITION_NON_DEFAULT);
                    | OverrideConditions.CONDITION_NON_DEFAULT
                    | OverrideConditions.CONDITION_DEFAULT_DATA_ENABLED
                    | OverrideConditions.CONDITION_DSDS_ENABLED);

    /**
     * The rule for always allowing mms. Without adding any condition to the rule, any condition can
@@ -157,6 +162,12 @@ public class DataEnabledOverride {
        /** Enable data only when device has ongoing voice call */
        static final int CONDITION_IN_VOICE_CALL = 1 << 1;

        /** Enable data only when default data is on */
        static final int CONDITION_DEFAULT_DATA_ENABLED = 1 << 2;

        /** Enable data only when device is in DSDS mode */
        static final int CONDITION_DSDS_ENABLED = 1 << 3;

        /** Enable data unconditionally in string format */
        static final String CONDITION_UNCONDITIONALLY_STRING = "unconditionally";

@@ -166,10 +177,18 @@ public class DataEnabledOverride {
        /** Enable data only when device has ongoing voice call in string format */
        static final String CONDITION_VOICE_CALL_STRING = "inVoiceCall";

        /** Enable data only when default data is on in string format */
        static final String CONDITION_DEFAULT_DATA_ENABLED_STRING = "DefaultDataOn";

        /** Enable data only when device is in DSDS mode in string format */
        static final String CONDITION_DSDS_ENABLED_STRING = "dsdsEnabled";

        /** @hide */
        @IntDef(flag = true, prefix = { "OVERRIDE_CONDITION_" }, value = {
                CONDITION_NON_DEFAULT,
                CONDITION_IN_VOICE_CALL,
                CONDITION_DEFAULT_DATA_ENABLED,
                CONDITION_DSDS_ENABLED
        })
        @Retention(RetentionPolicy.SOURCE)
        public @interface Condition {}
@@ -182,6 +201,10 @@ public class DataEnabledOverride {
                    CONDITION_NON_DEFAULT_STRING);
            OVERRIDE_CONDITION_INT_MAP.put(CONDITION_IN_VOICE_CALL,
                    CONDITION_VOICE_CALL_STRING);
            OVERRIDE_CONDITION_INT_MAP.put(CONDITION_DEFAULT_DATA_ENABLED,
                    CONDITION_DEFAULT_DATA_ENABLED_STRING);
            OVERRIDE_CONDITION_INT_MAP.put(CONDITION_DSDS_ENABLED,
                    CONDITION_DSDS_ENABLED_STRING);

            OVERRIDE_CONDITION_STRING_MAP.put(CONDITION_UNCONDITIONALLY_STRING,
                    CONDITION_UNCONDITIONALLY);
@@ -189,6 +212,10 @@ public class DataEnabledOverride {
                    CONDITION_NON_DEFAULT);
            OVERRIDE_CONDITION_STRING_MAP.put(CONDITION_VOICE_CALL_STRING,
                    CONDITION_IN_VOICE_CALL);
            OVERRIDE_CONDITION_STRING_MAP.put(CONDITION_DEFAULT_DATA_ENABLED_STRING,
                    CONDITION_DEFAULT_DATA_ENABLED);
            OVERRIDE_CONDITION_STRING_MAP.put(CONDITION_DSDS_ENABLED_STRING,
                    CONDITION_DSDS_ENABLED);
        }

        private final @Condition int mConditions;
@@ -353,9 +380,23 @@ public class DataEnabledOverride {
                conditions |= OverrideConditions.CONDITION_IN_VOICE_CALL;
            }

            if (phone.getSubId() != SubscriptionController.getInstance().getDefaultDataSubId()) {
            int defaultDataSubId = SubscriptionController.getInstance().getDefaultDataSubId();

            if (phone.getSubId() != defaultDataSubId) {
                conditions |= OverrideConditions.CONDITION_NON_DEFAULT;
            }

            if (defaultDataSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
                int phoneId = SubscriptionController.getInstance().getPhoneId(defaultDataSubId);
                Phone defaultDataPhone = PhoneFactory.getPhone(phoneId);
                if (defaultDataPhone.isUserDataEnabled()) {
                    conditions |= OverrideConditions.CONDITION_DEFAULT_DATA_ENABLED;
                }
            }

            if (TelephonyManager.from(phone.getContext()).isMultiSimEnabled()) {
                conditions |= OverrideConditions.CONDITION_DSDS_ENABLED;
            }
        }

        return conditions;
+2 −3
Original line number Diff line number Diff line
@@ -210,10 +210,9 @@ public class DataEnabledOverrideTest extends TelephonyTest {
        doReturn(2).when(mSubscriptionController).getDefaultSmsSubId();

        doReturn(PhoneConstants.State.OFFHOOK).when(mPhone).getState();
        assertTrue(deo.getRules(), deo.shouldOverrideDataEnabledSettings(mPhone,
                ApnSetting.TYPE_DEFAULT));
        deo.setDataAllowedInVoiceCall(false);
        assertFalse(deo.shouldOverrideDataEnabledSettings(mPhone, ApnSetting.TYPE_DEFAULT));
        assertFalse(deo.getRules(), deo.shouldOverrideDataEnabledSettings(
                mPhone, ApnSetting.TYPE_DEFAULT));
        assertFalse(deo.isDataAllowedInVoiceCall());
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ public class DataEnabledSettingsTest extends TelephonyTest {
        ArgumentCaptor<String> stringCaptor = ArgumentCaptor.forClass(String.class);
        verify(mSubscriptionController).setDataEnabledOverrideRules(anyInt(),
                stringCaptor.capture());
        assertEquals("*=nonDefault&inVoiceCall", stringCaptor.getValue());
        assertEquals("*=nonDefault&inVoiceCall&DefaultDataOn&dsdsEnabled", stringCaptor.getValue());

        clearInvocations(mSubscriptionController);