From 444cabf2b361a1279e7090b35cd9108601fa1864 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Wed, 10 Nov 2021 15:10:17 +0000 Subject: [PATCH] Dont throw exception if admin is null For policy_suspend_packages(or for other policies which are not user restriction) admin component comes to be null always when fetched from DPMS and the code changed as part of this change used to throw exception. So handling this case to show generic learn more link in policy transparency dialog which opens settings showing list of all admins, if admin details are not found. Bug: 203564700 Test: com.android.cts.devicepolicy.MixedProfileOwnerTest#testSuspendPackage Change-Id: Ib3b4490eaa11ceab53f0004f4b7d089f3c0ba4fb --- .../enterprise/ActionDisabledLearnMoreButtonLauncher.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledLearnMoreButtonLauncher.java b/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledLearnMoreButtonLauncher.java index ba63a8e8b1954..0416b68670bf5 100644 --- a/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledLearnMoreButtonLauncher.java +++ b/packages/SettingsLib/src/com/android/settingslib/enterprise/ActionDisabledLearnMoreButtonLauncher.java @@ -52,7 +52,6 @@ public abstract class ActionDisabledLearnMoreButtonLauncher { public final void setupLearnMoreButtonToShowAdminPolicies(Context context, int enforcementAdminUserId, EnforcedAdmin enforcedAdmin) { requireNonNull(context, "context cannot be null"); - requireNonNull(enforcedAdmin, "enforcedAdmin cannot be null"); // The "Learn more" button appears only if the restriction is enforced by an admin in the // same profile group or by the device owner. Otherwise the admin package and its policies @@ -132,7 +131,7 @@ public abstract class ActionDisabledLearnMoreButtonLauncher { } private void showAdminPolicies(Context context, EnforcedAdmin enforcedAdmin) { - if (enforcedAdmin.component != null) { + if (enforcedAdmin != null && enforcedAdmin.component != null) { launchShowAdminPolicies(context, enforcedAdmin.user, enforcedAdmin.component); } else { launchShowAdminSettings(context);