diff options
25 files changed, 144 insertions, 110 deletions
diff --git a/data/etc/android.hardware.bluetooth_le.channel_sounding.xml b/data/etc/android.hardware.bluetooth_le.channel_sounding.xml new file mode 100644 index 0000000000..f0ee5d999f --- /dev/null +++ b/data/etc/android.hardware.bluetooth_le.channel_sounding.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2024 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!-- Adds the feature indicating support for the BLE Channel sounding --> +<permissions> + <feature name="android.hardware.bluetooth_le.channel_sounding" /> +</permissions> diff --git a/include/powermanager/OWNERS b/include/powermanager/OWNERS new file mode 100644 index 0000000000..9f40e27a10 --- /dev/null +++ b/include/powermanager/OWNERS @@ -0,0 +1 @@ +file:platform/frameworks/base:/ADPF_OWNERS
\ No newline at end of file diff --git a/libs/gui/BufferItemConsumer.cpp b/libs/gui/BufferItemConsumer.cpp index bfe3d6e023..8566419435 100644 --- a/libs/gui/BufferItemConsumer.cpp +++ b/libs/gui/BufferItemConsumer.cpp @@ -140,7 +140,7 @@ status_t BufferItemConsumer::releaseBufferSlotLocked(int slotIndex, const sp<Gra BI_LOGE("Failed to addReleaseFenceLocked"); } - err = releaseBufferLocked(slotIndex, buffer, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR); + err = releaseBufferLocked(slotIndex, buffer); if (err != OK && err != IGraphicBufferConsumer::STALE_BUFFER_SLOT) { BI_LOGE("Failed to release buffer: %s (%d)", strerror(-err), err); diff --git a/libs/gui/GLConsumer.cpp b/libs/gui/GLConsumer.cpp index 95cce5c1df..f2173cd740 100644 --- a/libs/gui/GLConsumer.cpp +++ b/libs/gui/GLConsumer.cpp @@ -314,7 +314,7 @@ status_t GLConsumer::releaseTexImage() { // so... basically, nothing more to do here. } - err = releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer, mEglDisplay, EGL_NO_SYNC_KHR); + err = releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer); if (err < NO_ERROR) { GLC_LOGE("releaseTexImage: failed to release buffer: %s (%d)", strerror(-err), err); @@ -418,16 +418,14 @@ status_t GLConsumer::updateAndReleaseLocked(const BufferItem& item, if (!mAttached) { GLC_LOGE("updateAndRelease: GLConsumer is not attached to an OpenGL " "ES context"); - releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer, - mEglDisplay, EGL_NO_SYNC_KHR); + releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer); return INVALID_OPERATION; } // Confirm state. err = checkAndUpdateEglStateLocked(); if (err != NO_ERROR) { - releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer, - mEglDisplay, EGL_NO_SYNC_KHR); + releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer); return err; } @@ -440,8 +438,7 @@ status_t GLConsumer::updateAndReleaseLocked(const BufferItem& item, if (err != NO_ERROR) { GLC_LOGW("updateAndRelease: unable to createImage on display=%p slot=%d", mEglDisplay, slot); - releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer, - mEglDisplay, EGL_NO_SYNC_KHR); + releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer); return UNKNOWN_ERROR; } @@ -453,8 +450,7 @@ status_t GLConsumer::updateAndReleaseLocked(const BufferItem& item, // release the old buffer, so instead we just drop the new frame. // As we are still under lock since acquireBuffer, it is safe to // release by slot. - releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer, - mEglDisplay, EGL_NO_SYNC_KHR); + releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer); return err; } } diff --git a/libs/gui/IGraphicBufferConsumer.cpp b/libs/gui/IGraphicBufferConsumer.cpp index c705d3926d..282957b940 100644 --- a/libs/gui/IGraphicBufferConsumer.cpp +++ b/libs/gui/IGraphicBufferConsumer.cpp @@ -26,6 +26,7 @@ #include <utils/NativeHandle.h> #include <utils/String8.h> +#include <cstdint> namespace android { @@ -84,7 +85,8 @@ public: EGLDisplay display __attribute__((unused)), EGLSyncKHR fence __attribute__((unused)), const sp<Fence>& releaseFence) override { - return callRemote<ReleaseBuffer>(Tag::RELEASE_BUFFER, buf, frameNumber, releaseFence); + using Signature = status_t (IGraphicBufferConsumer::*)(int, uint64_t, const sp<Fence>&); + return callRemote<Signature>(Tag::RELEASE_BUFFER, buf, frameNumber, releaseFence); } status_t consumerConnect(const sp<IConsumerListener>& consumer, bool controlledByApp) override { @@ -188,8 +190,10 @@ status_t BnGraphicBufferConsumer::onTransact(uint32_t code, const Parcel& data, return callLocal(data, reply, &IGraphicBufferConsumer::detachBuffer); case Tag::ATTACH_BUFFER: return callLocal(data, reply, &IGraphicBufferConsumer::attachBuffer); - case Tag::RELEASE_BUFFER: - return callLocal(data, reply, &IGraphicBufferConsumer::releaseHelper); + case Tag::RELEASE_BUFFER: { + using Signature = status_t (IGraphicBufferConsumer::*)(int, uint64_t, const sp<Fence>&); + return callLocal<Signature>(data, reply, &IGraphicBufferConsumer::releaseBuffer); + } case Tag::CONSUMER_CONNECT: return callLocal(data, reply, &IGraphicBufferConsumer::consumerConnect); case Tag::CONSUMER_DISCONNECT: diff --git a/libs/gui/StreamSplitter.cpp b/libs/gui/StreamSplitter.cpp index 2f8e104ea0..653b91bcf6 100644 --- a/libs/gui/StreamSplitter.cpp +++ b/libs/gui/StreamSplitter.cpp @@ -234,8 +234,7 @@ void StreamSplitter::onBufferReleasedByOutput( LOG_ALWAYS_FATAL_IF(status != NO_ERROR, "attaching buffer to input failed (%d)", status); - status = mInput->releaseBuffer(consumerSlot, /* frameNumber */ 0, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, tracker->getMergedFence()); + status = mInput->releaseBuffer(consumerSlot, /* frameNumber */ 0, tracker->getMergedFence()); LOG_ALWAYS_FATAL_IF(status != NO_ERROR, "releasing buffer to input failed (%d)", status); diff --git a/libs/gui/include/gui/GLConsumer.h b/libs/gui/include/gui/GLConsumer.h index bfe3eb31e8..8a66dc0cf1 100644 --- a/libs/gui/include/gui/GLConsumer.h +++ b/libs/gui/include/gui/GLConsumer.h @@ -268,9 +268,9 @@ protected: // releaseBufferLocked overrides the ConsumerBase method to update the // mEglSlots array in addition to the ConsumerBase. - virtual status_t releaseBufferLocked(int slot, - const sp<GraphicBuffer> graphicBuffer, - EGLDisplay display, EGLSyncKHR eglFence) override; + virtual status_t releaseBufferLocked(int slot, const sp<GraphicBuffer> graphicBuffer, + EGLDisplay display = EGL_NO_DISPLAY, + EGLSyncKHR eglFence = EGL_NO_SYNC_KHR) override; status_t releaseBufferLocked(int slot, const sp<GraphicBuffer> graphicBuffer, EGLSyncKHR eglFence) { diff --git a/libs/gui/include/gui/IGraphicBufferConsumer.h b/libs/gui/include/gui/IGraphicBufferConsumer.h index 0b92e7df62..18f5488173 100644 --- a/libs/gui/include/gui/IGraphicBufferConsumer.h +++ b/libs/gui/include/gui/IGraphicBufferConsumer.h @@ -137,16 +137,9 @@ public: virtual status_t releaseBuffer(int buf, uint64_t frameNumber, EGLDisplay display, EGLSyncKHR fence, const sp<Fence>& releaseFence) = 0; - status_t releaseHelper(int buf, uint64_t frameNumber, const sp<Fence>& releaseFence) { + status_t releaseBuffer(int buf, uint64_t frameNumber, const sp<Fence>& releaseFence) { return releaseBuffer(buf, frameNumber, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence); } - // This is explicitly *not* the actual signature of IGBC::releaseBuffer, but: - // 1) We have no easy way to send the EGL objects across Binder - // 2) This has always been broken, probably because - // 3) IGBC is rarely remoted - // For now, we will choose to bury our heads in the sand and ignore this problem until such time - // as we can finally finish converting away from EGL sync to native Android sync - using ReleaseBuffer = decltype(&IGraphicBufferConsumer::releaseHelper); // consumerConnect connects a consumer to the BufferQueue. Only one consumer may be connected, // and when that consumer disconnects the BufferQueue is placed into the "abandoned" state, diff --git a/libs/gui/tests/BufferQueue_test.cpp b/libs/gui/tests/BufferQueue_test.cpp index b026e640aa..16060990bd 100644 --- a/libs/gui/tests/BufferQueue_test.cpp +++ b/libs/gui/tests/BufferQueue_test.cpp @@ -425,8 +425,7 @@ TEST_F(BufferQueueTest, DetachAndReattachOnConsumerSide) { ASSERT_EQ(BAD_VALUE, mConsumer->attachBuffer(&newSlot, nullptr)); ASSERT_EQ(OK, mConsumer->attachBuffer(&newSlot, item.mGraphicBuffer)); - ASSERT_EQ(OK, mConsumer->releaseBuffer(newSlot, 0, EGL_NO_DISPLAY, - EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(newSlot, 0, Fence::NO_FENCE)); ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION, mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, GRALLOC_USAGE_SW_WRITE_OFTEN, @@ -609,8 +608,7 @@ TEST_F(BufferQueueTest, TestSharedBufferModeWithoutAutoRefresh) { ASSERT_EQ(true, item.mQueuedBuffer); ASSERT_EQ(false, item.mAutoRefresh); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); // attempt to acquire a second time should return no buffer available ASSERT_EQ(IGraphicBufferConsumer::NO_BUFFER_AVAILABLE, @@ -653,8 +651,7 @@ TEST_F(BufferQueueTest, TestSharedBufferModeWithAutoRefresh) { ASSERT_EQ(i == 0, item.mQueuedBuffer); ASSERT_EQ(true, item.mAutoRefresh); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); } // Repeatedly queue and dequeue a buffer from the producer side, it should @@ -684,8 +681,7 @@ TEST_F(BufferQueueTest, TestSharedBufferModeWithAutoRefresh) { ASSERT_EQ(i == 0, item.mQueuedBuffer); ASSERT_EQ(true, item.mAutoRefresh); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); } } @@ -735,8 +731,7 @@ TEST_F(BufferQueueTest, TestSharedBufferModeUsingAlreadyDequeuedBuffer) { ASSERT_EQ(true, item.mQueuedBuffer); ASSERT_EQ(false, item.mAutoRefresh); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); // attempt to acquire a second time should return no buffer available ASSERT_EQ(IGraphicBufferConsumer::NO_BUFFER_AVAILABLE, @@ -874,8 +869,7 @@ TEST_F(BufferQueueTest, CanRetrieveLastQueuedBuffer) { for (size_t i = 0; i < 2; ++i) { BufferItem item; ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); } // Make sure we got the second buffer back @@ -929,8 +923,7 @@ TEST_F(BufferQueueTest, TestOccupancyHistory) { nullptr, nullptr)); ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output)); ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); std::this_thread::sleep_for(16ms); } @@ -946,8 +939,7 @@ TEST_F(BufferQueueTest, TestOccupancyHistory) { nullptr, nullptr)); ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output)); ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); std::this_thread::sleep_for(16ms); } ASSERT_EQ(OK, @@ -959,12 +951,10 @@ TEST_F(BufferQueueTest, TestOccupancyHistory) { nullptr)); ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output)); ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); std::this_thread::sleep_for(16ms); ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); // Sleep between segments std::this_thread::sleep_for(500ms); @@ -981,13 +971,11 @@ TEST_F(BufferQueueTest, TestOccupancyHistory) { nullptr, nullptr)); ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output)); ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); std::this_thread::sleep_for(16ms); } ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); // Now we read the segments std::vector<OccupancyTracker::Segment> history; @@ -1108,8 +1096,7 @@ TEST_F(BufferQueueTest, TestDiscardFreeBuffers) { // Acquire and free 1 buffer ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); int releasedSlot = item.mSlot; // Acquire 1 buffer, leaving 1 filled buffer in queue @@ -1376,8 +1363,7 @@ TEST_F(BufferQueueTest, TestStaleBufferHandleSentAfterDisconnect) { ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); ASSERT_EQ(slot, item.mSlot); ASSERT_NE(nullptr, item.mGraphicBuffer.get()); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); // Dequeue and queue the buffer again ASSERT_EQ(OK, @@ -1390,8 +1376,7 @@ TEST_F(BufferQueueTest, TestStaleBufferHandleSentAfterDisconnect) { ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); ASSERT_EQ(slot, item.mSlot); ASSERT_EQ(nullptr, item.mGraphicBuffer.get()); - ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); // Dequeue and queue the buffer again ASSERT_EQ(OK, diff --git a/libs/gui/tests/StreamSplitter_test.cpp b/libs/gui/tests/StreamSplitter_test.cpp index f34b03eade..1c439cdb45 100644 --- a/libs/gui/tests/StreamSplitter_test.cpp +++ b/libs/gui/tests/StreamSplitter_test.cpp @@ -95,8 +95,7 @@ TEST_F(StreamSplitterTest, OneInputOneOutput) { ASSERT_EQ(*dataOut, TEST_DATA); ASSERT_EQ(OK, item.mGraphicBuffer->unlock()); - ASSERT_EQ(OK, outputConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE)); + ASSERT_EQ(OK, outputConsumer->releaseBuffer(item.mSlot, item.mFrameNumber, Fence::NO_FENCE)); // This should succeed even with allocation disabled since it will have // received the buffer back from the output BufferQueue @@ -168,9 +167,9 @@ TEST_F(StreamSplitterTest, OneInputMultipleOutputs) { ASSERT_EQ(*dataOut, TEST_DATA); ASSERT_EQ(OK, item.mGraphicBuffer->unlock()); - ASSERT_EQ(OK, outputConsumers[output]->releaseBuffer(item.mSlot, - item.mFrameNumber, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, - Fence::NO_FENCE)); + ASSERT_EQ(OK, + outputConsumers[output]->releaseBuffer(item.mSlot, item.mFrameNumber, + Fence::NO_FENCE)); } // This should succeed even with allocation disabled since it will have diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index 88893b64ba..c74186682e 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -201,9 +201,9 @@ protected: releasedItems.resize(1+extraDiscardedBuffers); for (size_t i = 0; i < releasedItems.size(); i++) { ASSERT_EQ(NO_ERROR, consumer->acquireBuffer(&releasedItems[i], 0)); - ASSERT_EQ(NO_ERROR, consumer->releaseBuffer(releasedItems[i].mSlot, - releasedItems[i].mFrameNumber, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, - Fence::NO_FENCE)); + ASSERT_EQ(NO_ERROR, + consumer->releaseBuffer(releasedItems[i].mSlot, releasedItems[i].mFrameNumber, + Fence::NO_FENCE)); } int32_t expectedReleaseCb = (enableReleasedCb ? releasedItems.size() : 0); if (hasSurfaceListener) { diff --git a/libs/input/rust/data_store.rs b/libs/input/rust/data_store.rs index 6bdcefda36..beb6e23478 100644 --- a/libs/input/rust/data_store.rs +++ b/libs/input/rust/data_store.rs @@ -17,7 +17,7 @@ //! Contains the DataStore, used to store input related data in a persistent way. use crate::input::KeyboardType; -use log::{debug, error}; +use log::{debug, error, info}; use serde::{Deserialize, Serialize}; use std::fs::File; use std::io::{Read, Write}; @@ -157,7 +157,7 @@ impl FileReaderWriter for DefaultFileReaderWriter { let path = Path::new(&self.filepath); let mut fs_string = String::new(); match File::open(path) { - Err(e) => error!("couldn't open {:?}: {}", path, e), + Err(e) => info!("couldn't open {:?}: {}", path, e), Ok(mut file) => match file.read_to_string(&mut fs_string) { Err(e) => error!("Couldn't read from {:?}: {}", path, e), Ok(_) => debug!("Successfully read from file {:?}", path), diff --git a/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp b/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp index 1210f711de..39bb841c0a 100644 --- a/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp +++ b/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp @@ -14,15 +14,18 @@ * limitations under the License. */ +#include <TestEventMatchers.h> #include <android-base/logging.h> #include <attestation/HmacKeyManager.h> #include <ftl/enum.h> +#include <gmock/gmock.h> #include <gtest/gtest.h> #include <input/BlockingQueue.h> #include <input/InputConsumerNoResampling.h> #include <input/InputTransport.h> using android::base::Result; +using ::testing::Matcher; namespace android { @@ -278,7 +281,7 @@ protected: void SetUp() override { std::unique_ptr<InputChannel> serverChannel; status_t result = - InputChannel::openInputChannelPair("channel name", serverChannel, mClientChannel); + InputChannel::openInputChannelPair("test channel", serverChannel, mClientChannel); ASSERT_EQ(OK, result); mPublisher = std::make_unique<InputPublisher>(std::move(serverChannel)); @@ -336,6 +339,8 @@ protected: // accessed on the test thread. BlockingQueue<bool> mProbablyHasInputResponses; + std::unique_ptr<MotionEvent> assertReceivedMotionEvent(const Matcher<MotionEvent>& matcher); + private: sp<MessageHandler> mMessageHandler; void handleMessage(const Message& message); @@ -389,6 +394,20 @@ void InputPublisherAndConsumerNoResamplingTest::sendMessage(LooperMessage messag mLooper->sendMessage(mMessageHandler, msg); } +std::unique_ptr<MotionEvent> InputPublisherAndConsumerNoResamplingTest::assertReceivedMotionEvent( + const Matcher<MotionEvent>& matcher) { + std::optional<std::unique_ptr<MotionEvent>> event = mMotionEvents.popWithTimeout(TIMEOUT); + if (!event) { + ADD_FAILURE() << "No event was received, but expected motion " << matcher; + return nullptr; + } + if (*event == nullptr) { + LOG(FATAL) << "Event was received, but it was null"; + } + EXPECT_THAT(**event, matcher); + return std::move(*event); +} + void InputPublisherAndConsumerNoResamplingTest::handleMessage(const Message& message) { switch (static_cast<LooperMessage>(message.what)) { case LooperMessage::CALL_PROBABLY_HAS_INPUT: { @@ -572,8 +591,7 @@ void InputPublisherAndConsumerNoResamplingTest::publishAndConsumeSinglePointerMu const nsecs_t publishTimeOfDown = systemTime(SYSTEM_TIME_MONOTONIC); publishMotionEvent(*mPublisher, argsDown); - // Consume the DOWN event. - ASSERT_TRUE(mMotionEvents.popWithTimeout(TIMEOUT).has_value()); + assertReceivedMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_DOWN)); verifyFinishedSignal(*mPublisher, mSeq, publishTimeOfDown); @@ -622,10 +640,10 @@ void InputPublisherAndConsumerNoResamplingTest::publishAndConsumeSinglePointerMu // the motion as a batched event, or as a sequence of multiple single-sample MotionEvents (or a // mix of those) while (singleSampledMotionEvents.size() != nSamples) { - const std::optional<std::unique_ptr<MotionEvent>> batchedMotionEvent = - mMotionEvents.popWithTimeout(TIMEOUT); + const std::unique_ptr<MotionEvent> batchedMotionEvent = + assertReceivedMotionEvent(WithMotionAction(ACTION_MOVE)); // The events received by these calls are never null - std::vector<MotionEvent> splitMotionEvents = splitBatchedMotionEvent(**batchedMotionEvent); + std::vector<MotionEvent> splitMotionEvents = splitBatchedMotionEvent(*batchedMotionEvent); singleSampledMotionEvents.insert(singleSampledMotionEvents.end(), splitMotionEvents.begin(), splitMotionEvents.end()); } @@ -681,10 +699,7 @@ void InputPublisherAndConsumerNoResamplingTest::publishAndConsumeBatchedMotionMo } mNotifyLooperMayProceed.notify_all(); - std::optional<std::unique_ptr<MotionEvent>> optMotion = mMotionEvents.popWithTimeout(TIMEOUT); - ASSERT_TRUE(optMotion.has_value()); - std::unique_ptr<MotionEvent> motion = std::move(*optMotion); - ASSERT_EQ(ACTION_MOVE, motion->getAction()); + assertReceivedMotionEvent(WithMotionAction(ACTION_MOVE)); verifyFinishedSignal(*mPublisher, seq, publishTime); } @@ -696,9 +711,7 @@ void InputPublisherAndConsumerNoResamplingTest::publishAndConsumeMotionEvent( nsecs_t publishTime = systemTime(SYSTEM_TIME_MONOTONIC); publishMotionEvent(*mPublisher, args); - std::optional<std::unique_ptr<MotionEvent>> optMotion = mMotionEvents.popWithTimeout(TIMEOUT); - ASSERT_TRUE(optMotion.has_value()); - std::unique_ptr<MotionEvent> event = std::move(*optMotion); + std::unique_ptr<MotionEvent> event = assertReceivedMotionEvent(WithMotionAction(action)); verifyArgsEqualToEvent(args, *event); diff --git a/libs/nativedisplay/include/surfacetexture/SurfaceTexture.h b/libs/nativedisplay/include/surfacetexture/SurfaceTexture.h index f1453bd64d..006a785cb7 100644 --- a/libs/nativedisplay/include/surfacetexture/SurfaceTexture.h +++ b/libs/nativedisplay/include/surfacetexture/SurfaceTexture.h @@ -344,7 +344,8 @@ protected: * mEglSlots array in addition to the ConsumerBase. */ virtual status_t releaseBufferLocked(int slot, const sp<GraphicBuffer> graphicBuffer, - EGLDisplay display, EGLSyncKHR eglFence) override; + EGLDisplay display = EGL_NO_DISPLAY, + EGLSyncKHR eglFence = EGL_NO_SYNC_KHR) override; /** * freeBufferLocked frees up the given buffer slot. If the slot has been diff --git a/libs/nativedisplay/surfacetexture/EGLConsumer.cpp b/libs/nativedisplay/surfacetexture/EGLConsumer.cpp index 275b7a4888..3959fce008 100644 --- a/libs/nativedisplay/surfacetexture/EGLConsumer.cpp +++ b/libs/nativedisplay/surfacetexture/EGLConsumer.cpp @@ -150,8 +150,7 @@ status_t EGLConsumer::releaseTexImage(SurfaceTexture& st) { } } - err = st.releaseBufferLocked(buf, st.mSlots[buf].mGraphicBuffer, mEglDisplay, - EGL_NO_SYNC_KHR); + err = st.releaseBufferLocked(buf, st.mSlots[buf].mGraphicBuffer); if (err < NO_ERROR) { EGC_LOGE("releaseTexImage: failed to release buffer: %s (%d)", strerror(-err), err); return err; @@ -234,14 +233,14 @@ status_t EGLConsumer::updateAndReleaseLocked(const BufferItem& item, PendingRele if (st.mOpMode != SurfaceTexture::OpMode::attachedToGL) { EGC_LOGE("updateAndRelease: EGLConsumer is not attached to an OpenGL " "ES context"); - st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer, mEglDisplay, EGL_NO_SYNC_KHR); + st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer); return INVALID_OPERATION; } // Confirm state. err = checkAndUpdateEglStateLocked(st); if (err != NO_ERROR) { - st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer, mEglDisplay, EGL_NO_SYNC_KHR); + st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer); return err; } @@ -254,7 +253,7 @@ status_t EGLConsumer::updateAndReleaseLocked(const BufferItem& item, PendingRele if (err != NO_ERROR) { EGC_LOGW("updateAndRelease: unable to createImage on display=%p slot=%d", mEglDisplay, slot); - st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer, mEglDisplay, EGL_NO_SYNC_KHR); + st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer); return UNKNOWN_ERROR; } @@ -266,8 +265,7 @@ status_t EGLConsumer::updateAndReleaseLocked(const BufferItem& item, PendingRele // release the old buffer, so instead we just drop the new frame. // As we are still under lock since acquireBuffer, it is safe to // release by slot. - st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer, mEglDisplay, - EGL_NO_SYNC_KHR); + st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer); return err; } } diff --git a/libs/nativedisplay/surfacetexture/ImageConsumer.cpp b/libs/nativedisplay/surfacetexture/ImageConsumer.cpp index 32b229d77c..60e87b54d5 100644 --- a/libs/nativedisplay/surfacetexture/ImageConsumer.cpp +++ b/libs/nativedisplay/surfacetexture/ImageConsumer.cpp @@ -64,8 +64,7 @@ sp<GraphicBuffer> ImageConsumer::dequeueBuffer(int* outSlotid, android_dataspace // Wait on the producer fence for the buffer to be ready. err = fenceWait(item.mFence->get(), fencePassThroughHandle); if (err != OK) { - st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer, EGL_NO_DISPLAY, - EGL_NO_SYNC_KHR); + st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer); return nullptr; } } @@ -79,8 +78,7 @@ sp<GraphicBuffer> ImageConsumer::dequeueBuffer(int* outSlotid, android_dataspace err = createFence(st.mUseFenceSync, &mImageSlots[slot].eglFence(), &display, &releaseFenceId, fencePassThroughHandle); if (OK != err) { - st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer, EGL_NO_DISPLAY, - EGL_NO_SYNC_KHR); + st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer); return nullptr; } @@ -91,8 +89,7 @@ sp<GraphicBuffer> ImageConsumer::dequeueBuffer(int* outSlotid, android_dataspace releaseFence); if (err != OK) { IMG_LOGE("dequeueImage: error adding release fence: %s (%d)", strerror(-err), err); - st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer, EGL_NO_DISPLAY, - EGL_NO_SYNC_KHR); + st.releaseBufferLocked(slot, st.mSlots[slot].mGraphicBuffer); return nullptr; } } diff --git a/services/gpuservice/gpuwork/bpfprogs/gpuWork.c b/services/gpuservice/gpuwork/bpfprogs/gpuWork.c index f4701896b6..94abc69426 100644 --- a/services/gpuservice/gpuwork/bpfprogs/gpuWork.c +++ b/services/gpuservice/gpuwork/bpfprogs/gpuWork.c @@ -20,11 +20,7 @@ #include <stddef.h> #include <stdint.h> -#ifdef MOCK_BPF -#include <test/mock_bpf_helpers.h> -#else #include <bpf_helpers.h> -#endif #define S_IN_NS (1000000000) #define SMALL_TIME_GAP_LIMIT_NS (S_IN_NS) diff --git a/services/inputflinger/include/InputReaderBase.h b/services/inputflinger/include/InputReaderBase.h index 305feab6c7..580cde39b1 100644 --- a/services/inputflinger/include/InputReaderBase.h +++ b/services/inputflinger/include/InputReaderBase.h @@ -362,6 +362,9 @@ public: /* Toggle Caps Lock */ virtual void toggleCapsLockState(int32_t deviceId) = 0; + /* Resets locked modifier state */ + virtual void resetLockedModifierState() = 0; + /* Determine whether physical keys exist for the given framework-domain key codes. */ virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, const std::vector<int32_t>& keyCodes, uint8_t* outFlags) = 0; diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp index ada6653f65..24919b678d 100644 --- a/services/inputflinger/reader/InputReader.cpp +++ b/services/inputflinger/reader/InputReader.cpp @@ -590,6 +590,11 @@ void InputReader::toggleCapsLockState(int32_t deviceId) { } } +void InputReader::resetLockedModifierState() { + std::scoped_lock _l(mLock); + updateLedMetaStateLocked(0); +} + bool InputReader::hasKeys(int32_t deviceId, uint32_t sourceMask, const std::vector<int32_t>& keyCodes, uint8_t* outFlags) { std::scoped_lock _l(mLock); diff --git a/services/inputflinger/reader/include/InputReader.h b/services/inputflinger/reader/include/InputReader.h index 7614a05470..1403ca2986 100644 --- a/services/inputflinger/reader/include/InputReader.h +++ b/services/inputflinger/reader/include/InputReader.h @@ -69,6 +69,8 @@ public: void toggleCapsLockState(int32_t deviceId) override; + void resetLockedModifierState() override; + bool hasKeys(int32_t deviceId, uint32_t sourceMask, const std::vector<int32_t>& keyCodes, uint8_t* outFlags) override; diff --git a/services/inputflinger/tests/KeyboardInputMapper_test.cpp b/services/inputflinger/tests/KeyboardInputMapper_test.cpp index 39b583c6ae..1dd32c447b 100644 --- a/services/inputflinger/tests/KeyboardInputMapper_test.cpp +++ b/services/inputflinger/tests/KeyboardInputMapper_test.cpp @@ -926,6 +926,33 @@ TEST_F(KeyboardInputMapperTest, Process_toggleCapsLockState) { ASSERT_EQ(AMETA_CAPS_LOCK_ON, mapper.getMetaState()); } +TEST_F(KeyboardInputMapperTest, Process_ResetLockedModifierState) { + mFakeEventHub->addKey(EVENTHUB_ID, KEY_CAPSLOCK, 0, AKEYCODE_CAPS_LOCK, 0); + mFakeEventHub->addKey(EVENTHUB_ID, KEY_NUMLOCK, 0, AKEYCODE_NUM_LOCK, 0); + mFakeEventHub->addKey(EVENTHUB_ID, KEY_SCROLLLOCK, 0, AKEYCODE_SCROLL_LOCK, 0); + + KeyboardInputMapper& mapper = + constructAndAddMapper<KeyboardInputMapper>(AINPUT_SOURCE_KEYBOARD); + // Initial metastate is AMETA_NONE. + ASSERT_EQ(AMETA_NONE, mapper.getMetaState()); + + // Toggle caps lock on. + process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_CAPSLOCK, 1); + process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_CAPSLOCK, 0); + + // Toggle num lock on. + process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_NUMLOCK, 1); + process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_NUMLOCK, 0); + + // Toggle scroll lock on. + process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_SCROLLLOCK, 1); + process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_SCROLLLOCK, 0); + ASSERT_EQ(AMETA_CAPS_LOCK_ON | AMETA_NUM_LOCK_ON | AMETA_SCROLL_LOCK_ON, mapper.getMetaState()); + + mReader->resetLockedModifierState(); + ASSERT_EQ(AMETA_NONE, mapper.getMetaState()); +} + TEST_F(KeyboardInputMapperTest, Process_LockedKeysShouldToggleInMultiDevices) { // keyboard 1. mFakeEventHub->addLed(EVENTHUB_ID, LED_CAPSL, true /*initially on*/); diff --git a/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp b/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp index 64f3c279a6..6be922dfdb 100644 --- a/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp +++ b/services/inputflinger/tests/fuzzers/InputReaderFuzzer.cpp @@ -75,6 +75,8 @@ public: void toggleCapsLockState(int32_t deviceId) { reader->toggleCapsLockState(deviceId); } + void resetLockedModifierState() { reader->resetLockedModifierState(); } + bool hasKeys(int32_t deviceId, uint32_t sourceMask, const std::vector<int32_t>& keyCodes, uint8_t* outFlags) { return reader->hasKeys(deviceId, sourceMask, keyCodes, outFlags); @@ -226,6 +228,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) { fdp->ConsumeIntegral<int32_t>()); }, [&]() -> void { reader->toggleCapsLockState(fdp->ConsumeIntegral<int32_t>()); }, + [&]() -> void { reader->resetLockedModifierState(); }, [&]() -> void { size_t count = fdp->ConsumeIntegralInRange<size_t>(1, 1024); std::vector<uint8_t> outFlags(count); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index a66380b358..37b35f2f63 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2248,12 +2248,10 @@ void SurfaceFlinger::onComposerHalHotplugEvent(hal::HWDisplayId hwcDisplayId, return; } - if (FlagManager::getInstance().hotplug2()) { - // TODO(b/311403559): use enum type instead of int - const auto errorCode = static_cast<int32_t>(event); - ALOGD("%s: Hotplug error %d for hwcDisplayId %" PRIu64, __func__, errorCode, hwcDisplayId); - mScheduler->dispatchHotplugError(errorCode); - } + // TODO(b/311403559): use enum type instead of int + const auto errorCode = static_cast<int32_t>(event); + ALOGD("%s: Hotplug error %d for hwcDisplayId %" PRIu64, __func__, errorCode, hwcDisplayId); + mScheduler->dispatchHotplugError(errorCode); } void SurfaceFlinger::onComposerHalVsyncPeriodTimingChanged( @@ -3483,10 +3481,8 @@ bool SurfaceFlinger::configureLocked() { processHotplugConnect(displayId, hwcDisplayId, std::move(*info), displayString.c_str()); if (!activeModeIdOpt) { - if (FlagManager::getInstance().hotplug2()) { - mScheduler->dispatchHotplugError( - static_cast<int32_t>(DisplayHotplugEvent::ERROR_UNKNOWN)); - } + mScheduler->dispatchHotplugError( + static_cast<int32_t>(DisplayHotplugEvent::ERROR_UNKNOWN)); getHwComposer().disconnectDisplay(displayId); continue; } diff --git a/services/surfaceflinger/common/FlagManager.cpp b/services/surfaceflinger/common/FlagManager.cpp index a99b57b60d..b56ee01422 100644 --- a/services/surfaceflinger/common/FlagManager.cpp +++ b/services/surfaceflinger/common/FlagManager.cpp @@ -123,7 +123,6 @@ void FlagManager::dump(std::string& result) const { DUMP_READ_ONLY_FLAG(frame_rate_category_mrr); DUMP_READ_ONLY_FLAG(misc1); DUMP_READ_ONLY_FLAG(vrr_config); - DUMP_READ_ONLY_FLAG(hotplug2); DUMP_READ_ONLY_FLAG(hdcp_level_hal); DUMP_READ_ONLY_FLAG(multithreaded_present); DUMP_READ_ONLY_FLAG(add_sf_skipped_frames_to_trace); @@ -233,7 +232,6 @@ FLAG_MANAGER_READ_ONLY_FLAG(stable_edid_ids, "debug.sf.stable_edid_ids") FLAG_MANAGER_READ_ONLY_FLAG(frame_rate_category_mrr, "debug.sf.frame_rate_category_mrr") FLAG_MANAGER_READ_ONLY_FLAG(misc1, "") FLAG_MANAGER_READ_ONLY_FLAG(vrr_config, "debug.sf.enable_vrr_config") -FLAG_MANAGER_READ_ONLY_FLAG(hotplug2, "") FLAG_MANAGER_READ_ONLY_FLAG(hdcp_level_hal, "") FLAG_MANAGER_READ_ONLY_FLAG(multithreaded_present, "debug.sf.multithreaded_present") FLAG_MANAGER_READ_ONLY_FLAG(add_sf_skipped_frames_to_trace, "") diff --git a/services/surfaceflinger/common/include/common/FlagManager.h b/services/surfaceflinger/common/include/common/FlagManager.h index 480c9ac5e0..9086537619 100644 --- a/services/surfaceflinger/common/include/common/FlagManager.h +++ b/services/surfaceflinger/common/include/common/FlagManager.h @@ -61,7 +61,6 @@ public: bool stable_edid_ids() const; bool misc1() const; bool vrr_config() const; - bool hotplug2() const; bool hdcp_level_hal() const; bool multithreaded_present() const; bool add_sf_skipped_frames_to_trace() const; |