diff options
author | Wale Ogunwale <ogunwale@google.com> | 2015-06-08 09:14:37 -0700 |
---|---|---|
committer | Wale Ogunwale <ogunwale@google.com> | 2015-06-08 09:14:37 -0700 |
commit | e9408f3157a9af3b3a896278343341c4e18f6502 (patch) | |
tree | df3462aab39af0c9cdcd8c0abd4aa1ab448b6f17 | |
parent | e1f3214e72b63ed7cbe368005622055f80da0e0d (diff) | |
download | frameworks_base-e9408f3157a9af3b3a896278343341c4e18f6502.zip frameworks_base-e9408f3157a9af3b3a896278343341c4e18f6502.tar.gz frameworks_base-e9408f3157a9af3b3a896278343341c4e18f6502.tar.bz2 |
Hold service lock when AMS.setProcessMemoryTrimLevel() is called
Bug: 21633189
Change-Id: I7203807466593ced6ec3dd328c1a03532caf3a31
-rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 28 |
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 efc38e2..7363e3b 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; |