summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWale Ogunwale <ogunwale@google.com>2015-06-08 16:50:20 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-08 16:50:22 +0000
commitaac4c5c28f6699ddcbbc25638e73e5ab42b8360e (patch)
treec905d081325fe8f7bbffa3ff695f7f4df43222b9
parent159f558a39d200e08e06245d64ec1df9a08e7d93 (diff)
parente9408f3157a9af3b3a896278343341c4e18f6502 (diff)
downloadframeworks_base-aac4c5c28f6699ddcbbc25638e73e5ab42b8360e.zip
frameworks_base-aac4c5c28f6699ddcbbc25638e73e5ab42b8360e.tar.gz
frameworks_base-aac4c5c28f6699ddcbbc25638e73e5ab42b8360e.tar.bz2
Merge "Hold service lock when AMS.setProcessMemoryTrimLevel() is called" into mnc-dev
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java28
1 files changed, 15 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 3cc9c03..b6cc1c7 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -3615,19 +3615,21 @@ public final class ActivityManagerService extends ActivityManagerNative
@Override
public boolean setProcessMemoryTrimLevel(String process, int userId, int level) {
- ProcessRecord app = getProcessRecordLocked(process, userId, true);
- if (app == null) {
- return false;
- }
- if (app.trimMemoryLevel < level && app.thread != null &&
- (level < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN ||
- app.trimMemoryLevel >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN)) {
- try {
- app.thread.scheduleTrimMemory(level);
- app.trimMemoryLevel = level;
- return true;
- } catch (RemoteException e) {
- // Fallthrough to failure case.
+ synchronized (this) {
+ final ProcessRecord app = getProcessRecordLocked(process, userId, true);
+ if (app == null) {
+ return false;
+ }
+ if (app.trimMemoryLevel < level && app.thread != null &&
+ (level < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN ||
+ app.trimMemoryLevel >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN)) {
+ try {
+ app.thread.scheduleTrimMemory(level);
+ app.trimMemoryLevel = level;
+ return true;
+ } catch (RemoteException e) {
+ // Fallthrough to failure case.
+ }
}
}
return false;