From 82194b8fe0e51e733663c99695d588fff9c811d9 Mon Sep 17 00:00:00 2001 From: Adam Bookatz Date: Tue, 6 Oct 2020 15:04:16 -0700 Subject: [PATCH] Use hasBadge instead of isManagedProfile To determine whether a user has a badge, the correct call is now hasBadge, rather than isManagedProfile. Currently, the only user that actually can have a badge is a managed profile, so this change is a no-op. In the future, if further profile support is expanded, then hasBadge will be correct. Bug: 170249807 Test: Treehugger (this cl is a no-op) Change-Id: I9144c4dc519936dfc5a2aeae0eb0bd91bea89db2 --- core/java/android/util/IconDrawableFactory.java | 2 +- .../com/android/server/appwidget/AppWidgetServiceImpl.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/java/android/util/IconDrawableFactory.java b/core/java/android/util/IconDrawableFactory.java index 721e6b39d24aa..5eeb122736615 100644 --- a/core/java/android/util/IconDrawableFactory.java +++ b/core/java/android/util/IconDrawableFactory.java @@ -48,7 +48,7 @@ public class IconDrawableFactory { } protected boolean needsBadging(ApplicationInfo appInfo, @UserIdInt int userId) { - return appInfo.isInstantApp() || mUm.isManagedProfile(userId); + return appInfo.isInstantApp() || mUm.hasBadge(userId); } @UnsupportedAppUsage diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java index 060d0971e391a..2264196fad684 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java @@ -630,8 +630,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku final long identity = Binder.clearCallingIdentity(); try { if (provider.maskedBySuspendedPackage) { - UserInfo userInfo = mUserManager.getUserInfo(providerUserId); - showBadge = userInfo.isManagedProfile(); + showBadge = mUserManager.hasBadge(providerUserId); final String suspendingPackage = mPackageManagerInternal.getSuspendingPackage( providerPackage, providerUserId); if (PLATFORM_PACKAGE_NAME.equals(suspendingPackage)) { @@ -3619,7 +3618,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku long token = Binder.clearCallingIdentity(); try { UserInfo userInfo = mUserManager.getUserInfo(userId); - if (userInfo != null && userInfo.isManagedProfile()) { + if (userInfo != null && userInfo.isProfile()) { UserInfo parentInfo = mUserManager.getProfileParent(userId); if (parentInfo != null && !isUserRunningAndUnlocked(parentInfo.getUserHandle().getIdentifier())) { @@ -3634,7 +3633,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku private boolean isProfileWithUnlockedParent(int userId) { UserInfo userInfo = mUserManager.getUserInfo(userId); - if (userInfo != null && userInfo.isManagedProfile()) { + if (userInfo != null && userInfo.isProfile()) { UserInfo parentInfo = mUserManager.getProfileParent(userId); if (parentInfo != null && mUserManager.isUserUnlockingOrUnlocked(parentInfo.getUserHandle())) {