diff options
Diffstat (limited to 'libs/gui')
| -rw-r--r-- | libs/gui/Android.bp | 9 | ||||
| -rw-r--r-- | libs/gui/LayerState.cpp | 9 | ||||
| -rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 15 | ||||
| -rw-r--r-- | libs/gui/android/gui/DropInputMode.aidl | 40 | ||||
| -rw-r--r-- | libs/gui/include/gui/LayerState.h | 8 | ||||
| -rw-r--r-- | libs/gui/include/gui/SurfaceComposerClient.h | 3 |
6 files changed, 81 insertions, 3 deletions
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp index 4a4510e047..6ec1f471c3 100644 --- a/libs/gui/Android.bp +++ b/libs/gui/Android.bp @@ -30,6 +30,14 @@ cc_library_headers { min_sdk_version: "29", } +// AIDL files that should be exposed to java +filegroup { + name: "guiconstants_aidl", + srcs: [ + "android/gui/DropInputMode.aidl", + ], +} + cc_library_shared { name: "libgui", vendor_available: false, @@ -41,6 +49,7 @@ cc_library_shared { defaults: ["libgui_bufferqueue-defaults"], srcs: [ + ":guiconstants_aidl", ":framework_native_aidl", ":libgui_bufferqueue_sources", diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp index a897d1025f..dfcef8fe7a 100644 --- a/libs/gui/LayerState.cpp +++ b/libs/gui/LayerState.cpp @@ -118,7 +118,7 @@ status_t layer_state_t::write(Parcel& output) const output.writeByte(frameRateCompatibility); output.writeUint32(fixedTransformHint); output.writeBool(isTrustedOverlay); - + output.writeUint32(static_cast<uint32_t>(dropInputMode)); return NO_ERROR; } @@ -204,6 +204,9 @@ status_t layer_state_t::read(const Parcel& input) fixedTransformHint = static_cast<ui::Transform::RotationFlags>(input.readUint32()); isTrustedOverlay = input.readBool(); + uint32_t mode; + mode = input.readUint32(); + dropInputMode = static_cast<gui::DropInputMode>(mode); return NO_ERROR; } @@ -447,6 +450,10 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eTrustedOverlayChanged; isTrustedOverlay = other.isTrustedOverlay; } + if (other.what & eDropInputModeChanged) { + what |= eDropInputModeChanged; + dropInputMode = other.dropInputMode; + } if ((other.what & what) != other.what) { ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " "other.what=0x%" PRIu64 " what=0x%" PRIu64, diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 78d932cc81..d2c96218f4 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -1497,6 +1497,21 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrust return *this; } +SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setDropInputMode( + const sp<SurfaceControl>& sc, gui::DropInputMode mode) { + layer_state_t* s = getLayerState(sc); + if (!s) { + mStatus = BAD_INDEX; + return *this; + } + + s->what |= layer_state_t::eDropInputModeChanged; + s->dropInputMode = mode; + + registerSurfaceControlForCallback(sc); + return *this; +} + // --------------------------------------------------------------------------- DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) { diff --git a/libs/gui/android/gui/DropInputMode.aidl b/libs/gui/android/gui/DropInputMode.aidl new file mode 100644 index 0000000000..248a0318b7 --- /dev/null +++ b/libs/gui/android/gui/DropInputMode.aidl @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2022, 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.gui; + + +/** + * Input event drop modes: Input event drop options for windows and its children. + * + * @hide + */ +@Backing(type="int") +enum DropInputMode { + /** + * Default mode, input events are sent to the target as usual. + */ + NONE, + + /** + * Window and its children will not receive any input even if it has a valid input channel. + * Touches and keys will be dropped. If a window is focused, it will remain focused but will + * not receive any keys. If the window has a touchable region and is the target of an input + * event, the event will be dropped and will not go to the window behind. ref: b/197296414 + */ + ALL, +} + diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h index a77e4b0462..39dbe9e035 100644 --- a/libs/gui/include/gui/LayerState.h +++ b/libs/gui/include/gui/LayerState.h @@ -25,6 +25,7 @@ #include <gui/ITransactionCompletedListener.h> #include <math/mat4.h> +#include <android/gui/DropInputMode.h> #ifndef NO_INPUT #include <input/InputWindow.h> #endif @@ -106,6 +107,7 @@ struct layer_state_t { eProducerDisconnect = 0x100'00000000, eFixedTransformHintChanged = 0x200'00000000, eTrustedOverlayChanged = 0x400'00000000, + eDropInputModeChanged = 0x8000'00000000, }; layer_state_t() @@ -141,7 +143,8 @@ struct layer_state_t { frameRate(0.0f), frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT), fixedTransformHint(ui::Transform::ROT_INVALID), - isTrustedOverlay(false) { + isTrustedOverlay(false), + dropInputMode(gui::DropInputMode::NONE) { matrix.dsdx = matrix.dtdy = 1.0f; matrix.dsdy = matrix.dtdx = 0.0f; hdrMetadata.validTypes = 0; @@ -243,6 +246,9 @@ struct layer_state_t { // An inherited state that indicates that this surface control and its children // should be trusted for input occlusion detection purposes bool isTrustedOverlay; + + // Force inputflinger to drop all input events for the layer and its children. + gui::DropInputMode dropInputMode; }; struct ComposerState { diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h index eebd9ca774..2e189e5d89 100644 --- a/libs/gui/include/gui/SurfaceComposerClient.h +++ b/libs/gui/include/gui/SurfaceComposerClient.h @@ -531,7 +531,8 @@ public: // Sets that this surface control and its children are trusted overlays for input Transaction& setTrustedOverlay(const sp<SurfaceControl>& sc, bool isTrustedOverlay); - + + Transaction& setDropInputMode(const sp<SurfaceControl>& sc, gui::DropInputMode mode); status_t setDisplaySurface(const sp<IBinder>& token, const sp<IGraphicBufferProducer>& bufferProducer); |