SurfaceFlinger: Add touch events to Scheduler
Add the notion of Touch Events to Scheduler to enhance the algorithm
to move to Performance refresh rate.
Scheduler selects Performance when:
- There is a touch event
- There is a buffer to HWC
This change also removes the behavior of Scheduler to move to Performance
on Choreographer callbacks.
Test: Switch between apps using gesture navigation
Bug: 131906818
Change-Id: I588cfc32449e87744e829dc7c5261a2e4151a8f8
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index 4372e16..6c9d81a 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -955,6 +955,27 @@
}
return NO_ERROR;
}
+
+ virtual status_t notifyPowerHint(int32_t hintId) {
+ Parcel data, reply;
+ status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
+ if (error != NO_ERROR) {
+ ALOGE("notifyPowerHint: failed to write interface token: %d", error);
+ return error;
+ }
+ error = data.writeInt32(hintId);
+ if (error != NO_ERROR) {
+ ALOGE("notifyPowerHint: failed to write hintId: %d", error);
+ return error;
+ }
+ error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_HINT, data, &reply,
+ IBinder::FLAG_ONEWAY);
+ if (error != NO_ERROR) {
+ ALOGE("notifyPowerHint: failed to transact: %d", error);
+ return error;
+ }
+ return NO_ERROR;
+ }
};
// Out-of-line virtual method definition to trigger vtable emission in this
@@ -1556,6 +1577,16 @@
}
return setDisplayBrightness(displayToken, brightness);
}
+ case NOTIFY_POWER_HINT: {
+ CHECK_INTERFACE(ISurfaceComposer, data, reply);
+ int32_t hintId;
+ status_t error = data.readInt32(&hintId);
+ if (error != NO_ERROR) {
+ ALOGE("notifyPowerHint: failed to read hintId: %d", error);
+ return error;
+ }
+ return notifyPowerHint(hintId);
+ }
default: {
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 5d4367d..1033d3d 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1543,6 +1543,10 @@
return ComposerService::getComposerService()->setDisplayBrightness(displayToken, brightness);
}
+status_t SurfaceComposerClient::notifyPowerHint(int32_t hintId) {
+ return ComposerService::getComposerService()->notifyPowerHint(hintId);
+}
+
// ----------------------------------------------------------------------------
status_t ScreenshotClient::capture(const sp<IBinder>& display, const ui::Dataspace reqDataSpace,
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index fd67754..e2f7736 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -425,6 +425,16 @@
*/
virtual status_t setDisplayBrightness(const sp<IBinder>& displayToken,
float brightness) const = 0;
+
+ /*
+ * Sends a power hint to the composer. This function is asynchronous.
+ *
+ * hintId
+ * hint id according to android::hardware::power::V1_0::PowerHint
+ *
+ * Returns NO_ERROR upon success.
+ */
+ virtual status_t notifyPowerHint(int32_t hintId) = 0;
};
// ----------------------------------------------------------------------------
@@ -477,6 +487,7 @@
GET_DISPLAY_BRIGHTNESS_SUPPORT,
SET_DISPLAY_BRIGHTNESS,
CAPTURE_SCREEN_BY_ID,
+ NOTIFY_POWER_HINT,
// Always append new enum to the end.
};
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index a038838..0e17c7b 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -201,6 +201,16 @@
*/
static status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness);
+ /*
+ * Sends a power hint to the composer. This function is asynchronous.
+ *
+ * hintId
+ * hint id according to android::hardware::power::V1_0::PowerHint
+ *
+ * Returns NO_ERROR upon success.
+ */
+ static status_t notifyPowerHint(int32_t hintId);
+
// ------------------------------------------------------------------------
// surface creation / destruction
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index db97fae..960cf18 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -704,6 +704,7 @@
std::vector<int32_t>* /*outAllowedConfigs*/) override {
return NO_ERROR;
}
+ status_t notifyPowerHint(int32_t /*hintId*/) override { return NO_ERROR; }
protected:
IBinder* onAsBinder() override { return nullptr; }