SF: Use std::string for layer names
Bug: 130554049
Test: Build
Change-Id: Id083a85fcb838da4138c39a55b12cf10ff0cdddb
diff --git a/services/surfaceflinger/EventLog/EventLog.cpp b/services/surfaceflinger/EventLog/EventLog.cpp
index 365a0bd..a532fc1 100644
--- a/services/surfaceflinger/EventLog/EventLog.cpp
+++ b/services/surfaceflinger/EventLog/EventLog.cpp
@@ -17,13 +17,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <log/log.h>
-#include <utils/String8.h>
#include "EventLog.h"
-// ---------------------------------------------------------------------------
namespace android {
-// ---------------------------------------------------------------------------
ANDROID_SINGLETON_STATIC_INSTANCE(EventLog)
@@ -31,11 +28,11 @@
EventLog::EventLog() {
}
-void EventLog::doLogFrameDurations(const String8& window,
- const int32_t* durations, size_t numDurations) {
+void EventLog::doLogFrameDurations(const std::string_view& name, const int32_t* durations,
+ size_t numDurations) {
EventLog::TagBuffer buffer(LOGTAG_SF_FRAME_DUR);
buffer.startList(1 + numDurations);
- buffer.writeString8(window);
+ buffer.writeString(name);
for (size_t i = 0; i < numDurations; i++) {
buffer.writeInt32(durations[i]);
}
@@ -43,10 +40,9 @@
buffer.log();
}
-void EventLog::logFrameDurations(const String8& window,
- const int32_t* durations, size_t numDurations) {
- EventLog::getInstance().doLogFrameDurations(window, durations,
- numDurations);
+void EventLog::logFrameDurations(const std::string_view& name, const int32_t* durations,
+ size_t numDurations) {
+ EventLog::getInstance().doLogFrameDurations(name, durations, numDurations);
}
// ---------------------------------------------------------------------------
@@ -113,9 +109,9 @@
mPos += needed;
}
-void EventLog::TagBuffer::writeString8(const String8& value) {
+void EventLog::TagBuffer::writeString(const std::string_view& value) {
if (mOverflow) return;
- const int32_t stringLen = value.length();
+ const size_t stringLen = value.length();
const size_t needed = 1 + sizeof(int32_t) + stringLen;
if (mPos + needed > STORAGE_MAX_SIZE) {
mOverflow = true;
@@ -123,11 +119,8 @@
}
mStorage[mPos + 0] = EVENT_TYPE_STRING;
memcpy(&mStorage[mPos + 1], &stringLen, sizeof(int32_t));
- memcpy(&mStorage[mPos + 5], value.string(), stringLen);
+ memcpy(&mStorage[mPos + 5], value.data(), stringLen);
mPos += needed;
}
-// ---------------------------------------------------------------------------
-}// namespace android
-
-// ---------------------------------------------------------------------------
+} // namespace android
diff --git a/services/surfaceflinger/EventLog/EventLog.h b/services/surfaceflinger/EventLog/EventLog.h
index efc5d70..ee3587e 100644
--- a/services/surfaceflinger/EventLog/EventLog.h
+++ b/services/surfaceflinger/EventLog/EventLog.h
@@ -14,24 +14,21 @@
* limitations under the License.
*/
-#include <stdint.h>
+#pragma once
+
#include <utils/Errors.h>
#include <utils/Singleton.h>
-#ifndef ANDROID_SF_EVENTLOG_H
-#define ANDROID_SF_EVENTLOG_H
+#include <cstdint>
+#include <string_view>
-// ---------------------------------------------------------------------------
namespace android {
-// ---------------------------------------------------------------------------
-
-class String8;
class EventLog : public Singleton<EventLog> {
public:
- static void logFrameDurations(const String8& window,
- const int32_t* durations, size_t numDurations);
+ static void logFrameDurations(const std::string_view& name, const int32_t* durations,
+ size_t numDurations);
protected:
EventLog();
@@ -54,18 +51,13 @@
public:
explicit TagBuffer(int32_t tag);
- // starts list of items
void startList(int8_t count);
- // terminates the list
void endList();
- // write a 32-bit integer
- void writeInt32(int32_t value);
- // write a 64-bit integer
- void writeInt64(int64_t value);
- // write a C string
- void writeString8(const String8& value);
- // outputs the the buffer to the log
+ void writeInt32(int32_t);
+ void writeInt64(int64_t);
+ void writeString(const std::string_view&);
+
void log();
};
@@ -74,12 +66,8 @@
EventLog& operator =(const EventLog&);
enum { LOGTAG_SF_FRAME_DUR = 60100 };
- void doLogFrameDurations(const String8& window, const int32_t* durations,
- size_t numDurations);
+ void doLogFrameDurations(const std::string_view& name, const int32_t* durations,
+ size_t numDurations);
};
-// ---------------------------------------------------------------------------
-}// namespace android
-// ---------------------------------------------------------------------------
-
-#endif /* ANDROID_SF_EVENTLOG_H */
+} // namespace android