Fix work profile issue

Test: manual
Bug: 281332256
Change-Id: I5f47aacc84e5abe739ecc3bbad474957334e7c91
This commit is contained in:
Becca Hughes
2023-05-08 17:43:20 +00:00
parent 2971c13923
commit ad13689915
10 changed files with 91 additions and 32 deletions

View File

@@ -26,6 +26,7 @@ import android.credentials.CredentialProviderInfo;
import android.graphics.drawable.Drawable;
import android.service.autofill.AutofillServiceInfo;
import android.text.TextUtils;
import android.util.IconDrawableFactory;
import java.util.ArrayList;
import java.util.Collections;
@@ -83,11 +84,12 @@ public final class CombinedProviderInfo {
/** Returns the app icon. */
@Nullable
public Drawable getAppIcon(@NonNull Context context) {
public Drawable getAppIcon(@NonNull Context context, int userId) {
IconDrawableFactory factory = IconDrawableFactory.newInstance(context);
Drawable icon = null;
ServiceInfo brandingService = getBrandingService();
if (brandingService != null) {
icon = brandingService.loadIcon(context.getPackageManager());
icon = factory.getBadgedIcon(brandingService, getApplicationInfo(), userId);
}
// If the branding service gave us a icon then use that.
@@ -95,8 +97,8 @@ public final class CombinedProviderInfo {
return icon;
}
// Otherwise fallback to the app label and then the package name.
return getApplicationInfo().loadIcon(context.getPackageManager());
// Otherwise fallback to the app icon and then the package name.
return factory.getBadgedIcon(getApplicationInfo(), userId);
}
/** Returns the app name. */