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

Commit 9ae4bd09 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11800966 from 610c01d2 to 24Q3-release

Change-Id: I151e4768491c2d423faed036abf22aaaa038f105
parents c4105d6d 610c01d2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@
#define __INTRODUCED_IN(__api_level) /* nothing */
#endif
#if !defined(__DEPRECATED_IN)
#define __DEPRECATED_IN(__api_level) __attribute__((__deprecated__))
#define __DEPRECATED_IN(__api_level, ...) __attribute__((__deprecated__))
#endif

__BEGIN_DECLS
+12 −0
Original line number Diff line number Diff line
@@ -24,6 +24,18 @@

namespace android::ftl {

// Determines if a container contains a value. This is a simplified version of the C++23
// std::ranges::contains function.
//
//   const ftl::StaticVector vector = {1, 2, 3};
//   assert(ftl::contains(vector, 1));
//
// TODO: Remove in C++23.
template <typename Container, typename Value>
auto contains(const Container& container, const Value& value) -> bool {
  return std::find(container.begin(), container.end(), value) != container.end();
}

// Adapter for std::find_if that converts the return value from iterator to optional.
//
//   const ftl::StaticVector vector = {"upside"sv, "down"sv, "cake"sv};
+104 −8
Original line number Diff line number Diff line
@@ -68,26 +68,28 @@ class NonNull final {
  constexpr NonNull(const NonNull&) = default;
  constexpr NonNull& operator=(const NonNull&) = default;

  constexpr const Pointer& get() const { return pointer_; }
  constexpr explicit operator const Pointer&() const { return get(); }
  [[nodiscard]] constexpr const Pointer& get() const { return pointer_; }
  [[nodiscard]] constexpr explicit operator const Pointer&() const { return get(); }

  // Move operations. These break the invariant, so care must be taken to avoid subsequent access.

  constexpr NonNull(NonNull&&) = default;
  constexpr NonNull& operator=(NonNull&&) = default;

  constexpr Pointer take() && { return std::move(pointer_); }
  constexpr explicit operator Pointer() && { return take(); }
  [[nodiscard]] constexpr Pointer take() && { return std::move(pointer_); }
  [[nodiscard]] constexpr explicit operator Pointer() && { return take(); }

  // Dereferencing.
  constexpr decltype(auto) operator*() const { return *get(); }
  constexpr decltype(auto) operator->() const { return get(); }
  [[nodiscard]] constexpr decltype(auto) operator*() const { return *get(); }
  [[nodiscard]] constexpr decltype(auto) operator->() const { return get(); }

  [[nodiscard]] constexpr explicit operator bool() const { return !(pointer_ == nullptr); }

  // Private constructor for ftl::as_non_null. Excluded from candidate constructors for conversions
  // through the passkey idiom, for clear compilation errors.
  template <typename P>
  constexpr NonNull(Passkey, P&& pointer) : pointer_(std::forward<P>(pointer)) {
    if (!pointer_) std::abort();
    if (pointer_ == nullptr) std::abort();
  }

 private:
@@ -98,11 +100,13 @@ class NonNull final {
};

template <typename P>
constexpr auto as_non_null(P&& pointer) -> NonNull<std::decay_t<P>> {
[[nodiscard]] constexpr auto as_non_null(P&& pointer) -> NonNull<std::decay_t<P>> {
  using Passkey = typename NonNull<std::decay_t<P>>::Passkey;
  return {Passkey{}, std::forward<P>(pointer)};
}

// NonNull<P> <=> NonNull<Q>

template <typename P, typename Q>
constexpr bool operator==(const NonNull<P>& lhs, const NonNull<Q>& rhs) {
  return lhs.get() == rhs.get();
@@ -113,4 +117,96 @@ constexpr bool operator!=(const NonNull<P>& lhs, const NonNull<Q>& rhs) {
  return !operator==(lhs, rhs);
}

template <typename P, typename Q>
constexpr bool operator<(const NonNull<P>& lhs, const NonNull<Q>& rhs) {
  return lhs.get() < rhs.get();
}

template <typename P, typename Q>
constexpr bool operator<=(const NonNull<P>& lhs, const NonNull<Q>& rhs) {
  return lhs.get() <= rhs.get();
}

template <typename P, typename Q>
constexpr bool operator>=(const NonNull<P>& lhs, const NonNull<Q>& rhs) {
  return lhs.get() >= rhs.get();
}

template <typename P, typename Q>
constexpr bool operator>(const NonNull<P>& lhs, const NonNull<Q>& rhs) {
  return lhs.get() > rhs.get();
}

// NonNull<P> <=> Q

template <typename P, typename Q>
constexpr bool operator==(const NonNull<P>& lhs, const Q& rhs) {
  return lhs.get() == rhs;
}

template <typename P, typename Q>
constexpr bool operator!=(const NonNull<P>& lhs, const Q& rhs) {
  return lhs.get() != rhs;
}

template <typename P, typename Q>
constexpr bool operator<(const NonNull<P>& lhs, const Q& rhs) {
  return lhs.get() < rhs;
}

template <typename P, typename Q>
constexpr bool operator<=(const NonNull<P>& lhs, const Q& rhs) {
  return lhs.get() <= rhs;
}

template <typename P, typename Q>
constexpr bool operator>=(const NonNull<P>& lhs, const Q& rhs) {
  return lhs.get() >= rhs;
}

template <typename P, typename Q>
constexpr bool operator>(const NonNull<P>& lhs, const Q& rhs) {
  return lhs.get() > rhs;
}

// P <=> NonNull<Q>

template <typename P, typename Q>
constexpr bool operator==(const P& lhs, const NonNull<Q>& rhs) {
  return lhs == rhs.get();
}

template <typename P, typename Q>
constexpr bool operator!=(const P& lhs, const NonNull<Q>& rhs) {
  return lhs != rhs.get();
}

template <typename P, typename Q>
constexpr bool operator<(const P& lhs, const NonNull<Q>& rhs) {
  return lhs < rhs.get();
}

template <typename P, typename Q>
constexpr bool operator<=(const P& lhs, const NonNull<Q>& rhs) {
  return lhs <= rhs.get();
}

template <typename P, typename Q>
constexpr bool operator>=(const P& lhs, const NonNull<Q>& rhs) {
  return lhs >= rhs.get();
}

template <typename P, typename Q>
constexpr bool operator>(const P& lhs, const NonNull<Q>& rhs) {
  return lhs > rhs.get();
}

}  // namespace android::ftl

// Specialize std::hash for ftl::NonNull<T>
template <typename P>
struct std::hash<android::ftl::NonNull<P>> {
  std::size_t operator()(const android::ftl::NonNull<P>& ptr) const {
    return std::hash<P>()(ptr.get());
  }
};
+19 −11
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ 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, // 0x800,
            android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT,
#else
    AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800,
#endif
@@ -54,11 +54,11 @@ enum {
    AKEY_EVENT_FLAG_START_TRACKING = 0x40000000,

    /* Key event is inconsistent with previously sent key events. */
    AKEY_EVENT_FLAG_TAINTED = 0x80000000,
    AKEY_EVENT_FLAG_TAINTED = android::os::IInputConstants::INPUT_EVENT_FLAG_TAINTED,
};

enum {

    // AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED is defined in include/android/input.h
    /**
     * This flag indicates that the window that received this motion event is partly
     * or wholly obscured by another visible window above it.  This flag is set to true
@@ -69,13 +69,16 @@ enum {
     * to drop the suspect touches or to take additional precautions to confirm the user's
     * actual intent.
     */
    AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2,

    AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED =
            android::os::IInputConstants::MOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED,
    AMOTION_EVENT_FLAG_HOVER_EXIT_PENDING =
            android::os::IInputConstants::MOTION_EVENT_FLAG_HOVER_EXIT_PENDING,
    /**
     * This flag indicates that the event has been generated by a gesture generator. It
     * provides a hint to the GestureDetector to not apply any touch slop.
     */
    AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE = 0x8,
    AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE =
            android::os::IInputConstants::MOTION_EVENT_FLAG_IS_GENERATED_GESTURE,

    /**
     * This flag indicates that the event will not cause a focus change if it is directed to an
@@ -83,20 +86,24 @@ enum {
     * gestures to allow the user to direct gestures to an unfocused window without bringing it
     * into focus.
     */
    AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE = 0x40,
    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, // 0x800,
            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,

    /* Motion event is inconsistent with previously sent motion events. */
    AMOTION_EVENT_FLAG_TAINTED = 0x80000000,
    AMOTION_EVENT_FLAG_TAINTED = android::os::IInputConstants::INPUT_EVENT_FLAG_TAINTED,
};

/**
@@ -116,9 +123,10 @@ constexpr int32_t VERIFIED_MOTION_EVENT_FLAGS = AMOTION_EVENT_FLAG_WINDOW_IS_OBS
/**
 * This flag indicates that the point up event has been canceled.
 * Typically this is used for palm event when the user has accidental touches.
 * TODO: Adjust flag to public api
 * TODO(b/338143308): Add this to NDK
 */
constexpr int32_t AMOTION_EVENT_FLAG_CANCELED = 0x20;
constexpr int32_t AMOTION_EVENT_FLAG_CANCELED =
        android::os::IInputConstants::INPUT_EVENT_FLAG_CANCELED;

enum {
    /*
+2 −1
Original line number Diff line number Diff line
@@ -130,8 +130,9 @@ enum class InputDeviceLightType : int32_t {
    INPUT = 0,
    PLAYER_ID = 1,
    KEYBOARD_BACKLIGHT = 2,
    KEYBOARD_MIC_MUTE = 3,

    ftl_last = KEYBOARD_BACKLIGHT
    ftl_last = KEYBOARD_MIC_MUTE
};

enum class InputDeviceLightCapability : uint32_t {
Loading