Merge "Fixed OneTimeSafetyChecker callback." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
caf9ae8b52
@@ -1073,6 +1073,7 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
|
|||||||
private void onOperationSafetyStateChanged(Context context, Intent intent) {
|
private void onOperationSafetyStateChanged(Context context, Intent intent) {
|
||||||
if (!hasRequiredExtra(intent, EXTRA_OPERATION_SAFETY_REASON)
|
if (!hasRequiredExtra(intent, EXTRA_OPERATION_SAFETY_REASON)
|
||||||
|| !hasRequiredExtra(intent, EXTRA_OPERATION_SAFETY_STATE)) {
|
|| !hasRequiredExtra(intent, EXTRA_OPERATION_SAFETY_STATE)) {
|
||||||
|
Log.w(TAG, "Igoring intent that's missing required extras");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1084,7 +1085,6 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
boolean isSafe = intent.getBooleanExtra(EXTRA_OPERATION_SAFETY_STATE,
|
boolean isSafe = intent.getBooleanExtra(EXTRA_OPERATION_SAFETY_STATE,
|
||||||
/* defaultValue=*/ false);
|
/* defaultValue=*/ false);
|
||||||
|
|
||||||
onOperationSafetyStateChanged(context, reason, isSafe);
|
onOperationSafetyStateChanged(context, reason, isSafe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12344,7 +12344,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
|||||||
Slog.v(LOG_TAG, String.format("notifyUnsafeOperationStateChanged(): %s=%b",
|
Slog.v(LOG_TAG, String.format("notifyUnsafeOperationStateChanged(): %s=%b",
|
||||||
DevicePolicyManager.operationSafetyReasonToString(reason), isSafe));
|
DevicePolicyManager.operationSafetyReasonToString(reason), isSafe));
|
||||||
}
|
}
|
||||||
|
|
||||||
Preconditions.checkArgument(mSafetyChecker == checker,
|
Preconditions.checkArgument(mSafetyChecker == checker,
|
||||||
"invalid checker: should be %s, was %s", 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.putInt(DeviceAdminReceiver.EXTRA_OPERATION_SAFETY_REASON, reason);
|
||||||
extras.putBoolean(DeviceAdminReceiver.EXTRA_OPERATION_SAFETY_STATE, isSafe);
|
extras.putBoolean(DeviceAdminReceiver.EXTRA_OPERATION_SAFETY_STATE, isSafe);
|
||||||
|
|
||||||
// TODO(b/178494483): add CTS test
|
|
||||||
sendDeviceOwnerCommand(DeviceAdminReceiver.ACTION_OPERATION_SAFETY_STATE_CHANGED,
|
sendDeviceOwnerCommand(DeviceAdminReceiver.ACTION_OPERATION_SAFETY_STATE_CHANGED,
|
||||||
extras);
|
extras);
|
||||||
for (int profileOwnerId : mOwners.getProfileOwnerKeys()) {
|
for (int profileOwnerId : mOwners.getProfileOwnerKeys()) {
|
||||||
|
|||||||
@@ -72,11 +72,11 @@ final class OneTimeSafetyChecker implements DevicePolicySafetyChecker {
|
|||||||
DevicePolicyManagerInternal dpmi = LocalServices
|
DevicePolicyManagerInternal dpmi = LocalServices
|
||||||
.getService(DevicePolicyManagerInternal.class);
|
.getService(DevicePolicyManagerInternal.class);
|
||||||
|
|
||||||
Slog.i(TAG, "notifying " + reasonName + " is active");
|
Slog.i(TAG, "notifying " + reasonName + " is UNSAFE");
|
||||||
dpmi.notifyUnsafeOperationStateChanged(this, reason, true);
|
dpmi.notifyUnsafeOperationStateChanged(this, reason, /* isSafe= */ false);
|
||||||
|
|
||||||
Slog.i(TAG, "notifying " + reasonName + " is inactive");
|
Slog.i(TAG, "notifying " + reasonName + " is SAFE");
|
||||||
dpmi.notifyUnsafeOperationStateChanged(this, reason, false);
|
dpmi.notifyUnsafeOperationStateChanged(this, reason, /* isSafe= */ true);
|
||||||
|
|
||||||
Slog.i(TAG, "returning " + reasonName);
|
Slog.i(TAG, "returning " + reasonName);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user