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

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

Snap for 11954976 from 9ad62b5e to 24Q3-release

Change-Id: I73f1de42bd8bbd61ba013ce3146d2bfe605daae5
parents 7760ec5d 9ad62b5e
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -69,6 +69,36 @@
    exp_.value();                                                         \
  })

// Given an expression `expr` that evaluates to an ftl::Expected<T, E> result (R for short),
// FTL_EXPECT unwraps T out of R, or bails out of the enclosing function F if R has an error E.
// While FTL_TRY bails out with R, FTL_EXPECT bails out with E, which is useful when F does not
// need to propagate R because T is not relevant to the caller.
//
// Example usage:
//
//   using StringExp = ftl::Expected<std::string, std::errc>;
//
//   std::errc repeat(StringExp exp, std::string& out) {
//     const std::string str = FTL_EXPECT(exp);
//     out = str + str;
//     return std::errc::operation_in_progress;
//   }
//
//   std::string str;
//   assert(std::errc::operation_in_progress == repeat(StringExp("ha"s), str));
//   assert("haha"s == str);
//   assert(std::errc::bad_message == repeat(ftl::Unexpected(std::errc::bad_message), str));
//   assert("haha"s == str);
//
#define FTL_EXPECT(expr)              \
  ({                                  \
    auto exp_ = (expr);               \
    if (!exp_.has_value()) {          \
      return std::move(exp_.error()); \
    }                                 \
    exp_.value();                     \
  })

namespace android::ftl {

// Superset of base::expected<T, E> with monadic operations.
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ namespace android::ftl {
//   // Create a typedef to give a more meaningful name and bound the size.
//   using MyFunction = ftl::Function<int(std::string_view), 2>;
//   int* ptr = nullptr;
//   auto f1 = MyFunction::make_function(
//   auto f1 = MyFunction::make(
//       [cls = &cls, ptr](std::string_view sv) {
//           return cls->on_string(ptr, sv);
//       });
+23 −7
Original line number Diff line number Diff line
@@ -99,6 +99,18 @@ enum {

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

    /** Private flag, not used in Java. */
    AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_ORIENTATION =
            android::os::IInputConstants::MOTION_EVENT_PRIVATE_FLAG_SUPPORTS_ORIENTATION,

    /** Private flag, not used in Java. */
    AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION = android::os::IInputConstants::
            MOTION_EVENT_PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION,

    /** Mask for all private flags that are not used in Java. */
    AMOTION_EVENT_PRIVATE_FLAG_MASK = AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_ORIENTATION |
            AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION,
};

/**
@@ -209,8 +221,12 @@ vec2 transformWithoutTranslation(const ui::Transform& transform, const vec2& xy)
 * Transform an angle on the x-y plane. An angle of 0 radians corresponds to "north" or
 * pointing upwards in the negative Y direction, a positive angle points towards the right, and a
 * negative angle points towards the left.
 *
 * If the angle represents a direction that needs to be preserved, set isDirectional to true to get
 * an output range of [-pi, pi]. If the angle's direction does not need to be preserved, set
 * isDirectional to false to get an output range of [-pi/2, pi/2].
 */
float transformAngle(const ui::Transform& transform, float angleRadians);
float transformAngle(const ui::Transform& transform, float angleRadians, bool isDirectional);

/**
 * The type of the InputEvent.
@@ -472,8 +488,6 @@ struct PointerCoords {
    // axes, however the window scaling will not.
    void scale(float globalScale, float windowXScale, float windowYScale);

    void transform(const ui::Transform& transform);

    inline float getX() const {
        return getAxisValue(AMOTION_EVENT_AXIS_X);
    }
@@ -940,10 +954,12 @@ public:
    // relative mouse device (since SOURCE_RELATIVE_MOUSE is a non-pointer source). These methods
    // are used to apply these transformations for different axes.
    static vec2 calculateTransformedXY(uint32_t source, const ui::Transform&, const vec2& xy);
    static float calculateTransformedAxisValue(int32_t axis, uint32_t source, const ui::Transform&,
                                               const PointerCoords&);
    static PointerCoords calculateTransformedCoords(uint32_t source, const ui::Transform&,
                                                    const PointerCoords&);
    static float calculateTransformedAxisValue(int32_t axis, uint32_t source, int32_t flags,
                                               const ui::Transform&, const PointerCoords&);
    static void calculateTransformedCoordsInPlace(PointerCoords& coords, uint32_t source,
                                                  int32_t flags, const ui::Transform&);
    static PointerCoords calculateTransformedCoords(uint32_t source, int32_t flags,
                                                    const ui::Transform&, const PointerCoords&);
    // The rounding precision for transformed motion events.
    static constexpr float ROUNDING_PRECISION = 0.001f;

+5 −1
Original line number Diff line number Diff line
@@ -30,7 +30,11 @@ enum AServiceManager_AddServiceFlag : uint32_t {
     * Services with methods that perform file IO, web socket creation or ways to egress data must
     * not be added with this flag for privacy concerns.
     */
    ADD_SERVICE_ALLOW_ISOLATED = 1,
    ADD_SERVICE_ALLOW_ISOLATED = 1 << 0,
    ADD_SERVICE_DUMP_FLAG_PRIORITY_CRITICAL = 1 << 1,
    ADD_SERVICE_DUMP_FLAG_PRIORITY_HIGH = 1 << 2,
    ADD_SERVICE_DUMP_FLAG_PRIORITY_NORMAL = 1 << 3,
    ADD_SERVICE_DUMP_FLAG_PRIORITY_DEFAULT = 1 << 4,
};

/**
+19 −1
Original line number Diff line number Diff line
@@ -49,7 +49,25 @@ binder_exception_t AServiceManager_addServiceWithFlags(AIBinder* binder, const c
    sp<IServiceManager> sm = defaultServiceManager();

    bool allowIsolated = flags & AServiceManager_AddServiceFlag::ADD_SERVICE_ALLOW_ISOLATED;
    status_t exception = sm->addService(String16(instance), binder->getBinder(), allowIsolated);
    int dumpFlags = 0;
    if (flags & AServiceManager_AddServiceFlag::ADD_SERVICE_DUMP_FLAG_PRIORITY_CRITICAL) {
        dumpFlags |= IServiceManager::DUMP_FLAG_PRIORITY_CRITICAL;
    }
    if (flags & AServiceManager_AddServiceFlag::ADD_SERVICE_DUMP_FLAG_PRIORITY_HIGH) {
        dumpFlags |= IServiceManager::DUMP_FLAG_PRIORITY_HIGH;
    }
    if (flags & AServiceManager_AddServiceFlag::ADD_SERVICE_DUMP_FLAG_PRIORITY_NORMAL) {
        dumpFlags |= IServiceManager::DUMP_FLAG_PRIORITY_NORMAL;
    }
    if (flags & AServiceManager_AddServiceFlag::ADD_SERVICE_DUMP_FLAG_PRIORITY_DEFAULT) {
        dumpFlags |= IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT;
    }
    if (dumpFlags == 0) {
        dumpFlags = IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT;
    }
    status_t exception =
            sm->addService(String16(instance), binder->getBinder(), allowIsolated, dumpFlags);

    return PruneException(exception);
}

Loading