summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorShuo Qian <shuoq@google.com>2021-02-17 23:39:17 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-02-17 23:39:17 +0000
commitdb9ef8e719c3b8a2c97f04070b05d0e4fd8d8ac3 (patch)
tree70f466049210159cf2da4e3858161fda63649ede /core/java/android
parentfe62a99c635cf5a068dd37ef4c604e69dd244dff (diff)
parentbdf653361180c1476f1950a75abfbf3109706f27 (diff)
Merge "Add APIs for updating, query 5G slicing status" into sc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java78
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl3
2 files changed, 81 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 305c22446e90..59e5144113c9 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -9851,6 +9851,84 @@ public class DevicePolicyManager {
}
/**
+ * Sets whether 5g slicing is enabled on the work profile.
+ *
+ * Slicing allows operators to virtually divide their networks in portions and use different
+ * portions for specific use cases; for example, a corporation can have a deal/agreement with
+ * a carrier that all of its employees’ devices use data on a slice dedicated for enterprise
+ * use.
+ *
+ * By default, 5g slicing is enabled on the work profile on supported carriers and devices.
+ * Admins can explicitly disable it with this API.
+ *
+ * <p>This method can only be called by the profile owner of a managed profile.
+ *
+ * @param enabled whether 5g Slice should be enabled.
+ * @throws SecurityException if the caller is not the profile owner.
+ **/
+ public void setNetworkSlicingEnabled(boolean enabled) {
+ throwIfParentInstance("setNetworkSlicingEnabled");
+ if (mService != null) {
+ try {
+ mService.setNetworkSlicingEnabled(enabled);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+ }
+
+ /**
+ * Indicates whether 5g slicing is enabled.
+ *
+ * <p>This method can be called by the profile owner of a managed profile.
+ *
+ * @return whether 5g Slice is enabled.
+ * @throws SecurityException if the caller is not the profile owner.
+ */
+ public boolean isNetworkSlicingEnabled() {
+ throwIfParentInstance("isNetworkSlicingEnabled");
+ if (mService == null) {
+ return false;
+ }
+ try {
+ return mService.isNetworkSlicingEnabled(myUserId());
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Indicates whether 5g slicing is enabled for specific user.
+ *
+ * This method can be called with permission
+ * {@link android.Manifest.permission#READ_NETWORK_DEVICE_CONFIG} by the profile owner of
+ * a managed profile. And the caller must hold the
+ * {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permission if query for
+ * other users.
+ *
+ * @param userHandle indicates the user to query the state
+ * @return indicates whether 5g Slice is enabled.
+ * @throws SecurityException if the caller is not granted the permission
+ * {@link android.Manifest.permission#READ_NETWORK_DEVICE_CONFIG}
+ * and not profile owner of a managed profile, and not granted the permission
+ * {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} if query for
+ * other users.
+ * @hide
+ */
+ @SystemApi
+ public boolean isNetworkSlicingEnabledForUser(@NonNull UserHandle userHandle) {
+ throwIfParentInstance("isNetworkSlicingEnabledForUser");
+ if (mService == null) {
+ return false;
+ }
+ try {
+ return mService.isNetworkSlicingEnabled(userHandle.getIdentifier());
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* This method is mostly deprecated.
* Most of the settings that still have an effect have dedicated setter methods or user
* restrictions. See individual settings for details.
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 91a9f3cff582..8a87b16b760b 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -267,6 +267,9 @@ interface IDevicePolicyManager {
void setSecondaryLockscreenEnabled(in ComponentName who, boolean enabled);
boolean isSecondaryLockscreenEnabled(in UserHandle userHandle);
+ void setNetworkSlicingEnabled(in boolean enabled);
+ boolean isNetworkSlicingEnabled(int userHandle);
+
void setLockTaskPackages(in ComponentName who, in String[] packages);
String[] getLockTaskPackages(in ComponentName who);
boolean isLockTaskPermitted(in String pkg);