Merge "[am] move incremental manager calls to post dumpStackTraces" into sc-dev
diff --git a/services/core/java/com/android/server/am/ProcessErrorStateRecord.java b/services/core/java/com/android/server/am/ProcessErrorStateRecord.java
index 167ed86..c1b2a9c 100644
--- a/services/core/java/com/android/server/am/ProcessErrorStateRecord.java
+++ b/services/core/java/com/android/server/am/ProcessErrorStateRecord.java
@@ -299,32 +299,6 @@
}
}
- // Check if package is still being loaded
- float loadingProgress = 1;
- IncrementalMetrics incrementalMetrics = null;
- final PackageManagerInternal packageManagerInternal = mService.getPackageManagerInternal();
- if (mApp.info != null && mApp.info.packageName != null) {
- IncrementalStatesInfo incrementalStatesInfo =
- packageManagerInternal.getIncrementalStatesInfo(
- mApp.info.packageName, mApp.uid, mApp.userId);
- if (incrementalStatesInfo != null) {
- loadingProgress = incrementalStatesInfo.getProgress();
- }
- final String codePath = mApp.info.getCodePath();
- if (IncrementalManager.isIncrementalPath(codePath)) {
- // Report in the main log that the incremental package is still loading
- Slog.e(TAG, "App ANR on incremental package " + mApp.info.packageName
- + " which is " + ((int) (loadingProgress * 100)) + "% loaded.");
- final IBinder incrementalService = ServiceManager.getService(
- Context.INCREMENTAL_SERVICE);
- if (incrementalService != null) {
- final IncrementalManager incrementalManager = new IncrementalManager(
- IIncrementalService.Stub.asInterface(incrementalService));
- incrementalMetrics = incrementalManager.getMetrics(codePath);
- }
- }
- }
-
// Log the ANR to the main log.
StringBuilder info = new StringBuilder();
info.setLength(0);
@@ -342,11 +316,6 @@
info.append("Parent: ").append(parentShortComponentName).append("\n");
}
- if (incrementalMetrics != null) {
- // Report in the main log about the incremental package
- info.append("Package is ").append((int) (loadingProgress * 100)).append("% loaded.\n");
- }
-
// Retrieve controller with max ANR delay from AnrControllers
// Note that we retrieve the controller before dumping stacks because dumping stacks can
// take a few seconds, after which the cause of the ANR delay might have completed and
@@ -418,6 +387,37 @@
mService.mProcessList.mAppExitInfoTracker.scheduleLogAnrTrace(
pid, mApp.uid, mApp.getPackageList(), tracesFile, offsets[0], offsets[1]);
}
+
+ // Check if package is still being loaded
+ float loadingProgress = 1;
+ IncrementalMetrics incrementalMetrics = null;
+ final PackageManagerInternal packageManagerInternal = mService.getPackageManagerInternal();
+ if (mApp.info != null && mApp.info.packageName != null) {
+ IncrementalStatesInfo incrementalStatesInfo =
+ packageManagerInternal.getIncrementalStatesInfo(
+ mApp.info.packageName, mApp.uid, mApp.userId);
+ if (incrementalStatesInfo != null) {
+ loadingProgress = incrementalStatesInfo.getProgress();
+ }
+ final String codePath = mApp.info.getCodePath();
+ if (IncrementalManager.isIncrementalPath(codePath)) {
+ // Report in the main log that the incremental package is still loading
+ Slog.e(TAG, "App ANR on incremental package " + mApp.info.packageName
+ + " which is " + ((int) (loadingProgress * 100)) + "% loaded.");
+ final IBinder incrementalService = ServiceManager.getService(
+ Context.INCREMENTAL_SERVICE);
+ if (incrementalService != null) {
+ final IncrementalManager incrementalManager = new IncrementalManager(
+ IIncrementalService.Stub.asInterface(incrementalService));
+ incrementalMetrics = incrementalManager.getMetrics(codePath);
+ }
+ }
+ }
+ if (incrementalMetrics != null) {
+ // Report in the main log about the incremental package
+ info.append("Package is ").append((int) (loadingProgress * 100)).append("% loaded.\n");
+ }
+
FrameworkStatsLog.write(FrameworkStatsLog.ANR_OCCURRED, mApp.uid, mApp.processName,
activityShortComponentName == null ? "unknown" : activityShortComponentName,
annotation,