Merge "Add flag for the ZlsProcessor and other processors." into main
diff --git a/include/input/InputEventBuilders.h b/include/input/InputEventBuilders.h
index 55e0583..5bd5070 100644
--- a/include/input/InputEventBuilders.h
+++ b/include/input/InputEventBuilders.h
@@ -19,6 +19,8 @@
#include <android/input.h>
#include <attestation/HmacKeyManager.h>
#include <input/Input.h>
+#include <input/InputTransport.h>
+#include <ui/LogicalDisplayId.h>
#include <utils/Timers.h> // for nsecs_t, systemTime
#include <vector>
@@ -44,6 +46,11 @@
PointerBuilder& y(float y) { return axis(AMOTION_EVENT_AXIS_Y, y); }
+ PointerBuilder& isResampled(bool isResampled) {
+ mCoords.isResampled = isResampled;
+ return *this;
+ }
+
PointerBuilder& axis(int32_t axis, float value) {
mCoords.setAxisValue(axis, value);
return *this;
@@ -58,6 +65,87 @@
PointerCoords mCoords;
};
+class InputMessageBuilder {
+public:
+ InputMessageBuilder(InputMessage::Type type, uint32_t seq) : mType{type}, mSeq{seq} {}
+
+ InputMessageBuilder& eventId(int32_t eventId) {
+ mEventId = eventId;
+ return *this;
+ }
+
+ InputMessageBuilder& eventTime(nsecs_t eventTime) {
+ mEventTime = eventTime;
+ return *this;
+ }
+
+ InputMessageBuilder& deviceId(DeviceId deviceId) {
+ mDeviceId = deviceId;
+ return *this;
+ }
+
+ InputMessageBuilder& source(int32_t source) {
+ mSource = source;
+ return *this;
+ }
+
+ InputMessageBuilder& displayId(ui::LogicalDisplayId displayId) {
+ mDisplayId = displayId;
+ return *this;
+ }
+
+ InputMessageBuilder& action(int32_t action) {
+ mAction = action;
+ return *this;
+ }
+
+ InputMessageBuilder& downTime(nsecs_t downTime) {
+ mDownTime = downTime;
+ return *this;
+ }
+
+ InputMessageBuilder& pointer(PointerBuilder pointerBuilder) {
+ mPointers.push_back(pointerBuilder);
+ return *this;
+ }
+
+ InputMessage build() const {
+ InputMessage message{};
+ // Header
+ message.header.type = mType;
+ message.header.seq = mSeq;
+ // Body
+ message.body.motion.eventId = mEventId;
+ message.body.motion.pointerCount = mPointers.size();
+ message.body.motion.eventTime = mEventTime;
+ message.body.motion.deviceId = mDeviceId;
+ message.body.motion.source = mSource;
+ message.body.motion.displayId = mDisplayId.val();
+ message.body.motion.action = mAction;
+ message.body.motion.downTime = mDownTime;
+
+ for (size_t i = 0; i < mPointers.size(); ++i) {
+ message.body.motion.pointers[i].properties = mPointers[i].buildProperties();
+ message.body.motion.pointers[i].coords = mPointers[i].buildCoords();
+ }
+ return message;
+ }
+
+private:
+ const InputMessage::Type mType;
+ const uint32_t mSeq;
+
+ int32_t mEventId{InputEvent::nextId()};
+ nsecs_t mEventTime{systemTime(SYSTEM_TIME_MONOTONIC)};
+ DeviceId mDeviceId{DEFAULT_DEVICE_ID};
+ int32_t mSource{AINPUT_SOURCE_TOUCHSCREEN};
+ ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT};
+ int32_t mAction{AMOTION_EVENT_ACTION_MOVE};
+ nsecs_t mDownTime{mEventTime};
+
+ std::vector<PointerBuilder> mPointers;
+};
+
class MotionEventBuilder {
public:
MotionEventBuilder(int32_t action, int32_t source) {
diff --git a/libs/binder/BackendUnifiedServiceManager.h b/libs/binder/BackendUnifiedServiceManager.h
index f5d7e66..8f3839f 100644
--- a/libs/binder/BackendUnifiedServiceManager.h
+++ b/libs/binder/BackendUnifiedServiceManager.h
@@ -57,8 +57,6 @@
return mTheRealServiceManager->getInterfaceDescriptor();
}
- IBinder* onAsBinder() override { return IInterface::asBinder(mTheRealServiceManager).get(); }
-
private:
sp<os::IServiceManager> mTheRealServiceManager;
void toBinderService(const os::Service& in, os::Service* _out);
diff --git a/libs/binder/ndk/include_ndk/android/binder_ibinder.h b/libs/binder/ndk/include_ndk/android/binder_ibinder.h
index 2929bce..72d255e 100644
--- a/libs/binder/ndk/include_ndk/android/binder_ibinder.h
+++ b/libs/binder/ndk/include_ndk/android/binder_ibinder.h
@@ -771,7 +771,7 @@
* This provides a per-process-unique total ordering of binders where a null
* AIBinder* object is considered to be before all other binder objects.
* For instance, two binders refer to the same object in a local or remote
- * process when both AIBinder_lt(a, b) and AIBinder(b, a) are false. This API
+ * process when both AIBinder_lt(a, b) and AIBinder_lt(b, a) are false. This API
* might be used to insert and lookup binders in binary search trees.
*
* AIBinder* pointers themselves actually also create a per-process-unique total
diff --git a/libs/binder/ndk/include_platform/android/binder_process.h b/libs/binder/ndk/include_platform/android/binder_process.h
index 68528e1..6aff994 100644
--- a/libs/binder/ndk/include_platform/android/binder_process.h
+++ b/libs/binder/ndk/include_platform/android/binder_process.h
@@ -47,8 +47,11 @@
* be called once before startThreadPool. The number of threads can never decrease.
*
* This count refers to the number of threads that will be created lazily by the kernel, in
- * addition to the threads created by ABinderProcess_startThreadPool or
- * ABinderProcess_joinThreadPool.
+ * addition to the single threads created by ABinderProcess_startThreadPool (+1) or
+ * ABinderProcess_joinThreadPool (+1). Note: ABinderProcess_startThreadPool starts a thread
+ * itself, but it also enables up to the number of threads passed to this function to start.
+ * This function does not start any threads itself; it only configures
+ * ABinderProcess_startThreadPool.
*
* Do not use this from a library. Apps setup their own threadpools, and otherwise, the main
* function should be responsible for configuring the threadpool for the entire application.
@@ -63,8 +66,8 @@
bool ABinderProcess_isThreadPoolStarted(void);
/**
* This adds the current thread to the threadpool. This thread will be in addition to the thread
- * started by ABinderProcess_startThreadPool and the lazy kernel-started threads specified by
- * ABinderProcess_setThreadPoolMaxThreadCount.
+ * configured with ABinderProcess_setThreadPoolMaxThreadCount and started with
+ * ABinderProcess_startThreadPool.
*
* Do not use this from a library. Apps setup their own threadpools, and otherwise, the main
* function should be responsible for configuring the threadpool for the entire application.
diff --git a/libs/binder/rust/rpcbinder/Android.bp b/libs/binder/rust/rpcbinder/Android.bp
index 2e46345..174fe8a 100644
--- a/libs/binder/rust/rpcbinder/Android.bp
+++ b/libs/binder/rust/rpcbinder/Android.bp
@@ -32,6 +32,7 @@
apex_available: [
"//apex_available:platform",
"com.android.compos",
+ "com.android.microfuchsia",
"com.android.uwb",
"com.android.virt",
],
@@ -60,6 +61,7 @@
apex_available: [
"//apex_available:platform",
"com.android.compos",
+ "com.android.microfuchsia",
"com.android.uwb",
"com.android.virt",
],
@@ -93,6 +95,7 @@
apex_available: [
"//apex_available:platform",
"com.android.compos",
+ "com.android.microfuchsia",
"com.android.uwb",
"com.android.virt",
],
diff --git a/libs/binder/tests/Android.bp b/libs/binder/tests/Android.bp
index 21c32ac..9578713 100644
--- a/libs/binder/tests/Android.bp
+++ b/libs/binder/tests/Android.bp
@@ -46,7 +46,7 @@
"libbinder",
],
test_suites: [
- "device-tests",
+ "general-tests",
"vts",
],
}
@@ -137,7 +137,7 @@
"libgmock",
],
test_suites: [
- "device-tests",
+ "general-tests",
"vts",
],
require_root: true,
@@ -705,7 +705,7 @@
"libutils",
],
test_suites: [
- "device-tests",
+ "general-tests",
"vts",
],
require_root: true,
@@ -762,7 +762,7 @@
],
test_suites: [
- "device-tests",
+ "general-tests",
"vts",
],
require_root: true,
diff --git a/libs/binder/tests/binderRpcUniversalTests.cpp b/libs/binder/tests/binderRpcUniversalTests.cpp
index 2cec243..c6fd487 100644
--- a/libs/binder/tests/binderRpcUniversalTests.cpp
+++ b/libs/binder/tests/binderRpcUniversalTests.cpp
@@ -301,7 +301,8 @@
auto proc = createRpcTestSocketServerProcess({});
- sp<IBinder> someRealBinder = IInterface::asBinder(defaultServiceManager());
+ sp<IBinder> someRealBinder = defaultServiceManager()->getService(String16("activity"));
+ ASSERT_NE(someRealBinder, nullptr);
sp<IBinder> outBinder;
EXPECT_EQ(INVALID_OPERATION,
proc.rootIface->repeatBinder(someRealBinder, &outBinder).transactionError());
diff --git a/libs/bufferstreams/rust/src/lib.rs b/libs/bufferstreams/rust/src/lib.rs
index 17d4d87..9c48b49 100644
--- a/libs/bufferstreams/rust/src/lib.rs
+++ b/libs/bufferstreams/rust/src/lib.rs
@@ -37,23 +37,23 @@
/// BufferPublishers are required to adhere to the following, based on the
/// reactive streams specification:
/// * The total number of on_next´s signalled by a Publisher to a Subscriber
-/// MUST be less than or equal to the total number of elements requested by that
-/// Subscriber´s Subscription at all times.
+/// MUST be less than or equal to the total number of elements requested by that
+/// Subscriber´s Subscription at all times.
/// * A Publisher MAY signal fewer on_next than requested and terminate the
-/// Subscription by calling on_complete or on_error.
+/// Subscription by calling on_complete or on_error.
/// * on_subscribe, on_next, on_error and on_complete signaled to a Subscriber
-/// MUST be signaled serially.
+/// MUST be signaled serially.
/// * If a Publisher fails it MUST signal an on_error.
/// * If a Publisher terminates successfully (finite stream) it MUST signal an
-/// on_complete.
+/// on_complete.
/// * If a Publisher signals either on_error or on_complete on a Subscriber,
-/// that Subscriber’s Subscription MUST be considered cancelled.
+/// that Subscriber’s Subscription MUST be considered cancelled.
/// * Once a terminal state has been signaled (on_error, on_complete) it is
-/// REQUIRED that no further signals occur.
+/// REQUIRED that no further signals occur.
/// * If a Subscription is cancelled its Subscriber MUST eventually stop being
-/// signaled.
+/// signaled.
/// * A Publisher MAY support multiple Subscribers and decides whether each
-/// Subscription is unicast or multicast.
+/// Subscription is unicast or multicast.
pub trait BufferPublisher {
/// Returns the StreamConfig of buffers that publisher creates.
fn get_publisher_stream_config(&self) -> StreamConfig;
@@ -69,25 +69,25 @@
/// BufferSubcribers are required to adhere to the following, based on the
/// reactive streams specification:
/// * The total number of on_next´s signalled by a Publisher to a Subscriber
-/// MUST be less than or equal to the total number of elements requested by that
-/// Subscriber´s Subscription at all times.
+/// MUST be less than or equal to the total number of elements requested by that
+/// Subscriber´s Subscription at all times.
/// * A Publisher MAY signal fewer on_next than requested and terminate the
-/// Subscription by calling on_complete or on_error.
+/// Subscription by calling on_complete or on_error.
/// * on_subscribe, on_next, on_error and on_complete signaled to a Subscriber
-/// MUST be signaled serially.
+/// MUST be signaled serially.
/// * If a Publisher fails it MUST signal an on_error.
/// * If a Publisher terminates successfully (finite stream) it MUST signal an
-/// on_complete.
+/// on_complete.
/// * If a Publisher signals either on_error or on_complete on a Subscriber,
-/// that Subscriber’s Subscription MUST be considered cancelled.
+/// that Subscriber’s Subscription MUST be considered cancelled.
/// * Once a terminal state has been signaled (on_error, on_complete) it is
-/// REQUIRED that no further signals occur.
+/// REQUIRED that no further signals occur.
/// * If a Subscription is cancelled its Subscriber MUST eventually stop being
-/// signaled.
+/// signaled.
/// * Publisher.subscribe MAY be called as many times as wanted but MUST be
-/// with a different Subscriber each time.
+/// with a different Subscriber each time.
/// * A Publisher MAY support multiple Subscribers and decides whether each
-/// Subscription is unicast or multicast.
+/// Subscription is unicast or multicast.
pub trait BufferSubscriber {
/// The StreamConfig of buffers that this subscriber expects.
fn get_subscriber_stream_config(&self) -> StreamConfig;
@@ -111,39 +111,39 @@
/// BufferSubcriptions are required to adhere to the following, based on the
/// reactive streams specification:
/// * Subscription.request and Subscription.cancel MUST only be called inside
-/// of its Subscriber context.
+/// of its Subscriber context.
/// * The Subscription MUST allow the Subscriber to call Subscription.request
-/// synchronously from within on_next or on_subscribe.
+/// synchronously from within on_next or on_subscribe.
/// * Subscription.request MUST place an upper bound on possible synchronous
-/// recursion between Publisher and Subscriber.
+/// recursion between Publisher and Subscriber.
/// * Subscription.request SHOULD respect the responsivity of its caller by
-/// returning in a timely manner.
+/// returning in a timely manner.
/// * Subscription.cancel MUST respect the responsivity of its caller by
-/// returning in a timely manner, MUST be idempotent and MUST be thread-safe.
+/// returning in a timely manner, MUST be idempotent and MUST be thread-safe.
/// * After the Subscription is cancelled, additional
-/// Subscription.request(n: u64) MUST be NOPs.
+/// Subscription.request(n: u64) MUST be NOPs.
/// * After the Subscription is cancelled, additional Subscription.cancel()
-/// MUST be NOPs.
+/// MUST be NOPs.
/// * While the Subscription is not cancelled, Subscription.request(n: u64)
-/// MUST register the given number of additional elements to be produced to the
-/// respective subscriber.
+/// MUST register the given number of additional elements to be produced to the
+/// respective subscriber.
/// * While the Subscription is not cancelled, Subscription.request(n: u64)
-/// MUST signal on_error if the argument is <= 0. The cause message SHOULD
-/// explain that non-positive request signals are illegal.
+/// MUST signal on_error if the argument is <= 0. The cause message SHOULD
+/// explain that non-positive request signals are illegal.
/// * While the Subscription is not cancelled, Subscription.request(n: u64)
-/// MAY synchronously call on_next on this (or other) subscriber(s).
+/// MAY synchronously call on_next on this (or other) subscriber(s).
/// * While the Subscription is not cancelled, Subscription.request(n: u64)
-/// MAY synchronously call on_complete or on_error on this (or other)
-/// subscriber(s).
+/// MAY synchronously call on_complete or on_error on this (or other)
+/// subscriber(s).
/// * While the Subscription is not cancelled, Subscription.cancel() MUST
-/// request the Publisher to eventually stop signaling its Subscriber. The
-/// operation is NOT REQUIRED to affect the Subscription immediately.
+/// request the Publisher to eventually stop signaling its Subscriber. The
+/// operation is NOT REQUIRED to affect the Subscription immediately.
/// * While the Subscription is not cancelled, Subscription.cancel() MUST
-/// request the Publisher to eventually drop any references to the corresponding
-/// subscriber.
+/// request the Publisher to eventually drop any references to the corresponding
+/// subscriber.
/// * While the Subscription is not cancelled, calling Subscription.cancel MAY
-/// cause the Publisher, if stateful, to transition into the shut-down state if
-/// no other Subscription exists at this point.
+/// cause the Publisher, if stateful, to transition into the shut-down state if
+/// no other Subscription exists at this point.
/// * Calling Subscription.cancel MUST return normally.
/// * Calling Subscription.request MUST return normally.
pub trait BufferSubscription: Send + Sync + 'static {
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index f065ffa..1fb59fd 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -356,8 +356,9 @@
if (context == nullptr) {
return;
}
- sp<BLASTBufferQueue> bq = static_cast<BLASTBufferQueue*>(context);
+ auto bq = static_cast<BLASTBufferQueue*>(context);
bq->transactionCallback(latchTime, presentFence, stats);
+ bq->decStrong((void*)transactionCallbackThunk);
}
void BLASTBufferQueue::transactionCallback(nsecs_t /*latchTime*/, const sp<Fence>& /*presentFence*/,
@@ -413,8 +414,6 @@
BQA_LOGE("No matching SurfaceControls found: mSurfaceControlsWithPendingCallback was "
"empty.");
}
-
- decStrong((void*)transactionCallbackThunk);
}
}
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 4a8df9e..76d74fe 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -43,7 +43,7 @@
#include <ui/GraphicBuffer.h>
#include <ui/Region.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/BufferItem.h>
#include <gui/ISurfaceComposer.h>
@@ -77,9 +77,28 @@
} // namespace
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+Surface::ProducerDeathListenerProxy::ProducerDeathListenerProxy(wp<SurfaceListener> surfaceListener)
+ : mSurfaceListener(surfaceListener) {}
+
+void Surface::ProducerDeathListenerProxy::binderDied(const wp<IBinder>&) {
+ sp<SurfaceListener> surfaceListener = mSurfaceListener.promote();
+ if (!surfaceListener) {
+ return;
+ }
+
+ if (surfaceListener->needsDeathNotify()) {
+ surfaceListener->onRemoteDied();
+ }
+}
+#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+
Surface::Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp,
const sp<IBinder>& surfaceControlHandle)
: mGraphicBufferProducer(bufferProducer),
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+ mSurfaceDeathListener(nullptr),
+#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
mCrop(Rect::EMPTY_RECT),
mBufferAge(0),
mGenerationNumber(0),
@@ -134,6 +153,12 @@
if (mConnectedToCpu) {
Surface::disconnect(NATIVE_WINDOW_API_CPU);
}
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+ if (mSurfaceDeathListener != nullptr) {
+ IInterface::asBinder(mGraphicBufferProducer)->unlinkToDeath(mSurfaceDeathListener);
+ mSurfaceDeathListener = nullptr;
+ }
+#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
}
sp<ISurfaceComposer> Surface::composerService() const {
@@ -2033,6 +2058,7 @@
Mutex::Autolock lock(mMutex);
IGraphicBufferProducer::QueueBufferOutput output;
mReportRemovedBuffers = reportBufferRemoval;
+
if (listener != nullptr) {
mListenerProxy = new ProducerListenerProxy(this, listener);
}
@@ -2053,6 +2079,13 @@
}
mConsumerRunningBehind = (output.numPendingBuffers >= 2);
+
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+ if (listener && listener->needsDeathNotify()) {
+ mSurfaceDeathListener = sp<ProducerDeathListenerProxy>::make(listener);
+ IInterface::asBinder(mGraphicBufferProducer)->linkToDeath(mSurfaceDeathListener);
+ }
+#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
}
if (!err && api == NATIVE_WINDOW_API_CPU) {
mConnectedToCpu = true;
@@ -2093,6 +2126,14 @@
mConnectedToCpu = false;
}
}
+
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+ if (mSurfaceDeathListener != nullptr) {
+ IInterface::asBinder(mGraphicBufferProducer)->unlinkToDeath(mSurfaceDeathListener);
+ mSurfaceDeathListener = nullptr;
+ }
+#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+
return err;
}
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index b5d9366..7d3e5c1 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -43,7 +43,7 @@
#include <system/graphics.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/BufferItemConsumer.h>
#include <gui/CpuConsumer.h>
#include <gui/IGraphicBufferProducer.h>
diff --git a/libs/gui/WindowInfosListenerReporter.cpp b/libs/gui/WindowInfosListenerReporter.cpp
index 0929b8e..91c9a85 100644
--- a/libs/gui/WindowInfosListenerReporter.cpp
+++ b/libs/gui/WindowInfosListenerReporter.cpp
@@ -15,7 +15,7 @@
*/
#include <android/gui/ISurfaceComposer.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/WindowInfosListenerReporter.h>
#include "gui/WindowInfosUpdate.h"
diff --git a/libs/gui/include/gui/AidlStatusUtil.h b/libs/gui/include/gui/AidlUtil.h
similarity index 97%
rename from libs/gui/include/gui/AidlStatusUtil.h
rename to libs/gui/include/gui/AidlUtil.h
index 159e032..a3ecd84 100644
--- a/libs/gui/include/gui/AidlStatusUtil.h
+++ b/libs/gui/include/gui/AidlUtil.h
@@ -70,7 +70,7 @@
*
* return_type method(type0 param0, ...)
*/
-static inline status_t statusTFromBinderStatus(const ::android::binder::Status &status) {
+static inline status_t statusTFromBinderStatus(const ::android::binder::Status& status) {
return status.isOk() ? OK // check OK,
: status.serviceSpecificErrorCode() // service-side error, not standard Java exception
// (fromServiceSpecificError)
@@ -86,8 +86,8 @@
* where Java callers expect an exception, not an integer return value.
*/
static inline ::android::binder::Status binderStatusFromStatusT(
- status_t status, const char *optionalMessage = nullptr) {
- const char *const emptyIfNull = optionalMessage == nullptr ? "" : optionalMessage;
+ status_t status, const char* optionalMessage = nullptr) {
+ const char* const emptyIfNull = optionalMessage == nullptr ? "" : optionalMessage;
// From binder::Status instructions:
// Prefer a generic exception code when possible, then a service specific
// code, and finally a status_t for low level failures or legacy support.
diff --git a/libs/gui/include/gui/Surface.h b/libs/gui/include/gui/Surface.h
index 0f51f2d..5ea81c4 100644
--- a/libs/gui/include/gui/Surface.h
+++ b/libs/gui/include/gui/Surface.h
@@ -66,6 +66,16 @@
virtual void onBufferAttached() {}
virtual bool needsAttachNotify() { return false; }
#endif
+
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+ // Called if this Surface is connected to a remote implementation and it
+ // dies or becomes unavailable.
+ virtual void onRemoteDied() {}
+
+ // Clients will overwrite this if they want to receive a notification
+ // via onRemoteDied. This should return a constant value.
+ virtual bool needsDeathNotify() { return false; }
+#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
};
class StubSurfaceListener : public SurfaceListener {
@@ -471,6 +481,21 @@
sp<SurfaceListener> mSurfaceListener;
};
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+ class ProducerDeathListenerProxy : public IBinder::DeathRecipient {
+ public:
+ ProducerDeathListenerProxy(wp<SurfaceListener> surfaceListener);
+ ProducerDeathListenerProxy(ProducerDeathListenerProxy&) = delete;
+
+ // IBinder::DeathRecipient
+ virtual void binderDied(const wp<IBinder>&) override;
+
+ private:
+ wp<SurfaceListener> mSurfaceListener;
+ };
+ friend class ProducerDeathListenerProxy;
+#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+
void querySupportedTimestampsLocked() const;
void freeAllBuffers();
@@ -502,6 +527,13 @@
// TODO: rename to mBufferProducer
sp<IGraphicBufferProducer> mGraphicBufferProducer;
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+ // mSurfaceDeathListener gets registered as mGraphicBufferProducer's
+ // DeathRecipient when SurfaceListener::needsDeathNotify returns true and
+ // gets notified when it dies.
+ sp<ProducerDeathListenerProxy> mSurfaceDeathListener;
+#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+
// mSlots stores the buffers that have been allocated for each buffer slot.
// It is initialized to null pointers, and gets filled in with the result of
// IGraphicBufferProducer::requestBuffer when the client dequeues a buffer from a
diff --git a/libs/gui/tests/BLASTBufferQueue_test.cpp b/libs/gui/tests/BLASTBufferQueue_test.cpp
index 46a19c2..eb2a61d 100644
--- a/libs/gui/tests/BLASTBufferQueue_test.cpp
+++ b/libs/gui/tests/BLASTBufferQueue_test.cpp
@@ -20,7 +20,7 @@
#include <android-base/thread_annotations.h>
#include <android/hardware/graphics/common/1.2/types.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/BufferQueueCore.h>
#include <gui/BufferQueueProducer.h>
#include <gui/FrameTimestamps.h>
diff --git a/libs/gui/tests/RegionSampling_test.cpp b/libs/gui/tests/RegionSampling_test.cpp
index 223e4b6..a0d8c53 100644
--- a/libs/gui/tests/RegionSampling_test.cpp
+++ b/libs/gui/tests/RegionSampling_test.cpp
@@ -19,7 +19,7 @@
#include <android/gui/BnRegionSamplingListener.h>
#include <binder/ProcessState.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/DisplayEventReceiver.h>
#include <gui/ISurfaceComposer.h>
#include <gui/Surface.h>
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 4232443..0c3859e 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -28,7 +28,7 @@
#include <binder/ProcessState.h>
#include <com_android_graphics_libgui_flags.h>
#include <configstore/Utils.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/BufferItemConsumer.h>
#include <gui/BufferQueue.h>
#include <gui/CpuConsumer.h>
@@ -50,7 +50,10 @@
#include <utils/Errors.h>
#include <utils/String8.h>
+#include <chrono>
#include <cstddef>
+#include <cstdint>
+#include <future>
#include <limits>
#include <thread>
@@ -108,6 +111,18 @@
std::vector<sp<GraphicBuffer>> mDiscardedBuffers;
};
+class DeathWatcherListener : public StubSurfaceListener {
+public:
+ virtual void onRemoteDied() { mDiedPromise.set_value(true); }
+
+ virtual bool needsDeathNotify() { return true; }
+
+ std::future<bool> getDiedFuture() { return mDiedPromise.get_future(); }
+
+private:
+ std::promise<bool> mDiedPromise;
+};
+
class SurfaceTest : public ::testing::Test {
protected:
SurfaceTest() {
@@ -2374,6 +2389,39 @@
surface.name = String16("name");
EXPECT_EQ("name", surface.toString());
}
+
+TEST_F(SurfaceTest, TestRemoteSurfaceDied_CallbackCalled) {
+ sp<TestServerClient> testServer = TestServerClient::Create();
+ sp<IGraphicBufferProducer> producer = testServer->CreateProducer();
+ EXPECT_NE(nullptr, producer);
+
+ sp<Surface> surface = sp<Surface>::make(producer);
+ sp<DeathWatcherListener> deathWatcher = sp<DeathWatcherListener>::make();
+ EXPECT_EQ(OK, surface->connect(NATIVE_WINDOW_API_CPU, deathWatcher));
+
+ auto diedFuture = deathWatcher->getDiedFuture();
+ EXPECT_EQ(OK, testServer->Kill());
+
+ diedFuture.wait();
+ EXPECT_TRUE(diedFuture.get());
+}
+
+TEST_F(SurfaceTest, TestRemoteSurfaceDied_Disconnect_CallbackNotCalled) {
+ sp<TestServerClient> testServer = TestServerClient::Create();
+ sp<IGraphicBufferProducer> producer = testServer->CreateProducer();
+ EXPECT_NE(nullptr, producer);
+
+ sp<Surface> surface = sp<Surface>::make(producer);
+ sp<DeathWatcherListener> deathWatcher = sp<DeathWatcherListener>::make();
+ EXPECT_EQ(OK, surface->connect(NATIVE_WINDOW_API_CPU, deathWatcher));
+ EXPECT_EQ(OK, surface->disconnect(NATIVE_WINDOW_API_CPU));
+
+ auto watcherDiedFuture = deathWatcher->getDiedFuture();
+ EXPECT_EQ(OK, testServer->Kill());
+
+ std::future_status status = watcherDiedFuture.wait_for(std::chrono::seconds(1));
+ EXPECT_EQ(std::future_status::timeout, status);
+}
#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
} // namespace android
diff --git a/libs/gui/tests/TestServer_test.cpp b/libs/gui/tests/TestServer_test.cpp
index 8712988..d640782 100644
--- a/libs/gui/tests/TestServer_test.cpp
+++ b/libs/gui/tests/TestServer_test.cpp
@@ -24,7 +24,7 @@
#include <binder/ProcessState.h>
#include <com_android_graphics_libgui_flags.h>
#include <configstore/Utils.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/BufferItemConsumer.h>
#include <gui/BufferQueue.h>
#include <gui/CpuConsumer.h>
diff --git a/libs/input/tests/Resampler_test.cpp b/libs/input/tests/Resampler_test.cpp
index b372c0b..7ae9a28 100644
--- a/libs/input/tests/Resampler_test.cpp
+++ b/libs/input/tests/Resampler_test.cpp
@@ -70,22 +70,18 @@
};
InputSample::operator InputMessage() const {
- InputMessage message;
- message.header.type = InputMessage::Type::MOTION;
- message.body.motion.pointerCount = pointers.size();
- message.body.motion.eventTime = static_cast<std::chrono::nanoseconds>(eventTime).count();
- message.body.motion.source = AINPUT_SOURCE_CLASS_POINTER;
- message.body.motion.downTime = 0;
+ InputMessageBuilder messageBuilder =
+ InputMessageBuilder{InputMessage::Type::MOTION, /*seq=*/0}
+ .eventTime(std::chrono::nanoseconds{eventTime}.count())
+ .source(AINPUT_SOURCE_TOUCHSCREEN)
+ .downTime(0);
- const uint32_t pointerCount = message.body.motion.pointerCount;
- for (uint32_t i = 0; i < pointerCount; ++i) {
- message.body.motion.pointers[i].properties.id = pointers[i].id;
- message.body.motion.pointers[i].properties.toolType = pointers[i].toolType;
- message.body.motion.pointers[i].coords.setAxisValue(AMOTION_EVENT_AXIS_X, pointers[i].x);
- message.body.motion.pointers[i].coords.setAxisValue(AMOTION_EVENT_AXIS_Y, pointers[i].y);
- message.body.motion.pointers[i].coords.isResampled = pointers[i].isResampled;
+ for (const Pointer& pointer : pointers) {
+ messageBuilder.pointer(
+ PointerBuilder{pointer.id, pointer.toolType}.x(pointer.x).y(pointer.y).isResampled(
+ pointer.isResampled));
}
- return message;
+ return messageBuilder.build();
}
struct InputStream {
diff --git a/services/inputflinger/include/InputReaderBase.h b/services/inputflinger/include/InputReaderBase.h
index 4ef43ba..7bec94e 100644
--- a/services/inputflinger/include/InputReaderBase.h
+++ b/services/inputflinger/include/InputReaderBase.h
@@ -34,6 +34,7 @@
#include <vector>
#include "PointerControllerInterface.h"
+#include "TouchpadHardwareState.h"
#include "VibrationElement.h"
#include "include/gestures.h"
@@ -461,6 +462,10 @@
*/
virtual void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) = 0;
+ /* Sends the hardware state of a connected touchpad */
+ virtual void notifyTouchpadHardwareState(const SelfContainedHardwareState& schs,
+ int32_t deviceId) = 0;
+
/* Gets the keyboard layout for a particular input device. */
virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay(
const InputDeviceIdentifier& identifier,
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
index ed79233..dbc2872 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
@@ -36,6 +36,7 @@
#include <log/log_main.h>
#include <stats_pull_atom_callback.h>
#include <statslog.h>
+#include "InputReaderBase.h"
#include "TouchCursorInputMapperCommon.h"
#include "TouchpadInputMapper.h"
#include "gestures/HardwareProperties.h"
@@ -424,10 +425,8 @@
std::optional<SelfContainedHardwareState> state = mStateConverter.processRawEvent(rawEvent);
if (state) {
if (mTouchpadHardwareStateNotificationsEnabled) {
- // TODO(b/286551975): Notify policy of the touchpad hardware state.
- LOG(DEBUG) << "Notify touchpad hardware state here!";
+ getPolicy()->notifyTouchpadHardwareState(*state, rawEvent.deviceId);
}
-
updatePalmDetectionMetrics();
return sendHardwareState(rawEvent.when, rawEvent.readTime, *state);
} else {
diff --git a/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h b/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h
index 66d62f8..148ca5a 100644
--- a/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h
+++ b/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h
@@ -28,6 +28,7 @@
#include "accumulator/TouchButtonAccumulator.h"
#include "include/TouchpadHardwareState.h"
+#include "TouchpadHardwareState.h"
#include "include/gestures.h"
namespace android {
diff --git a/services/inputflinger/tests/FakeInputReaderPolicy.cpp b/services/inputflinger/tests/FakeInputReaderPolicy.cpp
index 6099c91..d77d539 100644
--- a/services/inputflinger/tests/FakeInputReaderPolicy.cpp
+++ b/services/inputflinger/tests/FakeInputReaderPolicy.cpp
@@ -65,6 +65,17 @@
ASSERT_FALSE(mDeviceIdOfNotifiedStylusGesture);
}
+void FakeInputReaderPolicy::assertTouchpadHardwareStateNotified() {
+ std::unique_lock lock(mLock);
+ base::ScopedLockAssertion assumeLocked(mLock);
+
+ const bool success =
+ mTouchpadHardwareStateNotified.wait_for(lock, WAIT_TIMEOUT, [this]() REQUIRES(mLock) {
+ return mTouchpadHardwareState.has_value();
+ });
+ ASSERT_TRUE(success) << "Timed out waiting for hardware state to be notified";
+}
+
void FakeInputReaderPolicy::clearViewports() {
mViewports.clear();
mConfig.setDisplayViewports(mViewports);
@@ -234,6 +245,13 @@
mDevicesChangedCondition.notify_all();
}
+void FakeInputReaderPolicy::notifyTouchpadHardwareState(const SelfContainedHardwareState& schs,
+ int32_t deviceId) {
+ std::scoped_lock lock(mLock);
+ mTouchpadHardwareState = schs;
+ mTouchpadHardwareStateNotified.notify_all();
+}
+
std::shared_ptr<KeyCharacterMap> FakeInputReaderPolicy::getKeyboardLayoutOverlay(
const InputDeviceIdentifier&, const std::optional<KeyboardLayoutInfo>) {
return nullptr;
diff --git a/services/inputflinger/tests/FakeInputReaderPolicy.h b/services/inputflinger/tests/FakeInputReaderPolicy.h
index 94f1311..e5ba620 100644
--- a/services/inputflinger/tests/FakeInputReaderPolicy.h
+++ b/services/inputflinger/tests/FakeInputReaderPolicy.h
@@ -42,6 +42,7 @@
void assertInputDevicesNotChanged();
void assertStylusGestureNotified(int32_t deviceId);
void assertStylusGestureNotNotified();
+ void assertTouchpadHardwareStateNotified();
virtual void clearViewports();
std::optional<DisplayViewport> getDisplayViewportByUniqueId(const std::string& uniqueId) const;
@@ -82,6 +83,8 @@
private:
void getReaderConfiguration(InputReaderConfiguration* outConfig) override;
void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) override;
+ void notifyTouchpadHardwareState(const SelfContainedHardwareState& schs,
+ int32_t deviceId) override;
std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay(
const InputDeviceIdentifier&, const std::optional<KeyboardLayoutInfo>) override;
std::string getDeviceAlias(const InputDeviceIdentifier&) override;
@@ -101,6 +104,9 @@
std::condition_variable mStylusGestureNotifiedCondition;
std::optional<DeviceId> mDeviceIdOfNotifiedStylusGesture GUARDED_BY(mLock){};
+ std::condition_variable mTouchpadHardwareStateNotified;
+ std::optional<SelfContainedHardwareState> mTouchpadHardwareState GUARDED_BY(mLock){};
+
uint32_t mNextPointerCaptureSequenceNumber{0};
};
diff --git a/services/inputflinger/tests/TouchpadInputMapper_test.cpp b/services/inputflinger/tests/TouchpadInputMapper_test.cpp
index fc8a7da..ea69fff 100644
--- a/services/inputflinger/tests/TouchpadInputMapper_test.cpp
+++ b/services/inputflinger/tests/TouchpadInputMapper_test.cpp
@@ -172,4 +172,22 @@
ASSERT_THAT(args, testing::IsEmpty());
}
+TEST_F(TouchpadInputMapperTest, TouchpadHardwareState) {
+ mReaderConfiguration.shouldNotifyTouchpadHardwareState = true;
+ std::list<NotifyArgs> args =
+ mMapper->reconfigure(ARBITRARY_TIME, mReaderConfiguration,
+ InputReaderConfiguration::Change::TOUCHPAD_SETTINGS);
+
+ args += process(EV_ABS, ABS_MT_TRACKING_ID, 1);
+ args += process(EV_KEY, BTN_TOUCH, 1);
+ setScanCodeState(KeyState::DOWN, {BTN_TOOL_FINGER});
+ args += process(EV_KEY, BTN_TOOL_FINGER, 1);
+ args += process(EV_ABS, ABS_MT_POSITION_X, 50);
+ args += process(EV_ABS, ABS_MT_POSITION_Y, 50);
+ args += process(EV_ABS, ABS_MT_PRESSURE, 1);
+ args += process(EV_SYN, SYN_REPORT, 0);
+
+ mFakePolicy->assertTouchpadHardwareStateNotified();
+}
+
} // namespace android
diff --git a/services/inputflinger/tests/fuzzers/MapperHelpers.h b/services/inputflinger/tests/fuzzers/MapperHelpers.h
index fea0d9a..ddc3310 100644
--- a/services/inputflinger/tests/fuzzers/MapperHelpers.h
+++ b/services/inputflinger/tests/fuzzers/MapperHelpers.h
@@ -281,6 +281,8 @@
FuzzInputReaderPolicy(std::shared_ptr<ThreadSafeFuzzedDataProvider> mFdp) : mFdp(mFdp) {}
void getReaderConfiguration(InputReaderConfiguration* outConfig) override {}
void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) override {}
+ void notifyTouchpadHardwareState(const SelfContainedHardwareState& schs,
+ int32_t deviceId) override {}
std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay(
const InputDeviceIdentifier& identifier,
const std::optional<KeyboardLayoutInfo> layoutInfo) override {
diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp
index 6b4215e..abeb2a9 100644
--- a/services/surfaceflinger/Client.cpp
+++ b/services/surfaceflinger/Client.cpp
@@ -21,7 +21,7 @@
#include <private/android_filesystem_config.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/SchedulingPolicy.h>
#include "Client.h"
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 566bb8e..be00079 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -127,7 +127,7 @@
mVsyncModulator->cancelRefreshRateChange();
mVsyncConfiguration->reset();
- updatePhaseConfiguration(pacesetterSelectorPtr()->getActiveMode().fps);
+ updatePhaseConfiguration(pacesetterId, pacesetterSelectorPtr()->getActiveMode().fps);
}
void Scheduler::registerDisplay(PhysicalDisplayId displayId, RefreshRateSelectorPtr selectorPtr,
@@ -487,7 +487,12 @@
}
}
-void Scheduler::updatePhaseConfiguration(Fps refreshRate) {
+void Scheduler::updatePhaseConfiguration(PhysicalDisplayId displayId, Fps refreshRate) {
+ const bool isPacesetter =
+ FTL_FAKE_GUARD(kMainThreadContext,
+ (std::scoped_lock(mDisplayLock), displayId == mPacesetterDisplayId));
+ if (!isPacesetter) return;
+
mRefreshRateStats->setRefreshRate(refreshRate);
mVsyncConfiguration->setRefreshRateFps(refreshRate);
setVsyncConfig(mVsyncModulator->setVsyncConfigSet(mVsyncConfiguration->getCurrentConfigs()),
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index 88f0e94..1367ec3 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -187,7 +187,7 @@
}
}
- void updatePhaseConfiguration(Fps);
+ void updatePhaseConfiguration(PhysicalDisplayId, Fps);
const VsyncConfiguration& getVsyncConfiguration() const { return *mVsyncConfiguration; }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 764e0cc..0c297d9 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -65,7 +65,7 @@
#include <ftl/fake_guard.h>
#include <ftl/future.h>
#include <ftl/unit.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/BufferQueue.h>
#include <gui/DebugEGLImageTracker.h>
#include <gui/IProducerListener.h>
@@ -1280,20 +1280,14 @@
return BAD_VALUE;
}
+ // TODO: b/277364366 - Require a display token from clients and remove fallback to pacesetter.
std::optional<PhysicalDisplayId> displayIdOpt;
- {
+ if (displayToken) {
Mutex::Autolock lock(mStateLock);
- if (displayToken) {
- displayIdOpt = getPhysicalDisplayIdLocked(displayToken);
- if (!displayIdOpt) {
- ALOGW("%s: Invalid physical display token %p", __func__, displayToken.get());
- return NAME_NOT_FOUND;
- }
- } else {
- // TODO (b/277364366): Clients should be updated to pass in the display they
- // want, rather than us picking an arbitrary one (the active display, in this
- // case).
- displayIdOpt = mActiveDisplayId;
+ displayIdOpt = getPhysicalDisplayIdLocked(displayToken);
+ if (!displayIdOpt) {
+ ALOGW("%s: Invalid physical display token %p", __func__, displayToken.get());
+ return NAME_NOT_FOUND;
}
}
@@ -1340,19 +1334,13 @@
// VsyncController model is locked.
mScheduler->modulateVsync(displayId, &VsyncModulator::onRefreshRateChangeInitiated);
- if (displayId == mActiveDisplayId) {
- mScheduler->updatePhaseConfiguration(mode.fps);
- }
-
+ mScheduler->updatePhaseConfiguration(displayId, mode.fps);
mScheduler->setModeChangePending(true);
break;
}
case DesiredModeAction::InitiateRenderRateSwitch:
mScheduler->setRenderRate(displayId, mode.fps, /*applyImmediately*/ false);
-
- if (displayId == mActiveDisplayId) {
- mScheduler->updatePhaseConfiguration(mode.fps);
- }
+ mScheduler->updatePhaseConfiguration(displayId, mode.fps);
if (emitEvent) {
mScheduler->onDisplayModeChanged(displayId, mode);
@@ -1447,9 +1435,7 @@
mDisplayModeController.finalizeModeChange(displayId, activeMode.modePtr->getId(),
activeMode.modePtr->getVsyncRate(), activeMode.fps);
- if (displayId == mActiveDisplayId) {
- mScheduler->updatePhaseConfiguration(activeMode.fps);
- }
+ mScheduler->updatePhaseConfiguration(displayId, activeMode.fps);
if (pendingModeOpt->emitEvent) {
mScheduler->onDisplayModeChanged(displayId, activeMode);
@@ -1473,11 +1459,9 @@
constexpr bool kAllowToEnable = true;
mScheduler->resyncToHardwareVsync(displayId, kAllowToEnable, std::move(activeModePtr).take());
- mScheduler->setRenderRate(displayId, renderFps, /*applyImmediately*/ true);
- if (displayId == mActiveDisplayId) {
- mScheduler->updatePhaseConfiguration(renderFps);
- }
+ mScheduler->setRenderRate(displayId, renderFps, /*applyImmediately*/ true);
+ mScheduler->updatePhaseConfiguration(displayId, renderFps);
}
void SurfaceFlinger::initiateDisplayModeChanges() {
diff --git a/services/surfaceflinger/tests/BootDisplayMode_test.cpp b/services/surfaceflinger/tests/BootDisplayMode_test.cpp
index 4f41a81..222642f 100644
--- a/services/surfaceflinger/tests/BootDisplayMode_test.cpp
+++ b/services/surfaceflinger/tests/BootDisplayMode_test.cpp
@@ -18,7 +18,7 @@
#include <gtest/gtest.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/SurfaceComposerClient.h>
#include <private/gui/ComposerService.h>
#include <private/gui/ComposerServiceAIDL.h>
diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp
index babbcd4..e6fed63 100644
--- a/services/surfaceflinger/tests/Credentials_test.cpp
+++ b/services/surfaceflinger/tests/Credentials_test.cpp
@@ -20,7 +20,7 @@
#include <android/gui/ISurfaceComposer.h>
#include <gtest/gtest.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
#include <private/android_filesystem_config.h>
diff --git a/services/surfaceflinger/tests/LayerTransactionTest.h b/services/surfaceflinger/tests/LayerTransactionTest.h
index 5b056d0..03f9005 100644
--- a/services/surfaceflinger/tests/LayerTransactionTest.h
+++ b/services/surfaceflinger/tests/LayerTransactionTest.h
@@ -23,7 +23,7 @@
#include <cutils/properties.h>
#include <gtest/gtest.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
#include <private/gui/ComposerService.h>
diff --git a/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp b/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp
index e655df7..76bae41 100644
--- a/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp
+++ b/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp
@@ -15,10 +15,10 @@
*/
// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#include "gui/AidlStatusUtil.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
+#include <gui/AidlUtil.h>
#include <gui/BufferItemConsumer.h>
#include <private/android_filesystem_config.h>
#include "TransactionTestHarnesses.h"
diff --git a/services/surfaceflinger/tests/MirrorLayer_test.cpp b/services/surfaceflinger/tests/MirrorLayer_test.cpp
index 2a53588..6cc1c51 100644
--- a/services/surfaceflinger/tests/MirrorLayer_test.cpp
+++ b/services/surfaceflinger/tests/MirrorLayer_test.cpp
@@ -20,7 +20,7 @@
#include <android-base/properties.h>
#include <common/FlagManager.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <private/android_filesystem_config.h>
#include "LayerTransactionTest.h"
#include "utils/TransactionUtils.h"
diff --git a/services/surfaceflinger/tests/ScreenCapture_test.cpp b/services/surfaceflinger/tests/ScreenCapture_test.cpp
index 069f199..c62f493 100644
--- a/services/surfaceflinger/tests/ScreenCapture_test.cpp
+++ b/services/surfaceflinger/tests/ScreenCapture_test.cpp
@@ -20,7 +20,7 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <private/android_filesystem_config.h>
#include <ui/DisplayState.h>
diff --git a/services/surfaceflinger/tests/TextureFiltering_test.cpp b/services/surfaceflinger/tests/TextureFiltering_test.cpp
index f8c5364..3f39cf6 100644
--- a/services/surfaceflinger/tests/TextureFiltering_test.cpp
+++ b/services/surfaceflinger/tests/TextureFiltering_test.cpp
@@ -17,7 +17,7 @@
#include <android/gui/DisplayCaptureArgs.h>
#include <android/gui/ISurfaceComposerClient.h>
#include <gtest/gtest.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <ui/GraphicTypes.h>
#include <ui/Rect.h>
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_HdrOutputControlTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_HdrOutputControlTest.cpp
index db6df22..4bc134f 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_HdrOutputControlTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_HdrOutputControlTest.cpp
@@ -18,7 +18,7 @@
#define LOG_TAG "LibSurfaceFlingerUnittests"
#include <gtest/gtest.h>
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <private/gui/ComposerService.h>
#include <private/gui/ComposerServiceAIDL.h>
diff --git a/services/surfaceflinger/tests/utils/ScreenshotUtils.h b/services/surfaceflinger/tests/utils/ScreenshotUtils.h
index efce6b6..0bedcd1 100644
--- a/services/surfaceflinger/tests/utils/ScreenshotUtils.h
+++ b/services/surfaceflinger/tests/utils/ScreenshotUtils.h
@@ -15,7 +15,7 @@
*/
#pragma once
-#include <gui/AidlStatusUtil.h>
+#include <gui/AidlUtil.h>
#include <gui/SyncScreenCaptureListener.h>
#include <private/gui/ComposerServiceAIDL.h>
#include <ui/FenceResult.h>
diff --git a/services/vibratorservice/VibratorHalWrapper.cpp b/services/vibratorservice/VibratorHalWrapper.cpp
index c97f401..3d8124b 100644
--- a/services/vibratorservice/VibratorHalWrapper.cpp
+++ b/services/vibratorservice/VibratorHalWrapper.cpp
@@ -32,6 +32,8 @@
using aidl::android::hardware::vibrator::Effect;
using aidl::android::hardware::vibrator::EffectStrength;
using aidl::android::hardware::vibrator::PrimitivePwle;
+using aidl::android::hardware::vibrator::PwleV2OutputMapEntry;
+using aidl::android::hardware::vibrator::PwleV2Primitive;
using aidl::android::hardware::vibrator::VendorEffect;
using std::chrono::milliseconds;
@@ -114,6 +116,12 @@
return HalResult<void>::unsupported();
}
+HalResult<void> HalWrapper::composePwleV2(const std::vector<PwleV2Primitive>&,
+ const std::function<void()>&) {
+ ALOGV("Skipped composePwleV2 because it's not available in Vibrator HAL");
+ return HalResult<void>::unsupported();
+}
+
HalResult<Capabilities> HalWrapper::getCapabilities() {
std::lock_guard<std::mutex> lock(mInfoMutex);
if (mInfoCache.mCapabilities.isFailed()) {
@@ -313,6 +321,13 @@
return HalResultFactory::fromStatus(getHal()->composePwle(primitives, cb));
}
+HalResult<void> AidlHalWrapper::composePwleV2(const std::vector<PwleV2Primitive>& composite,
+ const std::function<void()>& completionCallback) {
+ // This method should always support callbacks, so no need to double check.
+ auto cb = ndk::SharedRefBase::make<HalCallbackWrapper>(completionCallback);
+ return HalResultFactory::fromStatus(getHal()->composePwleV2(composite, cb));
+}
+
HalResult<Capabilities> AidlHalWrapper::getCapabilitiesInternal() {
int32_t cap = 0;
auto status = getHal()->getCapabilities(&cap);
diff --git a/services/vibratorservice/include/vibratorservice/VibratorHalWrapper.h b/services/vibratorservice/include/vibratorservice/VibratorHalWrapper.h
index 20979bd..ae0d9ab 100644
--- a/services/vibratorservice/include/vibratorservice/VibratorHalWrapper.h
+++ b/services/vibratorservice/include/vibratorservice/VibratorHalWrapper.h
@@ -354,6 +354,8 @@
using CompositeEffect = aidl::android::hardware::vibrator::CompositeEffect;
using Braking = aidl::android::hardware::vibrator::Braking;
using PrimitivePwle = aidl::android::hardware::vibrator::PrimitivePwle;
+ using PwleV2Primitive = aidl::android::hardware::vibrator::PwleV2Primitive;
+ using PwleV2OutputMapEntry = aidl::android::hardware::vibrator::PwleV2OutputMapEntry;
explicit HalWrapper(std::shared_ptr<CallbackScheduler> scheduler)
: mCallbackScheduler(std::move(scheduler)) {}
@@ -391,6 +393,9 @@
virtual HalResult<void> performPwleEffect(const std::vector<PrimitivePwle>& primitives,
const std::function<void()>& completionCallback);
+ virtual HalResult<void> composePwleV2(const std::vector<PwleV2Primitive>& composite,
+ const std::function<void()>& completionCallback);
+
protected:
// Shared pointer to allow CallbackScheduler to outlive this wrapper.
const std::shared_ptr<CallbackScheduler> mCallbackScheduler;
@@ -471,6 +476,9 @@
const std::vector<PrimitivePwle>& primitives,
const std::function<void()>& completionCallback) override final;
+ HalResult<void> composePwleV2(const std::vector<PwleV2Primitive>& composite,
+ const std::function<void()>& completionCallback) override final;
+
protected:
HalResult<Capabilities> getCapabilitiesInternal() override final;
HalResult<std::vector<Effect>> getSupportedEffectsInternal() override final;
diff --git a/services/vibratorservice/test/VibratorHalWrapperAidlTest.cpp b/services/vibratorservice/test/VibratorHalWrapperAidlTest.cpp
index 7bcc59a..ba7e1f0 100644
--- a/services/vibratorservice/test/VibratorHalWrapperAidlTest.cpp
+++ b/services/vibratorservice/test/VibratorHalWrapperAidlTest.cpp
@@ -39,6 +39,7 @@
using aidl::android::hardware::vibrator::IVibrator;
using aidl::android::hardware::vibrator::IVibratorCallback;
using aidl::android::hardware::vibrator::PrimitivePwle;
+using aidl::android::hardware::vibrator::PwleV2Primitive;
using aidl::android::hardware::vibrator::VendorEffect;
using aidl::android::os::PersistableBundle;
@@ -681,3 +682,38 @@
ASSERT_TRUE(result.isOk());
ASSERT_EQ(1, *callbackCounter.get());
}
+
+TEST_F(VibratorHalWrapperAidlTest, TestComposePwleV2) {
+ auto pwleEffect = {
+ PwleV2Primitive(/*amplitude=*/0.2, /*frequency=*/50, /*time=*/100),
+ PwleV2Primitive(/*amplitude=*/0.5, /*frequency=*/150, /*time=*/100),
+ PwleV2Primitive(/*amplitude=*/0.8, /*frequency=*/250, /*time=*/100),
+ };
+
+ {
+ InSequence seq;
+ EXPECT_CALL(*mMockHal.get(), composePwleV2(_, _))
+ .Times(Exactly(3))
+ .WillOnce(Return(ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION)))
+ .WillOnce(Return(ndk::ScopedAStatus::fromExceptionCode(EX_SECURITY)))
+ .WillOnce(DoAll(WithArg<1>(vibrator::TriggerCallback()),
+ Return(ndk::ScopedAStatus::ok())));
+ }
+
+ std::unique_ptr<int32_t> callbackCounter = std::make_unique<int32_t>();
+ auto callback = vibrator::TestFactory::createCountingCallback(callbackCounter.get());
+
+ auto result = mWrapper->composePwleV2(pwleEffect, callback);
+ ASSERT_TRUE(result.isUnsupported());
+ // Callback not triggered on failure
+ ASSERT_EQ(0, *callbackCounter.get());
+
+ result = mWrapper->composePwleV2(pwleEffect, callback);
+ ASSERT_TRUE(result.isFailed());
+ // Callback not triggered for unsupported
+ ASSERT_EQ(0, *callbackCounter.get());
+
+ result = mWrapper->composePwleV2(pwleEffect, callback);
+ ASSERT_TRUE(result.isOk());
+ ASSERT_EQ(1, *callbackCounter.get());
+}
diff --git a/services/vibratorservice/test/VibratorHalWrapperHidlV1_0Test.cpp b/services/vibratorservice/test/VibratorHalWrapperHidlV1_0Test.cpp
index 9a7c69d..83430d7 100644
--- a/services/vibratorservice/test/VibratorHalWrapperHidlV1_0Test.cpp
+++ b/services/vibratorservice/test/VibratorHalWrapperHidlV1_0Test.cpp
@@ -40,6 +40,7 @@
using aidl::android::hardware::vibrator::EffectStrength;
using aidl::android::hardware::vibrator::IVibrator;
using aidl::android::hardware::vibrator::PrimitivePwle;
+using aidl::android::hardware::vibrator::PwleV2Primitive;
using aidl::android::hardware::vibrator::VendorEffect;
using aidl::android::os::PersistableBundle;
@@ -369,3 +370,19 @@
// No callback is triggered.
ASSERT_EQ(0, *callbackCounter.get());
}
+
+TEST_F(VibratorHalWrapperHidlV1_0Test, TestComposePwleV2Unsupported) {
+ auto pwleEffect = {
+ PwleV2Primitive(/*amplitude=*/0.2, /*frequency=*/50, /*time=*/100),
+ PwleV2Primitive(/*amplitude=*/0.5, /*frequency=*/150, /*time=*/100),
+ PwleV2Primitive(/*amplitude=*/0.8, /*frequency=*/250, /*time=*/100),
+ };
+
+ std::unique_ptr<int32_t> callbackCounter = std::make_unique<int32_t>();
+ auto callback = vibrator::TestFactory::createCountingCallback(callbackCounter.get());
+
+ ASSERT_TRUE(mWrapper->composePwleV2(pwleEffect, callback).isUnsupported());
+
+ // No callback is triggered.
+ ASSERT_EQ(0, *callbackCounter.get());
+}
diff --git a/services/vibratorservice/test/test_mocks.h b/services/vibratorservice/test/test_mocks.h
index 2f9451e..5e09084 100644
--- a/services/vibratorservice/test/test_mocks.h
+++ b/services/vibratorservice/test/test_mocks.h
@@ -41,6 +41,8 @@
using aidl::android::hardware::vibrator::IVibrator;
using aidl::android::hardware::vibrator::IVibratorCallback;
using aidl::android::hardware::vibrator::PrimitivePwle;
+using aidl::android::hardware::vibrator::PwleV2OutputMapEntry;
+using aidl::android::hardware::vibrator::PwleV2Primitive;
using aidl::android::hardware::vibrator::VendorEffect;
// -------------------------------------------------------------------------------------------------
@@ -89,6 +91,17 @@
MOCK_METHOD(ndk::ScopedAStatus, getPwlePrimitiveDurationMax, (int32_t * ret), (override));
MOCK_METHOD(ndk::ScopedAStatus, getPwleCompositionSizeMax, (int32_t * ret), (override));
MOCK_METHOD(ndk::ScopedAStatus, getSupportedBraking, (std::vector<Braking> * ret), (override));
+ MOCK_METHOD(ndk::ScopedAStatus, getPwleV2FrequencyToOutputAccelerationMap,
+ (std::vector<PwleV2OutputMapEntry> * ret), (override));
+ MOCK_METHOD(ndk::ScopedAStatus, getPwleV2PrimitiveDurationMaxMillis, (int32_t* ret),
+ (override));
+ MOCK_METHOD(ndk::ScopedAStatus, getPwleV2PrimitiveDurationMinMillis, (int32_t* ret),
+ (override));
+ MOCK_METHOD(ndk::ScopedAStatus, getPwleV2CompositionSizeMax, (int32_t* ret), (override));
+ MOCK_METHOD(ndk::ScopedAStatus, composePwleV2,
+ (const std::vector<PwleV2Primitive>& e,
+ const std::shared_ptr<IVibratorCallback>& cb),
+ (override));
MOCK_METHOD(ndk::ScopedAStatus, getInterfaceVersion, (int32_t*), (override));
MOCK_METHOD(ndk::ScopedAStatus, getInterfaceHash, (std::string*), (override));
MOCK_METHOD(ndk::SpAIBinder, asBinder, (), (override));