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

Commit 387668c0 authored by Rubin Xu's avatar Rubin Xu Committed by Automerger Merge Worker
Browse files

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

Merge "DPM.isUsbDataSignalingEnabled() callable on unmanaged device" into sc-dev am: 3c0f63ab am: 97fdd9f0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15042814

Change-Id: I859cb4baa91173e7bc183279b7bbeb20b39da10d
parents b383d37f 97fdd9f0
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() {