Fix minor issues.

Test: btest CtsDevicePolicyTestCases
Bug: 280269495
Change-Id: I0f78cb714253091e54951a3928d546adb86d2954
This commit is contained in:
Jonathan Scott
2023-05-09 11:09:36 +00:00
parent d6a5b13008
commit ae1653b95e
2 changed files with 13 additions and 5 deletions

View File

@@ -8742,6 +8742,7 @@ public class DevicePolicyManager {
*/
@RequiresPermission(anyOf = {SET_TIME, QUERY_ADMIN_POLICY}, conditional = true)
public boolean getAutoTimeEnabled(@Nullable ComponentName admin) {
throwIfParentInstance("getAutoTimeEnabled");
if (mService != null) {
try {
return mService.getAutoTimeEnabled(admin, mContext.getPackageName());

View File

@@ -447,6 +447,7 @@ import android.util.AtomicFile;
import android.util.DebugUtils;
import android.util.IndentingPrintWriter;
import android.util.IntArray;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
@@ -12079,7 +12080,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
Objects.requireNonNull(who, "ComponentName is null");
final CallerIdentity caller = getCallerIdentity(who);
Preconditions.checkCallAuthorization(
isDeviceOwner(caller) || isProfileOwner(caller));
isDefaultDeviceOwner(caller) || isProfileOwner(caller));
if (packageList != null) {
for (String pkg : packageList) {
@@ -13364,8 +13365,14 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
PolicyDefinition<Boolean> policyDefinition =
PolicyDefinition.getPolicyDefinitionForUserRestriction(key);
if (enabledFromThisOwner) {
setLocalUserRestrictionInternal(
admin, key, /* enabled= */ true, affectedUserId);
// TODO: Remove this special case - replace with breaking change to require
// setGlobally to disable ADB
if (key.equals(UserManager.DISALLOW_DEBUGGING_FEATURES) && parent) {
setGlobalUserRestrictionInternal(admin, key, /* enabled= */ true);
} else {
setLocalUserRestrictionInternal(
admin, key, /* enabled= */ true, affectedUserId);
}
} else {
// Remove any local and global policy that was set by the admin
if (!policyDefinition.isLocalOnlyPolicy()) {
@@ -15154,7 +15161,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.SET_LOCKTASK_MODE_ENABLED)
.setAdmin(admin.info.getPackageName())
.setAdmin(admin.info == null ? null : admin.info.getPackageName())
.setBoolean(isEnabled)
.setStrings(pkg)
.write();
@@ -22718,7 +22725,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
private void handleFinancedDeviceKioskRoleChange() {
if (!isPermissionCheckFlagEnabled()) {
if (!isPolicyEngineForFinanceFlagEnabled()) {
return;
}
Slog.i(LOG_TAG, "Handling action " + ACTION_DEVICE_FINANCING_STATE_CHANGED);