Remove __linux__ ifdefs where not needed
The downstream branches now know about Parcel and binder, so in some
places, these #ifdef statements are not needed.
This CL should help reduce the divergence with downstream efforts. See
the merge conflict resolution CL as an example:
https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/native/+/27201796/-2..3
Bug: 309829647
Test: presubmit
Change-Id: Iec17cface5069ca79a565c205546db8ada8a07ee
diff --git a/include/input/Input.h b/include/input/Input.h
index 092a698..e939145 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -41,13 +41,11 @@
* Additional private constants not defined in ndk/ui/input.h.
*/
enum {
-#ifdef __linux__
+
/* This event was generated or modified by accessibility service. */
AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT =
android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT,
-#else
- AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800,
-#endif
+
/* Signifies that the key is being predispatched */
AKEY_EVENT_FLAG_PREDISPATCH = 0x20000000,
@@ -90,15 +88,11 @@
AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE =
android::os::IInputConstants::MOTION_EVENT_FLAG_NO_FOCUS_CHANGE,
-#if defined(__linux__)
/**
* This event was generated or modified by accessibility service.
*/
AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT =
android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT,
-#else
- AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800,
-#endif
AMOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS =
android::os::IInputConstants::MOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS,
@@ -204,9 +198,7 @@
namespace android {
-#ifdef __linux__
class Parcel;
-#endif
/*
* Apply the given transform to the point without applying any translation/offset.
@@ -312,12 +304,8 @@
POLICY_FLAG_RAW_MASK = 0x0000ffff,
-#ifdef __linux__
POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY =
android::os::IInputConstants::POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY,
-#else
- POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY = 0x20000,
-#endif
/* These flags are set by the input dispatcher. */
@@ -486,10 +474,8 @@
vec2 getXYValue() const { return vec2(getX(), getY()); }
-#ifdef __linux__
status_t readFromParcel(Parcel* parcel);
status_t writeToParcel(Parcel* parcel) const;
-#endif
bool operator==(const PointerCoords& other) const;
inline bool operator!=(const PointerCoords& other) const {
@@ -912,10 +898,8 @@
// Matrix is in row-major form and compatible with SkMatrix.
void applyTransform(const std::array<float, 9>& matrix);
-#ifdef __linux__
status_t readFromParcel(Parcel* parcel);
status_t writeToParcel(Parcel* parcel) const;
-#endif
static bool isTouchEvent(uint32_t source, int32_t action);
inline bool isTouchEvent() const {
diff --git a/include/input/KeyCharacterMap.h b/include/input/KeyCharacterMap.h
index dfcf766..92d5ec4 100644
--- a/include/input/KeyCharacterMap.h
+++ b/include/input/KeyCharacterMap.h
@@ -19,9 +19,7 @@
#include <stdint.h>
#include <list>
-#ifdef __linux__
#include <binder/IBinder.h>
-#endif
#include <android-base/result.h>
#include <input/Input.h>
@@ -144,13 +142,11 @@
std::pair<int32_t /*keyCode*/, int32_t /*metaState*/> applyKeyBehavior(int32_t keyCode,
int32_t metaState) const;
-#ifdef __linux__
/* Reads a key map from a parcel. */
static std::unique_ptr<KeyCharacterMap> readFromParcel(Parcel* parcel);
/* Writes a key map to a parcel. */
void writeToParcel(Parcel* parcel) const;
-#endif
bool operator==(const KeyCharacterMap& other) const = default;
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index d271563..1178d02 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -32,9 +32,7 @@
#include <input/InputDevice.h>
#include <input/InputEventLabels.h>
-#ifdef __linux__
#include <binder/Parcel.h>
-#endif
#if defined(__ANDROID__)
#include <sys/random.h>
#endif
@@ -483,7 +481,6 @@
scaleAxisValue(*this, AMOTION_EVENT_AXIS_RELATIVE_Y, windowYScale);
}
-#ifdef __linux__
status_t PointerCoords::readFromParcel(Parcel* parcel) {
bits = parcel->readInt64();
@@ -511,7 +508,6 @@
parcel->writeBool(isResampled);
return OK;
}
-#endif
void PointerCoords::tooManyAxes(int axis) {
ALOGW("Could not set value for axis %d because the PointerCoords structure is full and "
@@ -801,7 +797,6 @@
}
}
-#ifdef __linux__
static status_t readFromParcel(ui::Transform& transform, const Parcel& parcel) {
float dsdx, dtdx, tx, dtdy, dsdy, ty;
status_t status = parcel.readFloat(&dsdx);
@@ -948,7 +943,6 @@
}
return OK;
}
-#endif
bool MotionEvent::isTouchEvent(uint32_t source, int32_t action) {
if (isFromSource(source, AINPUT_SOURCE_CLASS_POINTER)) {
diff --git a/libs/input/KeyCharacterMap.cpp b/libs/input/KeyCharacterMap.cpp
index 41909bf..f75bf41 100644
--- a/libs/input/KeyCharacterMap.cpp
+++ b/libs/input/KeyCharacterMap.cpp
@@ -19,11 +19,9 @@
#include <stdlib.h>
#include <string.h>
-#ifdef __linux__
-#include <binder/Parcel.h>
-#endif
#include <android/keycodes.h>
#include <attestation/HmacKeyManager.h>
+#include <binder/Parcel.h>
#include <input/InputEventLabels.h>
#include <input/KeyCharacterMap.h>
#include <input/Keyboard.h>
@@ -611,7 +609,6 @@
}
}
-#ifdef __linux__
std::unique_ptr<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) {
if (parcel == nullptr) {
ALOGE("%s: Null parcel", __func__);
@@ -744,7 +741,6 @@
parcel->writeInt32(toAndroidKeyCode);
}
}
-#endif // __linux__
// --- KeyCharacterMap::Parser ---