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
Merged-In: I2266d7f428901ccbba6bf538a7c7696e6566b96c
Change-Id: I2266d7f428901ccbba6bf538a7c7696e6566b96c
(cherry picked from commit 0d26d718b3)
This commit is contained in:
Jack Yu
2019-05-23 16:37:35 -07:00
parent bdc8e00211
commit a726a48fcd
5 changed files with 81 additions and 3 deletions

View File

@@ -302,10 +302,26 @@ public class SubscriptionManager {
* subscription. * subscription.
* *
* Default value is 0. * 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"; 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. * 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 * <p> A Local-SIM can be a physical SIM inserted into a sim-slot in the device, or eSIM on the

View File

@@ -10975,4 +10975,52 @@ public class TelephonyManager {
} }
return true; 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;
}
} }

View File

@@ -1310,6 +1310,9 @@ public class ApnSetting implements Parcelable {
* @hide * @hide
*/ */
public static String getApnTypeString(int apnType) { public static String getApnTypeString(int apnType) {
if (apnType == TYPE_ALL) {
return "*";
}
String apnTypeString = APN_TYPE_INT_MAP.get(apnType); String apnTypeString = APN_TYPE_INT_MAP.get(apnType);
return apnTypeString == null ? "Unknown" : apnTypeString; return apnTypeString == null ? "Unknown" : apnTypeString;
} }

View File

@@ -94,7 +94,7 @@ public class DctConstants {
public static final int EVENT_ROAMING_SETTING_CHANGE = BASE + 48; 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_DATA_SERVICE_BINDING_CHANGED = BASE + 49;
public static final int EVENT_DEVICE_PROVISIONED_CHANGE = BASE + 50; 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 *****/ /***** Constants *****/

View File

@@ -1612,7 +1612,7 @@ interface ITelephony {
* <p> * <p>
* See {@link UiccCardInfo} for more details on the kind of information available. * See {@link UiccCardInfo} for more details on the kind of information available.
* *
* @param callingPackage package making the call, used to evaluate carrier privileges * @param callingPackage package making the call, used to evaluate carrier privileges
* @return a list of UiccCardInfo objects, representing information on the currently inserted * @return a list of UiccCardInfo objects, representing information on the currently inserted
* UICCs and eUICCs. Each UiccCardInfo in the list will have private information filtered out if * UICCs and eUICCs. Each UiccCardInfo in the list will have private information filtered out if
* the caller does not have adequate permissions for that card. * the caller does not have adequate permissions for that card.
@@ -1983,4 +1983,15 @@ interface ITelephony {
* Returns the MMS user agent profile URL. * Returns the MMS user agent profile URL.
*/ */
String getMmsUAProfUrl(int subId); 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);
} }