Always sync user restriction state to UserManager
On certain Android 14 builds, global restrictions set by the DPC can errornously go into UserManager's local restriction store, resulting in a bad state where they cannot be unset in future. Fix this by always force syncing user restrictions from the policy engine to the UserManager when a restriction is being set or cleared by the DPC. The force sync ensures that both local and global restriction states of UserManager are consistent with policy engine, for the restriction that is being updated. Ran through the following manual tests: 1. (DO) Start with A14 bad build, set global restrictions -> OTA to this fix -> try clearing policy 2. (DO) Start with A14 bad build, set global restrictions -> reboot device -> OTA to this fix -> try clearing policy 3. (DO) A13 with local & global restrictions set -> OTA to A14 bad build -> set same restrictions again -> OTA to this fix -> try clearing policy 4. (DO) A13 with local & global restrictions set -> OTA to A14 bad build -> reboot device -> set same restrictions again -> OTA to this fix -> try clearing policy 5. (DO) A13 with local & global restrictions set -> OTA to A14 bad build -> OTA to this fix -> try clearing policy 6. (DO) A13 with local & global restrictions set -> OTA to A14 bad build -> reboot device -> OTA to this fix -> try clearing policy 7. (DO) A13 with local & global restrictions set -> OTA to this fix -> try clearing policy 8. (BYOD PO) A13 with global restrictions set -> OTA to A14 bad build -> reboot device -> OTA to this fix -> try clearing policy Case 1 & 2: fresh A14 setup Case 3 & 4: OTA'ed devices with workaround applied Case 5 & 6: OTA'ed devices without workaround applied Case 7: directly OTA'ed to build with fix Case 8: same as case 5 & 6 but on a BYOD PO device Bug: 311687929 Bug: 299302474 Test: btest a.d.c.PolicyEngineTest Test: atest android.devicepolicy.cts.UserRestrictionsTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:5394ddbee5dd88a35e2a9a8508dc260395895ac1) Merged-In: I4d700bc42ec114d1c0fc86f230f7f7612819195c Change-Id: I4d700bc42ec114d1c0fc86f230f7f7612819195c
Loading
Please register or sign in to comment