Fix boot-loop vulnerability in setPermissionGrantState A malicious BYOD work-profile DPC could persistently boot-loop the device by passing an out-of-range `grantState` to `setPermissionGrantState()`. This unvalidated value was saved to disk and threw an uncaught `IllegalArgumentException` during subsequent `system_server` boots, requiring a factory reset. This commit fixes the issue by: 1. Adding a `Preconditions.checkArgument` in `DevicePolicyManagerService` to validate the `grantState` when the coexistence flag is enabled, preventing invalid states from being stored. 2. Wrapping policy re-application calls in `DevicePolicyEngine` with try-catch blocks to ensure that any invalid saved policy state logs a non-fatal error instead of crashing the `system_server` during boot. Test: Added and ran testSetPermissionGrantState_coexistence_invalidState_throwsException in DevicePolicyManagerTest Bug: 515158597 Flag: EXEMPT BUGFIX This was autogenerated by MendIt (go/androidmendit) Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:f5cf9571ac81791f9245fd16dfcf42ecd51c793d Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:213028e7bf0b005e9db136abd3c50029ee1fa5a9 Merged-In: I090604a48f409e5109327217f642730258fb720f Change-Id: I090604a48f409e5109327217f642730258fb720f