Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +27 −11 Original line number Diff line number Diff line Loading @@ -225,6 +225,7 @@ import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_ENTERPR import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_ENTERPRISE_NO_FALLBACK; import static android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK; import static android.provider.DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER; import static android.provider.DeviceConfig.NAMESPACE_TELEPHONY; import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER; import static android.provider.Settings.Secure.MANAGED_PROVISIONING_DPC_DOWNLOADED; import static android.provider.Settings.Secure.USER_SETUP_COMPLETE; Loading Loading @@ -3324,7 +3325,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { onLockSettingsReady(); loadAdminDataAsync(); mOwners.systemReady(); if (isWorkProfileTelephonyFlagEnabled()) { if (isWorkProfileTelephonyEnabled()) { applyManagedSubscriptionsPolicyIfRequired(); } break; Loading Loading @@ -7640,7 +7641,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } mLockSettingsInternal.refreshStrongAuthTimeout(parentId); if (isWorkProfileTelephonyFlagEnabled()) { if (isWorkProfileTelephonyEnabled()) { clearManagedSubscriptionsPolicy(); clearLauncherShortcutOverrides(); updateTelephonyCrossProfileIntentFilters(parentId, UserHandle.USER_NULL, false); Loading Loading @@ -10991,8 +10992,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (mSubscriptionsChangedListenerLock) { pw.println("Subscription changed listener : " + mSubscriptionsChangedListener); } pw.println( "Flag enable_work_profile_telephony : " + isWorkProfileTelephonyFlagEnabled()); pw.println("DPM Flag enable_work_profile_telephony : " + isWorkProfileTelephonyDevicePolicyManagerFlagEnabled()); pw.println("Telephony Flag enable_work_profile_telephony : " + isWorkProfileTelephonySubscriptionManagerFlagEnabled()); mHandler.post(() -> handleDump(pw)); dumpResources(pw); Loading Loading @@ -22705,11 +22708,24 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { DEFAULT_KEEP_PROFILES_RUNNING_FLAG); } private static boolean isWorkProfileTelephonyFlagEnabled() { return DeviceConfig.getBoolean( NAMESPACE_DEVICE_POLICY_MANAGER, ENABLE_WORK_PROFILE_TELEPHONY_FLAG, DEFAULT_WORK_PROFILE_TELEPHONY_FLAG); private boolean isWorkProfileTelephonyEnabled() { return isWorkProfileTelephonyDevicePolicyManagerFlagEnabled() && isWorkProfileTelephonySubscriptionManagerFlagEnabled(); } private boolean isWorkProfileTelephonyDevicePolicyManagerFlagEnabled() { return DeviceConfig.getBoolean(NAMESPACE_DEVICE_POLICY_MANAGER, ENABLE_WORK_PROFILE_TELEPHONY_FLAG, DEFAULT_WORK_PROFILE_TELEPHONY_FLAG); } private boolean isWorkProfileTelephonySubscriptionManagerFlagEnabled() { final long ident = mInjector.binderClearCallingIdentity(); try { return DeviceConfig.getBoolean(NAMESPACE_TELEPHONY, ENABLE_WORK_PROFILE_TELEPHONY_FLAG, false); } finally { mInjector.binderRestoreCallingIdentity(ident); } } @Override Loading Loading @@ -22822,7 +22838,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public ManagedSubscriptionsPolicy getManagedSubscriptionsPolicy() { if (isWorkProfileTelephonyFlagEnabled()) { if (isWorkProfileTelephonyEnabled()) { synchronized (getLockObject()) { ActiveAdmin admin = getProfileOwnerOfOrganizationOwnedDeviceLocked(); if (admin != null && admin.mManagedSubscriptionsPolicy != null) { Loading @@ -22836,7 +22852,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public void setManagedSubscriptionsPolicy(ManagedSubscriptionsPolicy policy) { if (!isWorkProfileTelephonyFlagEnabled()) { if (!isWorkProfileTelephonyEnabled()) { throw new UnsupportedOperationException("This api is not enabled"); } CallerIdentity caller = getCallerIdentity(); services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -5002,6 +5002,8 @@ public class DevicePolicyManagerTest extends DpmTestBase { configureProfileOwnerOfOrgOwnedDevice(admin1, CALLER_USER_HANDLE); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER, FLAG_ENABLE_WORK_PROFILE_TELEPHONY, "true", false); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY, FLAG_ENABLE_WORK_PROFILE_TELEPHONY, "true", false); // Even if the caller is the managed profile, the current user is the user 0 when(getServices().iactivityManager.getCurrentUser()) .thenReturn(new UserInfo(UserHandle.USER_SYSTEM, "user system", 0)); Loading Loading @@ -5064,6 +5066,8 @@ public class DevicePolicyManagerTest extends DpmTestBase { verify(getServices().subscriptionManager).setSubscriptionUserHandle(0, null); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER, FLAG_ENABLE_WORK_PROFILE_TELEPHONY, "false", false); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY, FLAG_ENABLE_WORK_PROFILE_TELEPHONY, "false", false); } @Test Loading Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +27 −11 Original line number Diff line number Diff line Loading @@ -225,6 +225,7 @@ import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_ENTERPR import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_ENTERPRISE_NO_FALLBACK; import static android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK; import static android.provider.DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER; import static android.provider.DeviceConfig.NAMESPACE_TELEPHONY; import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER; import static android.provider.Settings.Secure.MANAGED_PROVISIONING_DPC_DOWNLOADED; import static android.provider.Settings.Secure.USER_SETUP_COMPLETE; Loading Loading @@ -3324,7 +3325,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { onLockSettingsReady(); loadAdminDataAsync(); mOwners.systemReady(); if (isWorkProfileTelephonyFlagEnabled()) { if (isWorkProfileTelephonyEnabled()) { applyManagedSubscriptionsPolicyIfRequired(); } break; Loading Loading @@ -7640,7 +7641,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } mLockSettingsInternal.refreshStrongAuthTimeout(parentId); if (isWorkProfileTelephonyFlagEnabled()) { if (isWorkProfileTelephonyEnabled()) { clearManagedSubscriptionsPolicy(); clearLauncherShortcutOverrides(); updateTelephonyCrossProfileIntentFilters(parentId, UserHandle.USER_NULL, false); Loading Loading @@ -10991,8 +10992,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (mSubscriptionsChangedListenerLock) { pw.println("Subscription changed listener : " + mSubscriptionsChangedListener); } pw.println( "Flag enable_work_profile_telephony : " + isWorkProfileTelephonyFlagEnabled()); pw.println("DPM Flag enable_work_profile_telephony : " + isWorkProfileTelephonyDevicePolicyManagerFlagEnabled()); pw.println("Telephony Flag enable_work_profile_telephony : " + isWorkProfileTelephonySubscriptionManagerFlagEnabled()); mHandler.post(() -> handleDump(pw)); dumpResources(pw); Loading Loading @@ -22705,11 +22708,24 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { DEFAULT_KEEP_PROFILES_RUNNING_FLAG); } private static boolean isWorkProfileTelephonyFlagEnabled() { return DeviceConfig.getBoolean( NAMESPACE_DEVICE_POLICY_MANAGER, ENABLE_WORK_PROFILE_TELEPHONY_FLAG, DEFAULT_WORK_PROFILE_TELEPHONY_FLAG); private boolean isWorkProfileTelephonyEnabled() { return isWorkProfileTelephonyDevicePolicyManagerFlagEnabled() && isWorkProfileTelephonySubscriptionManagerFlagEnabled(); } private boolean isWorkProfileTelephonyDevicePolicyManagerFlagEnabled() { return DeviceConfig.getBoolean(NAMESPACE_DEVICE_POLICY_MANAGER, ENABLE_WORK_PROFILE_TELEPHONY_FLAG, DEFAULT_WORK_PROFILE_TELEPHONY_FLAG); } private boolean isWorkProfileTelephonySubscriptionManagerFlagEnabled() { final long ident = mInjector.binderClearCallingIdentity(); try { return DeviceConfig.getBoolean(NAMESPACE_TELEPHONY, ENABLE_WORK_PROFILE_TELEPHONY_FLAG, false); } finally { mInjector.binderRestoreCallingIdentity(ident); } } @Override Loading Loading @@ -22822,7 +22838,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public ManagedSubscriptionsPolicy getManagedSubscriptionsPolicy() { if (isWorkProfileTelephonyFlagEnabled()) { if (isWorkProfileTelephonyEnabled()) { synchronized (getLockObject()) { ActiveAdmin admin = getProfileOwnerOfOrganizationOwnedDeviceLocked(); if (admin != null && admin.mManagedSubscriptionsPolicy != null) { Loading @@ -22836,7 +22852,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public void setManagedSubscriptionsPolicy(ManagedSubscriptionsPolicy policy) { if (!isWorkProfileTelephonyFlagEnabled()) { if (!isWorkProfileTelephonyEnabled()) { throw new UnsupportedOperationException("This api is not enabled"); } CallerIdentity caller = getCallerIdentity();
services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -5002,6 +5002,8 @@ public class DevicePolicyManagerTest extends DpmTestBase { configureProfileOwnerOfOrgOwnedDevice(admin1, CALLER_USER_HANDLE); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER, FLAG_ENABLE_WORK_PROFILE_TELEPHONY, "true", false); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY, FLAG_ENABLE_WORK_PROFILE_TELEPHONY, "true", false); // Even if the caller is the managed profile, the current user is the user 0 when(getServices().iactivityManager.getCurrentUser()) .thenReturn(new UserInfo(UserHandle.USER_SYSTEM, "user system", 0)); Loading Loading @@ -5064,6 +5066,8 @@ public class DevicePolicyManagerTest extends DpmTestBase { verify(getServices().subscriptionManager).setSubscriptionUserHandle(0, null); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER, FLAG_ENABLE_WORK_PROFILE_TELEPHONY, "false", false); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY, FLAG_ENABLE_WORK_PROFILE_TELEPHONY, "false", false); } @Test Loading