From a52cd7e0a293637f11064462937c18be84a4fe35 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Tue, 5 Nov 2024 13:44:24 +0900 Subject: Use __builtin_available guard Bug: 362658565 Test: m Change-Id: I2fa5d366b591afa878f62ba39f2831e48a6df5cd --- libs/ui/Gralloc5.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'libs') diff --git a/libs/ui/Gralloc5.cpp b/libs/ui/Gralloc5.cpp index c9ec036186..2143f79f11 100644 --- a/libs/ui/Gralloc5.cpp +++ b/libs/ui/Gralloc5.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -91,7 +90,7 @@ static void *loadIMapperLibrary() { } void* so = nullptr; - if API_LEVEL_AT_LEAST (__ANDROID_API_V__, 202404) { + if (__builtin_available(android __ANDROID_API_V__, *)) { so = AServiceManager_openDeclaredPassthroughHal("mapper", mapperSuffix.c_str(), RTLD_LOCAL | RTLD_NOW); } else { -- cgit v1.2.3-59-g8ed1b From 8fdf7eb239a4c6173067ecf36f5208cc1ff37268 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Wed, 6 Nov 2024 13:16:25 +0900 Subject: Deprecating llndk-versioning.h Symbols are still guarded by API_LEVEL_AT_LEAST(api_level). Vendor variants use the same guard now instead of __ANDROID_VENDOR_API__. Bug: 362658565 Test: m Change-Id: I47d95795fe030a2e0fac5a29d92ac91d2892c360 --- libs/binder/ndk/Android.bp | 3 - .../include_cpp/android/binder_interface_utils.h | 17 ++-- .../include_cpp/android/persistable_bundle_aidl.h | 101 ++++++++++----------- .../trusty/ndk/include/android/llndk-versioning.h | 19 ---- 4 files changed, 56 insertions(+), 84 deletions(-) delete mode 100644 libs/binder/trusty/ndk/include/android/llndk-versioning.h (limited to 'libs') diff --git a/libs/binder/ndk/Android.bp b/libs/binder/ndk/Android.bp index a7423b3d2a..5710bbfa9f 100644 --- a/libs/binder/ndk/Android.bp +++ b/libs/binder/ndk/Android.bp @@ -82,7 +82,6 @@ cc_library { llndk: { symbol_file: "libbinder_ndk.map.txt", - export_llndk_headers: ["libvendorsupport_llndk_headers"], }, cflags: [ @@ -110,11 +109,9 @@ cc_library { ], header_libs: [ - "libvendorsupport_llndk_headers", "jni_headers", ], export_header_lib_headers: [ - "libvendorsupport_llndk_headers", "jni_headers", ], diff --git a/libs/binder/ndk/include_cpp/android/binder_interface_utils.h b/libs/binder/ndk/include_cpp/android/binder_interface_utils.h index 0ad110ee83..c6518d816f 100644 --- a/libs/binder/ndk/include_cpp/android/binder_interface_utils.h +++ b/libs/binder/ndk/include_cpp/android/binder_interface_utils.h @@ -30,16 +30,14 @@ #include #include -#if defined(__ANDROID_VENDOR_API__) -#include -#elif !defined(API_LEVEL_AT_LEAST) #if defined(__BIONIC__) -#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) \ - (__builtin_available(android sdk_api_level, *)) +#define API_LEVEL_AT_LEAST(sdk_api_level) __builtin_available(android sdk_api_level, *) +#elif defined(TRUSTY_USERSPACE) +// TODO(b/349936395): set to true for Trusty +#define API_LEVEL_AT_LEAST(sdk_api_level) (false) #else -#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) (true) +#define API_LEVEL_AT_LEAST(sdk_api_level) (true) #endif // __BIONIC__ -#endif // __ANDROID_VENDOR_API__ #if __has_include() #include @@ -298,9 +296,8 @@ AIBinder_Class* ICInterface::defineClass(const char* interfaceDescriptor, #endif #if defined(__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__) || __ANDROID_API__ >= 36 - if API_LEVEL_AT_LEAST (36, 202504) { - if (codeToFunction != nullptr && - (&AIBinder_Class_setTransactionCodeToFunctionNameMap != nullptr)) { + if (API_LEVEL_AT_LEAST(36)) { + if (codeToFunction != nullptr) { AIBinder_Class_setTransactionCodeToFunctionNameMap(clazz, codeToFunction, functionCount); } diff --git a/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h b/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h index 83976b3771..f3f3c3802a 100644 --- a/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h +++ b/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h @@ -22,17 +22,14 @@ #include #include -// Include llndk-versioning.h only for non-system build as it is not available for NDK headers. -#if defined(__ANDROID_VENDOR_API__) -#include -#elif !defined(API_LEVEL_AT_LEAST) #if defined(__BIONIC__) -#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) \ - (__builtin_available(android sdk_api_level, *)) +#define API_LEVEL_AT_LEAST(sdk_api_level) __builtin_available(android sdk_api_level, *) +#elif defined(TRUSTY_USERSPACE) +// TODO(b/349936395): set to true for Trusty +#define API_LEVEL_AT_LEAST(sdk_api_level) (false) #else -#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) (true) +#define API_LEVEL_AT_LEAST(sdk_api_level) (true) #endif // __BIONIC__ -#endif // __ANDROID_VENDOR_API__ namespace aidl::android::os { @@ -44,7 +41,7 @@ namespace aidl::android::os { class PersistableBundle { public: PersistableBundle() noexcept { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { mPBundle = APersistableBundle_new(); } } @@ -54,13 +51,13 @@ class PersistableBundle { PersistableBundle(PersistableBundle&& other) noexcept : mPBundle(other.release()) {} // duplicates, does not take ownership of the APersistableBundle* PersistableBundle(const PersistableBundle& other) { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { mPBundle = APersistableBundle_dup(other.mPBundle); } } // duplicates, does not take ownership of the APersistableBundle* PersistableBundle& operator=(const PersistableBundle& other) { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { mPBundle = APersistableBundle_dup(other.mPBundle); } return *this; @@ -70,7 +67,7 @@ class PersistableBundle { binder_status_t readFromParcel(const AParcel* _Nonnull parcel) { reset(); - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return APersistableBundle_readFromParcel(parcel, &mPBundle); } else { return STATUS_INVALID_OPERATION; @@ -81,7 +78,7 @@ class PersistableBundle { if (!mPBundle) { return STATUS_BAD_VALUE; } - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return APersistableBundle_writeToParcel(mPBundle, parcel); } else { return STATUS_INVALID_OPERATION; @@ -96,7 +93,7 @@ class PersistableBundle { */ void reset(APersistableBundle* _Nullable pBundle = nullptr) noexcept { if (mPBundle) { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { APersistableBundle_delete(mPBundle); } mPBundle = nullptr; @@ -109,7 +106,7 @@ class PersistableBundle { * what should be used to check for equality. */ bool deepEquals(const PersistableBundle& rhs) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return APersistableBundle_isEqual(get(), rhs.get()); } else { return false; @@ -148,7 +145,7 @@ class PersistableBundle { inline std::string toString() const { if (!mPBundle) { return ""; - } else if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + } else if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { std::ostringstream os; os << "& vec) { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { // std::vector has no ::data(). int32_t num = vec.size(); if (num > 0) { @@ -222,7 +219,7 @@ class PersistableBundle { } void putIntVector(const std::string& key, const std::vector& vec) { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { int32_t num = vec.size(); if (num > 0) { APersistableBundle_putIntVector(mPBundle, key.c_str(), vec.data(), num); @@ -230,7 +227,7 @@ class PersistableBundle { } } void putLongVector(const std::string& key, const std::vector& vec) { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { int32_t num = vec.size(); if (num > 0) { APersistableBundle_putLongVector(mPBundle, key.c_str(), vec.data(), num); @@ -238,7 +235,7 @@ class PersistableBundle { } } void putDoubleVector(const std::string& key, const std::vector& vec) { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { int32_t num = vec.size(); if (num > 0) { APersistableBundle_putDoubleVector(mPBundle, key.c_str(), vec.data(), num); @@ -246,7 +243,7 @@ class PersistableBundle { } } void putStringVector(const std::string& key, const std::vector& vec) { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { int32_t num = vec.size(); if (num > 0) { char** inVec = (char**)malloc(num * sizeof(char*)); @@ -261,13 +258,13 @@ class PersistableBundle { } } void putPersistableBundle(const std::string& key, const PersistableBundle& pBundle) { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { APersistableBundle_putPersistableBundle(mPBundle, key.c_str(), pBundle.mPBundle); } } bool getBoolean(const std::string& key, bool* _Nonnull val) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return APersistableBundle_getBoolean(mPBundle, key.c_str(), val); } else { return false; @@ -275,7 +272,7 @@ class PersistableBundle { } bool getInt(const std::string& key, int32_t* _Nonnull val) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return APersistableBundle_getInt(mPBundle, key.c_str(), val); } else { return false; @@ -283,7 +280,7 @@ class PersistableBundle { } bool getLong(const std::string& key, int64_t* _Nonnull val) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return APersistableBundle_getLong(mPBundle, key.c_str(), val); } else { return false; @@ -291,7 +288,7 @@ class PersistableBundle { } bool getDouble(const std::string& key, double* _Nonnull val) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return APersistableBundle_getDouble(mPBundle, key.c_str(), val); } else { return false; @@ -303,7 +300,7 @@ class PersistableBundle { } bool getString(const std::string& key, std::string* _Nonnull val) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { char* outString = nullptr; bool ret = APersistableBundle_getString(mPBundle, key.c_str(), &outString, &stringAllocator, nullptr); @@ -321,7 +318,7 @@ class PersistableBundle { const char* _Nonnull, T* _Nullable, int32_t), const APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, std::vector* _Nonnull vec) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { int32_t bytes = 0; // call first with nullptr to get required size in bytes bytes = getVec(pBundle, key, nullptr, 0); @@ -343,28 +340,28 @@ class PersistableBundle { } bool getBooleanVector(const std::string& key, std::vector* _Nonnull vec) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getVecInternal(&APersistableBundle_getBooleanVector, mPBundle, key.c_str(), vec); } return false; } bool getIntVector(const std::string& key, std::vector* _Nonnull vec) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getVecInternal(&APersistableBundle_getIntVector, mPBundle, key.c_str(), vec); } return false; } bool getLongVector(const std::string& key, std::vector* _Nonnull vec) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getVecInternal(&APersistableBundle_getLongVector, mPBundle, key.c_str(), vec); } return false; } bool getDoubleVector(const std::string& key, std::vector* _Nonnull vec) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getVecInternal(&APersistableBundle_getDoubleVector, mPBundle, key.c_str(), vec); } @@ -389,7 +386,7 @@ class PersistableBundle { } bool getStringVector(const std::string& key, std::vector* _Nonnull vec) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { int32_t bytes = APersistableBundle_getStringVector(mPBundle, key.c_str(), nullptr, 0, &stringAllocator, nullptr); if (bytes > 0) { @@ -406,7 +403,7 @@ class PersistableBundle { } bool getPersistableBundle(const std::string& key, PersistableBundle* _Nonnull val) const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { APersistableBundle* bundle = nullptr; bool ret = APersistableBundle_getPersistableBundle(mPBundle, key.c_str(), &bundle); if (ret) { @@ -438,77 +435,77 @@ class PersistableBundle { } std::set getBooleanKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getBooleanKeys, mPBundle); } else { return {}; } } std::set getIntKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getIntKeys, mPBundle); } else { return {}; } } std::set getLongKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getLongKeys, mPBundle); } else { return {}; } } std::set getDoubleKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getDoubleKeys, mPBundle); } else { return {}; } } std::set getStringKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getStringKeys, mPBundle); } else { return {}; } } std::set getBooleanVectorKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getBooleanVectorKeys, mPBundle); } else { return {}; } } std::set getIntVectorKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getIntVectorKeys, mPBundle); } else { return {}; } } std::set getLongVectorKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getLongVectorKeys, mPBundle); } else { return {}; } } std::set getDoubleVectorKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getDoubleVectorKeys, mPBundle); } else { return {}; } } std::set getStringVectorKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getStringVectorKeys, mPBundle); } else { return {}; } } std::set getPersistableBundleKeys() const { - if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { + if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { return getKeys(&APersistableBundle_getPersistableBundleKeys, mPBundle); } else { return {}; diff --git a/libs/binder/trusty/ndk/include/android/llndk-versioning.h b/libs/binder/trusty/ndk/include/android/llndk-versioning.h deleted file mode 100644 index e955a34bdf..0000000000 --- a/libs/binder/trusty/ndk/include/android/llndk-versioning.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ -#pragma once - -// TODO(b/349936395): set to true for Trusty -#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) (false) -- cgit v1.2.3-59-g8ed1b From 3a28c3165d1a6c05c0e176b005eaa8596c487499 Mon Sep 17 00:00:00 2001 From: Vaibhav Devmurari Date: Mon, 4 Nov 2024 11:55:14 +0000 Subject: Add new 25Q2 keycodes to native Test: None Bug: 365920375 Flag: com.android.hardware.input.enable_new_25q2_keycodes Change-Id: If8d07744844eff38226e022dfb04195321a0976b --- include/android/keycodes.h | 38 ++++++++++++++++++++++++++++++++++++++ libs/input/InputEventLabels.cpp | 21 ++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) (limited to 'libs') diff --git a/include/android/keycodes.h b/include/android/keycodes.h index 79cdbcaf7b..495e0bdb1f 100644 --- a/include/android/keycodes.h +++ b/include/android/keycodes.h @@ -843,6 +843,44 @@ enum { AKEYCODE_EMOJI_PICKER = 317, /** Take Screenshot */ AKEYCODE_SCREENSHOT = 318, + /** To start dictate to an input field */ + AKEYCODE_DICTATE = 319, + /** AC New */ + AKEYCODE_NEW = 320, + /** AC Close */ + AKEYCODE_CLOSE = 321, + /** To toggle 'Do Not Disturb' mode */ + AKEYCODE_DO_NOT_DISTURB = 322, + /** To Print */ + AKEYCODE_PRINT = 323, + /** To Lock the screen */ + AKEYCODE_LOCK = 324, + /** To toggle fullscreen mode (on the current application) */ + AKEYCODE_FULLSCREEN = 325, + /** F13 key */ + AKEYCODE_F13 = 326, + /** F14 key */ + AKEYCODE_F14 = 327, + /** F15 key */ + AKEYCODE_F15 = 328, + /** F16 key */ + AKEYCODE_F16 = 329, + /** F17 key */ + AKEYCODE_F17 = 330, + /** F18 key */ + AKEYCODE_F18 = 331, + /** F19 key */ + AKEYCODE_F19 = 332, + /** F20 key */ + AKEYCODE_F20 = 333, + /** F21 key */ + AKEYCODE_F21 = 334, + /** F22 key */ + AKEYCODE_F22 = 335, + /** F23 key */ + AKEYCODE_F23 = 336, + /** F24 key */ + AKEYCODE_F24 = 337, // NOTE: If you add a new keycode here you must also add it to several other files. // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. diff --git a/libs/input/InputEventLabels.cpp b/libs/input/InputEventLabels.cpp index 8db0ca588b..b537feb68f 100644 --- a/libs/input/InputEventLabels.cpp +++ b/libs/input/InputEventLabels.cpp @@ -350,7 +350,26 @@ namespace android { DEFINE_KEYCODE(MACRO_3), \ DEFINE_KEYCODE(MACRO_4), \ DEFINE_KEYCODE(EMOJI_PICKER), \ - DEFINE_KEYCODE(SCREENSHOT) + DEFINE_KEYCODE(SCREENSHOT), \ + DEFINE_KEYCODE(DICTATE), \ + DEFINE_KEYCODE(NEW), \ + DEFINE_KEYCODE(CLOSE), \ + DEFINE_KEYCODE(DO_NOT_DISTURB), \ + DEFINE_KEYCODE(PRINT), \ + DEFINE_KEYCODE(LOCK), \ + DEFINE_KEYCODE(FULLSCREEN), \ + DEFINE_KEYCODE(F13), \ + DEFINE_KEYCODE(F14), \ + DEFINE_KEYCODE(F15), \ + DEFINE_KEYCODE(F16), \ + DEFINE_KEYCODE(F17), \ + DEFINE_KEYCODE(F18), \ + DEFINE_KEYCODE(F19),\ + DEFINE_KEYCODE(F20), \ + DEFINE_KEYCODE(F21), \ + DEFINE_KEYCODE(F22), \ + DEFINE_KEYCODE(F23), \ + DEFINE_KEYCODE(F24) // NOTE: If you add a new axis here you must also add it to several other files. // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list. -- cgit v1.2.3-59-g8ed1b From 1d038d478f8f9ddee71e2fe90ac97ed96303f554 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Tue, 29 Oct 2024 11:25:58 -0700 Subject: Consume full tap in EndToEndNativeInputTest Currently, the injection inside the test is happening asynchronously. Occasionally, it seems that an inconsistent event stream is being sent. Without further debugging about how this is possible, a speculative fix is being made here by consuming a complete motion sequence after a tap is injected. This way, we know that the test must wait for the UP event to be received, thus hopefully preventing the next test from running and starting the asynchronous injection. To prevent misuse of 'consumeEvent' in the future, it is also being made private in this CL. Unfortunately, a bunch of other fields should also be private (but were not made so in the beginning, possibly a typo). As a result, some of the fields are now relied upon. These are kept as is to keep focus of this CL. Bug: 361264974 Test: atest libgui_test Flag: TEST_ONLY Change-Id: I99bac4022bab2b3aa106e0838b227f24eb512ea1 --- libs/gui/tests/EndToEndNativeInputTest.cpp | 38 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'libs') diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp index 17630e304f..2f58a6cc8f 100644 --- a/libs/gui/tests/EndToEndNativeInputTest.cpp +++ b/libs/gui/tests/EndToEndNativeInputTest.cpp @@ -183,20 +183,6 @@ public: return std::make_unique(surfaceControl, width, height); } - InputEvent* consumeEvent(std::chrono::milliseconds timeout = 3000ms) { - mClientChannel->waitForMessage(timeout); - - InputEvent* ev; - uint32_t seqId; - status_t consumed = mInputConsumer->consume(&mInputEventFactory, true, -1, &seqId, &ev); - if (consumed != OK) { - return nullptr; - } - status_t status = mInputConsumer->sendFinishedSignal(seqId, true); - EXPECT_EQ(OK, status) << "Could not send finished signal"; - return ev; - } - void assertFocusChange(bool hasFocus) { InputEvent* ev = consumeEvent(); ASSERT_NE(ev, nullptr); @@ -323,14 +309,30 @@ public: } public: + // But should be private + WindowInfo mInputInfo; sp mSurfaceControl; + +private: std::shared_ptr mClientChannel; sp mInputFlinger; - WindowInfo mInputInfo; - PreallocatedInputEventFactory mInputEventFactory; InputConsumer* mInputConsumer; + + InputEvent* consumeEvent(std::chrono::milliseconds timeout = 3000ms) { + mClientChannel->waitForMessage(timeout); + + InputEvent* ev; + uint32_t seqId; + status_t consumed = mInputConsumer->consume(&mInputEventFactory, true, -1, &seqId, &ev); + if (consumed != OK) { + return nullptr; + } + status_t status = mInputConsumer->sendFinishedSignal(seqId, true); + EXPECT_EQ(OK, status) << "Could not send finished signal"; + return ev; + } }; class BlastInputSurface : public InputSurface { @@ -458,7 +460,7 @@ TEST_F(InputSurfacesTest, can_receive_input) { injectTap(101, 101); - EXPECT_NE(surface->consumeEvent(), nullptr); + surface->expectTap(1, 1); } /** @@ -612,7 +614,7 @@ TEST_F(InputSurfacesTest, touchable_region) { // A tap within the surface but outside the touchable region should not be sent to the surface. injectTap(20, 30); - EXPECT_EQ(surface->consumeEvent(/*timeout=*/200ms), nullptr); + surface->assertNoEvent(); injectTap(31, 52); surface->expectTap(20, 30); -- cgit v1.2.3-59-g8ed1b From 0980aa8675918ac2c18acca4668db683a93c65be Mon Sep 17 00:00:00 2001 From: Justin Lannin Date: Wed, 6 Nov 2024 07:25:00 +0000 Subject: ASM: Add required AppOp lookup to custom sensors for all permissions. Previously, we only made an AppOp lookup if the custom sensor used BODY_SENSORS. We are deprecating BODY_SENSORS in favor of READ_HEART_RATE and other granular health permissions. This CL ensures the correct AppOp is used if the custom sensor uses these other permissions. In the spirit of flagging, we guard the expanded AppOp lookup behind the replace_body_sensor_permission_enabled flag. However, it's worth noting that any permission with an existing AppOp would now be used (not just READ_HEART_RATE). Bug: 377576685 Change-Id: Ia16663795479ee49d5b5a82cd5b304b6dd6a26f1 Flag: android.permission.flags.replace_body_sensor_permission_enabled --- libs/sensor/Sensor.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'libs') diff --git a/libs/sensor/Sensor.cpp b/libs/sensor/Sensor.cpp index eddd568fb5..797efbe5df 100644 --- a/libs/sensor/Sensor.cpp +++ b/libs/sensor/Sensor.cpp @@ -306,7 +306,18 @@ Sensor::Sensor(struct sensor_t const& hwSensor, const uuid_t& uuid, int halVersi } if (halVersion > SENSORS_DEVICE_API_VERSION_1_0 && hwSensor.requiredPermission) { mRequiredPermission = hwSensor.requiredPermission; - if (!strcmp(mRequiredPermission, SENSOR_PERMISSION_BODY_SENSORS)) { + bool requiresBodySensorPermission = + !strcmp(mRequiredPermission, SENSOR_PERMISSION_BODY_SENSORS); + if (android::permission::flags::replace_body_sensor_permission_enabled()) { + if (requiresBodySensorPermission) { + ALOGE("Sensor %s using deprecated Body Sensor permission", mName.c_str()); + } + + AppOpsManager appOps; + // Lookup to see if an AppOp exists for the permission. If none + // does, the default value of -1 is used. + mRequiredAppOp = appOps.permissionToOpCode(String16(mRequiredPermission)); + } else if (requiresBodySensorPermission) { AppOpsManager appOps; mRequiredAppOp = appOps.permissionToOpCode(String16(SENSOR_PERMISSION_BODY_SENSORS)); } -- cgit v1.2.3-59-g8ed1b From 87602161374f8dcede06e7280f267f77c2bee3c5 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Tue, 5 Nov 2024 10:13:19 -0600 Subject: Update Transaction::setInputWindowInfo to take WindowInfoHandle This change allows us to reuse WindowInfoHandle objects instead of allocating a new WindowInfoHandle object for each call. Bug: 294381558 Flag: EXEMPT refactor Test: presubmits Change-Id: I39d965217763a9cacfc9e77d0723200038fd2afe --- libs/gui/SurfaceComposerClient.cpp | 4 +- libs/gui/include/gui/SurfaceComposerClient.h | 3 +- libs/gui/tests/EndToEndNativeInputTest.cpp | 107 ++++++++++++--------- services/surfaceflinger/tests/Credentials_test.cpp | 12 ++- .../tests/WindowInfosListener_test.cpp | 24 ++--- 5 files changed, 82 insertions(+), 68 deletions(-) (limited to 'libs') diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 3260c53a62..c97dfd4cda 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -2129,13 +2129,13 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::notifyPr } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setInputWindowInfo( - const sp& sc, const WindowInfo& info) { + const sp& sc, sp info) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } - s->windowInfoHandle = new WindowInfoHandle(info); + s->windowInfoHandle = std::move(info); s->what |= layer_state_t::eInputInfoChanged; return *this; } diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h index e9262b3870..7c6b3416f8 100644 --- a/libs/gui/include/gui/SurfaceComposerClient.h +++ b/libs/gui/include/gui/SurfaceComposerClient.h @@ -687,7 +687,8 @@ public: // ONLY FOR BLAST ADAPTER Transaction& notifyProducerDisconnect(const sp& sc); - Transaction& setInputWindowInfo(const sp& sc, const gui::WindowInfo& info); + Transaction& setInputWindowInfo(const sp& sc, + sp info); Transaction& setFocusedWindow(const gui::FocusRequest& request); Transaction& addWindowInfosReportedListener( diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp index 2f58a6cc8f..0e84d68eec 100644 --- a/libs/gui/tests/EndToEndNativeInputTest.cpp +++ b/libs/gui/tests/EndToEndNativeInputTest.cpp @@ -112,7 +112,7 @@ public: mInputFlinger = getInputFlinger(); if (noInputChannel) { - mInputInfo.setInputConfig(WindowInfo::InputConfig::NO_INPUT_CHANNEL, true); + mInputInfo->editInfo()->setInputConfig(WindowInfo::InputConfig::NO_INPUT_CHANNEL, true); } else { android::os::InputChannelCore tempChannel; android::binder::Status result = @@ -121,21 +121,21 @@ public: ADD_FAILURE() << "binder call to createInputChannel failed"; } mClientChannel = InputChannel::create(std::move(tempChannel)); - mInputInfo.token = mClientChannel->getConnectionToken(); + mInputInfo->editInfo()->token = mClientChannel->getConnectionToken(); mInputConsumer = new InputConsumer(mClientChannel); } - mInputInfo.name = "Test info"; - mInputInfo.dispatchingTimeout = 5s; - mInputInfo.globalScaleFactor = 1.0; - mInputInfo.touchableRegion.orSelf(Rect(0, 0, width, height)); + mInputInfo->editInfo()->name = "Test info"; + mInputInfo->editInfo()->dispatchingTimeout = 5s; + mInputInfo->editInfo()->globalScaleFactor = 1.0; + mInputInfo->editInfo()->touchableRegion.orSelf(Rect(0, 0, width, height)); InputApplicationInfo aInfo; aInfo.token = new BBinder(); aInfo.name = "Test app info"; aInfo.dispatchingTimeoutMillis = std::chrono::duration_cast(DISPATCHING_TIMEOUT).count(); - mInputInfo.applicationInfo = aInfo; + mInputInfo->editInfo()->applicationInfo = aInfo; } static std::unique_ptr makeColorInputSurface(const sp& scc, @@ -300,8 +300,8 @@ public: void requestFocus(ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT) { SurfaceComposerClient::Transaction t; FocusRequest request; - request.token = mInputInfo.token; - request.windowName = mInputInfo.name; + request.token = mInputInfo->getInfo()->token; + request.windowName = mInputInfo->getInfo()->name; request.timestamp = systemTime(SYSTEM_TIME_MONOTONIC); request.displayId = displayId.val(); t.setFocusedWindow(request); @@ -310,7 +310,7 @@ public: public: // But should be private - WindowInfo mInputInfo; + sp mInputInfo = sp::make(); sp mSurfaceControl; private: @@ -523,7 +523,7 @@ TEST_F(InputSurfacesTest, input_respects_surface_insets) { std::unique_ptr fgSurface = makeSurface(100, 100); bgSurface->showAt(100, 100); - fgSurface->mInputInfo.surfaceInset = 5; + fgSurface->mInputInfo->editInfo()->surfaceInset = 5; fgSurface->showAt(100, 100); injectTap(106, 106); @@ -538,8 +538,8 @@ TEST_F(InputSurfacesTest, input_respects_surface_insets_with_replaceTouchableReg std::unique_ptr fgSurface = makeSurface(100, 100); bgSurface->showAt(100, 100); - fgSurface->mInputInfo.surfaceInset = 5; - fgSurface->mInputInfo.replaceTouchableRegionWithCrop = true; + fgSurface->mInputInfo->editInfo()->surfaceInset = 5; + fgSurface->mInputInfo->editInfo()->replaceTouchableRegionWithCrop = true; fgSurface->showAt(100, 100); injectTap(106, 106); @@ -555,7 +555,7 @@ TEST_F(InputSurfacesTest, input_respects_cropped_surface_insets) { std::unique_ptr childSurface = makeSurface(100, 100); parentSurface->showAt(100, 100); - childSurface->mInputInfo.surfaceInset = 10; + childSurface->mInputInfo->editInfo()->surfaceInset = 10; childSurface->showAt(100, 100); childSurface->doTransaction([&](auto& t, auto& sc) { @@ -576,7 +576,7 @@ TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets) { std::unique_ptr fgSurface = makeSurface(100, 100); bgSurface->showAt(100, 100); - fgSurface->mInputInfo.surfaceInset = 5; + fgSurface->mInputInfo->editInfo()->surfaceInset = 5; fgSurface->showAt(100, 100); fgSurface->doTransaction([&](auto& t, auto& sc) { t.setMatrix(sc, 2.0, 0, 0, 4.0); }); @@ -595,7 +595,7 @@ TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets_overflow) { bgSurface->showAt(100, 100); // In case we pass the very big inset without any checking. - fgSurface->mInputInfo.surfaceInset = INT32_MAX; + fgSurface->mInputInfo->editInfo()->surfaceInset = INT32_MAX; fgSurface->showAt(100, 100); fgSurface->doTransaction([&](auto& t, auto& sc) { t.setMatrix(sc, 2.0, 0, 0, 2.0); }); @@ -608,7 +608,7 @@ TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets_overflow) { TEST_F(InputSurfacesTest, touchable_region) { std::unique_ptr surface = makeSurface(100, 100); - surface->mInputInfo.touchableRegion.set(Rect{19, 29, 21, 31}); + surface->mInputInfo->editInfo()->touchableRegion.set(Rect{19, 29, 21, 31}); surface->showAt(11, 22); @@ -629,7 +629,8 @@ TEST_F(InputSurfacesTest, input_respects_touchable_region_offset_overflow) { // Since the surface is offset from the origin, the touchable region will be transformed into // display space, which would trigger an overflow or an underflow. Ensure that we are protected // against such a situation. - fgSurface->mInputInfo.touchableRegion.orSelf(Rect{INT32_MIN, INT32_MIN, INT32_MAX, INT32_MAX}); + fgSurface->mInputInfo->editInfo()->touchableRegion.orSelf( + Rect{INT32_MIN, INT32_MIN, INT32_MAX, INT32_MAX}); fgSurface->showAt(100, 100); @@ -644,7 +645,8 @@ TEST_F(InputSurfacesTest, input_respects_scaled_touchable_region_overflow) { std::unique_ptr fgSurface = makeSurface(100, 100); bgSurface->showAt(0, 0); - fgSurface->mInputInfo.touchableRegion.orSelf(Rect{INT32_MIN, INT32_MIN, INT32_MAX, INT32_MAX}); + fgSurface->mInputInfo->editInfo()->touchableRegion.orSelf( + Rect{INT32_MIN, INT32_MIN, INT32_MAX, INT32_MAX}); fgSurface->showAt(0, 0); fgSurface->doTransaction([&](auto& t, auto& sc) { t.setMatrix(sc, 2.0, 0, 0, 2.0); }); @@ -814,7 +816,7 @@ TEST_F(InputSurfacesTest, rotate_surface_with_scale) { TEST_F(InputSurfacesTest, rotate_surface_with_scale_and_insets) { std::unique_ptr surface = makeSurface(100, 100); - surface->mInputInfo.surfaceInset = 5; + surface->mInputInfo->editInfo()->surfaceInset = 5; surface->showAt(100, 100); surface->doTransaction([](auto& t, auto& sc) { @@ -843,11 +845,12 @@ TEST_F(InputSurfacesTest, touch_flag_obscured) { // Add non touchable window to fully cover touchable window. Window behind gets touch, but // with flag AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED std::unique_ptr nonTouchableSurface = makeSurface(100, 100); - nonTouchableSurface->mInputInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); - nonTouchableSurface->mInputInfo.ownerUid = gui::Uid{22222}; + nonTouchableSurface->mInputInfo->editInfo() + ->setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); + nonTouchableSurface->mInputInfo->editInfo()->ownerUid = gui::Uid{22222}; // Overriding occlusion mode otherwise the touch would be discarded at InputDispatcher by // the default obscured/untrusted touch filter introduced in S. - nonTouchableSurface->mInputInfo.touchOcclusionMode = TouchOcclusionMode::ALLOW; + nonTouchableSurface->mInputInfo->editInfo()->touchOcclusionMode = TouchOcclusionMode::ALLOW; nonTouchableSurface->showAt(100, 100); injectTap(190, 199); @@ -863,10 +866,12 @@ TEST_F(InputSurfacesTest, touch_flag_partially_obscured_with_crop) { // AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED std::unique_ptr parentSurface = makeSurface(100, 100); std::unique_ptr nonTouchableSurface = makeSurface(100, 100); - nonTouchableSurface->mInputInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); - parentSurface->mInputInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); - nonTouchableSurface->mInputInfo.ownerUid = gui::Uid{22222}; - parentSurface->mInputInfo.ownerUid = gui::Uid{22222}; + nonTouchableSurface->mInputInfo->editInfo() + ->setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); + parentSurface->mInputInfo->editInfo()->setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, + true); + nonTouchableSurface->mInputInfo->editInfo()->ownerUid = gui::Uid{22222}; + parentSurface->mInputInfo->editInfo()->ownerUid = gui::Uid{22222}; nonTouchableSurface->showAt(0, 0); parentSurface->showAt(100, 100); @@ -887,10 +892,12 @@ TEST_F(InputSurfacesTest, touch_not_obscured_with_crop) { // the touchable window. Window behind gets touch with no obscured flags. std::unique_ptr parentSurface = makeSurface(100, 100); std::unique_ptr nonTouchableSurface = makeSurface(100, 100); - nonTouchableSurface->mInputInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); - parentSurface->mInputInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); - nonTouchableSurface->mInputInfo.ownerUid = gui::Uid{22222}; - parentSurface->mInputInfo.ownerUid = gui::Uid{22222}; + nonTouchableSurface->mInputInfo->editInfo() + ->setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); + parentSurface->mInputInfo->editInfo()->setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, + true); + nonTouchableSurface->mInputInfo->editInfo()->ownerUid = gui::Uid{22222}; + parentSurface->mInputInfo->editInfo()->ownerUid = gui::Uid{22222}; nonTouchableSurface->showAt(0, 0); parentSurface->showAt(50, 50); @@ -908,8 +915,9 @@ TEST_F(InputSurfacesTest, touch_not_obscured_with_zero_sized_bql) { std::unique_ptr bufferSurface = InputSurface::makeBufferInputSurface(mComposerClient, 0, 0); - bufferSurface->mInputInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); - bufferSurface->mInputInfo.ownerUid = gui::Uid{22222}; + bufferSurface->mInputInfo->editInfo()->setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, + true); + bufferSurface->mInputInfo->editInfo()->ownerUid = gui::Uid{22222}; surface->showAt(10, 10); bufferSurface->showAt(50, 50, Rect::EMPTY_RECT); @@ -923,8 +931,9 @@ TEST_F(InputSurfacesTest, touch_not_obscured_with_zero_sized_blast) { std::unique_ptr bufferSurface = BlastInputSurface::makeBlastInputSurface(mComposerClient, 0, 0); - bufferSurface->mInputInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); - bufferSurface->mInputInfo.ownerUid = gui::Uid{22222}; + bufferSurface->mInputInfo->editInfo()->setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, + true); + bufferSurface->mInputInfo->editInfo()->ownerUid = gui::Uid{22222}; surface->showAt(10, 10); bufferSurface->showAt(50, 50, Rect::EMPTY_RECT); @@ -967,13 +976,14 @@ TEST_F(InputSurfacesTest, strict_unobscured_input_scaled_without_crop_window) { TEST_F(InputSurfacesTest, strict_unobscured_input_obscured_window) { std::unique_ptr surface = makeSurface(100, 100); - surface->mInputInfo.ownerUid = gui::Uid{11111}; + surface->mInputInfo->editInfo()->ownerUid = gui::Uid{11111}; surface->doTransaction( [&](auto& t, auto& sc) { t.setDropInputMode(sc, gui::DropInputMode::OBSCURED); }); surface->showAt(100, 100); std::unique_ptr obscuringSurface = makeSurface(100, 100); - obscuringSurface->mInputInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); - obscuringSurface->mInputInfo.ownerUid = gui::Uid{22222}; + obscuringSurface->mInputInfo->editInfo()->setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, + true); + obscuringSurface->mInputInfo->editInfo()->ownerUid = gui::Uid{22222}; obscuringSurface->showAt(100, 100); injectTap(101, 101); surface->assertNoEvent(); @@ -986,13 +996,14 @@ TEST_F(InputSurfacesTest, strict_unobscured_input_obscured_window) { TEST_F(InputSurfacesTest, strict_unobscured_input_partially_obscured_window) { std::unique_ptr surface = makeSurface(100, 100); - surface->mInputInfo.ownerUid = gui::Uid{11111}; + surface->mInputInfo->editInfo()->ownerUid = gui::Uid{11111}; surface->doTransaction( [&](auto& t, auto& sc) { t.setDropInputMode(sc, gui::DropInputMode::OBSCURED); }); surface->showAt(100, 100); std::unique_ptr obscuringSurface = makeSurface(100, 100); - obscuringSurface->mInputInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, true); - obscuringSurface->mInputInfo.ownerUid = gui::Uid{22222}; + obscuringSurface->mInputInfo->editInfo()->setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, + true); + obscuringSurface->mInputInfo->editInfo()->ownerUid = gui::Uid{22222}; obscuringSurface->showAt(190, 190); injectTap(101, 101); @@ -1056,7 +1067,7 @@ TEST_F(InputSurfacesTest, ignore_touch_region_with_zero_sized_blast) { BlastInputSurface::makeBlastInputSurface(mComposerClient, 0, 0); surface->showAt(100, 100); - bufferSurface->mInputInfo.touchableRegion.orSelf(Rect(0, 0, 200, 200)); + bufferSurface->mInputInfo->editInfo()->touchableRegion.orSelf(Rect(0, 0, 200, 200)); bufferSurface->showAt(100, 100, Rect::EMPTY_RECT); injectTap(101, 101); @@ -1099,8 +1110,8 @@ TEST_F(InputSurfacesTest, cropped_container_replaces_touchable_region_with_null_ InputSurface::makeContainerInputSurface(mComposerClient, 100, 100); containerSurface->doTransaction( [&](auto& t, auto& sc) { t.reparent(sc, parentContainer->mSurfaceControl); }); - containerSurface->mInputInfo.replaceTouchableRegionWithCrop = true; - containerSurface->mInputInfo.touchableRegionCropHandle = nullptr; + containerSurface->mInputInfo->editInfo()->replaceTouchableRegionWithCrop = true; + containerSurface->mInputInfo->editInfo()->touchableRegionCropHandle = nullptr; parentContainer->showAt(10, 10, Rect(0, 0, 20, 20)); containerSurface->showAt(10, 10, Rect(0, 0, 5, 5)); @@ -1126,8 +1137,8 @@ TEST_F(InputSurfacesTest, uncropped_container_replaces_touchable_region_with_nul InputSurface::makeContainerInputSurface(mComposerClient, 100, 100); containerSurface->doTransaction( [&](auto& t, auto& sc) { t.reparent(sc, parentContainer->mSurfaceControl); }); - containerSurface->mInputInfo.replaceTouchableRegionWithCrop = true; - containerSurface->mInputInfo.touchableRegionCropHandle = nullptr; + containerSurface->mInputInfo->editInfo()->replaceTouchableRegionWithCrop = true; + containerSurface->mInputInfo->editInfo()->touchableRegionCropHandle = nullptr; parentContainer->doTransaction( [&](auto& t, auto& sc) { t.reparent(sc, bgContainer->mSurfaceControl); }); bgContainer->showAt(0, 0, Rect(0, 0, 100, 100)); @@ -1154,8 +1165,8 @@ TEST_F(InputSurfacesTest, replace_touchable_region_with_crop) { std::unique_ptr containerSurface = InputSurface::makeContainerInputSurface(mComposerClient, 100, 100); - containerSurface->mInputInfo.replaceTouchableRegionWithCrop = true; - containerSurface->mInputInfo.touchableRegionCropHandle = + containerSurface->mInputInfo->editInfo()->replaceTouchableRegionWithCrop = true; + containerSurface->mInputInfo->editInfo()->touchableRegionCropHandle = cropLayer->mSurfaceControl->getHandle(); containerSurface->showAt(10, 10, Rect::INVALID_RECT); diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp index e6fed63d96..7b6e4bff6a 100644 --- a/services/surfaceflinger/tests/Credentials_test.cpp +++ b/services/surfaceflinger/tests/Credentials_test.cpp @@ -341,9 +341,9 @@ TEST_F(CredentialsTest, TransactionPermissionTest) { WindowInfosListenerUtils windowInfosListenerUtils; std::string name = "Test Layer"; sp token = sp::make(); - WindowInfo windowInfo; - windowInfo.name = name; - windowInfo.token = token; + auto windowInfo = sp::make(); + windowInfo->editInfo()->name = name; + windowInfo->editInfo()->token = token; sp surfaceControl = mComposerClient->createSurface(String8(name.c_str()), 100, 100, PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eFXSurfaceBufferState); @@ -370,7 +370,8 @@ TEST_F(CredentialsTest, TransactionPermissionTest) { UIDFaker f(AID_SYSTEM); auto windowIsPresentAndNotTrusted = [&](const std::vector& windowInfos) { auto foundWindowInfo = - WindowInfosListenerUtils::findMatchingWindowInfo(windowInfo, windowInfos); + WindowInfosListenerUtils::findMatchingWindowInfo(*windowInfo->getInfo(), + windowInfos); if (!foundWindowInfo) { return false; } @@ -386,7 +387,8 @@ TEST_F(CredentialsTest, TransactionPermissionTest) { Transaction().setTrustedOverlay(surfaceControl, true).apply(/*synchronous=*/true); auto windowIsPresentAndTrusted = [&](const std::vector& windowInfos) { auto foundWindowInfo = - WindowInfosListenerUtils::findMatchingWindowInfo(windowInfo, windowInfos); + WindowInfosListenerUtils::findMatchingWindowInfo(*windowInfo->getInfo(), + windowInfos); if (!foundWindowInfo) { return false; } diff --git a/services/surfaceflinger/tests/WindowInfosListener_test.cpp b/services/surfaceflinger/tests/WindowInfosListener_test.cpp index ad9a674456..2dd0dd9bd3 100644 --- a/services/surfaceflinger/tests/WindowInfosListener_test.cpp +++ b/services/surfaceflinger/tests/WindowInfosListener_test.cpp @@ -50,9 +50,9 @@ protected: TEST_F(WindowInfosListenerTest, WindowInfoAddedAndRemoved) { std::string name = "Test Layer"; sp token = sp::make(); - WindowInfo windowInfo; - windowInfo.name = name; - windowInfo.token = token; + auto windowInfo = sp::make(); + windowInfo->editInfo()->name = name; + windowInfo->editInfo()->token = token; sp surfaceControl = mClient->createSurface(String8(name.c_str()), 100, 100, PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eFXSurfaceBufferState); @@ -65,14 +65,14 @@ TEST_F(WindowInfosListenerTest, WindowInfoAddedAndRemoved) { .apply(); auto windowPresent = [&](const std::vector& windowInfos) { - return findMatchingWindowInfo(windowInfo, windowInfos); + return findMatchingWindowInfo(*windowInfo->getInfo(), windowInfos); }; ASSERT_TRUE(waitForWindowInfosPredicate(windowPresent)); Transaction().reparent(surfaceControl, nullptr).apply(); auto windowNotPresent = [&](const std::vector& windowInfos) { - return !findMatchingWindowInfo(windowInfo, windowInfos); + return !findMatchingWindowInfo(*windowInfo->getInfo(), windowInfos); }; ASSERT_TRUE(waitForWindowInfosPredicate(windowNotPresent)); } @@ -80,9 +80,9 @@ TEST_F(WindowInfosListenerTest, WindowInfoAddedAndRemoved) { TEST_F(WindowInfosListenerTest, WindowInfoChanged) { std::string name = "Test Layer"; sp token = sp::make(); - WindowInfo windowInfo; - windowInfo.name = name; - windowInfo.token = token; + auto windowInfo = sp::make(); + windowInfo->editInfo()->name = name; + windowInfo->editInfo()->token = token; sp surfaceControl = mClient->createSurface(String8(name.c_str()), 100, 100, PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eFXSurfaceBufferState); @@ -96,7 +96,7 @@ TEST_F(WindowInfosListenerTest, WindowInfoChanged) { .apply(); auto windowIsPresentAndTouchableRegionEmpty = [&](const std::vector& windowInfos) { - auto foundWindowInfo = findMatchingWindowInfo(windowInfo, windowInfos); + auto foundWindowInfo = findMatchingWindowInfo(*windowInfo->getInfo(), windowInfos); if (!foundWindowInfo) { return false; } @@ -104,19 +104,19 @@ TEST_F(WindowInfosListenerTest, WindowInfoChanged) { }; ASSERT_TRUE(waitForWindowInfosPredicate(windowIsPresentAndTouchableRegionEmpty)); - windowInfo.addTouchableRegion({0, 0, 50, 50}); + windowInfo->editInfo()->addTouchableRegion({0, 0, 50, 50}); Transaction().setInputWindowInfo(surfaceControl, windowInfo).apply(); auto windowIsPresentAndTouchableRegionMatches = [&](const std::vector& windowInfos) { - auto foundWindowInfo = findMatchingWindowInfo(windowInfo, windowInfos); + auto foundWindowInfo = findMatchingWindowInfo(*windowInfo->getInfo(), windowInfos); if (!foundWindowInfo) { return false; } auto touchableRegion = foundWindowInfo->transform.transform(foundWindowInfo->touchableRegion); - return touchableRegion.hasSameRects(windowInfo.touchableRegion); + return touchableRegion.hasSameRects(windowInfo->getInfo()->touchableRegion); }; ASSERT_TRUE(waitForWindowInfosPredicate(windowIsPresentAndTouchableRegionMatches)); } -- cgit v1.2.3-59-g8ed1b From 8ded18ccb61c0d16a3289498791dd91329b83f52 Mon Sep 17 00:00:00 2001 From: "Priyanka Advani (xWF)" Date: Fri, 8 Nov 2024 17:37:24 +0000 Subject: Revert "Deprecating llndk-versioning.h" Revert submission 3334193-no-llndk-versioning Reason for revert: Droidmonitor created revert due to b/378038995. Will be verifying through ABTD before submission. Reverted changes: /q/submissionid:3334193-no-llndk-versioning Change-Id: I30bd8aaf4a3dc59dc3855dc1323c3a689e3cba00 --- libs/binder/ndk/Android.bp | 3 + .../include_cpp/android/binder_interface_utils.h | 17 ++-- .../include_cpp/android/persistable_bundle_aidl.h | 101 +++++++++++---------- .../trusty/ndk/include/android/llndk-versioning.h | 19 ++++ 4 files changed, 84 insertions(+), 56 deletions(-) create mode 100644 libs/binder/trusty/ndk/include/android/llndk-versioning.h (limited to 'libs') diff --git a/libs/binder/ndk/Android.bp b/libs/binder/ndk/Android.bp index 5710bbfa9f..a7423b3d2a 100644 --- a/libs/binder/ndk/Android.bp +++ b/libs/binder/ndk/Android.bp @@ -82,6 +82,7 @@ cc_library { llndk: { symbol_file: "libbinder_ndk.map.txt", + export_llndk_headers: ["libvendorsupport_llndk_headers"], }, cflags: [ @@ -109,9 +110,11 @@ cc_library { ], header_libs: [ + "libvendorsupport_llndk_headers", "jni_headers", ], export_header_lib_headers: [ + "libvendorsupport_llndk_headers", "jni_headers", ], diff --git a/libs/binder/ndk/include_cpp/android/binder_interface_utils.h b/libs/binder/ndk/include_cpp/android/binder_interface_utils.h index c6518d816f..0ad110ee83 100644 --- a/libs/binder/ndk/include_cpp/android/binder_interface_utils.h +++ b/libs/binder/ndk/include_cpp/android/binder_interface_utils.h @@ -30,14 +30,16 @@ #include #include +#if defined(__ANDROID_VENDOR_API__) +#include +#elif !defined(API_LEVEL_AT_LEAST) #if defined(__BIONIC__) -#define API_LEVEL_AT_LEAST(sdk_api_level) __builtin_available(android sdk_api_level, *) -#elif defined(TRUSTY_USERSPACE) -// TODO(b/349936395): set to true for Trusty -#define API_LEVEL_AT_LEAST(sdk_api_level) (false) +#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) \ + (__builtin_available(android sdk_api_level, *)) #else -#define API_LEVEL_AT_LEAST(sdk_api_level) (true) +#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) (true) #endif // __BIONIC__ +#endif // __ANDROID_VENDOR_API__ #if __has_include() #include @@ -296,8 +298,9 @@ AIBinder_Class* ICInterface::defineClass(const char* interfaceDescriptor, #endif #if defined(__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__) || __ANDROID_API__ >= 36 - if (API_LEVEL_AT_LEAST(36)) { - if (codeToFunction != nullptr) { + if API_LEVEL_AT_LEAST (36, 202504) { + if (codeToFunction != nullptr && + (&AIBinder_Class_setTransactionCodeToFunctionNameMap != nullptr)) { AIBinder_Class_setTransactionCodeToFunctionNameMap(clazz, codeToFunction, functionCount); } diff --git a/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h b/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h index f3f3c3802a..83976b3771 100644 --- a/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h +++ b/libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h @@ -22,14 +22,17 @@ #include #include +// Include llndk-versioning.h only for non-system build as it is not available for NDK headers. +#if defined(__ANDROID_VENDOR_API__) +#include +#elif !defined(API_LEVEL_AT_LEAST) #if defined(__BIONIC__) -#define API_LEVEL_AT_LEAST(sdk_api_level) __builtin_available(android sdk_api_level, *) -#elif defined(TRUSTY_USERSPACE) -// TODO(b/349936395): set to true for Trusty -#define API_LEVEL_AT_LEAST(sdk_api_level) (false) +#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) \ + (__builtin_available(android sdk_api_level, *)) #else -#define API_LEVEL_AT_LEAST(sdk_api_level) (true) +#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) (true) #endif // __BIONIC__ +#endif // __ANDROID_VENDOR_API__ namespace aidl::android::os { @@ -41,7 +44,7 @@ namespace aidl::android::os { class PersistableBundle { public: PersistableBundle() noexcept { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { mPBundle = APersistableBundle_new(); } } @@ -51,13 +54,13 @@ class PersistableBundle { PersistableBundle(PersistableBundle&& other) noexcept : mPBundle(other.release()) {} // duplicates, does not take ownership of the APersistableBundle* PersistableBundle(const PersistableBundle& other) { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { mPBundle = APersistableBundle_dup(other.mPBundle); } } // duplicates, does not take ownership of the APersistableBundle* PersistableBundle& operator=(const PersistableBundle& other) { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { mPBundle = APersistableBundle_dup(other.mPBundle); } return *this; @@ -67,7 +70,7 @@ class PersistableBundle { binder_status_t readFromParcel(const AParcel* _Nonnull parcel) { reset(); - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_readFromParcel(parcel, &mPBundle); } else { return STATUS_INVALID_OPERATION; @@ -78,7 +81,7 @@ class PersistableBundle { if (!mPBundle) { return STATUS_BAD_VALUE; } - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_writeToParcel(mPBundle, parcel); } else { return STATUS_INVALID_OPERATION; @@ -93,7 +96,7 @@ class PersistableBundle { */ void reset(APersistableBundle* _Nullable pBundle = nullptr) noexcept { if (mPBundle) { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_delete(mPBundle); } mPBundle = nullptr; @@ -106,7 +109,7 @@ class PersistableBundle { * what should be used to check for equality. */ bool deepEquals(const PersistableBundle& rhs) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_isEqual(get(), rhs.get()); } else { return false; @@ -145,7 +148,7 @@ class PersistableBundle { inline std::string toString() const { if (!mPBundle) { return ""; - } else if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + } else if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { std::ostringstream os; os << "& vec) { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { // std::vector has no ::data(). int32_t num = vec.size(); if (num > 0) { @@ -219,7 +222,7 @@ class PersistableBundle { } void putIntVector(const std::string& key, const std::vector& vec) { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { int32_t num = vec.size(); if (num > 0) { APersistableBundle_putIntVector(mPBundle, key.c_str(), vec.data(), num); @@ -227,7 +230,7 @@ class PersistableBundle { } } void putLongVector(const std::string& key, const std::vector& vec) { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { int32_t num = vec.size(); if (num > 0) { APersistableBundle_putLongVector(mPBundle, key.c_str(), vec.data(), num); @@ -235,7 +238,7 @@ class PersistableBundle { } } void putDoubleVector(const std::string& key, const std::vector& vec) { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { int32_t num = vec.size(); if (num > 0) { APersistableBundle_putDoubleVector(mPBundle, key.c_str(), vec.data(), num); @@ -243,7 +246,7 @@ class PersistableBundle { } } void putStringVector(const std::string& key, const std::vector& vec) { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { int32_t num = vec.size(); if (num > 0) { char** inVec = (char**)malloc(num * sizeof(char*)); @@ -258,13 +261,13 @@ class PersistableBundle { } } void putPersistableBundle(const std::string& key, const PersistableBundle& pBundle) { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putPersistableBundle(mPBundle, key.c_str(), pBundle.mPBundle); } } bool getBoolean(const std::string& key, bool* _Nonnull val) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_getBoolean(mPBundle, key.c_str(), val); } else { return false; @@ -272,7 +275,7 @@ class PersistableBundle { } bool getInt(const std::string& key, int32_t* _Nonnull val) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_getInt(mPBundle, key.c_str(), val); } else { return false; @@ -280,7 +283,7 @@ class PersistableBundle { } bool getLong(const std::string& key, int64_t* _Nonnull val) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_getLong(mPBundle, key.c_str(), val); } else { return false; @@ -288,7 +291,7 @@ class PersistableBundle { } bool getDouble(const std::string& key, double* _Nonnull val) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_getDouble(mPBundle, key.c_str(), val); } else { return false; @@ -300,7 +303,7 @@ class PersistableBundle { } bool getString(const std::string& key, std::string* _Nonnull val) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { char* outString = nullptr; bool ret = APersistableBundle_getString(mPBundle, key.c_str(), &outString, &stringAllocator, nullptr); @@ -318,7 +321,7 @@ class PersistableBundle { const char* _Nonnull, T* _Nullable, int32_t), const APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, std::vector* _Nonnull vec) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { int32_t bytes = 0; // call first with nullptr to get required size in bytes bytes = getVec(pBundle, key, nullptr, 0); @@ -340,28 +343,28 @@ class PersistableBundle { } bool getBooleanVector(const std::string& key, std::vector* _Nonnull vec) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal(&APersistableBundle_getBooleanVector, mPBundle, key.c_str(), vec); } return false; } bool getIntVector(const std::string& key, std::vector* _Nonnull vec) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal(&APersistableBundle_getIntVector, mPBundle, key.c_str(), vec); } return false; } bool getLongVector(const std::string& key, std::vector* _Nonnull vec) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal(&APersistableBundle_getLongVector, mPBundle, key.c_str(), vec); } return false; } bool getDoubleVector(const std::string& key, std::vector* _Nonnull vec) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal(&APersistableBundle_getDoubleVector, mPBundle, key.c_str(), vec); } @@ -386,7 +389,7 @@ class PersistableBundle { } bool getStringVector(const std::string& key, std::vector* _Nonnull vec) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { int32_t bytes = APersistableBundle_getStringVector(mPBundle, key.c_str(), nullptr, 0, &stringAllocator, nullptr); if (bytes > 0) { @@ -403,7 +406,7 @@ class PersistableBundle { } bool getPersistableBundle(const std::string& key, PersistableBundle* _Nonnull val) const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle* bundle = nullptr; bool ret = APersistableBundle_getPersistableBundle(mPBundle, key.c_str(), &bundle); if (ret) { @@ -435,77 +438,77 @@ class PersistableBundle { } std::set getBooleanKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getBooleanKeys, mPBundle); } else { return {}; } } std::set getIntKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getIntKeys, mPBundle); } else { return {}; } } std::set getLongKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getLongKeys, mPBundle); } else { return {}; } } std::set getDoubleKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getDoubleKeys, mPBundle); } else { return {}; } } std::set getStringKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getStringKeys, mPBundle); } else { return {}; } } std::set getBooleanVectorKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getBooleanVectorKeys, mPBundle); } else { return {}; } } std::set getIntVectorKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getIntVectorKeys, mPBundle); } else { return {}; } } std::set getLongVectorKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getLongVectorKeys, mPBundle); } else { return {}; } } std::set getDoubleVectorKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getDoubleVectorKeys, mPBundle); } else { return {}; } } std::set getStringVectorKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getStringVectorKeys, mPBundle); } else { return {}; } } std::set getPersistableBundleKeys() const { - if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { + if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getKeys(&APersistableBundle_getPersistableBundleKeys, mPBundle); } else { return {}; diff --git a/libs/binder/trusty/ndk/include/android/llndk-versioning.h b/libs/binder/trusty/ndk/include/android/llndk-versioning.h new file mode 100644 index 0000000000..e955a34bdf --- /dev/null +++ b/libs/binder/trusty/ndk/include/android/llndk-versioning.h @@ -0,0 +1,19 @@ +/* + * 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. + */ +#pragma once + +// TODO(b/349936395): set to true for Trusty +#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) (false) -- cgit v1.2.3-59-g8ed1b From 0034aef56f2ece07055bb4955a32df389a0334bc Mon Sep 17 00:00:00 2001 From: "Priyanka Advani (xWF)" Date: Fri, 8 Nov 2024 17:37:24 +0000 Subject: Revert "Use __builtin_available guard" Revert submission 3334193-no-llndk-versioning Reason for revert: Droidmonitor created revert due to b/378038995. Will be verifying through ABTD before submission. Reverted changes: /q/submissionid:3334193-no-llndk-versioning Change-Id: I7c8262a79fe1f85f1f225a5421aab6126dc76175 --- libs/ui/Gralloc5.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libs') diff --git a/libs/ui/Gralloc5.cpp b/libs/ui/Gralloc5.cpp index 2143f79f11..c9ec036186 100644 --- a/libs/ui/Gralloc5.cpp +++ b/libs/ui/Gralloc5.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -90,7 +91,7 @@ static void *loadIMapperLibrary() { } void* so = nullptr; - if (__builtin_available(android __ANDROID_API_V__, *)) { + if API_LEVEL_AT_LEAST (__ANDROID_API_V__, 202404) { so = AServiceManager_openDeclaredPassthroughHal("mapper", mapperSuffix.c_str(), RTLD_LOCAL | RTLD_NOW); } else { -- cgit v1.2.3-59-g8ed1b