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

Commit 8daff29a authored by Kholoud Mohamed's avatar Kholoud Mohamed Committed by Android (Google) Code Review
Browse files

Merge "Migrate the setUsbDataSignalingEnabled api to the device policy engine"

parents c338f494 3c731be6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -540,6 +540,7 @@ package android.app.admin {
    field public static final String PERMITTED_INPUT_METHODS_POLICY = "permittedInputMethods";
    field public static final String PERSONAL_APPS_SUSPENDED_POLICY = "personalAppsSuspended";
    field public static final String SCREEN_CAPTURE_DISABLED_POLICY = "screenCaptureDisabled";
    field public static final String USB_DATA_SIGNALING_POLICY = "usbDataSignaling";
  }

  public class DevicePolicyManager {
+8 −0
Original line number Diff line number Diff line
@@ -159,6 +159,14 @@ public final class DevicePolicyIdentifiers {
     */
    public static final String CROSS_PROFILE_WIDGET_PROVIDER_POLICY = "crossProfileWidgetProvider";

    /**
     * String identifier for {@link DevicePolicyManager#setUsbDataSignalingEnabled}.
     *
     * @hide
     */
    @TestApi
    public static final String USB_DATA_SIGNALING_POLICY = "usbDataSignaling";

    /**
     * @hide
     */
+19 −20
Original line number Diff line number Diff line
@@ -16585,6 +16585,24 @@ public class DevicePolicyManager {
     * {@link #canUsbDataSignalingBeDisabled()} to check whether enabling or disabling USB data
     * signaling is supported on the device.
     *
     * Starting from {@link Build.VERSION_CODES#VANILLA_ICE_CREAM}, after the USB data signaling
     * policy has been set, {@link PolicyUpdateReceiver#onPolicySetResult(Context, String,
     * Bundle, TargetUser, PolicyUpdateResult)} will notify the admin on whether the policy was
     * successfully set or not. This callback will contain:
     * <ul>
     * li> The policy identifier {@link DevicePolicyIdentifiers#USB_DATA_SIGNALING_POLICY}
     * <li> The {@link TargetUser} that this policy relates to
     * <li> The {@link PolicyUpdateResult}, which will be
     * {@link PolicyUpdateResult#RESULT_POLICY_SET} if the policy was successfully set or the
     * reason the policy failed to be set
     * e.g. {@link PolicyUpdateResult#RESULT_FAILURE_CONFLICTING_ADMIN_POLICY})
     * </ul>
     * If there has been a change to the policy,
     * {@link PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser,
     * PolicyUpdateResult)} will notify the admin of this change. This callback will contain the
     * same parameters as PolicyUpdateReceiver#onPolicySetResult and the {@link PolicyUpdateResult}
     * will contain the reason why the policy changed.
     *
     * @param enabled whether USB data signaling should be enabled or not.
     * @throws SecurityException if the caller is not permitted to set this policy
     * @throws IllegalStateException if disabling USB data signaling is not supported or
@@ -16623,25 +16641,6 @@ public class DevicePolicyManager {
        return true;
    }
    /**
     * Called by the system to check whether USB data signaling is currently enabled for this user.
     *
     * @param userId which user to check for.
     * @return {@code true} if USB data signaling is enabled, {@code false} otherwise.
     * @hide
     */
    public boolean isUsbDataSignalingEnabledForUser(@UserIdInt int userId) {
        throwIfParentInstance("isUsbDataSignalingEnabledForUser");
        if (mService != null) {
            try {
                return mService.isUsbDataSignalingEnabledForUser(userId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return true;
    }
    /**
     * Returns whether enabling or disabling USB data signaling is supported on the device.
     *
+0 −1
Original line number Diff line number Diff line
@@ -565,7 +565,6 @@ interface IDevicePolicyManager {

    void setUsbDataSignalingEnabled(String callerPackage, boolean enabled);
    boolean isUsbDataSignalingEnabled(String callerPackage);
    boolean isUsbDataSignalingEnabledForUser(int userId);
    boolean canUsbDataSignalingBeDisabled();

    void setMinimumRequiredWifiSecurityLevel(String callerPackageName, int level);
+1 −1
Original line number Diff line number Diff line
@@ -409,7 +409,7 @@ public class RestrictedLockUtilsInternal extends RestrictedLockUtils {
     */
    public static EnforcedAdmin checkIfUsbDataSignalingIsDisabled(Context context, int userId) {
        DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
        if (dpm == null || dpm.isUsbDataSignalingEnabledForUser(userId)) {
        if (dpm == null || dpm.isUsbDataSignalingEnabled()) {
            return null;
        } else {
            EnforcedAdmin admin = getProfileOrDeviceOwner(context, getUserHandleOf(userId));
Loading