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

Commit 7e32be5b authored by Songchun Fan's avatar Songchun Fan
Browse files

[am/incremental] add package loading info in main logcat for crash/ANRs

Example output in logcat for app crash:

  11-10 01:48:11.933  1575  8016 E ActivityManager: App crashed when package com.unity.megacity is 18% loaded.

BUG: 162600251
Test: manual
Change-Id: I3558b9af5c65380cdd29f73386cd22eb8b86a6c0
parent 6a6c0cf5
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -7583,6 +7583,11 @@ public class ActivityManagerService extends IActivityManager.Stub
                    mPackageManagerInt.getIncrementalStatesInfo(r.info.packageName, r.uid,
                            r.userId);
            isPackageLoading = incrementalStatesInfo.isLoading();
            if (isPackageLoading) {
                // Report in the main log that the package is still loading
                Slog.e(TAG, "App crashed when package " + r.info.packageName + " is "
                        + ((int) (incrementalStatesInfo.getProgress() * 100)) + "% loaded.");
            }
        }
        EventLogTags.writeAmCrash(Binder.getCallingPid(),
+7 −0
Original line number Diff line number Diff line
@@ -1684,6 +1684,13 @@ class ProcessRecord implements WindowProcessListener {
            info.append("Parent: ").append(parentShortComponentName).append("\n");
        }

        if (isPackageLoading) {
            // Report in the main log that the package is still loading
            final float loadingProgress = packageManagerInternal.getIncrementalStatesInfo(
                    aInfo.packageName, uid, userId).getProgress();
            info.append("Package is ").append((int) (loadingProgress * 100)).append("% loaded.\n");
        }

        StringBuilder report = new StringBuilder();
        report.append(MemoryPressureUtil.currentPsiState());
        ProcessCpuTracker processCpuTracker = new ProcessCpuTracker(true);