Merge "EGL: Disconnect native window in eglDestroySurface" into nyc-dev
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp
index 60118a8..90ef277 100644
--- a/cmds/installd/commands.cpp
+++ b/cmds/installd/commands.cpp
@@ -1022,16 +1022,15 @@
 }
 
 static fd_t open_profile_dir(const std::string& profile_dir) {
-    struct stat buffer;
-    if (TEMP_FAILURE_RETRY(lstat(profile_dir.c_str(), &buffer)) == -1) {
-        PLOG(ERROR) << "Failed to lstat profile_dir: " << profile_dir;
-        return -1;
-    }
-
     fd_t profile_dir_fd = TEMP_FAILURE_RETRY(open(profile_dir.c_str(),
             O_PATH | O_CLOEXEC | O_DIRECTORY | O_NOFOLLOW));
     if (profile_dir_fd < 0) {
-        PLOG(ERROR) << "Failed to open profile_dir: " << profile_dir;
+        // In a multi-user environment, these directories can be created at
+        // different points and it's possible we'll attempt to open a profile
+        // dir before it exists.
+        if (errno != ENOENT) {
+            PLOG(ERROR) << "Failed to open profile_dir: " << profile_dir;
+        }
     }
     return profile_dir_fd;
 }
diff --git a/services/sensorservice/RecentEventLogger.cpp b/services/sensorservice/RecentEventLogger.cpp
index dba7211..754b603 100644
--- a/services/sensorservice/RecentEventLogger.cpp
+++ b/services/sensorservice/RecentEventLogger.cpp
@@ -76,7 +76,8 @@
     std::lock_guard<std::mutex> lk(mLock);
 
     if (mRecentEvents.size()) {
-        *event = mRecentEvents[mRecentEvents.size()-1].mEvent;
+        // Index 0 contains the latest event emplace()'ed
+        *event = mRecentEvents[0].mEvent;
         return true;
     } else {
         return false;
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index c640f58..96252f3 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -178,6 +178,9 @@
     for (auto& point : mRemoteSyncPoints) {
         point->setTransactionApplied();
     }
+    for (auto& point : mLocalSyncPoints) {
+        point->setFrameAvailable();
+    }
     mFlinger->deleteTextureAsync(mTextureName);
     mFrameTracker.logAndResetStats(mName);
 }
@@ -1478,6 +1481,17 @@
                 (type >= Transform::SCALE));
     }
 
+    // If the layer is hidden, signal and clear out all local sync points so
+    // that transactions for layers depending on this layer's frames becoming
+    // visible are not blocked
+    if (c.flags & layer_state_t::eLayerHidden) {
+        Mutex::Autolock lock(mLocalSyncPointMutex);
+        for (auto& point : mLocalSyncPoints) {
+            point->setFrameAvailable();
+        }
+        mLocalSyncPoints.clear();
+    }
+
     // Commit the transaction
     commitTransaction(c);
     return flags;