My enterprise has 2 policies: POLICY_1 and POLICY_2. My device was provisioned with the POLICY_1, but I would like to change it to POLICY_2.
I'm using the Java lib 'com.google.apis:google-api-services-androidmanagement:v1-rev20201012-1.30.10'.
I'm trying to change its policy with the following code:
private void updateMyDevicePolicy(String enterpriseName, String deviceName) throws IOException {
Device device = getMyDevice(deviceName);
String policyName = enterpriseName + "/policies/POLICY_2";
device.setPolicyName(policyName);
device.setAppliedPolicyName(policyName);
Device deviceUpdated = androidManagementClient.enterprises().devices().patch(deviceName, device).execute();
System.out.println("DEVICE policy updated = " + deviceUpdated);
}
The problem is: The patch command does not work. The device policy remains "POLICY_1".
Please, how can I change the device policy?