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

Commit 3c0f63ab authored by Rubin Xu's avatar Rubin Xu Committed by Android (Google) Code Review
Browse files

Merge "DPM.isUsbDataSignalingEnabled() callable on unmanaged device" into sc-dev

parents e8db0791 b4fe2478
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -13896,7 +13896,11 @@ public class DevicePolicyManager {
    }
    /**
     * Returns whether USB data signaling is currently enabled by the admin. Callable by any app.
     * Returns whether USB data signaling is currently enabled.
     *
     * <p> When called by a device owner or profile owner of an organization-owned managed profile,
     * this API returns whether USB data signaling is currently enabled by that admin. When called
     * by any other app, returns whether USB data signaling is currently enabled on the device.
     *
     * @return {@code true} if USB data signaling is enabled, {@code false} otherwise.
     */
+15 −6
Original line number Diff line number Diff line
@@ -17565,10 +17565,15 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    @Override
    public boolean isUsbDataSignalingEnabled(String packageName) {
        final CallerIdentity caller = getCallerIdentity(packageName);
        synchronized (getLockObject()) {
            final ActiveAdmin admin = getProfileOwnerOrDeviceOwnerLocked(
                    getCallerIdentity(packageName));
            return admin.mUsbDataSignalingEnabled;
            // If the caller is an admin, return the policy set by itself. Otherwise
            // return the device-wide policy.
            if (isDeviceOwner(caller) || isProfileOwnerOfOrganizationOwnedDevice(caller)) {
                return getProfileOwnerOrDeviceOwnerLocked(caller).mUsbDataSignalingEnabled;
            } else {
                return isUsbDataSignalingEnabledInternalLocked();
            }
        }
    }
@@ -17578,11 +17583,15 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        Preconditions.checkCallAuthorization(isSystemUid(caller));
        synchronized (getLockObject()) {
            return isUsbDataSignalingEnabledInternalLocked();
        }
    }
    private boolean isUsbDataSignalingEnabledInternalLocked() {
        final ActiveAdmin admin = getDeviceOwnerOrProfileOwnerOfOrganizationOwnedDeviceLocked(
                UserHandle.USER_SYSTEM);
        return admin == null || admin.mUsbDataSignalingEnabled;
    }
    }
    @Override
    public boolean canUsbDataSignalingBeDisabled() {