summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ruben Brunk <rubenbrunk@google.com> 2016-08-10 01:31:13 +0000
committer android-build-merger <android-build-merger@google.com> 2016-08-10 01:31:13 +0000
commit05f58f6be4ccf1ea9b0113f5f6cc18472b788ba2 (patch)
tree6ce10850ac3edb17d8f7d6edafed46915d3bdbf5
parent2350c91ae85275be06818c329a74f21b60764906 (diff)
parent34e4e80db1bdea26f1ae45f10bfb37750afe5dcc (diff)
Fix setVrThread's exception handling. am: 83ea55a9c6 am: b25be4bd37
am: 34e4e80db1 Change-Id: Iec0098aa85e3388cadf18f644451189005908065
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 0cf7dc4c5b13..0ffc35b6a5f0 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -12550,23 +12550,33 @@ public final class ActivityManagerService extends ActivityManagerNative
synchronized (mPidsSelfLocked) {
final int pid = Binder.getCallingPid();
proc = mPidsSelfLocked.get(pid);
+
if (proc != null && mInVrMode && tid >= 0) {
// ensure the tid belongs to the process
if (!Process.isThreadInProcess(pid, tid)) {
throw new IllegalArgumentException("VR thread does not belong to process");
}
- // reset existing VR thread to CFS
- if (proc.vrThreadTid != 0) {
- Process.setThreadScheduler(proc.vrThreadTid, Process.SCHED_OTHER, 0);
+
+ // reset existing VR thread to CFS if this thread still exists and belongs to
+ // the calling process
+ if (proc.vrThreadTid != 0
+ && Process.isThreadInProcess(pid, proc.vrThreadTid)) {
+ try {
+ Process.setThreadScheduler(proc.vrThreadTid, Process.SCHED_OTHER, 0);
+ } catch (IllegalArgumentException e) {
+ // Ignore this. Only occurs in race condition where previous VR thread
+ // was destroyed during this method call.
+ }
}
- // add check to guarantee that tid belongs to pid?
+
proc.vrThreadTid = tid;
+
// promote to FIFO now if the tid is non-zero
- if (proc.curSchedGroup == ProcessList.SCHED_GROUP_TOP_APP && proc.vrThreadTid > 0) {
- Process.setThreadScheduler(proc.vrThreadTid, Process.SCHED_FIFO | Process.SCHED_RESET_ON_FORK, 1);
+ if (proc.curSchedGroup == ProcessList.SCHED_GROUP_TOP_APP
+ && proc.vrThreadTid > 0) {
+ Process.setThreadScheduler(proc.vrThreadTid,
+ Process.SCHED_FIFO | Process.SCHED_RESET_ON_FORK, 1);
}
- } else {
- //Slog.e("VR_FIFO", "Didn't set thread from setVrThread?");
}
}
}