Merge "fix result code for user controlled disabled package" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6d5bec185a
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.server.devicepolicy;
|
package com.android.server.devicepolicy;
|
||||||
|
|
||||||
|
import static android.app.admin.DevicePolicyIdentifiers.USER_CONTROL_DISABLED_PACKAGES_POLICY;
|
||||||
import static android.app.admin.PolicyUpdateReceiver.EXTRA_POLICY_TARGET_USER_ID;
|
import static android.app.admin.PolicyUpdateReceiver.EXTRA_POLICY_TARGET_USER_ID;
|
||||||
import static android.app.admin.PolicyUpdateReceiver.EXTRA_POLICY_UPDATE_RESULT_KEY;
|
import static android.app.admin.PolicyUpdateReceiver.EXTRA_POLICY_UPDATE_RESULT_KEY;
|
||||||
import static android.app.admin.PolicyUpdateResult.RESULT_FAILURE_CONFLICTING_ADMIN_POLICY;
|
import static android.app.admin.PolicyUpdateResult.RESULT_FAILURE_CONFLICTING_ADMIN_POLICY;
|
||||||
@@ -176,6 +177,16 @@ final class DevicePolicyEngine {
|
|||||||
}
|
}
|
||||||
boolean policyEnforced = Objects.equals(
|
boolean policyEnforced = Objects.equals(
|
||||||
localPolicyState.getCurrentResolvedPolicy(), value);
|
localPolicyState.getCurrentResolvedPolicy(), value);
|
||||||
|
// TODO(b/285532044): remove hack and handle properly
|
||||||
|
if (!policyEnforced
|
||||||
|
&& policyDefinition.getPolicyKey().getIdentifier().equals(
|
||||||
|
USER_CONTROL_DISABLED_PACKAGES_POLICY)) {
|
||||||
|
PolicyValue<Set<String>> parsedValue = (PolicyValue<Set<String>>) value;
|
||||||
|
PolicyValue<Set<String>> parsedResolvedValue =
|
||||||
|
(PolicyValue<Set<String>>) localPolicyState.getCurrentResolvedPolicy();
|
||||||
|
policyEnforced = (parsedResolvedValue != null && parsedValue != null
|
||||||
|
&& parsedResolvedValue.getValue().containsAll(parsedValue.getValue()));
|
||||||
|
}
|
||||||
sendPolicyResultToAdmin(
|
sendPolicyResultToAdmin(
|
||||||
enforcingAdmin,
|
enforcingAdmin,
|
||||||
policyDefinition,
|
policyDefinition,
|
||||||
@@ -418,6 +429,17 @@ final class DevicePolicyEngine {
|
|||||||
|
|
||||||
boolean policyAppliedGlobally = Objects.equals(
|
boolean policyAppliedGlobally = Objects.equals(
|
||||||
globalPolicyState.getCurrentResolvedPolicy(), value);
|
globalPolicyState.getCurrentResolvedPolicy(), value);
|
||||||
|
// TODO(b/285532044): remove hack and handle properly
|
||||||
|
if (!policyAppliedGlobally
|
||||||
|
&& policyDefinition.getPolicyKey().getIdentifier().equals(
|
||||||
|
USER_CONTROL_DISABLED_PACKAGES_POLICY)) {
|
||||||
|
PolicyValue<Set<String>> parsedValue = (PolicyValue<Set<String>>) value;
|
||||||
|
PolicyValue<Set<String>> parsedResolvedValue =
|
||||||
|
(PolicyValue<Set<String>>) globalPolicyState.getCurrentResolvedPolicy();
|
||||||
|
policyAppliedGlobally = (parsedResolvedValue != null && parsedValue != null
|
||||||
|
&& parsedResolvedValue.getValue().containsAll(parsedValue.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
boolean policyApplied = policyAppliedGlobally && policyAppliedOnAllUsers;
|
boolean policyApplied = policyAppliedGlobally && policyAppliedOnAllUsers;
|
||||||
|
|
||||||
sendPolicyResultToAdmin(
|
sendPolicyResultToAdmin(
|
||||||
@@ -539,9 +561,21 @@ final class DevicePolicyEngine {
|
|||||||
userId);
|
userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// TODO(b/285532044): remove hack and handle properly
|
||||||
|
if (policyDefinition.getPolicyKey().getIdentifier().equals(
|
||||||
|
USER_CONTROL_DISABLED_PACKAGES_POLICY)) {
|
||||||
|
if (!Objects.equals(value, localPolicyState.getCurrentResolvedPolicy())) {
|
||||||
|
PolicyValue<Set<String>> parsedValue = (PolicyValue<Set<String>>) value;
|
||||||
|
PolicyValue<Set<String>> parsedResolvedValue =
|
||||||
|
(PolicyValue<Set<String>>) localPolicyState.getCurrentResolvedPolicy();
|
||||||
|
isAdminPolicyApplied &= (parsedResolvedValue != null && parsedValue != null
|
||||||
|
&& parsedResolvedValue.getValue().containsAll(parsedValue.getValue()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
isAdminPolicyApplied &= Objects.equals(
|
isAdminPolicyApplied &= Objects.equals(
|
||||||
value, localPolicyState.getCurrentResolvedPolicy());
|
value, localPolicyState.getCurrentResolvedPolicy());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return isAdminPolicyApplied;
|
return isAdminPolicyApplied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user