From 3520557a7c6836c98cd3c943028ab7db6b265b78 Mon Sep 17 00:00:00 2001 From: Muhammad Hasan Khan Date: Fri, 7 Jan 2022 18:13:11 +0000 Subject: [PATCH] arc: Do not construct RestrictionSet with empty restrictions bundle The legacy device_policy_restrictions tag can be empty and the code tries to construct a restriction set with the empty bundle which causes a crash. The newer device_policy_local_restrictions parses correctly with empty body because the parsing code avoids passing empty bundle to the set. In this fix we're adding a check on the bundle emptiness before constructing the restriction set with it. Bug: 213364202 Test: replace the new tag with the legacy tag and verify that app launches successfully Change-Id: Ib8dbbb4a550c4309e2243bf0611bb6c8565c0e96 --- .../java/com/android/server/pm/UserManagerService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index 6d8137e740613..075275ac533c2 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -3402,8 +3402,11 @@ public class UserManagerService extends IUserManager.Stub { Slog.wtf(LOG_TAG, "Seeing both legacy and current local restrictions in xml"); } } else if (legacyLocalRestrictions != null) { - mDevicePolicyLocalUserRestrictions.put(id, - new RestrictionsSet(id, legacyLocalRestrictions)); + RestrictionsSet legacyLocalRestrictionsSet = + legacyLocalRestrictions.isEmpty() + ? new RestrictionsSet() + : new RestrictionsSet(id, legacyLocalRestrictions); + mDevicePolicyLocalUserRestrictions.put(id, legacyLocalRestrictionsSet); } if (globalRestrictions != null) { mDevicePolicyGlobalUserRestrictions.updateRestrictions(id,