Merge "send DEVICE_POLICY_MANAGER_STATE_CHANGED to system services" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b9ed644187
@@ -27,6 +27,7 @@ import static android.content.pm.UserProperties.INHERIT_DEVICE_POLICY_FROM_PAREN
|
||||
import android.Manifest;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.BroadcastOptions;
|
||||
import android.app.admin.DevicePolicyIdentifiers;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.admin.DevicePolicyState;
|
||||
@@ -353,6 +354,7 @@ final class DevicePolicyEngine {
|
||||
policyDefinition,
|
||||
userId);
|
||||
}
|
||||
sendDevicePolicyChangedToSystem(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -478,6 +480,8 @@ final class DevicePolicyEngine {
|
||||
enforcingAdmin,
|
||||
policyDefinition,
|
||||
UserHandle.USER_ALL);
|
||||
|
||||
sendDevicePolicyChangedToSystem(UserHandle.USER_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -761,6 +765,20 @@ final class DevicePolicyEngine {
|
||||
policyValue == null ? null : policyValue.getValue(), mContext, userId);
|
||||
}
|
||||
|
||||
private void sendDevicePolicyChangedToSystem(int userId) {
|
||||
Intent intent = new Intent(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
|
||||
intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
|
||||
Bundle options = new BroadcastOptions()
|
||||
.setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
|
||||
.setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
|
||||
.toBundle();
|
||||
Binder.withCleanCallingIdentity(() -> mContext.sendBroadcastAsUser(
|
||||
intent,
|
||||
new UserHandle(userId),
|
||||
/* receiverPermissions= */ null,
|
||||
options));
|
||||
}
|
||||
|
||||
private <V> void sendPolicyResultToAdmin(
|
||||
EnforcingAdmin admin, PolicyDefinition<V> policyDefinition, int result, int userId) {
|
||||
Intent intent = new Intent(PolicyUpdateReceiver.ACTION_DEVICE_POLICY_SET_RESULT);
|
||||
|
||||
Reference in New Issue
Block a user