Added Data roaming user restriction

Added new user restriction DISALLOW_DATA_ROAMING, can only be set
by device owners.

Bug: 24890464
Change-Id: Ic4cb37dd5f9bbffa35f921751488ef7c7ff99452
This commit is contained in:
Mahaver Chopra
2015-12-17 11:02:37 +00:00
parent 66d298cab5
commit dea471ef54
6 changed files with 47 additions and 3 deletions

View File

@@ -28415,6 +28415,7 @@ package android.os {
field public static final java.lang.String DISALLOW_CONFIG_WIFI = "no_config_wifi";
field public static final java.lang.String DISALLOW_CREATE_WINDOWS = "no_create_windows";
field public static final java.lang.String DISALLOW_CROSS_PROFILE_COPY_PASTE = "no_cross_profile_copy_paste";
field public static final java.lang.String DISALLOW_DATA_ROAMING = "no_data_roaming";
field public static final java.lang.String DISALLOW_DEBUGGING_FEATURES = "no_debugging_features";
field public static final java.lang.String DISALLOW_FACTORY_RESET = "no_factory_reset";
field public static final java.lang.String DISALLOW_FUN = "no_fun";

View File

@@ -30418,6 +30418,7 @@ package android.os {
field public static final java.lang.String DISALLOW_CONFIG_WIFI = "no_config_wifi";
field public static final java.lang.String DISALLOW_CREATE_WINDOWS = "no_create_windows";
field public static final java.lang.String DISALLOW_CROSS_PROFILE_COPY_PASTE = "no_cross_profile_copy_paste";
field public static final java.lang.String DISALLOW_DATA_ROAMING = "no_data_roaming";
field public static final java.lang.String DISALLOW_DEBUGGING_FEATURES = "no_debugging_features";
field public static final java.lang.String DISALLOW_FACTORY_RESET = "no_factory_reset";
field public static final java.lang.String DISALLOW_FUN = "no_fun";

View File

@@ -28424,6 +28424,7 @@ package android.os {
field public static final java.lang.String DISALLOW_CONFIG_WIFI = "no_config_wifi";
field public static final java.lang.String DISALLOW_CREATE_WINDOWS = "no_create_windows";
field public static final java.lang.String DISALLOW_CROSS_PROFILE_COPY_PASTE = "no_cross_profile_copy_paste";
field public static final java.lang.String DISALLOW_DATA_ROAMING = "no_data_roaming";
field public static final java.lang.String DISALLOW_DEBUGGING_FEATURES = "no_debugging_features";
field public static final java.lang.String DISALLOW_FACTORY_RESET = "no_factory_reset";
field public static final java.lang.String DISALLOW_FUN = "no_fun";

View File

@@ -517,6 +517,16 @@ public class UserManager {
*/
public static final String DISALLOW_CAMERA = "no_camera";
/**
* Specifies if a user is not allowed to use cellular data when roaming. This can only be set by
* device owners. The default value is <code>false</code>.
*
* @see DevicePolicyManager#addUserRestriction(ComponentName, String)
* @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
* @see #getUserRestrictions()
*/
public static final String DISALLOW_DATA_ROAMING = "no_data_roaming";
/**
* Allows apps in the parent profile to handle web links from the managed profile.
*

View File

@@ -1010,6 +1010,11 @@ public class SettingsProvider extends ContentProvider {
break;
default:
if (setting.startsWith(Settings.Global.DATA_ROAMING)) {
if ("0".equals(value)) return false;
restriction = UserManager.DISALLOW_DATA_ROAMING;
break;
}
return false;
}

View File

@@ -33,6 +33,8 @@ import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.util.Log;
import org.xmlpull.v1.XmlPullParser;
@@ -40,10 +42,11 @@ import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Set;
/**
* Utility methods for uesr restrictions.
* Utility methods for user restrictions.
*
* <p>See {@link UserManagerService} for the method suffixes.
*/
@@ -88,7 +91,8 @@ public class UserRestrictionsUtils {
UserManager.ALLOW_PARENT_PROFILE_APP_LINKING,
UserManager.DISALLOW_RECORD_AUDIO,
UserManager.DISALLOW_CAMERA,
UserManager.DISALLOW_RUN_IN_BACKGROUND
UserManager.DISALLOW_RUN_IN_BACKGROUND,
UserManager.DISALLOW_DATA_ROAMING
);
/**
@@ -113,7 +117,8 @@ public class UserRestrictionsUtils {
UserManager.DISALLOW_SMS,
UserManager.DISALLOW_FUN,
UserManager.DISALLOW_SAFE_BOOT,
UserManager.DISALLOW_CREATE_WINDOWS
UserManager.DISALLOW_CREATE_WINDOWS,
UserManager.DISALLOW_DATA_ROAMING
);
/**
@@ -315,6 +320,27 @@ public class UserRestrictionsUtils {
.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0, userId);
}
break;
case UserManager.DISALLOW_DATA_ROAMING:
if (newValue) {
// DISALLOW_DATA_ROAMING user restriction is set.
// Multi sim device.
SubscriptionManager subscriptionManager = new SubscriptionManager(context);
final List<SubscriptionInfo> subscriptionInfoList =
subscriptionManager.getActiveSubscriptionInfoList();
if (subscriptionInfoList != null) {
for (SubscriptionInfo subInfo : subscriptionInfoList) {
android.provider.Settings.Global.putStringForUser(cr,
android.provider.Settings.Global.DATA_ROAMING
+ subInfo.getSubscriptionId(), "0", userId);
}
}
// Single sim device.
android.provider.Settings.Global.putStringForUser(cr,
android.provider.Settings.Global.DATA_ROAMING, "0", userId);
}
break;
case UserManager.DISALLOW_SHARE_LOCATION:
if (newValue) {
android.provider.Settings.Secure.putIntForUser(cr,