Skip to content

Commit

Permalink
Merge pull request #2828 from dimagi/print-memory-info-for-critical-s…
Browse files Browse the repository at this point in the history
…tate

Print memory info for critical level
  • Loading branch information
avazirna authored Aug 26, 2024
2 parents 63ab5ea + aeba8ce commit 28f33c9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/src/org/commcare/CommCareApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -1263,17 +1263,13 @@ public void onTrimMemory(int level) {
super.onTrimMemory(level);
Logger.log("memory-trim-request", "Memory level: " + getMemoryLevelName(level));
switch (level) {
case android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL,
android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE,
android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
case TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_MODERATE, TRIM_MEMORY_BACKGROUND:
break;
case TRIM_MEMORY_UI_HIDDEN:
// this could be an option to write the logs when the app goes to the background but
// LifecycleEventObserver seems more reliable
break;
case TRIM_MEMORY_BACKGROUND:
case TRIM_MEMORY_MODERATE:
case TRIM_MEMORY_COMPLETE:
case TRIM_MEMORY_COMPLETE, TRIM_MEMORY_RUNNING_CRITICAL:
logMemoryAndBatteryInfo("memory-trim-request");
break;
}
Expand All @@ -1289,8 +1285,10 @@ private String getMemoryLevelName(int level) {
return "TRIM_MEMORY_MODERATE";
case TRIM_MEMORY_COMPLETE:
return "TRIM_MEMORY_COMPLETE";
case TRIM_MEMORY_RUNNING_CRITICAL:
return "TRIM_MEMORY_RUNNING_CRITICAL";
default:
return "Level: " + level;
return String.valueOf(level);
}
}

Expand Down

0 comments on commit 28f33c9

Please sign in to comment.