Merge "Installd: restorecon mislabeled gsf" into sc-dev
diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h
index 1fec080..7f0324a 100644
--- a/include/input/InputDevice.h
+++ b/include/input/InputDevice.h
@@ -257,13 +257,9 @@
return mMotionRanges;
}
- const InputDeviceSensorInfo* getSensorInfo(InputDeviceSensorType type);
+ std::vector<InputDeviceSensorInfo> getSensors();
- const std::vector<InputDeviceSensorType> getSensorTypes();
-
- const std::vector<int32_t> getLightIds();
-
- const InputDeviceLightInfo* getLightInfo(int32_t id);
+ std::vector<InputDeviceLightInfo> getLights();
private:
int32_t mId;
diff --git a/libs/binder/tests/Android.bp b/libs/binder/tests/Android.bp
index ec231b2..fb84f04 100644
--- a/libs/binder/tests/Android.bp
+++ b/libs/binder/tests/Android.bp
@@ -156,6 +156,10 @@
],
test_suites: ["general-tests"],
require_root: true,
+ // Prevent the unit test target from running on sc-dev as it's not ready.
+ test_options: {
+ unit_test: false,
+ },
}
cc_benchmark {
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index a2868c6..b9a293f 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -302,23 +302,25 @@
// So we pass in a weak pointer to the BBQ and if it still alive, then we release the buffer.
// Otherwise, this is a no-op.
static void releaseBufferCallbackThunk(wp<BLASTBufferQueue> context, uint64_t graphicBufferId,
- const sp<Fence>& releaseFence) {
+ const sp<Fence>& releaseFence, uint32_t transformHint) {
sp<BLASTBufferQueue> blastBufferQueue = context.promote();
ALOGV("releaseBufferCallbackThunk graphicBufferId=%" PRIu64 " blastBufferQueue=%s",
graphicBufferId, blastBufferQueue ? "alive" : "dead");
if (blastBufferQueue) {
- blastBufferQueue->releaseBufferCallback(graphicBufferId, releaseFence);
+ blastBufferQueue->releaseBufferCallback(graphicBufferId, releaseFence, transformHint);
}
}
void BLASTBufferQueue::releaseBufferCallback(uint64_t graphicBufferId,
- const sp<Fence>& releaseFence) {
+ const sp<Fence>& releaseFence,
+ uint32_t transformHint) {
ATRACE_CALL();
std::unique_lock _lock{mMutex};
BQA_LOGV("releaseBufferCallback graphicBufferId=%" PRIu64, graphicBufferId);
if (mSurfaceControl != nullptr) {
- mTransformHint = mSurfaceControl->getTransformHint();
+ mTransformHint = transformHint;
+ mSurfaceControl->setTransformHint(transformHint);
mBufferItemConsumer->setTransformHint(mTransformHint);
}
@@ -412,7 +414,7 @@
auto releaseBufferCallback =
std::bind(releaseBufferCallbackThunk, wp<BLASTBufferQueue>(this) /* callbackContext */,
- std::placeholders::_1, std::placeholders::_2);
+ std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
t->setBuffer(mSurfaceControl, buffer, releaseBufferCallback);
t->setDataspace(mSurfaceControl, static_cast<ui::Dataspace>(bufferItem.mDataSpace));
t->setHdrMetadata(mSurfaceControl, bufferItem.mHdrMetadata);
diff --git a/libs/gui/ITransactionCompletedListener.cpp b/libs/gui/ITransactionCompletedListener.cpp
index f74f91e..63d07ba 100644
--- a/libs/gui/ITransactionCompletedListener.cpp
+++ b/libs/gui/ITransactionCompletedListener.cpp
@@ -251,10 +251,11 @@
stats);
}
- void onReleaseBuffer(uint64_t graphicBufferId, sp<Fence> releaseFence) override {
+ void onReleaseBuffer(uint64_t graphicBufferId, sp<Fence> releaseFence,
+ uint32_t transformHint) override {
callRemoteAsync<decltype(
&ITransactionCompletedListener::onReleaseBuffer)>(Tag::ON_RELEASE_BUFFER,
- graphicBufferId, releaseFence);
+ graphicBufferId, releaseFence, transformHint);
}
};
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 371454a..9610437 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -331,7 +331,8 @@
callback(surfaceStats.previousBufferId,
surfaceStats.previousReleaseFence
? surfaceStats.previousReleaseFence
- : Fence::NO_FENCE);
+ : Fence::NO_FENCE,
+ surfaceStats.transformHint);
}
}
}
@@ -357,7 +358,8 @@
}
void TransactionCompletedListener::onReleaseBuffer(uint64_t graphicBufferId,
- sp<Fence> releaseFence) {
+ sp<Fence> releaseFence,
+ uint32_t transformHint) {
ReleaseBufferCallback callback;
{
std::scoped_lock<std::mutex> lock(mMutex);
@@ -367,7 +369,7 @@
ALOGE("Could not call release buffer callback, buffer not found %" PRIu64, graphicBufferId);
return;
}
- callback(graphicBufferId, releaseFence);
+ callback(graphicBufferId, releaseFence, transformHint);
}
ReleaseBufferCallback TransactionCompletedListener::popReleaseBufferCallbackLocked(
diff --git a/libs/gui/include/gui/BLASTBufferQueue.h b/libs/gui/include/gui/BLASTBufferQueue.h
index c4ca399..3ab1ee1 100644
--- a/libs/gui/include/gui/BLASTBufferQueue.h
+++ b/libs/gui/include/gui/BLASTBufferQueue.h
@@ -89,7 +89,8 @@
void transactionCallback(nsecs_t latchTime, const sp<Fence>& presentFence,
const std::vector<SurfaceControlStats>& stats);
- void releaseBufferCallback(uint64_t graphicBufferId, const sp<Fence>& releaseFence);
+ void releaseBufferCallback(uint64_t graphicBufferId, const sp<Fence>& releaseFence,
+ uint32_t transformHint);
void setNextTransaction(SurfaceComposerClient::Transaction *t);
void mergeWithNextTransaction(SurfaceComposerClient::Transaction* t, uint64_t frameNumber);
void setTransactionCompleteCallback(uint64_t frameNumber,
diff --git a/libs/gui/include/gui/ITransactionCompletedListener.h b/libs/gui/include/gui/ITransactionCompletedListener.h
index 2d71194..3bfeef1 100644
--- a/libs/gui/include/gui/ITransactionCompletedListener.h
+++ b/libs/gui/include/gui/ITransactionCompletedListener.h
@@ -158,7 +158,8 @@
virtual void onTransactionCompleted(ListenerStats stats) = 0;
- virtual void onReleaseBuffer(uint64_t graphicBufferId, sp<Fence> releaseFence) = 0;
+ virtual void onReleaseBuffer(uint64_t graphicBufferId, sp<Fence> releaseFence,
+ uint32_t transformHint) = 0;
};
class BnTransactionCompletedListener : public SafeBnInterface<ITransactionCompletedListener> {
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 2582882..62a782f 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -82,7 +82,8 @@
std::function<void(nsecs_t /*latchTime*/, const sp<Fence>& /*presentFence*/,
const std::vector<SurfaceControlStats>& /*stats*/)>;
using ReleaseBufferCallback =
- std::function<void(uint64_t /* graphicsBufferId */, const sp<Fence>& /*releaseFence*/)>;
+ std::function<void(uint64_t /* graphicsBufferId */, const sp<Fence>& /*releaseFence*/,
+ uint32_t transformHint)>;
using SurfaceStatsCallback =
std::function<void(void* /*context*/, nsecs_t /*latchTime*/,
@@ -716,7 +717,8 @@
// BnTransactionCompletedListener overrides
void onTransactionCompleted(ListenerStats stats) override;
- void onReleaseBuffer(uint64_t /* graphicsBufferId */, sp<Fence> releaseFence) override;
+ void onReleaseBuffer(uint64_t /* graphicsBufferId */, sp<Fence> releaseFence,
+ uint32_t transformHint) override;
private:
ReleaseBufferCallback popReleaseBufferCallbackLocked(uint64_t /* graphicsBufferId */);
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp
index 61d72ad..30c42a3 100644
--- a/libs/input/InputDevice.cpp
+++ b/libs/input/InputDevice.cpp
@@ -247,36 +247,22 @@
mLights.insert_or_assign(info.id, info);
}
-const std::vector<InputDeviceSensorType> InputDeviceInfo::getSensorTypes() {
- std::vector<InputDeviceSensorType> types;
+std::vector<InputDeviceSensorInfo> InputDeviceInfo::getSensors() {
+ std::vector<InputDeviceSensorInfo> infos;
+ infos.reserve(mSensors.size());
for (const auto& [type, info] : mSensors) {
- types.push_back(type);
+ infos.push_back(info);
}
- return types;
+ return infos;
}
-const InputDeviceSensorInfo* InputDeviceInfo::getSensorInfo(InputDeviceSensorType type) {
- auto it = mSensors.find(type);
- if (it == mSensors.end()) {
- return nullptr;
- }
- return &it->second;
-}
-
-const std::vector<int32_t> InputDeviceInfo::getLightIds() {
- std::vector<int32_t> ids;
+std::vector<InputDeviceLightInfo> InputDeviceInfo::getLights() {
+ std::vector<InputDeviceLightInfo> infos;
+ infos.reserve(mLights.size());
for (const auto& [id, info] : mLights) {
- ids.push_back(id);
+ infos.push_back(info);
}
- return ids;
-}
-
-const InputDeviceLightInfo* InputDeviceInfo::getLightInfo(int32_t id) {
- auto it = mLights.find(id);
- if (it == mLights.end()) {
- return nullptr;
- }
- return &it->second;
+ return infos;
}
} // namespace android
diff --git a/services/inputflinger/include/InputReaderBase.h b/services/inputflinger/include/InputReaderBase.h
index 19abfd9..7fdbbfd 100644
--- a/services/inputflinger/include/InputReaderBase.h
+++ b/services/inputflinger/include/InputReaderBase.h
@@ -113,9 +113,9 @@
/* Get battery status of a particular input device. */
virtual std::optional<int32_t> getBatteryStatus(int32_t deviceId) = 0;
- virtual std::vector<int32_t> getLightIds(int32_t deviceId) = 0;
+ virtual std::vector<InputDeviceLightInfo> getLights(int32_t deviceId) = 0;
- virtual const InputDeviceLightInfo* getLightInfo(int32_t deviceId, int32_t lightId) = 0;
+ virtual std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) = 0;
/* Return true if the device can send input events to the specified display. */
virtual bool canDispatchToDisplay(int32_t deviceId, int32_t displayId) = 0;
diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp
index ad503fd..7af014c 100644
--- a/services/inputflinger/reader/InputDevice.cpp
+++ b/services/inputflinger/reader/InputDevice.cpp
@@ -89,8 +89,7 @@
}
void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) {
- InputDeviceInfo deviceInfo;
- getDeviceInfo(&deviceInfo);
+ InputDeviceInfo deviceInfo = getDeviceInfo();
dump += StringPrintf(INDENT "Device %d: %s\n", deviceInfo.getId(),
deviceInfo.getDisplayName().c_str());
@@ -417,15 +416,17 @@
for_each_mapper([state](InputMapper& mapper) { mapper.updateExternalStylusState(state); });
}
-void InputDevice::getDeviceInfo(InputDeviceInfo* outDeviceInfo) {
- outDeviceInfo->initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal,
- mHasMic);
+InputDeviceInfo InputDevice::getDeviceInfo() {
+ InputDeviceInfo outDeviceInfo;
+ outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal,
+ mHasMic);
for_each_mapper(
- [outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(outDeviceInfo); });
+ [&outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(&outDeviceInfo); });
if (mController) {
- mController->populateDeviceInfo(outDeviceInfo);
+ mController->populateDeviceInfo(&outDeviceInfo);
}
+ return outDeviceInfo;
}
int32_t InputDevice::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp
index e91f84e..10c04f6 100644
--- a/services/inputflinger/reader/InputReader.cpp
+++ b/services/inputflinger/reader/InputReader.cpp
@@ -406,9 +406,7 @@
for (auto& devicePair : mDevices) {
std::shared_ptr<InputDevice>& device = devicePair.second;
if (device->getClasses().test(InputDeviceClass::EXTERNAL_STYLUS) && !device->isIgnored()) {
- InputDeviceInfo info;
- device->getDeviceInfo(&info);
- outDevices.push_back(info);
+ outDevices.push_back(device->getDeviceInfo());
}
}
}
@@ -498,9 +496,7 @@
for (const auto& [device, eventHubIds] : mDeviceToEventHubIdsMap) {
if (!device->isIgnored()) {
- InputDeviceInfo info;
- device->getDeviceInfo(&info);
- outInputDevices.push_back(info);
+ outInputDevices.push_back(device->getDeviceInfo());
}
}
return outInputDevices;
@@ -695,28 +691,26 @@
return std::nullopt;
}
-std::vector<int32_t> InputReader::getLightIds(int32_t deviceId) {
+std::vector<InputDeviceLightInfo> InputReader::getLights(int32_t deviceId) {
std::scoped_lock _l(mLock);
InputDevice* device = findInputDeviceLocked(deviceId);
- if (device) {
- InputDeviceInfo info;
- device->getDeviceInfo(&info);
- return info.getLightIds();
+ if (device == nullptr) {
+ return {};
}
- return {};
+
+ return device->getDeviceInfo().getLights();
}
-const InputDeviceLightInfo* InputReader::getLightInfo(int32_t deviceId, int32_t lightId) {
+std::vector<InputDeviceSensorInfo> InputReader::getSensors(int32_t deviceId) {
std::scoped_lock _l(mLock);
InputDevice* device = findInputDeviceLocked(deviceId);
- if (device) {
- InputDeviceInfo info;
- device->getDeviceInfo(&info);
- return info.getLightInfo(lightId);
+ if (device == nullptr) {
+ return {};
}
- return nullptr;
+
+ return device->getDeviceInfo().getSensors();
}
bool InputReader::setLightColor(int32_t deviceId, int32_t lightId, int32_t color) {
diff --git a/services/inputflinger/reader/include/InputDevice.h b/services/inputflinger/reader/include/InputDevice.h
index 291f105..2f2eba7 100644
--- a/services/inputflinger/reader/include/InputDevice.h
+++ b/services/inputflinger/reader/include/InputDevice.h
@@ -80,7 +80,7 @@
void timeoutExpired(nsecs_t when);
void updateExternalStylusState(const StylusState& state);
- void getDeviceInfo(InputDeviceInfo* outDeviceInfo);
+ InputDeviceInfo getDeviceInfo();
int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode);
int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode);
int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode);
diff --git a/services/inputflinger/reader/include/InputReader.h b/services/inputflinger/reader/include/InputReader.h
index bc79ccf..a00c5af 100644
--- a/services/inputflinger/reader/include/InputReader.h
+++ b/services/inputflinger/reader/include/InputReader.h
@@ -99,9 +99,9 @@
std::optional<int32_t> getBatteryStatus(int32_t deviceId) override;
- std::vector<int32_t> getLightIds(int32_t deviceId) override;
+ std::vector<InputDeviceLightInfo> getLights(int32_t deviceId) override;
- const InputDeviceLightInfo* getLightInfo(int32_t deviceId, int32_t lightId) override;
+ std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) override;
bool setLightColor(int32_t deviceId, int32_t lightId, int32_t color) override;
@@ -130,24 +130,24 @@
// lock is already held by the input loop
void updateGlobalMetaState() NO_THREAD_SAFETY_ANALYSIS override;
int32_t getGlobalMetaState() NO_THREAD_SAFETY_ANALYSIS override;
- void disableVirtualKeysUntil(nsecs_t time) NO_THREAD_SAFETY_ANALYSIS override;
- bool shouldDropVirtualKey(nsecs_t now, int32_t keyCode,
- int32_t scanCode) NO_THREAD_SAFETY_ANALYSIS override;
- void fadePointer() NO_THREAD_SAFETY_ANALYSIS override;
+ void disableVirtualKeysUntil(nsecs_t time) REQUIRES(mReader->mLock) override;
+ bool shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode)
+ REQUIRES(mReader->mLock) override;
+ void fadePointer() REQUIRES(mReader->mLock) override;
std::shared_ptr<PointerControllerInterface> getPointerController(int32_t deviceId)
- NO_THREAD_SAFETY_ANALYSIS override;
- void requestTimeoutAtTime(nsecs_t when) NO_THREAD_SAFETY_ANALYSIS override;
+ REQUIRES(mReader->mLock) override;
+ void requestTimeoutAtTime(nsecs_t when) REQUIRES(mReader->mLock) override;
int32_t bumpGeneration() NO_THREAD_SAFETY_ANALYSIS override;
void getExternalStylusDevices(std::vector<InputDeviceInfo>& outDevices)
- NO_THREAD_SAFETY_ANALYSIS override;
+ REQUIRES(mReader->mLock) override;
void dispatchExternalStylusState(const StylusState& outState)
- NO_THREAD_SAFETY_ANALYSIS override;
- InputReaderPolicyInterface* getPolicy() NO_THREAD_SAFETY_ANALYSIS override;
- InputListenerInterface* getListener() NO_THREAD_SAFETY_ANALYSIS override;
- EventHubInterface* getEventHub() NO_THREAD_SAFETY_ANALYSIS override;
+ REQUIRES(mReader->mLock) override;
+ InputReaderPolicyInterface* getPolicy() REQUIRES(mReader->mLock) override;
+ InputListenerInterface* getListener() REQUIRES(mReader->mLock) override;
+ EventHubInterface* getEventHub() REQUIRES(mReader->mLock) override;
int32_t getNextId() NO_THREAD_SAFETY_ANALYSIS override;
- void updateLedMetaState(int32_t metaState) NO_THREAD_SAFETY_ANALYSIS override;
- int32_t getLedMetaState() NO_THREAD_SAFETY_ANALYSIS override;
+ void updateLedMetaState(int32_t metaState) REQUIRES(mReader->mLock) override;
+ int32_t getLedMetaState() REQUIRES(mReader->mLock) REQUIRES(mLock) override;
} mContext;
friend class ContextImpl;
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 7a11ca7..73198bc 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -1524,20 +1524,6 @@
}
};
-TEST_F(InputReaderTest, ReaderGetInputDevices) {
- ASSERT_NO_FATAL_FAILURE(addDevice(1, "keyboard", InputDeviceClass::KEYBOARD, nullptr));
- ASSERT_NO_FATAL_FAILURE(addDevice(2, "ignored", Flags<InputDeviceClass>(0),
- nullptr)); // no classes so device will be ignored
-
- const std::vector<InputDeviceInfo> inputDevices = mReader->getInputDevices();
- ASSERT_EQ(1U, inputDevices.size());
- ASSERT_EQ(END_RESERVED_ID + 1, inputDevices[0].getId());
- ASSERT_STREQ("keyboard", inputDevices[0].getIdentifier().name.c_str());
- ASSERT_EQ(AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC, inputDevices[0].getKeyboardType());
- ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, inputDevices[0].getSources());
- ASSERT_EQ(size_t(0), inputDevices[0].getMotionRanges().size());
-}
-
TEST_F(InputReaderTest, PolicyGetInputDevices) {
ASSERT_NO_FATAL_FAILURE(addDevice(1, "keyboard", InputDeviceClass::KEYBOARD, nullptr));
ASSERT_NO_FATAL_FAILURE(addDevice(2, "ignored", Flags<InputDeviceClass>(0),
@@ -1550,7 +1536,7 @@
ASSERT_STREQ("keyboard", inputDevices[0].getIdentifier().name.c_str());
ASSERT_EQ(AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC, inputDevices[0].getKeyboardType());
ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, inputDevices[0].getSources());
- ASSERT_EQ(size_t(0), inputDevices[0].getMotionRanges().size());
+ ASSERT_EQ(0U, inputDevices[0].getMotionRanges().size());
}
TEST_F(InputReaderTest, GetMergedInputDevices) {
@@ -1571,7 +1557,7 @@
addDevice(eventHubIds[1], "fake2", InputDeviceClass::KEYBOARD, nullptr));
// Two devices will be merged to one input device as they have same identifier
- ASSERT_EQ(1U, mReader->getInputDevices().size());
+ ASSERT_EQ(1U, mFakePolicy->getInputDevices().size());
}
TEST_F(InputReaderTest, GetMergedInputDevicesEnabled) {
@@ -2189,7 +2175,7 @@
ASSERT_EQ(initialNumDevices + 1, mFakePolicy->getInputDevices().size());
// Find the test device by its name.
- const std::vector<InputDeviceInfo> inputDevices = mReader->getInputDevices();
+ const std::vector<InputDeviceInfo> inputDevices = mFakePolicy->getInputDevices();
const auto& it =
std::find_if(inputDevices.begin(), inputDevices.end(),
[&keyboard](const InputDeviceInfo& info) {
@@ -2463,8 +2449,7 @@
ASSERT_TRUE(mDevice->isIgnored());
ASSERT_EQ(AINPUT_SOURCE_UNKNOWN, mDevice->getSources());
- InputDeviceInfo info;
- mDevice->getDeviceInfo(&info);
+ InputDeviceInfo info = mDevice->getDeviceInfo();
ASSERT_EQ(DEVICE_ID, info.getId());
ASSERT_STREQ(DEVICE_NAME, info.getIdentifier().name.c_str());
ASSERT_EQ(AINPUT_KEYBOARD_TYPE_NONE, info.getKeyboardType());
@@ -2533,8 +2518,7 @@
ASSERT_FALSE(mDevice->isIgnored());
ASSERT_EQ(uint32_t(AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TOUCHSCREEN), mDevice->getSources());
- InputDeviceInfo info;
- mDevice->getDeviceInfo(&info);
+ InputDeviceInfo info = mDevice->getDeviceInfo();
ASSERT_EQ(DEVICE_ID, info.getId());
ASSERT_STREQ(DEVICE_NAME, info.getIdentifier().name.c_str());
ASSERT_EQ(AINPUT_KEYBOARD_TYPE_ALPHABETIC, info.getKeyboardType());
@@ -8444,8 +8428,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
ASSERT_EQ(AINPUT_SOURCE_TOUCHPAD, mapper.getSources());
- InputDeviceInfo deviceInfo;
- mDevice->getDeviceInfo(&deviceInfo);
+ InputDeviceInfo deviceInfo = mDevice->getDeviceInfo();
const InputDeviceInfo::MotionRange* relRangeX =
deviceInfo.getMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, AINPUT_SOURCE_TOUCHPAD);
@@ -8755,12 +8738,12 @@
PeripheralController& controller = addControllerAndConfigure<PeripheralController>();
InputDeviceInfo info;
controller.populateDeviceInfo(&info);
- const auto& ids = info.getLightIds();
- ASSERT_EQ(1UL, ids.size());
- ASSERT_EQ(InputDeviceLightType::MONO, info.getLightInfo(ids[0])->type);
+ std::vector<InputDeviceLightInfo> lights = info.getLights();
+ ASSERT_EQ(1U, lights.size());
+ ASSERT_EQ(InputDeviceLightType::MONO, lights[0].type);
- ASSERT_TRUE(controller.setLightColor(ids[0], LIGHT_BRIGHTNESS));
- ASSERT_EQ(controller.getLightColor(ids[0]).value_or(-1), LIGHT_BRIGHTNESS);
+ ASSERT_TRUE(controller.setLightColor(lights[0].id, LIGHT_BRIGHTNESS));
+ ASSERT_EQ(controller.getLightColor(lights[0].id).value_or(-1), LIGHT_BRIGHTNESS);
}
TEST_F(LightControllerTest, RGBLight) {
@@ -8786,12 +8769,12 @@
PeripheralController& controller = addControllerAndConfigure<PeripheralController>();
InputDeviceInfo info;
controller.populateDeviceInfo(&info);
- const auto& ids = info.getLightIds();
- ASSERT_EQ(1UL, ids.size());
- ASSERT_EQ(InputDeviceLightType::RGB, info.getLightInfo(ids[0])->type);
+ std::vector<InputDeviceLightInfo> lights = info.getLights();
+ ASSERT_EQ(1U, lights.size());
+ ASSERT_EQ(InputDeviceLightType::RGB, lights[0].type);
- ASSERT_TRUE(controller.setLightColor(ids[0], LIGHT_COLOR));
- ASSERT_EQ(controller.getLightColor(ids[0]).value_or(-1), LIGHT_COLOR);
+ ASSERT_TRUE(controller.setLightColor(lights[0].id, LIGHT_COLOR));
+ ASSERT_EQ(controller.getLightColor(lights[0].id).value_or(-1), LIGHT_COLOR);
}
TEST_F(LightControllerTest, MultiColorRGBLight) {
@@ -8808,12 +8791,12 @@
PeripheralController& controller = addControllerAndConfigure<PeripheralController>();
InputDeviceInfo info;
controller.populateDeviceInfo(&info);
- const auto& ids = info.getLightIds();
- ASSERT_EQ(1UL, ids.size());
- ASSERT_EQ(InputDeviceLightType::MULTI_COLOR, info.getLightInfo(ids[0])->type);
+ std::vector<InputDeviceLightInfo> lights = info.getLights();
+ ASSERT_EQ(1U, lights.size());
+ ASSERT_EQ(InputDeviceLightType::MULTI_COLOR, lights[0].type);
- ASSERT_TRUE(controller.setLightColor(ids[0], LIGHT_COLOR));
- ASSERT_EQ(controller.getLightColor(ids[0]).value_or(-1), LIGHT_COLOR);
+ ASSERT_TRUE(controller.setLightColor(lights[0].id, LIGHT_COLOR));
+ ASSERT_EQ(controller.getLightColor(lights[0].id).value_or(-1), LIGHT_COLOR);
}
TEST_F(LightControllerTest, PlayerIdLight) {
@@ -8845,13 +8828,13 @@
PeripheralController& controller = addControllerAndConfigure<PeripheralController>();
InputDeviceInfo info;
controller.populateDeviceInfo(&info);
- const auto& ids = info.getLightIds();
- ASSERT_EQ(1UL, ids.size());
- ASSERT_EQ(InputDeviceLightType::PLAYER_ID, info.getLightInfo(ids[0])->type);
+ std::vector<InputDeviceLightInfo> lights = info.getLights();
+ ASSERT_EQ(1U, lights.size());
+ ASSERT_EQ(InputDeviceLightType::PLAYER_ID, lights[0].type);
- ASSERT_FALSE(controller.setLightColor(ids[0], LIGHT_COLOR));
- ASSERT_TRUE(controller.setLightPlayerId(ids[0], LIGHT_PLAYER_ID));
- ASSERT_EQ(controller.getLightPlayerId(ids[0]).value_or(-1), LIGHT_PLAYER_ID);
+ ASSERT_FALSE(controller.setLightColor(lights[0].id, LIGHT_COLOR));
+ ASSERT_TRUE(controller.setLightPlayerId(lights[0].id, LIGHT_PLAYER_ID));
+ ASSERT_EQ(controller.getLightPlayerId(lights[0].id).value_or(-1), LIGHT_PLAYER_ID);
}
} // namespace android
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index 5298772..d68a0e0 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -43,11 +43,13 @@
using PresentState = frametimeline::SurfaceFrame::PresentState;
namespace {
void callReleaseBufferCallback(const sp<ITransactionCompletedListener>& listener,
- const sp<GraphicBuffer>& buffer, const sp<Fence>& releaseFence) {
+ const sp<GraphicBuffer>& buffer, const sp<Fence>& releaseFence,
+ uint32_t transformHint) {
if (!listener) {
return;
}
- listener->onReleaseBuffer(buffer->getId(), releaseFence ? releaseFence : Fence::NO_FENCE);
+ listener->onReleaseBuffer(buffer->getId(), releaseFence ? releaseFence : Fence::NO_FENCE,
+ transformHint);
}
} // namespace
@@ -72,7 +74,8 @@
// issue with the clone layer trying to use the texture.
if (mBufferInfo.mBuffer != nullptr && !isClone()) {
callReleaseBufferCallback(mDrawingState.releaseBufferListener,
- mBufferInfo.mBuffer->getBuffer(), mBufferInfo.mFence);
+ mBufferInfo.mBuffer->getBuffer(), mBufferInfo.mFence,
+ mTransformHint);
}
}
@@ -427,7 +430,8 @@
// call any release buffer callbacks if set.
callReleaseBufferCallback(mCurrentState.releaseBufferListener,
mCurrentState.buffer->getBuffer(),
- mCurrentState.acquireFence);
+ mCurrentState.acquireFence,
+ mTransformHint);
decrementPendingBufferCount();
if (mCurrentState.bufferSurfaceFrameTX != nullptr) {
addSurfaceFrameDroppedForBuffer(mCurrentState.bufferSurfaceFrameTX);
@@ -946,7 +950,8 @@
// then we will drop a buffer and should decrement the pending buffer count and
// call any release buffer callbacks if set.
callReleaseBufferCallback(mDrawingState.releaseBufferListener,
- mDrawingState.buffer->getBuffer(), mDrawingState.acquireFence);
+ mDrawingState.buffer->getBuffer(), mDrawingState.acquireFence,
+ mTransformHint);
decrementPendingBufferCount();
}
}
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h
index 4e2f879..2c18a60 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h
@@ -135,6 +135,8 @@
bool hasHdrLayers() const;
+ bool hasProtectedLayers() const;
+
private:
CachedSet() = default;
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Flattener.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Flattener.h
index ca1d69d..c76078d 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Flattener.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Flattener.h
@@ -37,7 +37,7 @@
class Flattener {
public:
- Flattener(bool enableHolePunch = false) : mEnableHolePunch(enableHolePunch) {}
+ Flattener(bool enableHolePunch = false);
void setDisplaySize(ui::Size size) { mDisplaySize = size; }
@@ -162,6 +162,7 @@
size_t mCachedSetCreationCount = 0;
size_t mCachedSetCreationCost = 0;
std::unordered_map<size_t, size_t> mInvalidatedCachedSetAges;
+ std::chrono::nanoseconds mActiveLayerTimeout = kActiveLayerTimeout;
static constexpr auto kActiveLayerTimeout = std::chrono::nanoseconds(150ms);
};
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h
index 13b8781..a20d7b3 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h
@@ -249,6 +249,10 @@
transfer == ui::Dataspace::TRANSFER_HLG);
}
+ bool isProtected() const {
+ return getOutputLayer()->getLayerFE().getCompositionState()->hasProtectedContent;
+ }
+
void dump(std::string& result) const;
std::optional<std::string> compare(const LayerState& other) const;
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp b/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp
index 9a294c7..dcfb05d 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp
@@ -350,6 +350,11 @@
[](const Layer& layer) { return layer.getState()->isHdr(); });
}
+bool CachedSet::hasProtectedLayers() const {
+ return std::any_of(mLayers.cbegin(), mLayers.cend(),
+ [](const Layer& layer) { return layer.getState()->isProtected(); });
+}
+
void CachedSet::dump(std::string& result) const {
const auto now = std::chrono::steady_clock::now();
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp b/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
index 550fdeb..48fb51f 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
@@ -19,6 +19,7 @@
// #define LOG_NDEBUG 0
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <android-base/properties.h>
#include <compositionengine/impl/planner/Flattener.h>
#include <compositionengine/impl/planner/LayerState.h>
@@ -59,6 +60,14 @@
} // namespace
+Flattener::Flattener(bool enableHolePunch) : mEnableHolePunch(enableHolePunch) {
+ const int timeoutInMs =
+ base::GetIntProperty(std::string("debug.sf.layer_caching_active_layer_timeout_ms"), 0);
+ if (timeoutInMs != 0) {
+ mActiveLayerTimeout = std::chrono::milliseconds(timeoutInMs);
+ }
+}
+
NonBufferHash Flattener::flattenLayers(const std::vector<const LayerState*>& layers,
NonBufferHash hash, time_point now) {
ATRACE_CALL();
@@ -370,10 +379,10 @@
bool runHasFirstLayer = false;
for (auto currentSet = mLayers.cbegin(); currentSet != mLayers.cend(); ++currentSet) {
- const bool layerIsInactive = now - currentSet->getLastUpdate() > kActiveLayerTimeout;
+ const bool layerIsInactive = now - currentSet->getLastUpdate() > mActiveLayerTimeout;
const bool layerHasBlur = currentSet->hasBlurBehind();
if (layerIsInactive && (firstLayer || runHasFirstLayer || !layerHasBlur) &&
- !currentSet->hasHdrLayers()) {
+ !currentSet->hasHdrLayers() && !currentSet->hasProtectedLayers()) {
if (isPartOfRun) {
builder.append(currentSet->getLayerCount());
} else {
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 2b4f9ef..a4b6fef 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2894,6 +2894,7 @@
// Commit layer transactions. This needs to happen after display transactions are
// committed because some geometry logic relies on display orientation.
if ((transactionFlags & eTraversalNeeded) || mForceTraversal || displayTransactionNeeded) {
+ mForceTraversal = false;
mCurrentState.traverse([&](Layer* layer) {
uint32_t trFlags = layer->getTransactionFlags(eTransactionNeeded);
if (!trFlags && !displayTransactionNeeded) return;
@@ -4474,6 +4475,11 @@
}
const auto vsyncPeriod = mRefreshRateConfigs->getCurrentRefreshRate().getVsyncPeriod();
if (currentMode == hal::PowerMode::OFF) {
+ // Keep uclamp in a separate syscall and set it before changing to RT due to b/190237315.
+ // We can merge the syscall later.
+ if (SurfaceFlinger::setSchedAttr(true) != NO_ERROR) {
+ ALOGW("Couldn't set uclamp.min on display on: %s\n", strerror(errno));
+ }
if (SurfaceFlinger::setSchedFifo(true) != NO_ERROR) {
ALOGW("Couldn't set SCHED_FIFO on display on: %s\n", strerror(errno));
}
@@ -4492,6 +4498,9 @@
if (SurfaceFlinger::setSchedFifo(false) != NO_ERROR) {
ALOGW("Couldn't set SCHED_OTHER on display off: %s\n", strerror(errno));
}
+ if (SurfaceFlinger::setSchedAttr(false) != NO_ERROR) {
+ ALOGW("Couldn't set uclamp.min on display off: %s\n", strerror(errno));
+ }
if (display->isPrimary() && currentMode != hal::PowerMode::DOZE_SUSPEND) {
mScheduler->disableHardwareVsync(true);
mScheduler->onScreenReleased(mAppConnectionHandle);
@@ -5841,6 +5850,44 @@
if (sched_setscheduler(0, sched_policy, ¶m) != 0) {
return -errno;
}
+
+ return NO_ERROR;
+}
+
+status_t SurfaceFlinger::setSchedAttr(bool enabled) {
+ static const unsigned int kUclampMin =
+ base::GetUintProperty<unsigned int>("ro.surface_flinger.uclamp.min", 0U);
+
+ if (!kUclampMin) {
+ // uclamp.min set to 0 (default), skip setting
+ return NO_ERROR;
+ }
+
+ // Currently, there is no wrapper in bionic: b/183240349.
+ struct sched_attr {
+ uint32_t size;
+ uint32_t sched_policy;
+ uint64_t sched_flags;
+ int32_t sched_nice;
+ uint32_t sched_priority;
+ uint64_t sched_runtime;
+ uint64_t sched_deadline;
+ uint64_t sched_period;
+ uint32_t sched_util_min;
+ uint32_t sched_util_max;
+ };
+
+ sched_attr attr = {};
+ attr.size = sizeof(attr);
+
+ attr.sched_flags = (SCHED_FLAG_KEEP_ALL | SCHED_FLAG_UTIL_CLAMP);
+ attr.sched_util_min = enabled ? kUclampMin : 0;
+ attr.sched_util_max = 1024;
+
+ if (syscall(__NR_sched_setattr, 0, &attr, 0)) {
+ return -errno;
+ }
+
return NO_ERROR;
}
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index be3417b..519a5ab 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -186,6 +186,9 @@
// set main thread scheduling policy
static status_t setSchedFifo(bool enabled) ANDROID_API;
+ // set main thread scheduling attributes
+ static status_t setSchedAttr(bool enabled);
+
static char const* getServiceName() ANDROID_API { return "SurfaceFlinger"; }
// This is the phase offset in nanoseconds of the software vsync event
diff --git a/services/surfaceflinger/main_surfaceflinger.cpp b/services/surfaceflinger/main_surfaceflinger.cpp
index 9686523..673239d 100644
--- a/services/surfaceflinger/main_surfaceflinger.cpp
+++ b/services/surfaceflinger/main_surfaceflinger.cpp
@@ -89,6 +89,12 @@
// binder threads to 4.
ProcessState::self()->setThreadPoolMaxThreadCount(4);
+ // Set uclamp.min setting on all threads, maybe an overkill but we want
+ // to cover important threads like RenderEngine.
+ if (SurfaceFlinger::setSchedAttr(true) != NO_ERROR) {
+ ALOGW("Couldn't set uclamp.min: %s\n", strerror(errno));
+ }
+
// The binder threadpool we start will inherit sched policy and priority
// of (this) creating thread. We want the binder thread pool to have
// SCHED_FIFO policy and priority 1 (lowest RT priority)