Merge "document isBinderAlive" into main
diff --git a/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h b/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h
index b2ffb2b..b771e96 100644
--- a/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h
+++ b/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h
@@ -271,7 +271,7 @@
         }
     }
 
-    bool getBoolean(const std::string& key, bool* _Nonnull val) {
+    bool getBoolean(const std::string& key, bool* _Nonnull val) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return APersistableBundle_getBoolean(mPBundle, key.c_str(), val);
         } else {
@@ -279,7 +279,7 @@
         }
     }
 
-    bool getInt(const std::string& key, int32_t* _Nonnull val) {
+    bool getInt(const std::string& key, int32_t* _Nonnull val) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return APersistableBundle_getInt(mPBundle, key.c_str(), val);
         } else {
@@ -287,7 +287,7 @@
         }
     }
 
-    bool getLong(const std::string& key, int64_t* _Nonnull val) {
+    bool getLong(const std::string& key, int64_t* _Nonnull val) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return APersistableBundle_getLong(mPBundle, key.c_str(), val);
         } else {
@@ -295,7 +295,7 @@
         }
     }
 
-    bool getDouble(const std::string& key, double* _Nonnull val) {
+    bool getDouble(const std::string& key, double* _Nonnull val) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return APersistableBundle_getDouble(mPBundle, key.c_str(), val);
         } else {
@@ -307,7 +307,7 @@
         return (char*)malloc(bufferSizeBytes);
     }
 
-    bool getString(const std::string& key, std::string* _Nonnull val) {
+    bool getString(const std::string& key, std::string* _Nonnull val) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             char* outString = nullptr;
             bool ret = APersistableBundle_getString(mPBundle, key.c_str(), &outString,
@@ -325,7 +325,7 @@
     bool getVecInternal(int32_t (*_Nonnull getVec)(const APersistableBundle* _Nonnull,
                                                    const char* _Nonnull, T* _Nullable, int32_t),
                         const APersistableBundle* _Nonnull pBundle, const char* _Nonnull key,
-                        std::vector<T>* _Nonnull vec) {
+                        std::vector<T>* _Nonnull vec) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             int32_t bytes = 0;
             // call first with nullptr to get required size in bytes
@@ -347,28 +347,28 @@
         return false;
     }
 
-    bool getBooleanVector(const std::string& key, std::vector<bool>* _Nonnull vec) {
+    bool getBooleanVector(const std::string& key, std::vector<bool>* _Nonnull vec) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getVecInternal<bool>(&APersistableBundle_getBooleanVector, mPBundle, key.c_str(),
                                         vec);
         }
         return false;
     }
-    bool getIntVector(const std::string& key, std::vector<int32_t>* _Nonnull vec) {
+    bool getIntVector(const std::string& key, std::vector<int32_t>* _Nonnull vec) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getVecInternal<int32_t>(&APersistableBundle_getIntVector, mPBundle, key.c_str(),
                                            vec);
         }
         return false;
     }
-    bool getLongVector(const std::string& key, std::vector<int64_t>* _Nonnull vec) {
+    bool getLongVector(const std::string& key, std::vector<int64_t>* _Nonnull vec) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getVecInternal<int64_t>(&APersistableBundle_getLongVector, mPBundle, key.c_str(),
                                            vec);
         }
         return false;
     }
-    bool getDoubleVector(const std::string& key, std::vector<double>* _Nonnull vec) {
+    bool getDoubleVector(const std::string& key, std::vector<double>* _Nonnull vec) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getVecInternal<double>(&APersistableBundle_getDoubleVector, mPBundle,
                                           key.c_str(), vec);
@@ -379,7 +379,7 @@
     // Takes ownership of and frees the char** and its elements.
     // Creates a new set or vector based on the array of char*.
     template <typename T>
-    T moveStringsInternal(char* _Nullable* _Nonnull strings, int32_t bufferSizeBytes) {
+    T moveStringsInternal(char* _Nullable* _Nonnull strings, int32_t bufferSizeBytes) const {
         if (strings && bufferSizeBytes > 0) {
             int32_t num = bufferSizeBytes / sizeof(char*);
             T ret;
@@ -393,7 +393,7 @@
         return T();
     }
 
-    bool getStringVector(const std::string& key, std::vector<std::string>* _Nonnull vec) {
+    bool getStringVector(const std::string& key, std::vector<std::string>* _Nonnull vec) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             int32_t bytes = APersistableBundle_getStringVector(mPBundle, key.c_str(), nullptr, 0,
                                                                &stringAllocator, nullptr);
@@ -410,7 +410,7 @@
         return false;
     }
 
-    bool getPersistableBundle(const std::string& key, PersistableBundle* _Nonnull val) {
+    bool getPersistableBundle(const std::string& key, PersistableBundle* _Nonnull val) const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             APersistableBundle* bundle = nullptr;
             bool ret = APersistableBundle_getPersistableBundle(mPBundle, key.c_str(), &bundle);
@@ -429,7 +429,7 @@
                                              int32_t bufferSizeBytes,
                                              APersistableBundle_stringAllocator stringAllocator,
                                              void* _Nullable),
-            const APersistableBundle* _Nonnull pBundle) {
+            const APersistableBundle* _Nonnull pBundle) const {
         // call first with nullptr to get required size in bytes
         int32_t bytes = getTypedKeys(pBundle, nullptr, 0, &stringAllocator, nullptr);
         if (bytes > 0) {
@@ -442,84 +442,84 @@
         return {};
     }
 
-    std::set<std::string> getBooleanKeys() {
+    std::set<std::string> getBooleanKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getBooleanKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getIntKeys() {
+    std::set<std::string> getIntKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getIntKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getLongKeys() {
+    std::set<std::string> getLongKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getLongKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getDoubleKeys() {
+    std::set<std::string> getDoubleKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getDoubleKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getStringKeys() {
+    std::set<std::string> getStringKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getStringKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getBooleanVectorKeys() {
+    std::set<std::string> getBooleanVectorKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getBooleanVectorKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getIntVectorKeys() {
+    std::set<std::string> getIntVectorKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getIntVectorKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getLongVectorKeys() {
+    std::set<std::string> getLongVectorKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getLongVectorKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getDoubleVectorKeys() {
+    std::set<std::string> getDoubleVectorKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getDoubleVectorKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getStringVectorKeys() {
+    std::set<std::string> getStringVectorKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getStringVectorKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getPersistableBundleKeys() {
+    std::set<std::string> getPersistableBundleKeys() const {
         if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) {
             return getKeys(&APersistableBundle_getPersistableBundleKeys, mPBundle);
         } else {
             return {};
         }
     }
-    std::set<std::string> getMonKeys() {
+    std::set<std::string> getMonKeys() const {
         // :P
         return {"c(o,o)b", "c(o,o)b"};
     }
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 736fec6..9c8887d 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -3178,6 +3178,8 @@
         callReleaseBufferCallback(mDrawingState.releaseBufferListener,
                                   mDrawingState.buffer->getBuffer(), mDrawingState.frameNumber,
                                   mDrawingState.acquireFence);
+        const int32_t layerId = getSequence();
+        mFlinger->mTimeStats->removeTimeRecord(layerId, mDrawingState.frameNumber);
         decrementPendingBufferCount();
         if (mDrawingState.bufferSurfaceFrameTX != nullptr &&
             mDrawingState.bufferSurfaceFrameTX->getPresentState() != PresentState::Presented) {