diff options
| author | 2023-03-21 17:22:09 +0000 | |
|---|---|---|
| committer | 2023-03-21 17:22:09 +0000 | |
| commit | cedae13bc124e1f438a379d010f4beb06622c995 (patch) | |
| tree | 7e69075b3ca6bfab0056f8bc1bfb1a81d0fb8a5f | |
| parent | bc19561d32b99c0ffe2b8cffd57556a0dc0c3f83 (diff) | |
| parent | 2057a5de5c88b94b743c23eb118e3ac2e00998c1 (diff) | |
Merge "Check if SubscriptionManager changes are disabled" into udc-dev
2 files changed, 31 insertions, 11 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index e9c50b54f5dd..a43c9253221b 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -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; @@ -3324,7 +3325,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { onLockSettingsReady(); loadAdminDataAsync(); mOwners.systemReady(); - if (isWorkProfileTelephonyFlagEnabled()) { + if (isWorkProfileTelephonyEnabled()) { applyManagedSubscriptionsPolicyIfRequired(); } break; @@ -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); @@ -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); @@ -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 @@ -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) { @@ -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(); 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 aaabb286589c..4f74ef8b5f70 100644 --- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java @@ -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)); @@ -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 |