diff options
| author | 2019-02-25 12:24:33 -0500 | |
|---|---|---|
| committer | 2019-02-25 12:39:58 -0500 | |
| commit | be459eaf15b4b90e883a758097e81eb1c5a24379 (patch) | |
| tree | c5bfcfd699471cd76e3d6aa7b340a2bc5fce2c33 | |
| parent | 8e95f0bfb9294da0bdbe57f12c616e593aafa5c3 (diff) | |
Fix badged apps in Privacy dialog
Badged icons are retrieved for managed profiles
Test: created a managed profile and launched Work camera
Fixes: 122918402
Change-Id: I089a465038b85f761a1b74adeaed684b8214ceff
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt index a6e48f8835c7..3f581c4de5fb 100644 --- a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt +++ b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt @@ -18,6 +18,8 @@ import android.content.Context import android.content.pm.ApplicationInfo import android.content.pm.PackageManager import android.graphics.drawable.Drawable +import android.os.UserHandle +import android.util.IconDrawableFactory import com.android.systemui.R typealias Privacy = PrivacyType @@ -46,14 +48,21 @@ data class PrivacyApplication(val packageName: String, val uid: Int, val context private val applicationInfo: ApplicationInfo? by lazy { try { - context.packageManager.getApplicationInfo(packageName, 0) + val userHandle = UserHandle.getUserHandleForUid(uid) + context.createPackageContextAsUser(packageName, 0, userHandle).getPackageManager() + .getApplicationInfo(packageName, 0) } catch (_: PackageManager.NameNotFoundException) { null } } val icon: Drawable by lazy { applicationInfo?.let { - context.packageManager.getApplicationIcon(it) + try { + val iconFactory = IconDrawableFactory.newInstance(context, true) + iconFactory.getBadgedIcon(it, UserHandle.getUserId(uid)) + } catch (_: Exception) { + null + } } ?: context.getDrawable(android.R.drawable.sym_def_app_icon) } |