Loading Android.bp +6 −0 Original line number Diff line number Diff line Loading @@ -86,3 +86,9 @@ cc_library_headers{ name: "libandroid_headers_private", export_include_dirs: ["include/private"], } filegroup { name: "deviceproductinfoconstants_aidl", srcs: ["aidl/android/hardware/display/IDeviceProductInfoConstants.aidl"], path: "aidl", } aidl/android/hardware/display/IDeviceProductInfoConstants.aidl 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright 2021 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. */ package android.hardware.display; /** @hide */ interface IDeviceProductInfoConstants { /** The device connection to the display sink is unknown. */ const int CONNECTION_TO_SINK_UNKNOWN = 0; /** The device is built-in in the display sink. */ const int CONNECTION_TO_SINK_BUILT_IN = 1; /** The device is directly connected to the display sink. */ const int CONNECTION_TO_SINK_DIRECT = 2; /** The device is transitively connected to the display sink. */ const int CONNECTION_TO_SINK_TRANSITIVE = 3; } No newline at end of file libs/binder/aidl/android/content/pm/IPackageManagerNative.aidl +10 −1 Original line number Diff line number Diff line Loading @@ -114,4 +114,13 @@ interface IPackageManagerNative { * Unknown packages will cause the call to fail. */ boolean isPackageDebuggable(in String packageName); /** * Check whether the given feature name and version is one of the available * features as returned by {@link PackageManager#getSystemAvailableFeatures()}. Since * features are defined to always be backwards compatible, this returns true * if the available feature version is greater than or equal to the * requested version. */ boolean hasSystemFeature(in String featureName, in int version); } services/inputflinger/tests/InputDispatcher_test.cpp +109 −16 Original line number Diff line number Diff line Loading @@ -898,6 +898,8 @@ public: mInfo.touchOcclusionMode = mode; } void setApplicationToken(sp<IBinder> token) { mInfo.applicationInfo.token = token; } void setFrame(const Rect& frame) { mInfo.frameLeft = frame.left; mInfo.frameTop = frame.top; Loading Loading @@ -4266,6 +4268,19 @@ TEST_F(InputDispatcherPointerCaptureTests, OutOfOrderRequests) { class InputDispatcherUntrustedTouchesTest : public InputDispatcherTest { protected: constexpr static const float MAXIMUM_OBSCURING_OPACITY = 0.8; constexpr static const float OPACITY_ABOVE_THRESHOLD = 0.9; static_assert(OPACITY_ABOVE_THRESHOLD > MAXIMUM_OBSCURING_OPACITY); constexpr static const float OPACITY_BELOW_THRESHOLD = 0.7; static_assert(OPACITY_BELOW_THRESHOLD < MAXIMUM_OBSCURING_OPACITY); // When combined twice, ie 1 - (1 - 0.5)*(1 - 0.5) = 0.75 < 8, is still below the threshold constexpr static const float OPACITY_FAR_BELOW_THRESHOLD = 0.5; static_assert(OPACITY_FAR_BELOW_THRESHOLD < MAXIMUM_OBSCURING_OPACITY); static_assert(1 - (1 - OPACITY_FAR_BELOW_THRESHOLD) * (1 - OPACITY_FAR_BELOW_THRESHOLD) < MAXIMUM_OBSCURING_OPACITY); static const int32_t TOUCHED_APP_UID = 10001; static const int32_t APP_B_UID = 10002; static const int32_t APP_C_UID = 10003; Loading Loading @@ -4320,6 +4335,17 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithBlockUntrustedOcclusionMod mTouchWindow->assertNoEvents(); } TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithBlockUntrustedOcclusionModeWithOpacityBelowThreshold_BlocksTouch) { const sp<FakeWindowHandle>& w = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED, 0.7f); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); mTouchWindow->assertNoEvents(); } TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithBlockUntrustedOcclusionMode_DoesNotReceiveTouch) { const sp<FakeWindowHandle>& w = Loading Loading @@ -4415,7 +4441,8 @@ TEST_F(InputDispatcherUntrustedTouchesTest, OutsideEvent_HasZeroCoordinates) { TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityBelowThreshold_AllowsTouch) { const sp<FakeWindowHandle>& w = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); Loading @@ -4436,7 +4463,8 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityAtThreshold_AllowsT TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityAboveThreshold_BlocksTouch) { const sp<FakeWindowHandle>& w = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); Loading @@ -4447,9 +4475,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityAboveThreshold_Bloc TEST_F(InputDispatcherUntrustedTouchesTest, WindowsWithCombinedOpacityAboveThreshold_BlocksTouch) { // Resulting opacity = 1 - (1 - 0.7)*(1 - 0.7) = .91 const sp<FakeWindowHandle>& w1 = getOccludingWindow(APP_B_UID, "B1", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B1", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& w2 = getOccludingWindow(APP_B_UID, "B2", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B2", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w1, w2, mTouchWindow}}}); touch(); Loading @@ -4460,9 +4490,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowsWithCombinedOpacityAboveThres TEST_F(InputDispatcherUntrustedTouchesTest, WindowsWithCombinedOpacityBelowThreshold_AllowsTouch) { // Resulting opacity = 1 - (1 - 0.5)*(1 - 0.5) = .75 const sp<FakeWindowHandle>& w1 = getOccludingWindow(APP_B_UID, "B1", TouchOcclusionMode::USE_OPACITY, 0.5f); getOccludingWindow(APP_B_UID, "B1", TouchOcclusionMode::USE_OPACITY, OPACITY_FAR_BELOW_THRESHOLD); const sp<FakeWindowHandle>& w2 = getOccludingWindow(APP_B_UID, "B2", TouchOcclusionMode::USE_OPACITY, 0.5f); getOccludingWindow(APP_B_UID, "B2", TouchOcclusionMode::USE_OPACITY, OPACITY_FAR_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w1, w2, mTouchWindow}}}); touch(); Loading @@ -4473,9 +4505,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowsWithCombinedOpacityBelowThres TEST_F(InputDispatcherUntrustedTouchesTest, WindowsFromDifferentAppsEachBelowThreshold_AllowsTouch) { const sp<FakeWindowHandle>& wB = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& wC = getOccludingWindow(APP_C_UID, "C", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_C_UID, "C", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {wB, wC, mTouchWindow}}}); touch(); Loading @@ -4485,9 +4519,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, TEST_F(InputDispatcherUntrustedTouchesTest, WindowsFromDifferentAppsOneAboveThreshold_BlocksTouch) { const sp<FakeWindowHandle>& wB = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& wC = getOccludingWindow(APP_C_UID, "C", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(APP_C_UID, "C", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {wB, wC, mTouchWindow}}}); touch(); Loading @@ -4498,9 +4534,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowsFromDifferentAppsOneAboveThre TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityAboveThresholdAndSelfWindow_BlocksTouch) { const sp<FakeWindowHandle>& wA = getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& wB = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {wA, wB, mTouchWindow}}}); touch(); Loading @@ -4511,9 +4549,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityBelowThresholdAndSelfWindow_AllowsTouch) { const sp<FakeWindowHandle>& wA = getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); const sp<FakeWindowHandle>& wB = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {wA, wB, mTouchWindow}}}); touch(); Loading @@ -4523,7 +4563,8 @@ TEST_F(InputDispatcherUntrustedTouchesTest, TEST_F(InputDispatcherUntrustedTouchesTest, SelfWindowWithOpacityAboveThreshold_AllowsTouch) { const sp<FakeWindowHandle>& w = getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); Loading Loading @@ -4568,7 +4609,59 @@ TEST_F(InputDispatcherUntrustedTouchesTest, OpacityThresholdIs1AndWindowBelowThreshold_AllowsTouch) { mDispatcher->setMaximumObscuringOpacityForTouch(1.0f); const sp<FakeWindowHandle>& w = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); mTouchWindow->consumeAnyMotionDown(); } TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithBlockUntrustedModeAndWindowWithOpacityBelowFromSameApp_BlocksTouch) { const sp<FakeWindowHandle>& w1 = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& w2 = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w1, w2, mTouchWindow}}}); touch(); mTouchWindow->assertNoEvents(); } /** * Window B of BLOCK_UNTRUSTED occlusion mode is enough to block the touch, we're testing that the * addition of another window (C) of USE_OPACITY occlusion mode and opacity below the threshold * (which alone would result in allowing touches) does not affect the blocking behavior. */ TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithBlockUntrustedModeAndWindowWithOpacityBelowFromDifferentApps_BlocksTouch) { const sp<FakeWindowHandle>& wB = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& wC = getOccludingWindow(APP_C_UID, "C", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {wB, wC, mTouchWindow}}}); touch(); mTouchWindow->assertNoEvents(); } /** * This test is testing that a window from a different UID but with same application token doesn't * block the touch. Apps can share the application token for close UI collaboration for example. */ TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithSameApplicationTokenFromDifferentApp_AllowsTouch) { const sp<FakeWindowHandle>& w = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED); w->setApplicationToken(mTouchWindow->getApplicationToken()); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); Loading services/surfaceflinger/BufferStateLayer.cpp +5 −12 Original line number Diff line number Diff line Loading @@ -370,9 +370,7 @@ bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer, const sp<Fence addFrameEvent(acquireFence, postTime, isAutoTimestamp ? 0 : desiredPresentTime); if (info.vsyncId != FrameTimelineInfo::INVALID_VSYNC_ID) { setFrameTimelineVsyncForBufferTransaction(info, postTime); } if (dequeueTime && *dequeueTime != 0) { const uint64_t bufferId = buffer->getId(); Loading Loading @@ -871,18 +869,13 @@ bool BufferStateLayer::bufferNeedsFiltering() const { return layerSize.width() != bufferWidth || layerSize.height() != bufferHeight; } void BufferStateLayer::incrementPendingBufferCount() { mPendingBufferTransactions++; tracePendingBufferCount(); } void BufferStateLayer::decrementPendingBufferCount() { mPendingBufferTransactions--; tracePendingBufferCount(); int32_t pendingBuffers = --mPendingBufferTransactions; tracePendingBufferCount(pendingBuffers); } void BufferStateLayer::tracePendingBufferCount() { ATRACE_INT(mBlastTransactionName.c_str(), mPendingBufferTransactions); void BufferStateLayer::tracePendingBufferCount(int32_t pendingBuffers) { ATRACE_INT(mBlastTransactionName.c_str(), pendingBuffers); } uint32_t BufferStateLayer::doTransaction(uint32_t flags) { Loading Loading
Android.bp +6 −0 Original line number Diff line number Diff line Loading @@ -86,3 +86,9 @@ cc_library_headers{ name: "libandroid_headers_private", export_include_dirs: ["include/private"], } filegroup { name: "deviceproductinfoconstants_aidl", srcs: ["aidl/android/hardware/display/IDeviceProductInfoConstants.aidl"], path: "aidl", }
aidl/android/hardware/display/IDeviceProductInfoConstants.aidl 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright 2021 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. */ package android.hardware.display; /** @hide */ interface IDeviceProductInfoConstants { /** The device connection to the display sink is unknown. */ const int CONNECTION_TO_SINK_UNKNOWN = 0; /** The device is built-in in the display sink. */ const int CONNECTION_TO_SINK_BUILT_IN = 1; /** The device is directly connected to the display sink. */ const int CONNECTION_TO_SINK_DIRECT = 2; /** The device is transitively connected to the display sink. */ const int CONNECTION_TO_SINK_TRANSITIVE = 3; } No newline at end of file
libs/binder/aidl/android/content/pm/IPackageManagerNative.aidl +10 −1 Original line number Diff line number Diff line Loading @@ -114,4 +114,13 @@ interface IPackageManagerNative { * Unknown packages will cause the call to fail. */ boolean isPackageDebuggable(in String packageName); /** * Check whether the given feature name and version is one of the available * features as returned by {@link PackageManager#getSystemAvailableFeatures()}. Since * features are defined to always be backwards compatible, this returns true * if the available feature version is greater than or equal to the * requested version. */ boolean hasSystemFeature(in String featureName, in int version); }
services/inputflinger/tests/InputDispatcher_test.cpp +109 −16 Original line number Diff line number Diff line Loading @@ -898,6 +898,8 @@ public: mInfo.touchOcclusionMode = mode; } void setApplicationToken(sp<IBinder> token) { mInfo.applicationInfo.token = token; } void setFrame(const Rect& frame) { mInfo.frameLeft = frame.left; mInfo.frameTop = frame.top; Loading Loading @@ -4266,6 +4268,19 @@ TEST_F(InputDispatcherPointerCaptureTests, OutOfOrderRequests) { class InputDispatcherUntrustedTouchesTest : public InputDispatcherTest { protected: constexpr static const float MAXIMUM_OBSCURING_OPACITY = 0.8; constexpr static const float OPACITY_ABOVE_THRESHOLD = 0.9; static_assert(OPACITY_ABOVE_THRESHOLD > MAXIMUM_OBSCURING_OPACITY); constexpr static const float OPACITY_BELOW_THRESHOLD = 0.7; static_assert(OPACITY_BELOW_THRESHOLD < MAXIMUM_OBSCURING_OPACITY); // When combined twice, ie 1 - (1 - 0.5)*(1 - 0.5) = 0.75 < 8, is still below the threshold constexpr static const float OPACITY_FAR_BELOW_THRESHOLD = 0.5; static_assert(OPACITY_FAR_BELOW_THRESHOLD < MAXIMUM_OBSCURING_OPACITY); static_assert(1 - (1 - OPACITY_FAR_BELOW_THRESHOLD) * (1 - OPACITY_FAR_BELOW_THRESHOLD) < MAXIMUM_OBSCURING_OPACITY); static const int32_t TOUCHED_APP_UID = 10001; static const int32_t APP_B_UID = 10002; static const int32_t APP_C_UID = 10003; Loading Loading @@ -4320,6 +4335,17 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithBlockUntrustedOcclusionMod mTouchWindow->assertNoEvents(); } TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithBlockUntrustedOcclusionModeWithOpacityBelowThreshold_BlocksTouch) { const sp<FakeWindowHandle>& w = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED, 0.7f); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); mTouchWindow->assertNoEvents(); } TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithBlockUntrustedOcclusionMode_DoesNotReceiveTouch) { const sp<FakeWindowHandle>& w = Loading Loading @@ -4415,7 +4441,8 @@ TEST_F(InputDispatcherUntrustedTouchesTest, OutsideEvent_HasZeroCoordinates) { TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityBelowThreshold_AllowsTouch) { const sp<FakeWindowHandle>& w = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); Loading @@ -4436,7 +4463,8 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityAtThreshold_AllowsT TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityAboveThreshold_BlocksTouch) { const sp<FakeWindowHandle>& w = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); Loading @@ -4447,9 +4475,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityAboveThreshold_Bloc TEST_F(InputDispatcherUntrustedTouchesTest, WindowsWithCombinedOpacityAboveThreshold_BlocksTouch) { // Resulting opacity = 1 - (1 - 0.7)*(1 - 0.7) = .91 const sp<FakeWindowHandle>& w1 = getOccludingWindow(APP_B_UID, "B1", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B1", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& w2 = getOccludingWindow(APP_B_UID, "B2", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B2", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w1, w2, mTouchWindow}}}); touch(); Loading @@ -4460,9 +4490,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowsWithCombinedOpacityAboveThres TEST_F(InputDispatcherUntrustedTouchesTest, WindowsWithCombinedOpacityBelowThreshold_AllowsTouch) { // Resulting opacity = 1 - (1 - 0.5)*(1 - 0.5) = .75 const sp<FakeWindowHandle>& w1 = getOccludingWindow(APP_B_UID, "B1", TouchOcclusionMode::USE_OPACITY, 0.5f); getOccludingWindow(APP_B_UID, "B1", TouchOcclusionMode::USE_OPACITY, OPACITY_FAR_BELOW_THRESHOLD); const sp<FakeWindowHandle>& w2 = getOccludingWindow(APP_B_UID, "B2", TouchOcclusionMode::USE_OPACITY, 0.5f); getOccludingWindow(APP_B_UID, "B2", TouchOcclusionMode::USE_OPACITY, OPACITY_FAR_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w1, w2, mTouchWindow}}}); touch(); Loading @@ -4473,9 +4505,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowsWithCombinedOpacityBelowThres TEST_F(InputDispatcherUntrustedTouchesTest, WindowsFromDifferentAppsEachBelowThreshold_AllowsTouch) { const sp<FakeWindowHandle>& wB = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& wC = getOccludingWindow(APP_C_UID, "C", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_C_UID, "C", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {wB, wC, mTouchWindow}}}); touch(); Loading @@ -4485,9 +4519,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, TEST_F(InputDispatcherUntrustedTouchesTest, WindowsFromDifferentAppsOneAboveThreshold_BlocksTouch) { const sp<FakeWindowHandle>& wB = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& wC = getOccludingWindow(APP_C_UID, "C", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(APP_C_UID, "C", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {wB, wC, mTouchWindow}}}); touch(); Loading @@ -4498,9 +4534,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, WindowsFromDifferentAppsOneAboveThre TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityAboveThresholdAndSelfWindow_BlocksTouch) { const sp<FakeWindowHandle>& wA = getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& wB = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {wA, wB, mTouchWindow}}}); touch(); Loading @@ -4511,9 +4549,11 @@ TEST_F(InputDispatcherUntrustedTouchesTest, TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithOpacityBelowThresholdAndSelfWindow_AllowsTouch) { const sp<FakeWindowHandle>& wA = getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); const sp<FakeWindowHandle>& wB = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.7f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {wA, wB, mTouchWindow}}}); touch(); Loading @@ -4523,7 +4563,8 @@ TEST_F(InputDispatcherUntrustedTouchesTest, TEST_F(InputDispatcherUntrustedTouchesTest, SelfWindowWithOpacityAboveThreshold_AllowsTouch) { const sp<FakeWindowHandle>& w = getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(TOUCHED_APP_UID, "T", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); Loading Loading @@ -4568,7 +4609,59 @@ TEST_F(InputDispatcherUntrustedTouchesTest, OpacityThresholdIs1AndWindowBelowThreshold_AllowsTouch) { mDispatcher->setMaximumObscuringOpacityForTouch(1.0f); const sp<FakeWindowHandle>& w = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.9f); getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_ABOVE_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); mTouchWindow->consumeAnyMotionDown(); } TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithBlockUntrustedModeAndWindowWithOpacityBelowFromSameApp_BlocksTouch) { const sp<FakeWindowHandle>& w1 = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& w2 = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w1, w2, mTouchWindow}}}); touch(); mTouchWindow->assertNoEvents(); } /** * Window B of BLOCK_UNTRUSTED occlusion mode is enough to block the touch, we're testing that the * addition of another window (C) of USE_OPACITY occlusion mode and opacity below the threshold * (which alone would result in allowing touches) does not affect the blocking behavior. */ TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithBlockUntrustedModeAndWindowWithOpacityBelowFromDifferentApps_BlocksTouch) { const sp<FakeWindowHandle>& wB = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED, OPACITY_BELOW_THRESHOLD); const sp<FakeWindowHandle>& wC = getOccludingWindow(APP_C_UID, "C", TouchOcclusionMode::USE_OPACITY, OPACITY_BELOW_THRESHOLD); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {wB, wC, mTouchWindow}}}); touch(); mTouchWindow->assertNoEvents(); } /** * This test is testing that a window from a different UID but with same application token doesn't * block the touch. Apps can share the application token for close UI collaboration for example. */ TEST_F(InputDispatcherUntrustedTouchesTest, WindowWithSameApplicationTokenFromDifferentApp_AllowsTouch) { const sp<FakeWindowHandle>& w = getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED); w->setApplicationToken(mTouchWindow->getApplicationToken()); mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}}); touch(); Loading
services/surfaceflinger/BufferStateLayer.cpp +5 −12 Original line number Diff line number Diff line Loading @@ -370,9 +370,7 @@ bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer, const sp<Fence addFrameEvent(acquireFence, postTime, isAutoTimestamp ? 0 : desiredPresentTime); if (info.vsyncId != FrameTimelineInfo::INVALID_VSYNC_ID) { setFrameTimelineVsyncForBufferTransaction(info, postTime); } if (dequeueTime && *dequeueTime != 0) { const uint64_t bufferId = buffer->getId(); Loading Loading @@ -871,18 +869,13 @@ bool BufferStateLayer::bufferNeedsFiltering() const { return layerSize.width() != bufferWidth || layerSize.height() != bufferHeight; } void BufferStateLayer::incrementPendingBufferCount() { mPendingBufferTransactions++; tracePendingBufferCount(); } void BufferStateLayer::decrementPendingBufferCount() { mPendingBufferTransactions--; tracePendingBufferCount(); int32_t pendingBuffers = --mPendingBufferTransactions; tracePendingBufferCount(pendingBuffers); } void BufferStateLayer::tracePendingBufferCount() { ATRACE_INT(mBlastTransactionName.c_str(), mPendingBufferTransactions); void BufferStateLayer::tracePendingBufferCount(int32_t pendingBuffers) { ATRACE_INT(mBlastTransactionName.c_str(), pendingBuffers); } uint32_t BufferStateLayer::doTransaction(uint32_t flags) { Loading