Cache remove_app_switch_drops flag

All of these new flags are not cached by default, so let's cache them to
avoid impacting performance.

Bug: 308729073
Test: TEST=inputflinger_tests; m $TEST &&
$ANDROID_HOST_OUT/nativetest64/$TEST/$TESTCache
remove_app_switch_drops flag

Change-Id: I3cfe29bf0538a0b88b14d59841328d43b6269972
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 47b9a0c..156697a 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -72,6 +72,8 @@
 using android::os::InputEventInjectionSync;
 namespace input_flags = com::android::input::flags;
 
+static const bool REMOVE_APP_SWITCH_DROPS = input_flags::remove_app_switch_drops();
+
 namespace android::inputdispatcher {
 
 namespace {
@@ -952,7 +954,7 @@
     // Essentially we start a short timeout when an app switch key (HOME / ENDCALL) has
     // been pressed.  When it expires, we preempt dispatch and drop all other pending events.
     bool isAppSwitchDue;
-    if (!input_flags::remove_app_switch_drops()) {
+    if (!REMOVE_APP_SWITCH_DROPS) {
         isAppSwitchDue = mAppSwitchDueTime <= currentTime;
         if (mAppSwitchDueTime < *nextWakeupTime) {
             *nextWakeupTime = mAppSwitchDueTime;
@@ -963,7 +965,7 @@
     // If we don't already have a pending event, go grab one.
     if (!mPendingEvent) {
         if (mInboundQueue.empty()) {
-            if (!input_flags::remove_app_switch_drops()) {
+            if (!REMOVE_APP_SWITCH_DROPS) {
                 if (isAppSwitchDue) {
                     // The inbound queue is empty so the app switch key we were waiting
                     // for will never arrive.  Stop waiting for it.
@@ -1067,7 +1069,7 @@
 
         case EventEntry::Type::KEY: {
             std::shared_ptr<KeyEntry> keyEntry = std::static_pointer_cast<KeyEntry>(mPendingEvent);
-            if (!input_flags::remove_app_switch_drops()) {
+            if (!REMOVE_APP_SWITCH_DROPS) {
                 if (isAppSwitchDue) {
                     if (isAppSwitchKeyEvent(*keyEntry)) {
                         resetPendingAppSwitchLocked(true);
@@ -1090,7 +1092,7 @@
         case EventEntry::Type::MOTION: {
             std::shared_ptr<MotionEntry> motionEntry =
                     std::static_pointer_cast<MotionEntry>(mPendingEvent);
-            if (!input_flags::remove_app_switch_drops()) {
+            if (!REMOVE_APP_SWITCH_DROPS) {
                 if (dropReason == DropReason::NOT_DROPPED && isAppSwitchDue) {
                     dropReason = DropReason::APP_SWITCH;
                 }
@@ -1108,7 +1110,7 @@
         case EventEntry::Type::SENSOR: {
             std::shared_ptr<SensorEntry> sensorEntry =
                     std::static_pointer_cast<SensorEntry>(mPendingEvent);
-            if (!input_flags::remove_app_switch_drops()) {
+            if (!REMOVE_APP_SWITCH_DROPS) {
                 if (dropReason == DropReason::NOT_DROPPED && isAppSwitchDue) {
                     dropReason = DropReason::APP_SWITCH;
                 }
@@ -1214,7 +1216,7 @@
             // the app switch key.
             const KeyEntry& keyEntry = static_cast<const KeyEntry&>(entry);
 
-            if (!input_flags::remove_app_switch_drops()) {
+            if (!REMOVE_APP_SWITCH_DROPS) {
                 if (isAppSwitchKeyEvent(keyEntry)) {
                     if (keyEntry.action == AKEY_EVENT_ACTION_DOWN) {
                         mAppSwitchSawKeyDown = true;
@@ -5843,7 +5845,7 @@
     }
 
     dump += "input_flags::remove_app_switch_drops() = ";
-    dump += toString(input_flags::remove_app_switch_drops());
+    dump += toString(REMOVE_APP_SWITCH_DROPS);
     dump += "\n";
     if (isAppSwitchPendingLocked()) {
         dump += StringPrintf(INDENT "AppSwitch: pending, due in %" PRId64 "ms\n",