Merge "EGL: add GPU frame completion tracing"
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c
index 0d5ab90..4556505 100644
--- a/cmds/dumpstate/utils.c
+++ b/cmds/dumpstate/utils.c
@@ -375,6 +375,7 @@
         *slash = '\0';
         if (!mkdir(anr_traces_dir, 0775)) {
             chown(anr_traces_dir, AID_SYSTEM, AID_SYSTEM);
+            chmod(anr_traces_dir, 0775);
         } else if (errno != EEXIST) {
             fprintf(stderr, "mkdir(%s): %s\n", anr_traces_dir, strerror(errno));
             return NULL;
@@ -382,11 +383,17 @@
     }
 
     /* create a new, empty traces.txt file to receive stack dumps */
-    int fd = open(traces_path, O_CREAT | O_WRONLY | O_TRUNC, 0666);  /* -rw-rw-rw- */
+    int fd = open(traces_path, O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW, 0666);  /* -rw-rw-rw- */
     if (fd < 0) {
         fprintf(stderr, "%s: %s\n", traces_path, strerror(errno));
         return NULL;
     }
+    int chmod_ret = fchmod(fd, 0666);
+    if (chmod_ret < 0) {
+        fprintf(stderr, "fchmod on %s failed: %s\n", traces_path, strerror(errno));
+        close(fd);
+        return NULL;
+    }
     close(fd);
 
     /* walk /proc and kill -QUIT all Dalvik processes */
diff --git a/libs/utils/Trace.cpp b/libs/utils/Trace.cpp
index d532296..f7d8abe 100644
--- a/libs/utils/Trace.cpp
+++ b/libs/utils/Trace.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#define LOG_TAG "Trace"
+
 #include <cutils/properties.h>
 #include <utils/Log.h>
 #include <utils/Trace.h>
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index e742d3e..a6804da 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -105,7 +105,7 @@
 
 status_t HWComposer::eventControl(int event, int enabled) {
     status_t err = NO_ERROR;
-    if (mHwc->common.version >= HWC_DEVICE_API_VERSION_0_3) {
+    if (mHwc && mHwc->common.version >= HWC_DEVICE_API_VERSION_0_3) {
         err = mHwc->methods->eventControl(mHwc, event, enabled);
     } else {
         if (mVSyncThread != NULL) {