Support task ID for fps listener rather than SurfaceControl.
Bug: 174956756
Test: e2e test with dashboard cls
Change-Id: I841af53ac820a91d270a75c5cc0ca258df0a3945
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index 05e1935..989abd9 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -755,11 +755,10 @@
return error;
}
- virtual status_t addFpsListener(const sp<IBinder>& layerHandle,
- const sp<gui::IFpsListener>& listener) {
+ virtual status_t addFpsListener(int32_t taskId, const sp<gui::IFpsListener>& listener) {
Parcel data, reply;
SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());
- SAFE_PARCEL(data.writeStrongBinder, layerHandle);
+ SAFE_PARCEL(data.writeInt32, taskId);
SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));
const status_t error =
remote()->transact(BnSurfaceComposer::ADD_FPS_LISTENER, data, &reply);
@@ -1669,8 +1668,8 @@
}
case ADD_FPS_LISTENER: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
- sp<IBinder> layerHandle;
- status_t result = data.readNullableStrongBinder(&layerHandle);
+ int32_t taskId;
+ status_t result = data.readInt32(&taskId);
if (result != NO_ERROR) {
ALOGE("addFpsListener: Failed to read layer handle");
return result;
@@ -1681,7 +1680,7 @@
ALOGE("addFpsListener: Failed to read listener");
return result;
}
- return addFpsListener(layerHandle, listener);
+ return addFpsListener(taskId, listener);
}
case REMOVE_FPS_LISTENER: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index f5cde59..5e8ab92 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1982,9 +1982,9 @@
return ComposerService::getComposerService()->removeRegionSamplingListener(listener);
}
-status_t SurfaceComposerClient::addFpsListener(const sp<IBinder>& layerHandle,
+status_t SurfaceComposerClient::addFpsListener(int32_t taskId,
const sp<gui::IFpsListener>& listener) {
- return ComposerService::getComposerService()->addFpsListener(layerHandle, listener);
+ return ComposerService::getComposerService()->addFpsListener(taskId, listener);
}
status_t SurfaceComposerClient::removeFpsListener(const sp<gui::IFpsListener>& listener) {
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 8b64bcf..88cfe4b 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -351,16 +351,15 @@
/* Registers a listener that streams fps updates from SurfaceFlinger.
*
- * The listener will stream fps updates for the layer tree rooted at layerHandle. Usually, this
- * should be tied to a task. Layers that are not descendants of that task are out of scope for
- * FPS computations.
+ * The listener will stream fps updates for the layer tree rooted at the layer denoted by the
+ * task ID, i.e., the layer must have the task ID as part of its layer metadata with key
+ * METADATA_TASK_ID. If there is no such layer, then no fps is expected to be reported.
*
* Multiple listeners may be supported.
*
- * Requires the ACCESS_SURFACE_FLINGER permission.
+ * Requires the READ_FRAME_BUFFER permission.
*/
- virtual status_t addFpsListener(const sp<IBinder>& layerHandle,
- const sp<gui::IFpsListener>& listener) = 0;
+ virtual status_t addFpsListener(int32_t taskId, const sp<gui::IFpsListener>& listener) = 0;
/*
* Removes a listener that was streaming fps updates from SurfaceFlinger.
*/
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index ab0347c..de88943 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -589,8 +589,7 @@
const sp<IBinder>& stopLayerHandle,
const sp<IRegionSamplingListener>& listener);
static status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener);
- static status_t addFpsListener(const sp<IBinder>& layerHandle,
- const sp<gui::IFpsListener>& listener);
+ static status_t addFpsListener(int32_t taskId, const sp<gui::IFpsListener>& listener);
static status_t removeFpsListener(const sp<gui::IFpsListener>& listener);
private:
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 91b2aff..e8fb71d 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -824,8 +824,7 @@
const sp<IRegionSamplingListener>& /*listener*/) override {
return NO_ERROR;
}
- status_t addFpsListener(const sp<IBinder>& /*layerHandle*/,
- const sp<gui::IFpsListener>& /*listener*/) {
+ status_t addFpsListener(int32_t /*taskId*/, const sp<gui::IFpsListener>& /*listener*/) {
return NO_ERROR;
}
status_t removeFpsListener(const sp<gui::IFpsListener>& /*listener*/) { return NO_ERROR; }