Loading services/sensorservice/SensorEventConnection.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -272,12 +272,17 @@ void SensorService::SensorEventConnection::updateLooperRegistrationLocked( } } void SensorService::SensorEventConnection::incrementPendingFlushCount(int32_t handle) { bool SensorService::SensorEventConnection::incrementPendingFlushCountIfHasAccess(int32_t handle) { if (hasSensorAccess()) { Mutex::Autolock _l(mConnectionLock); if (mSensorInfo.count(handle) > 0) { FlushInfo& flushInfo = mSensorInfo[handle]; flushInfo.mPendingFlushEventsToSend++; } return true; } else { return false; } } status_t SensorService::SensorEventConnection::sendEvents( Loading services/sensorservice/SensorEventConnection.h +3 −2 Original line number Diff line number Diff line Loading @@ -116,8 +116,9 @@ private: // for writing send the data from the cache. virtual int handleEvent(int fd, int events, void* data); // Increment mPendingFlushEventsToSend for the given sensor handle. void incrementPendingFlushCount(int32_t handle); // Increment mPendingFlushEventsToSend for the given handle if the connection has sensor access. // Returns true if this connection does have sensor access. bool incrementPendingFlushCountIfHasAccess(int32_t handle); // Add or remove the file descriptor associated with the BitTube to the looper. If mDead is set // to true or there are no more sensors for this connection, the file descriptor is removed if Loading services/sensorservice/SensorService.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -1774,7 +1774,10 @@ status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection, if (halVersion <= SENSORS_DEVICE_API_VERSION_1_0 || isVirtualSensor(handle)) { // For older devices just increment pending flush count which will send a trivial // flush complete event. connection->incrementPendingFlushCount(handle); if (!connection->incrementPendingFlushCountIfHasAccess(handle)) { ALOGE("flush called on an inaccessible sensor"); err = INVALID_OPERATION; } } else { if (!canAccessSensor(sensor->getSensor(), "Tried flushing", opPackageName)) { err = INVALID_OPERATION; Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -212,10 +212,8 @@ const RefreshRate& RefreshRateConfigs::getBestRefreshRate( bool inPrimaryRange = scores[i].first->inPolicy(policy->primaryRange.min, policy->primaryRange.max); if ((primaryRangeIsSingleRate || !inPrimaryRange) && !(layer.focused && (layer.vote == LayerVoteType::ExplicitDefault || layer.vote == LayerVoteType::ExplicitExactOrMultiple))) { // Only focused layers with explicit frame rate settings are allowed to score !(layer.focused && layer.vote == LayerVoteType::ExplicitDefault)) { // Only focused layers with ExplicitDefault frame rate settings are allowed to score // refresh rates outside the primary range. continue; } Loading services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +3 −19 Original line number Diff line number Diff line Loading @@ -1130,15 +1130,6 @@ TEST_F(RefreshRateConfigsTest, auto& lr = layers[0]; RefreshRateConfigs::GlobalSignals consideredSignals; lr.vote = LayerVoteType::ExplicitExactOrMultiple; lr.desiredRefreshRate = 60.0f; lr.name = "60Hz ExplicitExactOrMultiple"; lr.focused = true; EXPECT_EQ(mExpected60Config, refreshRateConfigs->getBestRefreshRate(layers, {.touch = true, .idle = true}, &consideredSignals)); EXPECT_EQ(false, consideredSignals.touch); lr.vote = LayerVoteType::ExplicitDefault; lr.desiredRefreshRate = 60.0f; lr.name = "60Hz ExplicitDefault"; Loading @@ -1162,13 +1153,6 @@ TEST_F(RefreshRateConfigsTest, auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}}; auto& lr = layers[0]; lr.vote = LayerVoteType::ExplicitExactOrMultiple; lr.desiredRefreshRate = 90.0f; lr.name = "90Hz ExplicitExactOrMultiple"; lr.focused = true; EXPECT_EQ(mExpected90Config, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = true})); lr.vote = LayerVoteType::ExplicitDefault; lr.desiredRefreshRate = 90.0f; lr.name = "90Hz ExplicitDefault"; Loading Loading @@ -1204,7 +1188,7 @@ TEST_F(RefreshRateConfigsTest, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})); lr.focused = true; EXPECT_EQ(mExpected60Config, EXPECT_EQ(mExpected90Config, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})); lr.vote = LayerVoteType::ExplicitDefault; Loading Loading @@ -1306,7 +1290,7 @@ TEST_F(RefreshRateConfigsTest, primaryVsAppRequestPolicy) { EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::Max, 90.f)); EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::Heuristic, 90.f)); EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitDefault, 90.f)); EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitExactOrMultiple, 90.f)); EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::ExplicitExactOrMultiple, 90.f)); // Layers not focused are not allowed to override primary config EXPECT_EQ(HWC_CONFIG_ID_60, Loading @@ -1321,7 +1305,7 @@ TEST_F(RefreshRateConfigsTest, primaryVsAppRequestPolicy) { // When we're higher than the primary range max due to a layer frame rate setting, touch boost // shouldn't drag us back down to the primary range max. EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitDefault, 90.f, /*touch=*/true)); EXPECT_EQ(HWC_CONFIG_ID_90, EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::ExplicitExactOrMultiple, 90.f, /*touch=*/true)); ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy( Loading Loading
services/sensorservice/SensorEventConnection.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -272,12 +272,17 @@ void SensorService::SensorEventConnection::updateLooperRegistrationLocked( } } void SensorService::SensorEventConnection::incrementPendingFlushCount(int32_t handle) { bool SensorService::SensorEventConnection::incrementPendingFlushCountIfHasAccess(int32_t handle) { if (hasSensorAccess()) { Mutex::Autolock _l(mConnectionLock); if (mSensorInfo.count(handle) > 0) { FlushInfo& flushInfo = mSensorInfo[handle]; flushInfo.mPendingFlushEventsToSend++; } return true; } else { return false; } } status_t SensorService::SensorEventConnection::sendEvents( Loading
services/sensorservice/SensorEventConnection.h +3 −2 Original line number Diff line number Diff line Loading @@ -116,8 +116,9 @@ private: // for writing send the data from the cache. virtual int handleEvent(int fd, int events, void* data); // Increment mPendingFlushEventsToSend for the given sensor handle. void incrementPendingFlushCount(int32_t handle); // Increment mPendingFlushEventsToSend for the given handle if the connection has sensor access. // Returns true if this connection does have sensor access. bool incrementPendingFlushCountIfHasAccess(int32_t handle); // Add or remove the file descriptor associated with the BitTube to the looper. If mDead is set // to true or there are no more sensors for this connection, the file descriptor is removed if Loading
services/sensorservice/SensorService.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -1774,7 +1774,10 @@ status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection, if (halVersion <= SENSORS_DEVICE_API_VERSION_1_0 || isVirtualSensor(handle)) { // For older devices just increment pending flush count which will send a trivial // flush complete event. connection->incrementPendingFlushCount(handle); if (!connection->incrementPendingFlushCountIfHasAccess(handle)) { ALOGE("flush called on an inaccessible sensor"); err = INVALID_OPERATION; } } else { if (!canAccessSensor(sensor->getSensor(), "Tried flushing", opPackageName)) { err = INVALID_OPERATION; Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -212,10 +212,8 @@ const RefreshRate& RefreshRateConfigs::getBestRefreshRate( bool inPrimaryRange = scores[i].first->inPolicy(policy->primaryRange.min, policy->primaryRange.max); if ((primaryRangeIsSingleRate || !inPrimaryRange) && !(layer.focused && (layer.vote == LayerVoteType::ExplicitDefault || layer.vote == LayerVoteType::ExplicitExactOrMultiple))) { // Only focused layers with explicit frame rate settings are allowed to score !(layer.focused && layer.vote == LayerVoteType::ExplicitDefault)) { // Only focused layers with ExplicitDefault frame rate settings are allowed to score // refresh rates outside the primary range. continue; } Loading
services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +3 −19 Original line number Diff line number Diff line Loading @@ -1130,15 +1130,6 @@ TEST_F(RefreshRateConfigsTest, auto& lr = layers[0]; RefreshRateConfigs::GlobalSignals consideredSignals; lr.vote = LayerVoteType::ExplicitExactOrMultiple; lr.desiredRefreshRate = 60.0f; lr.name = "60Hz ExplicitExactOrMultiple"; lr.focused = true; EXPECT_EQ(mExpected60Config, refreshRateConfigs->getBestRefreshRate(layers, {.touch = true, .idle = true}, &consideredSignals)); EXPECT_EQ(false, consideredSignals.touch); lr.vote = LayerVoteType::ExplicitDefault; lr.desiredRefreshRate = 60.0f; lr.name = "60Hz ExplicitDefault"; Loading @@ -1162,13 +1153,6 @@ TEST_F(RefreshRateConfigsTest, auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}}; auto& lr = layers[0]; lr.vote = LayerVoteType::ExplicitExactOrMultiple; lr.desiredRefreshRate = 90.0f; lr.name = "90Hz ExplicitExactOrMultiple"; lr.focused = true; EXPECT_EQ(mExpected90Config, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = true})); lr.vote = LayerVoteType::ExplicitDefault; lr.desiredRefreshRate = 90.0f; lr.name = "90Hz ExplicitDefault"; Loading Loading @@ -1204,7 +1188,7 @@ TEST_F(RefreshRateConfigsTest, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})); lr.focused = true; EXPECT_EQ(mExpected60Config, EXPECT_EQ(mExpected90Config, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})); lr.vote = LayerVoteType::ExplicitDefault; Loading Loading @@ -1306,7 +1290,7 @@ TEST_F(RefreshRateConfigsTest, primaryVsAppRequestPolicy) { EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::Max, 90.f)); EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::Heuristic, 90.f)); EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitDefault, 90.f)); EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitExactOrMultiple, 90.f)); EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::ExplicitExactOrMultiple, 90.f)); // Layers not focused are not allowed to override primary config EXPECT_EQ(HWC_CONFIG_ID_60, Loading @@ -1321,7 +1305,7 @@ TEST_F(RefreshRateConfigsTest, primaryVsAppRequestPolicy) { // When we're higher than the primary range max due to a layer frame rate setting, touch boost // shouldn't drag us back down to the primary range max. EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitDefault, 90.f, /*touch=*/true)); EXPECT_EQ(HWC_CONFIG_ID_90, EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::ExplicitExactOrMultiple, 90.f, /*touch=*/true)); ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy( Loading