Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdf65336 authored by Shuo Qian's avatar Shuo Qian
Browse files

Add APIs for updating, query 5G slicing status

Test: atest DevicePolicyManagerTest
Bug: 178655595
Change-Id: I6f823be6737f7c7b3dc918230cbb927fac97c6eb
Merged-In: I6f823be6737f7c7b3dc918230cbb927fac97c6eb
(cherry picked from commit 1f4ea44b)
parent 2fd099f1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -7080,6 +7080,7 @@ package android.app.admin {
    method public boolean isManagedProfile(@NonNull android.content.ComponentName);
    method public boolean isMasterVolumeMuted(@NonNull android.content.ComponentName);
    method public boolean isNetworkLoggingEnabled(@Nullable android.content.ComponentName);
    method public boolean isNetworkSlicingEnabled();
    method public boolean isOrganizationOwnedDeviceWithManagedProfile();
    method public boolean isOverrideApnEnabled(@NonNull android.content.ComponentName);
    method public boolean isPackageSuspended(@NonNull android.content.ComponentName, String) throws android.content.pm.PackageManager.NameNotFoundException;
@@ -7151,6 +7152,7 @@ package android.app.admin {
    method public void setMaximumTimeToLock(@NonNull android.content.ComponentName, long);
    method @NonNull public java.util.List<java.lang.String> setMeteredDataDisabledPackages(@NonNull android.content.ComponentName, @NonNull java.util.List<java.lang.String>);
    method public void setNetworkLoggingEnabled(@Nullable android.content.ComponentName, boolean);
    method public void setNetworkSlicingEnabled(boolean);
    method @Deprecated public void setOrganizationColor(@NonNull android.content.ComponentName, int);
    method public void setOrganizationId(@NonNull String);
    method public void setOrganizationName(@NonNull android.content.ComponentName, @Nullable CharSequence);
+2 −0
Original line number Diff line number Diff line
@@ -194,6 +194,7 @@ package android {
    field public static final String READ_DEVICE_CONFIG = "android.permission.READ_DEVICE_CONFIG";
    field public static final String READ_DREAM_STATE = "android.permission.READ_DREAM_STATE";
    field public static final String READ_INSTALL_SESSIONS = "android.permission.READ_INSTALL_SESSIONS";
    field public static final String READ_NETWORK_DEVICE_CONFIG = "android.permission.READ_NETWORK_DEVICE_CONFIG";
    field public static final String READ_NETWORK_USAGE_HISTORY = "android.permission.READ_NETWORK_USAGE_HISTORY";
    field public static final String READ_OEM_UNLOCK_STATE = "android.permission.READ_OEM_UNLOCK_STATE";
    field public static final String READ_PRINT_SERVICES = "android.permission.READ_PRINT_SERVICES";
@@ -888,6 +889,7 @@ package android.app.admin {
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioned();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioningConfigApplied();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isManagedKiosk();
    method public boolean isNetworkSlicingEnabledForUser(@NonNull android.os.UserHandle);
    method public boolean isSecondaryLockscreenEnabled(@NonNull android.os.UserHandle);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isUnattendedManagedKiosk();
    method @RequiresPermission("android.permission.NOTIFY_PENDING_SYSTEM_UPDATE") public void notifyPendingSystemUpdate(long);
+78 −0
Original line number Diff line number Diff line
@@ -9850,6 +9850,84 @@ public class DevicePolicyManager {
        return 0;
    }
    /**
     * 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
+3 −0
Original line number Diff line number Diff line
@@ -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);
+5 −0
Original line number Diff line number Diff line
@@ -2263,6 +2263,11 @@
    <permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
        android:protectionLevel="signature|privileged" />

    <!-- @SystemApi Allows read access to privileged network state in the device config.
         @hide Used internally. -->
    <permission android:name="android.permission.READ_NETWORK_DEVICE_CONFIG"
        android:protectionLevel="signature|privileged" />

    <!-- Allows to read device identifiers and use ICC based authentication like EAP-AKA.
         Often required in authentication to access the carrier's server and manage services
         of the subscriber.
Loading