Plumb owner pid into Layer
For shared timeline visualization, the pid of the process owning the
layer is needed to show the information in the respective process
tracks. This change stores the newly added METADATA_OWNER_PID
information sent as a part of the Layer creation args
Bug: 170911969
Test: pid section of `adb shell dumpsys SurfaceFlinger --frametimeline -<all/jank>`
Change-Id: Ib1cd9b6239501b0b92283dca19d7de3916fff604
diff --git a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
index 996479c..bd87482 100644
--- a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
+++ b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
@@ -177,10 +177,11 @@
}
}
-SurfaceFrame::SurfaceFrame(uid_t ownerUid, std::string layerName, std::string debugName,
- PredictionState predictionState,
+SurfaceFrame::SurfaceFrame(pid_t ownerPid, uid_t ownerUid, std::string layerName,
+ std::string debugName, PredictionState predictionState,
frametimeline::TimelineItem&& predictions)
- : mOwnerUid(ownerUid),
+ : mOwnerPid(ownerPid),
+ mOwnerUid(ownerUid),
mLayerName(std::move(layerName)),
mDebugName(std::move(debugName)),
mPresentState(PresentState::Unknown),
@@ -241,14 +242,6 @@
return mJankType;
}
-uid_t SurfaceFrame::getOwnerUid() const {
- return mOwnerUid;
-}
-
-const std::string& SurfaceFrame::getName() const {
- return mLayerName;
-}
-
nsecs_t SurfaceFrame::getBaseTime() const {
std::lock_guard<std::mutex> lock(mMutex);
nsecs_t baseTime = std::numeric_limits<nsecs_t>::max();
@@ -285,6 +278,8 @@
}
StringAppendF(&result, "\n");
StringAppendF(&result, "%s", indent.c_str());
+ StringAppendF(&result, "Owner Pid : %d\n", mOwnerPid);
+ StringAppendF(&result, "%s", indent.c_str());
StringAppendF(&result, "Present State : %s\n", presentStateToString(mPresentState).c_str());
StringAppendF(&result, "%s", indent.c_str());
StringAppendF(&result, "Prediction State : %s\n", toString(mPredictionState).c_str());
@@ -311,20 +306,23 @@
}
std::unique_ptr<android::frametimeline::SurfaceFrame> FrameTimeline::createSurfaceFrameForToken(
- uid_t uid, std::string layerName, std::string debugName, std::optional<int64_t> token) {
+ pid_t ownerPid, uid_t ownerUid, std::string layerName, std::string debugName,
+ std::optional<int64_t> token) {
ATRACE_CALL();
if (!token) {
- return std::make_unique<impl::SurfaceFrame>(uid, std::move(layerName), std::move(debugName),
- PredictionState::None, TimelineItem());
+ return std::make_unique<impl::SurfaceFrame>(ownerPid, ownerUid, std::move(layerName),
+ std::move(debugName), PredictionState::None,
+ TimelineItem());
}
std::optional<TimelineItem> predictions = mTokenManager.getPredictionsForToken(*token);
if (predictions) {
- return std::make_unique<impl::SurfaceFrame>(uid, std::move(layerName), std::move(debugName),
- PredictionState::Valid,
+ return std::make_unique<impl::SurfaceFrame>(ownerPid, ownerUid, std::move(layerName),
+ std::move(debugName), PredictionState::Valid,
std::move(*predictions));
}
- return std::make_unique<impl::SurfaceFrame>(uid, std::move(layerName), std::move(debugName),
- PredictionState::Expired, TimelineItem());
+ return std::make_unique<impl::SurfaceFrame>(ownerPid, ownerUid, std::move(layerName),
+ std::move(debugName), PredictionState::Expired,
+ TimelineItem());
}
void FrameTimeline::addSurfaceFrame(