diff options
author | 2021-05-20 11:03:07 -0700 | |
---|---|---|
committer | 2021-05-21 22:49:43 +0000 | |
commit | 63c9e34ae9dea99c72048f971e1dfc47479b13bb (patch) | |
tree | 52fa55fac84d80df8359e8a8afd07bb172299d3f | |
parent | f00bff3308b689f3d3f4d6d5dc9ab5a8c431951f (diff) |
Change default value from true to false for preferential network service enabling
Test: atest DevicePolicyManagerTest#testSetGetPreferentialNetworkServiceEnabled;
atest DevicePolicyManagerTest#testUpdateNetworkPreferenceOnStartUser;
atest DevicePolicyManagerTest#testUpdateNetworkPreferenceOnStopUser;
atest MixedManagedProfileOwnerTest#testSetPreferentialNetworkServiceStatusLogged;
atest MixedManagedProfileOwnerTest#testSetGetPreferentialNetworkServiceStatus
Bug: 187771747
Change-Id: I3c7af4de7fb2c8ed284a27ada9092450e32aeb89
4 files changed, 25 insertions, 11 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index c23cacb6a4c2..8d747961fab1 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -505,6 +505,13 @@ public class DevicePolicyManager { "android.app.extra.bugreport_notification_type"; /** + * Default value for preferential network service enabling. + * + * @hide + */ + public static final boolean PREFERENTIAL_NETWORK_SERVICE_ENABLED_DEFAULT = false; + + /** * Notification type for a started remote bugreport flow. * * @hide diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java b/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java index ff7514a377e5..8d43bbb37c71 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/ActiveAdmin.java @@ -150,7 +150,6 @@ class ActiveAdmin { private static final String ATTR_VALUE = "value"; private static final String ATTR_LAST_NETWORK_LOGGING_NOTIFICATION = "last-notification"; private static final String ATTR_NUM_NETWORK_LOGGING_NOTIFICATIONS = "num-notifications"; - private static final boolean PREFERENTIAL_NETWORK_SERVICE_ENABLED_DEFAULT = true; DeviceAdminInfo info; @@ -297,7 +296,7 @@ class ActiveAdmin { public String mEnrollmentSpecificId; public boolean mAdminCanGrantSensorsPermissions; public boolean mPreferentialNetworkServiceEnabled = - PREFERENTIAL_NETWORK_SERVICE_ENABLED_DEFAULT; + DevicePolicyManager.PREFERENTIAL_NETWORK_SERVICE_ENABLED_DEFAULT; private static final boolean USB_DATA_SIGNALING_ENABLED_DEFAULT = true; boolean mUsbDataSignalingEnabled = USB_DATA_SIGNALING_ENABLED_DEFAULT; @@ -576,10 +575,8 @@ class ActiveAdmin { } writeAttributeValueToXml(out, TAG_ADMIN_CAN_GRANT_SENSORS_PERMISSIONS, mAdminCanGrantSensorsPermissions); - if (mPreferentialNetworkServiceEnabled != PREFERENTIAL_NETWORK_SERVICE_ENABLED_DEFAULT) { - writeAttributeValueToXml(out, TAG_PREFERENTIAL_NETWORK_SERVICE_ENABLED, - mPreferentialNetworkServiceEnabled); - } + writeAttributeValueToXml(out, TAG_PREFERENTIAL_NETWORK_SERVICE_ENABLED, + mPreferentialNetworkServiceEnabled); if (mUsbDataSignalingEnabled != USB_DATA_SIGNALING_ENABLED_DEFAULT) { writeAttributeValueToXml(out, TAG_USB_DATA_SIGNALING, mUsbDataSignalingEnabled); } @@ -807,8 +804,8 @@ class ActiveAdmin { } else if (TAG_ALWAYS_ON_VPN_LOCKDOWN.equals(tag)) { mAlwaysOnVpnLockdown = parser.getAttributeBoolean(null, ATTR_VALUE, false); } else if (TAG_PREFERENTIAL_NETWORK_SERVICE_ENABLED.equals(tag)) { - mPreferentialNetworkServiceEnabled = parser.getAttributeBoolean( - null, ATTR_VALUE, PREFERENTIAL_NETWORK_SERVICE_ENABLED_DEFAULT); + mPreferentialNetworkServiceEnabled = parser.getAttributeBoolean(null, ATTR_VALUE, + DevicePolicyManager.PREFERENTIAL_NETWORK_SERVICE_ENABLED_DEFAULT); } else if (TAG_COMMON_CRITERIA_MODE.equals(tag)) { mCommonCriteriaMode = parser.getAttributeBoolean(null, ATTR_VALUE, false); } else if (TAG_PASSWORD_COMPLEXITY.equals(tag)) { diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 8089fb102513..64e4da98537f 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -3176,11 +3176,12 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { updatePermissionPolicyCache(userId); updateAdminCanGrantSensorsPermissionCache(userId); - boolean preferentialNetworkServiceEnabled = true; + final boolean preferentialNetworkServiceEnabled; synchronized (getLockObject()) { ActiveAdmin owner = getDeviceOrProfileOwnerAdminLocked(userId); preferentialNetworkServiceEnabled = owner != null - ? owner.mPreferentialNetworkServiceEnabled : true; + ? owner.mPreferentialNetworkServiceEnabled + : DevicePolicyManager.PREFERENTIAL_NETWORK_SERVICE_ENABLED_DEFAULT; } updateNetworkPreferenceForUser(userId, preferentialNetworkServiceEnabled); diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java index bfdf5af259f6..654d9fcf9210 100644 --- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java @@ -4030,7 +4030,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { } @Test - public void testUpdateNetworkPreferenceOnStartOnStopUser() throws Exception { + public void testUpdateNetworkPreferenceOnStartUser() throws Exception { final int managedProfileUserId = 15; final int managedProfileAdminUid = UserHandle.getUid(managedProfileUserId, 19436); addManagedProfile(admin1, managedProfileAdminUid, admin1); @@ -4044,6 +4044,15 @@ public class DevicePolicyManagerTest extends DpmTestBase { any(), any() ); + } + + @Test + public void testUpdateNetworkPreferenceOnStopUser() throws Exception { + final int managedProfileUserId = 15; + final int managedProfileAdminUid = UserHandle.getUid(managedProfileUserId, 19436); + addManagedProfile(admin1, managedProfileAdminUid, admin1); + mContext.binder.callingUid = managedProfileAdminUid; + mServiceContext.permissions.add(permission.INTERACT_ACROSS_USERS_FULL); dpms.handleStopUser(managedProfileUserId); verify(getServices().connectivityManager, times(1)).setProfileNetworkPreference( |