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

Commit 0d26d718 authored by Jack Yu's avatar Jack Yu
Browse files

Supported data enabled override for different scenarios

Added override rules support for always allowing mms and
internet data during voice call.

Test: Manual + unit tests
Bug: 132113695
Change-Id: I2266d7f428901ccbba6bf538a7c7696e6566b96c
parent d6d8091d
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -302,10 +302,26 @@ public class SubscriptionManager {
     * subscription.
     *
     * Default value is 0.
     *
     * @deprecated Replaced by {@link #DATA_ENABLED_OVERRIDE_RULES}
     * @hide
     */
    /** @hide */
    @Deprecated
    public static final String WHITE_LISTED_APN_DATA = "white_listed_apn_data";

    /**
     * TelephonyProvider column name data_enabled_override_rules.
     * It's a list of rules for overriding data enabled settings. The syntax is
     * For example, "mms=nonDefault" indicates enabling data for mms in non-default subscription.
     * "default=nonDefault&inVoiceCall" indicates enabling data for internet in non-default
     * subscription and while is in voice call.
     *
     * Default value is empty string.
     *
     * @hide
     */
    public static final String DATA_ENABLED_OVERRIDE_RULES = "data_enabled_override_rules";

    /**
     * This constant is to designate a subscription as a Local-SIM Subscription.
     * <p> A Local-SIM can be a physical SIM inserted into a sim-slot in the device, or eSIM on the
+48 −0
Original line number Diff line number Diff line
@@ -11141,4 +11141,52 @@ public class TelephonyManager {
        }
        return true;
    }

    /**
     * Set allowing mobile data during voice call.
     *
     * @param allow {@code true} if allowing using data during voice call, {@code false} if
     * disallowed
     *
     * @return {@code false} if the setting is changed.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public boolean setDataAllowedDuringVoiceCall(boolean allow) {
        try {
            ITelephony service = getITelephony();
            if (service != null) {
                return service.setDataAllowedDuringVoiceCall(getSubId(), allow);
            }
        } catch (RemoteException ex) {
            if (!isSystemProcess()) {
                ex.rethrowAsRuntimeException();
            }
        }
        return false;
    }

    /**
     * Check whether data is allowed during voice call. Note this is for dual sim device that
     * data might be disabled on non-default data subscription but explicitly turned on by settings.
     *
     * @return {@code true} if data is allowed during voice call.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    public boolean isDataAllowedInVoiceCall() {
        try {
            ITelephony service = getITelephony();
            if (service != null) {
                return service.isDataAllowedInVoiceCall(getSubId());
            }
        } catch (RemoteException ex) {
            if (!isSystemProcess()) {
                ex.rethrowAsRuntimeException();
            }
        }
        return false;
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -1310,6 +1310,9 @@ public class ApnSetting implements Parcelable {
     * @hide
     */
    public static String getApnTypeString(int apnType) {
        if (apnType == TYPE_ALL) {
            return "*";
        }
        String apnTypeString = APN_TYPE_INT_MAP.get(apnType);
        return apnTypeString == null ? "Unknown" : apnTypeString;
    }
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ public class DctConstants {
    public static final int EVENT_ROAMING_SETTING_CHANGE = BASE + 48;
    public static final int EVENT_DATA_SERVICE_BINDING_CHANGED = BASE + 49;
    public static final int EVENT_DEVICE_PROVISIONED_CHANGE = BASE + 50;
    public static final int EVENT_APN_WHITE_LIST_CHANGE = BASE + 51;
    public static final int EVENT_DATA_ENABLED_OVERRIDE_RULES_CHANGED = BASE + 51;

    /***** Constants *****/

+12 −1
Original line number Diff line number Diff line
@@ -1996,4 +1996,15 @@ interface ITelephony {
     * Returns the MMS user agent profile URL.
     */
    String getMmsUAProfUrl(int subId);

    /**
     * Set allowing mobile data during voice call.
     */
    boolean setDataAllowedDuringVoiceCall(int subId, boolean allow);

    /**
     * Check whether data is allowed during voice call. Note this is for dual sim device that
     * data might be disabled on non-default data subscription but explicitly turned on by settings.
     */
    boolean isDataAllowedInVoiceCall(int subId);
}