Allow any apps to call DPM.isUsbDataSignalingEnabled()
This is to allow 3p apps to query the state of the policy so they can show appropriate UX to the user in case the app's interaction with the plugged-in USB devices is disrupted by the admin policy. Bug: 190024751 Test: atest FrameworksServicesTests:DevicePolicyManagerTest Change-Id: I829ff84256e0288b88c11add53da312ee2bc2558
This commit is contained in:
@@ -13872,8 +13872,7 @@ public class DevicePolicyManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by device owner or profile owner of an organization-owned managed profile to return
|
||||
* whether USB data signaling is currently enabled by the admin.
|
||||
* Returns whether USB data signaling is currently enabled by the admin. Callable by any app.
|
||||
*
|
||||
* @return {@code true} if USB data signaling is enabled, {@code false} otherwise.
|
||||
*/
|
||||
|
||||
@@ -17415,14 +17415,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
|
||||
@Override
|
||||
public boolean isUsbDataSignalingEnabled(String packageName) {
|
||||
final CallerIdentity caller = getCallerIdentity(packageName);
|
||||
Preconditions.checkCallAuthorization(
|
||||
isDeviceOwner(caller) || isProfileOwnerOfOrganizationOwnedDevice(caller),
|
||||
"USB data signaling can only be controlled by a device owner or "
|
||||
+ "a profile owner on an organization-owned device.");
|
||||
|
||||
synchronized (getLockObject()) {
|
||||
final ActiveAdmin admin = getProfileOwnerOrDeviceOwnerLocked(caller);
|
||||
final ActiveAdmin admin = getProfileOwnerOrDeviceOwnerLocked(
|
||||
getCallerIdentity(packageName));
|
||||
return admin.mUsbDataSignalingEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user