Merge "Fixed OneTimeSafetyChecker callback." into sc-dev

This commit is contained in:
TreeHugger Robot
2021-02-22 04:18:27 +00:00
committed by Android (Google) Code Review
3 changed files with 5 additions and 7 deletions

View File

@@ -1073,6 +1073,7 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
private void onOperationSafetyStateChanged(Context context, Intent intent) {
if (!hasRequiredExtra(intent, EXTRA_OPERATION_SAFETY_REASON)
|| !hasRequiredExtra(intent, EXTRA_OPERATION_SAFETY_STATE)) {
Log.w(TAG, "Igoring intent that's missing required extras");
return;
}
@@ -1084,7 +1085,6 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
}
boolean isSafe = intent.getBooleanExtra(EXTRA_OPERATION_SAFETY_STATE,
/* defaultValue=*/ false);
onOperationSafetyStateChanged(context, reason, isSafe);
}

View File

@@ -12344,7 +12344,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
Slog.v(LOG_TAG, String.format("notifyUnsafeOperationStateChanged(): %s=%b",
DevicePolicyManager.operationSafetyReasonToString(reason), isSafe));
}
Preconditions.checkArgument(mSafetyChecker == checker,
"invalid checker: should be %s, was %s", mSafetyChecker, checker);
@@ -12352,7 +12351,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
extras.putInt(DeviceAdminReceiver.EXTRA_OPERATION_SAFETY_REASON, reason);
extras.putBoolean(DeviceAdminReceiver.EXTRA_OPERATION_SAFETY_STATE, isSafe);
// TODO(b/178494483): add CTS test
sendDeviceOwnerCommand(DeviceAdminReceiver.ACTION_OPERATION_SAFETY_STATE_CHANGED,
extras);
for (int profileOwnerId : mOwners.getProfileOwnerKeys()) {

View File

@@ -72,11 +72,11 @@ final class OneTimeSafetyChecker implements DevicePolicySafetyChecker {
DevicePolicyManagerInternal dpmi = LocalServices
.getService(DevicePolicyManagerInternal.class);
Slog.i(TAG, "notifying " + reasonName + " is active");
dpmi.notifyUnsafeOperationStateChanged(this, reason, true);
Slog.i(TAG, "notifying " + reasonName + " is UNSAFE");
dpmi.notifyUnsafeOperationStateChanged(this, reason, /* isSafe= */ false);
Slog.i(TAG, "notifying " + reasonName + " is inactive");
dpmi.notifyUnsafeOperationStateChanged(this, reason, false);
Slog.i(TAG, "notifying " + reasonName + " is SAFE");
dpmi.notifyUnsafeOperationStateChanged(this, reason, /* isSafe= */ true);
Slog.i(TAG, "returning " + reasonName);