Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9cde09e3 authored by Kevin Lim's avatar Kevin Lim
Browse files

[IconCache] Create persistent log method when package manager returns empty...

[IconCache] Create persistent log method when package manager returns empty ApplicationInfo or default app icon

Bug: b/343233224
Flag: NONE logging change for investigation
Test: NONE logging change for investigation
Change-Id: I754812d222207e98859c5cb9be02136c5b41ed62
parent 4203d70f
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -583,7 +583,12 @@ public abstract class BaseIconCache {
                            PackageManager.PackageInfoFlags.of(flags));
                    ApplicationInfo appInfo = info.applicationInfo;
                    if (appInfo == null) {
                        throw new NameNotFoundException("ApplicationInfo is null");
                        NameNotFoundException e = new NameNotFoundException(
                                "ApplicationInfo is null");
                        logdPersistently(TAG,
                                String.format("ApplicationInfo is null for %s", packageName),
                                e);
                        throw e;
                    }

                    BaseIconFactory li = getIconFactory();
@@ -591,8 +596,9 @@ public abstract class BaseIconCache {
                    // only keep the low resolution icon instead of the larger full-sized icon
                    Drawable appIcon = appInfo.loadIcon(mPackageManager);
                    if (mPackageManager.isDefaultApplicationIcon(appIcon)) {
                        // TODO(b/343233224): Log in more persistent location such as FileLog.
                        Log.d(TAG, String.format("Default icon returned for %s", packageName));
                        logdPersistently(TAG,
                                String.format("Default icon returned for %s", packageName),
                                null);
                    }
                    BitmapInfo iconInfo = li.createBadgedIconBitmap(appIcon,
                            new IconOptions().setUser(user).setInstantApp(isInstantApp(appInfo)));
@@ -809,4 +815,9 @@ public abstract class BaseIconCache {
            throw new IllegalStateException("Cache accessed on wrong thread " + Looper.myLooper());
        }
    }

    /** Log to Log.d. Subclasses can override this method to log persistently for debugging. */
    protected void logdPersistently(String tag, String message, @Nullable Exception e) {
        Log.d(tag, message, e);
    }
}