Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b58c0c31 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

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
parent 870f4e7e
Loading
Loading
Loading
Loading
+2 −18
Original line number Diff line number Diff line
@@ -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 @@ enum {
    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 @@ struct AInputDevice {

namespace android {

#ifdef __linux__
class Parcel;
#endif

/*
 * Apply the given transform to the point without applying any translation/offset.
@@ -312,12 +304,8 @@ enum {

    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 @@ struct PointerCoords {

    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 @@ public:
    // 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 {
+0 −4
Original line number Diff line number Diff line
@@ -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 @@ public:
    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;

+0 −6
Original line number Diff line number Diff line
@@ -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 @@ void PointerCoords::scale(float globalScaleFactor, float windowXScale, float win
    scaleAxisValue(*this, AMOTION_EVENT_AXIS_RELATIVE_Y, windowYScale);
}

#ifdef __linux__
status_t PointerCoords::readFromParcel(Parcel* parcel) {
    bits = parcel->readInt64();

@@ -511,7 +508,6 @@ status_t PointerCoords::writeToParcel(Parcel* parcel) const {
    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 @@ void MotionEvent::applyTransform(const std::array<float, 9>& matrix) {
    }
}

#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 @@ status_t MotionEvent::writeToParcel(Parcel* parcel) const {
    }
    return OK;
}
#endif

bool MotionEvent::isTouchEvent(uint32_t source, int32_t action) {
    if (isFromSource(source, AINPUT_SOURCE_CLASS_POINTER)) {
+1 −5
Original line number Diff line number Diff line
@@ -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 @@ void KeyCharacterMap::addLockedMetaKey(Vector<KeyEvent>& outEvents,
    }
}

#ifdef __linux__
std::unique_ptr<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) {
    if (parcel == nullptr) {
        ALOGE("%s: Null parcel", __func__);
@@ -744,7 +741,6 @@ void KeyCharacterMap::writeToParcel(Parcel* parcel) const {
        parcel->writeInt32(toAndroidKeyCode);
    }
}
#endif // __linux__

// --- KeyCharacterMap::Parser ---