Merge changes I15da2563,I7845542d into nyc-mr1-dev

* changes:
  Don't reset current thread's priority accidentally.
  add tracepoint for when the display chain is stuffed
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 5003c6a..bfcb0e5 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -234,6 +234,7 @@
     }
 
     // All signs point to a stuffed swap chain
+    ATRACE_NAME("swap chain stuffed");
     return true;
 }
 
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 8716811..67ff085 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -20265,10 +20265,12 @@
                         if (mUseFifoUiScheduling) {
                             // Reset UI pipeline to SCHED_OTHER
                             Process.setThreadScheduler(app.pid, Process.SCHED_OTHER, 0);
-                            Process.setThreadScheduler(app.renderThreadTid,
-                                Process.SCHED_OTHER, 0);
                             Process.setThreadPriority(app.pid, app.savedPriority);
-                            Process.setThreadPriority(app.renderThreadTid, -4);
+                            if (app.renderThreadTid != 0) {
+                                Process.setThreadScheduler(app.renderThreadTid,
+                                    Process.SCHED_OTHER, 0);
+                                Process.setThreadPriority(app.renderThreadTid, -4);
+                            }
                         }
                     }
                 } catch (Exception e) {