Loading libs/binder/ndk/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ cc_library { llndk: { symbol_file: "libbinder_ndk.map.txt", export_llndk_headers: ["libvendorsupport_llndk_headers"], }, cflags: [ Loading Loading @@ -109,9 +110,11 @@ cc_library { ], header_libs: [ "libvendorsupport_llndk_headers", "jni_headers", ], export_header_lib_headers: [ "libvendorsupport_llndk_headers", "jni_headers", ], Loading libs/binder/ndk/include_cpp/android/binder_interface_utils.h +10 −7 Original line number Diff line number Diff line Loading @@ -30,14 +30,16 @@ #include <android/binder_auto_utils.h> #include <android/binder_ibinder.h> #if defined(__ANDROID_VENDOR_API__) #include <android/llndk-versioning.h> #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(<android/binder_shell.h>) #include <android/binder_shell.h> Loading Loading @@ -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); } Loading libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h +52 −49 Original line number Diff line number Diff line Loading @@ -22,14 +22,17 @@ #include <set> #include <sstream> // Include llndk-versioning.h only for non-system build as it is not available for NDK headers. #if defined(__ANDROID_VENDOR_API__) #include <android/llndk-versioning.h> #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 { Loading @@ -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(); } } Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading Loading @@ -145,7 +148,7 @@ class PersistableBundle { inline std::string toString() const { if (!mPBundle) { return "<PersistableBundle: null>"; } else if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { } else if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { std::ostringstream os; os << "<PersistableBundle: "; os << "size: " << std::to_string(APersistableBundle_size(mPBundle)); Loading @@ -156,7 +159,7 @@ class PersistableBundle { } int32_t size() const { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_size(mPBundle); } else { return 0; Loading @@ -164,7 +167,7 @@ class PersistableBundle { } int32_t erase(const std::string& key) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_erase(mPBundle, key.c_str()); } else { return 0; Loading @@ -172,37 +175,37 @@ class PersistableBundle { } void putBoolean(const std::string& key, bool val) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putBoolean(mPBundle, key.c_str(), val); } } void putInt(const std::string& key, int32_t val) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putInt(mPBundle, key.c_str(), val); } } void putLong(const std::string& key, int64_t val) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putLong(mPBundle, key.c_str(), val); } } void putDouble(const std::string& key, double val) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putDouble(mPBundle, key.c_str(), val); } } void putString(const std::string& key, const std::string& val) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putString(mPBundle, key.c_str(), val.c_str()); } } void putBooleanVector(const std::string& key, const std::vector<bool>& vec) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { // std::vector<bool> has no ::data(). int32_t num = vec.size(); if (num > 0) { Loading @@ -219,7 +222,7 @@ class PersistableBundle { } void putIntVector(const std::string& key, const std::vector<int32_t>& 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); Loading @@ -227,7 +230,7 @@ class PersistableBundle { } } void putLongVector(const std::string& key, const std::vector<int64_t>& 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); Loading @@ -235,7 +238,7 @@ class PersistableBundle { } } void putDoubleVector(const std::string& key, const std::vector<double>& 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); Loading @@ -243,7 +246,7 @@ class PersistableBundle { } } void putStringVector(const std::string& key, const std::vector<std::string>& 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*)); Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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); Loading @@ -318,7 +321,7 @@ class PersistableBundle { const char* _Nonnull, T* _Nullable, int32_t), const APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, std::vector<T>* _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); Loading @@ -340,28 +343,28 @@ class PersistableBundle { } bool getBooleanVector(const std::string& key, std::vector<bool>* _Nonnull vec) const { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal<bool>(&APersistableBundle_getBooleanVector, mPBundle, key.c_str(), vec); } return false; } bool getIntVector(const std::string& key, std::vector<int32_t>* _Nonnull vec) const { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal<int32_t>(&APersistableBundle_getIntVector, mPBundle, key.c_str(), vec); } return false; } bool getLongVector(const std::string& key, std::vector<int64_t>* _Nonnull vec) const { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal<int64_t>(&APersistableBundle_getLongVector, mPBundle, key.c_str(), vec); } return false; } bool getDoubleVector(const std::string& key, std::vector<double>* _Nonnull vec) const { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal<double>(&APersistableBundle_getDoubleVector, mPBundle, key.c_str(), vec); } Loading @@ -386,7 +389,7 @@ class PersistableBundle { } bool getStringVector(const std::string& key, std::vector<std::string>* _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) { Loading @@ -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) { Loading Loading @@ -435,77 +438,77 @@ class PersistableBundle { } std::set<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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 {}; Loading libs/binder/trusty/ndk/include/android/llndk-versioning.h 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * 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) libs/ui/Gralloc5.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <aidlcommonsupport/NativeHandle.h> #include <android/binder_manager.h> #include <android/hardware/graphics/mapper/utils/IMapperMetadataTypes.h> #include <android/llndk-versioning.h> #include <binder/IPCThreadState.h> #include <dlfcn.h> #include <ui/FatVector.h> Loading Loading @@ -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 { Loading Loading
libs/binder/ndk/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ cc_library { llndk: { symbol_file: "libbinder_ndk.map.txt", export_llndk_headers: ["libvendorsupport_llndk_headers"], }, cflags: [ Loading Loading @@ -109,9 +110,11 @@ cc_library { ], header_libs: [ "libvendorsupport_llndk_headers", "jni_headers", ], export_header_lib_headers: [ "libvendorsupport_llndk_headers", "jni_headers", ], Loading
libs/binder/ndk/include_cpp/android/binder_interface_utils.h +10 −7 Original line number Diff line number Diff line Loading @@ -30,14 +30,16 @@ #include <android/binder_auto_utils.h> #include <android/binder_ibinder.h> #if defined(__ANDROID_VENDOR_API__) #include <android/llndk-versioning.h> #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(<android/binder_shell.h>) #include <android/binder_shell.h> Loading Loading @@ -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); } Loading
libs/binder/ndk/include_cpp/android/persistable_bundle_aidl.h +52 −49 Original line number Diff line number Diff line Loading @@ -22,14 +22,17 @@ #include <set> #include <sstream> // Include llndk-versioning.h only for non-system build as it is not available for NDK headers. #if defined(__ANDROID_VENDOR_API__) #include <android/llndk-versioning.h> #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 { Loading @@ -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(); } } Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading Loading @@ -145,7 +148,7 @@ class PersistableBundle { inline std::string toString() const { if (!mPBundle) { return "<PersistableBundle: null>"; } else if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { } else if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { std::ostringstream os; os << "<PersistableBundle: "; os << "size: " << std::to_string(APersistableBundle_size(mPBundle)); Loading @@ -156,7 +159,7 @@ class PersistableBundle { } int32_t size() const { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_size(mPBundle); } else { return 0; Loading @@ -164,7 +167,7 @@ class PersistableBundle { } int32_t erase(const std::string& key) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return APersistableBundle_erase(mPBundle, key.c_str()); } else { return 0; Loading @@ -172,37 +175,37 @@ class PersistableBundle { } void putBoolean(const std::string& key, bool val) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putBoolean(mPBundle, key.c_str(), val); } } void putInt(const std::string& key, int32_t val) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putInt(mPBundle, key.c_str(), val); } } void putLong(const std::string& key, int64_t val) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putLong(mPBundle, key.c_str(), val); } } void putDouble(const std::string& key, double val) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putDouble(mPBundle, key.c_str(), val); } } void putString(const std::string& key, const std::string& val) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { APersistableBundle_putString(mPBundle, key.c_str(), val.c_str()); } } void putBooleanVector(const std::string& key, const std::vector<bool>& vec) { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { // std::vector<bool> has no ::data(). int32_t num = vec.size(); if (num > 0) { Loading @@ -219,7 +222,7 @@ class PersistableBundle { } void putIntVector(const std::string& key, const std::vector<int32_t>& 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); Loading @@ -227,7 +230,7 @@ class PersistableBundle { } } void putLongVector(const std::string& key, const std::vector<int64_t>& 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); Loading @@ -235,7 +238,7 @@ class PersistableBundle { } } void putDoubleVector(const std::string& key, const std::vector<double>& 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); Loading @@ -243,7 +246,7 @@ class PersistableBundle { } } void putStringVector(const std::string& key, const std::vector<std::string>& 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*)); Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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); Loading @@ -318,7 +321,7 @@ class PersistableBundle { const char* _Nonnull, T* _Nullable, int32_t), const APersistableBundle* _Nonnull pBundle, const char* _Nonnull key, std::vector<T>* _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); Loading @@ -340,28 +343,28 @@ class PersistableBundle { } bool getBooleanVector(const std::string& key, std::vector<bool>* _Nonnull vec) const { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal<bool>(&APersistableBundle_getBooleanVector, mPBundle, key.c_str(), vec); } return false; } bool getIntVector(const std::string& key, std::vector<int32_t>* _Nonnull vec) const { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal<int32_t>(&APersistableBundle_getIntVector, mPBundle, key.c_str(), vec); } return false; } bool getLongVector(const std::string& key, std::vector<int64_t>* _Nonnull vec) const { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal<int64_t>(&APersistableBundle_getLongVector, mPBundle, key.c_str(), vec); } return false; } bool getDoubleVector(const std::string& key, std::vector<double>* _Nonnull vec) const { if (API_LEVEL_AT_LEAST(__ANDROID_API_V__)) { if API_LEVEL_AT_LEAST(__ANDROID_API_V__, 202404) { return getVecInternal<double>(&APersistableBundle_getDoubleVector, mPBundle, key.c_str(), vec); } Loading @@ -386,7 +389,7 @@ class PersistableBundle { } bool getStringVector(const std::string& key, std::vector<std::string>* _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) { Loading @@ -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) { Loading Loading @@ -435,77 +438,77 @@ class PersistableBundle { } std::set<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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 {}; Loading
libs/binder/trusty/ndk/include/android/llndk-versioning.h 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * 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)
libs/ui/Gralloc5.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <aidlcommonsupport/NativeHandle.h> #include <android/binder_manager.h> #include <android/hardware/graphics/mapper/utils/IMapperMetadataTypes.h> #include <android/llndk-versioning.h> #include <binder/IPCThreadState.h> #include <dlfcn.h> #include <ui/FatVector.h> Loading Loading @@ -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 { Loading