Use current thread for SetTaskProfiles
After the recent std::thread refactor, the input thread profile is being
set to the current thread. Therefore, we no longer have to explicitly
provide a thread id to the SetTaskProfiles - we can just send "0", and
rely on the fact that ExecuteForTask calls GetThreadId() for those
cases. That's not documented, but is an existing behaviour.
This will be supported on more platforms, and allows us to remove the
__ANDROID__ ifdefs.
Bug: 378761104
Test: none
Flag: EXEMPT refactor
Change-Id: I8e8325e1ecb43d31621657d250530924f40ecc43
diff --git a/services/inputflinger/InputThread.cpp b/services/inputflinger/InputThread.cpp
index 41b1b7e..7f7b289 100644
--- a/services/inputflinger/InputThread.cpp
+++ b/services/inputflinger/InputThread.cpp
@@ -28,13 +28,8 @@
namespace {
bool applyInputEventProfile() {
-#if defined(__ANDROID__)
- return SetTaskProfiles(gettid(), {"InputPolicy"});
-#else
- // Since thread information (gettid()) is not available and there's no benefit of
- // applying the task profile on host, return directly.
- return true;
-#endif
+ static constexpr pid_t CURRENT_THREAD = 0;
+ return SetTaskProfiles(CURRENT_THREAD, {"InputPolicy"});
}
class JvmAttacher {