From 0e88d61de00152c16586b7cca8765c7ac3bc34d5 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Thu, 23 Jan 2020 13:28:36 +0900 Subject: [PATCH 001/117] Use optional for nullable types AIDL generates optional for nullable T types for C++, which is more efficient and idomatic and easy to use. Bug: 144773267 Test: build/flash/boot Change-Id: I6bf4c2017f113f4d326fddb1d76163c2fed34d50 --- gatekeeperd/gatekeeperd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gatekeeperd/gatekeeperd.cpp b/gatekeeperd/gatekeeperd.cpp index 1d65b1ced..c81a80ef3 100644 --- a/gatekeeperd/gatekeeperd.cpp +++ b/gatekeeperd/gatekeeperd.cpp @@ -159,8 +159,8 @@ public: #define GK_ERROR *gkResponse = GKResponse::error(), Status::ok() - Status enroll(int32_t uid, const std::unique_ptr>& currentPasswordHandle, - const std::unique_ptr>& currentPassword, + Status enroll(int32_t uid, const std::optional>& currentPasswordHandle, + const std::optional>& currentPassword, const std::vector& desiredPassword, GKResponse* gkResponse) override { IPCThreadState* ipc = IPCThreadState::self(); const int calling_pid = ipc->getCallingPid(); From edd38f5a7f34ee22cae6636959aeb96d580e5fa3 Mon Sep 17 00:00:00 2001 From: Alessio Balsini Date: Tue, 21 Jan 2020 18:38:34 +0000 Subject: [PATCH 002/117] snapshotctl: init reports merge statistics Enable the --report flag in init rc script to collect and send snapshot merge statistics after OTA. Bug: 138817833 Bug: 148138124 Test: statsd_testdrive Change-Id: Ie32a2c6d7d1671ca2b1846c6a8d33cea2ab22a4c Signed-off-by: Alessio Balsini --- fs_mgr/libsnapshot/snapshotctl.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs_mgr/libsnapshot/snapshotctl.rc b/fs_mgr/libsnapshot/snapshotctl.rc index 5dbe35255..ccb2c410b 100644 --- a/fs_mgr/libsnapshot/snapshotctl.rc +++ b/fs_mgr/libsnapshot/snapshotctl.rc @@ -1,2 +1,2 @@ on property:sys.boot_completed=1 - exec_background - root root -- /system/bin/snapshotctl merge --logcat --log-to-file + exec_background - root root -- /system/bin/snapshotctl merge --logcat --log-to-file --report From cab9854fa91b4721eef4d4a549f702f73b7edd8a Mon Sep 17 00:00:00 2001 From: Luke Huang Date: Tue, 18 Feb 2020 15:53:44 +0800 Subject: [PATCH 003/117] Use libbase to get the elapsed time instead of libutils To minimize the external library dependencies Bug: 149721367 Test: atest Change-Id: I7b79223ad58c2af94d01a35ad39be6cdd1de7f47 --- libstats/push_compat/Android.bp | 1 - libstats/push_compat/StatsEventCompat.cpp | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libstats/push_compat/Android.bp b/libstats/push_compat/Android.bp index 3e695567a..4de95dc0d 100644 --- a/libstats/push_compat/Android.bp +++ b/libstats/push_compat/Android.bp @@ -36,7 +36,6 @@ cc_defaults { static_libs: [ "libbase", "liblog", - "libutils", ], } diff --git a/libstats/push_compat/StatsEventCompat.cpp b/libstats/push_compat/StatsEventCompat.cpp index de458b3e5..b065af21c 100644 --- a/libstats/push_compat/StatsEventCompat.cpp +++ b/libstats/push_compat/StatsEventCompat.cpp @@ -15,12 +15,16 @@ */ #include "include/StatsEventCompat.h" + +#include + +#include #include #include #include #include -#include +using android::base::boot_clock; using android::base::GetProperty; const static int kStatsEventTag = 1937006964; @@ -41,6 +45,12 @@ bool StatsEventCompat::mAttemptedLoad = false; void* StatsEventCompat::mStatsEventApi = nullptr; std::mutex StatsEventCompat::mLoadLock; +static int64_t elapsedRealtimeNano() { + return std::chrono::time_point_cast(boot_clock::now()) + .time_since_epoch() + .count(); +} + StatsEventCompat::StatsEventCompat() : mEventQ(kStatsEventTag) { // guard loading because StatsEventCompat might be called from multithreaded // environment @@ -61,7 +71,7 @@ StatsEventCompat::StatsEventCompat() : mEventQ(kStatsEventTag) { if (mStatsEventApi) { // mEventR = mStatsEventApi->obtain(); } else if (!mPlatformAtLeastR) { - mEventQ << android::elapsedRealtimeNano(); + mEventQ << elapsedRealtimeNano(); } } From 9848eb4f1c6780c0cfb253417d7542663421fb7e Mon Sep 17 00:00:00 2001 From: Ruchir Rastogi Date: Wed, 19 Feb 2020 16:31:13 -0800 Subject: [PATCH 004/117] Use dlsym to load libstatssocket API Also fixes a bug in the tests where the platform version was being checked by querying version.release instead of version.codename (currently, version.release == 10, while version.codename == R). Test: bit libstatspush_compat_test:* (on Q and R) Test: libsstatssocket.so is not placed in resolv apex (on R) 1|bonito:/ $ ls apex/com.android.resolv/lib64 libclang_rt.ubsan_standalone-aarch64-android.so libcrypto.so libnetd_resolv.so libssl.so Test: NETWORK_DNS_EVENT_REPORTED atom is logged to statsd (on R) - adb shell cmd stats print-stats (atom 116 count > 0) Bug: 148743333 Change-Id: Ib3eaa32835905bcf6e3b003054bf0f3c4e7ec0a4 --- libstats/push_compat/StatsEventCompat.cpp | 135 +++++++++++------- .../push_compat/include/StatsEventCompat.h | 28 +++- .../tests/StatsEventCompat_test.cpp | 4 +- 3 files changed, 111 insertions(+), 56 deletions(-) diff --git a/libstats/push_compat/StatsEventCompat.cpp b/libstats/push_compat/StatsEventCompat.cpp index b065af21c..e1a86ae1a 100644 --- a/libstats/push_compat/StatsEventCompat.cpp +++ b/libstats/push_compat/StatsEventCompat.cpp @@ -40,10 +40,10 @@ const bool StatsEventCompat::mPlatformAtLeastR = GetProperty("ro.build.version.codename", "") == "R" || android_get_device_api_level() > __ANDROID_API_Q__; -// definitions of static class variables +// initializations of static class variables bool StatsEventCompat::mAttemptedLoad = false; -void* StatsEventCompat::mStatsEventApi = nullptr; std::mutex StatsEventCompat::mLoadLock; +AStatsEventApi StatsEventCompat::mAStatsEventApi; static int64_t elapsedRealtimeNano() { return std::chrono::time_point_cast(boot_clock::now()) @@ -56,11 +56,10 @@ StatsEventCompat::StatsEventCompat() : mEventQ(kStatsEventTag) { // environment { std::lock_guard lg(mLoadLock); - if (!mAttemptedLoad) { + if (!mAttemptedLoad && mPlatformAtLeastR) { void* handle = dlopen("libstatssocket.so", RTLD_NOW); if (handle) { - // mStatsEventApi = (struct AStatsEvent_apiTable*)dlsym(handle, - // "table"); + initializeApiTableLocked(handle); } else { ALOGE("dlopen failed: %s\n", dlerror()); } @@ -68,61 +67,93 @@ StatsEventCompat::StatsEventCompat() : mEventQ(kStatsEventTag) { mAttemptedLoad = true; } - if (mStatsEventApi) { - // mEventR = mStatsEventApi->obtain(); - } else if (!mPlatformAtLeastR) { + if (useRSchema()) { + mEventR = mAStatsEventApi.obtain(); + } else if (useQSchema()) { mEventQ << elapsedRealtimeNano(); } } StatsEventCompat::~StatsEventCompat() { - // if (mStatsEventApi) mStatsEventApi->release(mEventR); + if (useRSchema()) mAStatsEventApi.release(mEventR); +} + +// Populates the AStatsEventApi struct by calling dlsym to find the address of +// each API function. +void StatsEventCompat::initializeApiTableLocked(void* handle) { + mAStatsEventApi.obtain = (AStatsEvent* (*)())dlsym(handle, "AStatsEvent_obtain"); + mAStatsEventApi.build = (void (*)(AStatsEvent*))dlsym(handle, "AStatsEvent_build"); + mAStatsEventApi.write = (int (*)(AStatsEvent*))dlsym(handle, "AStatsEvent_write"); + mAStatsEventApi.release = (void (*)(AStatsEvent*))dlsym(handle, "AStatsEvent_release"); + mAStatsEventApi.setAtomId = + (void (*)(AStatsEvent*, uint32_t))dlsym(handle, "AStatsEvent_setAtomId"); + mAStatsEventApi.writeInt32 = + (void (*)(AStatsEvent*, int32_t))dlsym(handle, "AStatsEvent_writeInt32"); + mAStatsEventApi.writeInt64 = + (void (*)(AStatsEvent*, int64_t))dlsym(handle, "AStatsEvent_writeInt64"); + mAStatsEventApi.writeFloat = + (void (*)(AStatsEvent*, float))dlsym(handle, "AStatsEvent_writeFloat"); + mAStatsEventApi.writeBool = + (void (*)(AStatsEvent*, bool))dlsym(handle, "AStatsEvent_writeBool"); + mAStatsEventApi.writeByteArray = (void (*)(AStatsEvent*, const uint8_t*, size_t))dlsym( + handle, "AStatsEvent_writeByteArray"); + mAStatsEventApi.writeString = + (void (*)(AStatsEvent*, const char*))dlsym(handle, "AStatsEvent_writeString"); + mAStatsEventApi.writeAttributionChain = + (void (*)(AStatsEvent*, const uint32_t*, const char* const*, uint8_t))dlsym( + handle, "AStatsEvent_writeAttributionChain"); + mAStatsEventApi.addBoolAnnotation = + (void (*)(AStatsEvent*, uint8_t, bool))dlsym(handle, "AStatsEvent_addBoolAnnotation"); + mAStatsEventApi.addInt32Annotation = (void (*)(AStatsEvent*, uint8_t, int32_t))dlsym( + handle, "AStatsEvent_addInt32Annotation"); + + mAStatsEventApi.initialized = true; } void StatsEventCompat::setAtomId(int32_t atomId) { - if (mStatsEventApi) { - // mStatsEventApi->setAtomId(mEventR, (uint32_t)atomId); - } else if (!mPlatformAtLeastR) { + if (useRSchema()) { + mAStatsEventApi.setAtomId(mEventR, (uint32_t)atomId); + } else if (useQSchema()) { mEventQ << atomId; } } void StatsEventCompat::writeInt32(int32_t value) { - if (mStatsEventApi) { - // mStatsEventApi->writeInt32(mEventR, value); - } else if (!mPlatformAtLeastR) { + if (useRSchema()) { + mAStatsEventApi.writeInt32(mEventR, value); + } else if (useQSchema()) { mEventQ << value; } } void StatsEventCompat::writeInt64(int64_t value) { - if (mStatsEventApi) { - // mStatsEventApi->writeInt64(mEventR, value); - } else if (!mPlatformAtLeastR) { + if (useRSchema()) { + mAStatsEventApi.writeInt64(mEventR, value); + } else if (useQSchema()) { mEventQ << value; } } void StatsEventCompat::writeFloat(float value) { - if (mStatsEventApi) { - // mStatsEventApi->writeFloat(mEventR, value); - } else if (!mPlatformAtLeastR) { + if (useRSchema()) { + mAStatsEventApi.writeFloat(mEventR, value); + } else if (useQSchema()) { mEventQ << value; } } void StatsEventCompat::writeBool(bool value) { - if (mStatsEventApi) { - // mStatsEventApi->writeBool(mEventR, value); - } else if (!mPlatformAtLeastR) { + if (useRSchema()) { + mAStatsEventApi.writeBool(mEventR, value); + } else if (useQSchema()) { mEventQ << value; } } void StatsEventCompat::writeByteArray(const char* buffer, size_t length) { - if (mStatsEventApi) { - // mStatsEventApi->writeByteArray(mEventR, (const uint8_t*)buffer, length); - } else if (!mPlatformAtLeastR) { + if (useRSchema()) { + mAStatsEventApi.writeByteArray(mEventR, reinterpret_cast(buffer), length); + } else if (useQSchema()) { mEventQ.AppendCharArray(buffer, length); } } @@ -130,19 +161,19 @@ void StatsEventCompat::writeByteArray(const char* buffer, size_t length) { void StatsEventCompat::writeString(const char* value) { if (value == nullptr) value = ""; - if (mStatsEventApi) { - // mStatsEventApi->writeString(mEventR, value); - } else if (!mPlatformAtLeastR) { + if (useRSchema()) { + mAStatsEventApi.writeString(mEventR, value); + } else if (useQSchema()) { mEventQ << value; } } void StatsEventCompat::writeAttributionChain(const int32_t* uids, size_t numUids, const vector& tags) { - if (mStatsEventApi) { - // mStatsEventApi->writeAttributionChain(mEventR, (const uint32_t*)uids, tags.data(), - // (uint8_t)numUids); - } else if (!mPlatformAtLeastR) { + if (useRSchema()) { + mAStatsEventApi.writeAttributionChain(mEventR, (const uint32_t*)uids, tags.data(), + (uint8_t)numUids); + } else if (useQSchema()) { mEventQ.begin(); for (size_t i = 0; i < numUids; i++) { mEventQ.begin(); @@ -159,8 +190,8 @@ void StatsEventCompat::writeKeyValuePairs(const map& int32Map, const map& int64Map, const map& stringMap, const map& floatMap) { - // Key value pairs are not supported with AStatsEvent. - if (!mPlatformAtLeastR) { + // AStatsEvent does not support key value pairs. + if (useQSchema()) { mEventQ.begin(); writeKeyValuePairMap(int32Map); writeKeyValuePairMap(int64Map); @@ -187,34 +218,36 @@ template void StatsEventCompat::writeKeyValuePairMap(const map(const map&); void StatsEventCompat::addBoolAnnotation(uint8_t annotationId, bool value) { - // Workaround for unused params. - (void)annotationId; - (void)value; - // if (mStatsEventApi) mStatsEventApi->addBoolAnnotation(mEventR, annotationId, value); + if (useRSchema()) { + mAStatsEventApi.addBoolAnnotation(mEventR, annotationId, value); + } // Don't do anything if on Q. } void StatsEventCompat::addInt32Annotation(uint8_t annotationId, int32_t value) { - // Workaround for unused params. - (void)annotationId; - (void)value; - // if (mStatsEventApi) mStatsEventApi->addInt32Annotation(mEventR, annotationId, value); + if (useRSchema()) { + mAStatsEventApi.addInt32Annotation(mEventR, annotationId, value); + } // Don't do anything if on Q. } int StatsEventCompat::writeToSocket() { - if (mStatsEventApi) { - // mStatsEventApi->build(mEventR); - // return mStatsEventApi->write(mEventR); + if (useRSchema()) { + mAStatsEventApi.build(mEventR); + return mAStatsEventApi.write(mEventR); } - if (!mPlatformAtLeastR) return mEventQ.write(LOG_ID_STATS); + if (useQSchema()) return mEventQ.write(LOG_ID_STATS); - // We reach here only if we're on R, but libstatspush_compat was unable to + // We reach here only if we're on R, but libstatssocket was unable to // be loaded using dlopen. return -ENOLINK; } -bool StatsEventCompat::usesNewSchema() { - return mStatsEventApi != nullptr; +bool StatsEventCompat::useRSchema() { + return mPlatformAtLeastR && mAStatsEventApi.initialized; +} + +bool StatsEventCompat::useQSchema() { + return !mPlatformAtLeastR; } diff --git a/libstats/push_compat/include/StatsEventCompat.h b/libstats/push_compat/include/StatsEventCompat.h index ad423a1c9..00bf48bf5 100644 --- a/libstats/push_compat/include/StatsEventCompat.h +++ b/libstats/push_compat/include/StatsEventCompat.h @@ -26,6 +26,26 @@ using std::map; using std::vector; +struct AStatsEventApi { + // Indicates whether the below function pointers have been set using dlsym. + bool initialized = false; + + AStatsEvent* (*obtain)(void); + void (*build)(AStatsEvent*); + int (*write)(AStatsEvent*); + void (*release)(AStatsEvent*); + void (*setAtomId)(AStatsEvent*, uint32_t); + void (*writeInt32)(AStatsEvent*, int32_t); + void (*writeInt64)(AStatsEvent*, int64_t); + void (*writeFloat)(AStatsEvent*, float); + void (*writeBool)(AStatsEvent*, bool); + void (*writeByteArray)(AStatsEvent*, const uint8_t*, size_t); + void (*writeString)(AStatsEvent*, const char*); + void (*writeAttributionChain)(AStatsEvent*, const uint32_t*, const char* const*, uint8_t); + void (*addBoolAnnotation)(AStatsEvent*, uint8_t, bool); + void (*addInt32Annotation)(AStatsEvent*, uint8_t, int32_t); +}; + class StatsEventCompat { public: StatsEventCompat(); @@ -57,8 +77,7 @@ class StatsEventCompat { const static bool mPlatformAtLeastR; static bool mAttemptedLoad; static std::mutex mLoadLock; - // static struct AStatsEvent_apiTable* mStatsEventApi; - static void* mStatsEventApi; + static AStatsEventApi mAStatsEventApi; // non-static member variables AStatsEvent* mEventR = nullptr; @@ -67,6 +86,9 @@ class StatsEventCompat { template void writeKeyValuePairMap(const map& keyValuePairMap); - bool usesNewSchema(); + void initializeApiTableLocked(void* handle); + bool useRSchema(); + bool useQSchema(); + FRIEND_TEST(StatsEventCompatTest, TestDynamicLoading); }; diff --git a/libstats/push_compat/tests/StatsEventCompat_test.cpp b/libstats/push_compat/tests/StatsEventCompat_test.cpp index 2be24ec10..dcb37973e 100644 --- a/libstats/push_compat/tests/StatsEventCompat_test.cpp +++ b/libstats/push_compat/tests/StatsEventCompat_test.cpp @@ -29,10 +29,10 @@ using android::base::GetProperty; * * TODO(b/146019024): migrate to android_get_device_api_level() */ -const static bool mPlatformAtLeastR = GetProperty("ro.build.version.release", "") == "R" || +const static bool mPlatformAtLeastR = GetProperty("ro.build.version.codename", "") == "R" || android_get_device_api_level() > __ANDROID_API_Q__; TEST(StatsEventCompatTest, TestDynamicLoading) { StatsEventCompat event; - EXPECT_EQ(mPlatformAtLeastR, event.usesNewSchema()); + EXPECT_EQ(mPlatformAtLeastR, event.useRSchema()); } From 7779c8e7c6fc9aa8a08896659f3b57c9525f44de Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 26 Feb 2020 14:59:08 -0800 Subject: [PATCH 005/117] libdm: Fix WaitForFile early-returning on failed accesses. WaitForFile/WaitForDeletedFile both early return true if an error like EPERM occurs. This was intentional because the code was modeled off earlier fs_mgr code, but it makes libdm inherently racy if sepolicy is not configured correctly. It's better to have these result in explicit and consistent failures. Bug: 148103327 Test: fastboot flashall Change-Id: I0c78818962e1db91b556e523c418db28f7d78fae --- fs_mgr/libdm/dm.cpp | 4 ++-- fs_mgr/libdm/utility.cpp | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs_mgr/libdm/dm.cpp b/fs_mgr/libdm/dm.cpp index 254fbed24..673e145f1 100644 --- a/fs_mgr/libdm/dm.cpp +++ b/fs_mgr/libdm/dm.cpp @@ -120,7 +120,7 @@ bool DeviceMapper::DeleteDevice(const std::string& name, return false; } if (!WaitForFileDeleted(unique_path, timeout_ms)) { - LOG(ERROR) << "Timeout out waiting for " << unique_path << " to be deleted"; + LOG(ERROR) << "Failed waiting for " << unique_path << " to be deleted"; return false; } return true; @@ -161,7 +161,7 @@ bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, s return true; } if (!WaitForFile(unique_path, timeout_ms)) { - LOG(ERROR) << "Timed out waiting for device path: " << unique_path; + LOG(ERROR) << "Failed waiting for device path: " << unique_path; DeleteDevice(name); return false; } diff --git a/fs_mgr/libdm/utility.cpp b/fs_mgr/libdm/utility.cpp index f252565fd..0eb59ab49 100644 --- a/fs_mgr/libdm/utility.cpp +++ b/fs_mgr/libdm/utility.cpp @@ -19,6 +19,8 @@ #include +#include + using namespace std::literals; namespace android { @@ -45,7 +47,11 @@ bool WaitForFile(const std::string& path, const std::chrono::milliseconds& timeo // If the file exists but returns EPERM or something, we consider the // condition met. if (access(path.c_str(), F_OK) != 0) { - if (errno == ENOENT) return WaitResult::Wait; + if (errno == ENOENT) { + return WaitResult::Wait; + } + PLOG(ERROR) << "access failed: " << path; + return WaitResult::Fail; } return WaitResult::Done; }; @@ -54,9 +60,13 @@ bool WaitForFile(const std::string& path, const std::chrono::milliseconds& timeo bool WaitForFileDeleted(const std::string& path, const std::chrono::milliseconds& timeout_ms) { auto condition = [&]() -> WaitResult { - if (access(path.c_str(), F_OK) == 0 || errno != ENOENT) { + if (access(path.c_str(), F_OK) == 0) { return WaitResult::Wait; } + if (errno != ENOENT) { + PLOG(ERROR) << "access failed: " << path; + return WaitResult::Fail; + } return WaitResult::Done; }; return WaitForCondition(condition, timeout_ms); From afc2cf0dec44fb7a65f418d0928b5c2c63bbc6cd Mon Sep 17 00:00:00 2001 From: Joshua Duong Date: Wed, 26 Feb 2020 15:43:44 -0800 Subject: [PATCH 006/117] Remove pairing_auth, pairing_connection from recovery. Also remove statically linking libc++, because these libraries are not exported native shared libraries. We are slightly over the 12MB limit for ramdisk recovery size, so let's remove the adb pairing libraries, since they won't be used in recovery mode. These are only used in normal boot mode, and currently, only by adb client. The pairing server is used by system server. Bug: 150317254 Test: Check size of ramdisk-recovery.img in walleye, walleye-hwasam build to be under 12MB. Also verify installed-files-recovery.txt no longer contains libadb_pairing*. Also put phone into recovery mode, check system/lib64 for no libadb_pairing*. Change-Id: Ida7c4fdc9dda2b09091b853feac8df8f125e4274 --- adb/Android.bp | 32 +++++++++++++++++++++++++++++-- adb/crypto/Android.bp | 2 -- adb/pairing_auth/Android.bp | 2 +- adb/pairing_connection/Android.bp | 4 ++-- adb/tls/Android.bp | 6 +----- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/adb/Android.bp b/adb/Android.bp index fea8c7807..af118f47d 100644 --- a/adb/Android.bp +++ b/adb/Android.bp @@ -418,6 +418,12 @@ cc_library_static { srcs: [ "daemon/usb_dummy.cpp", ] + }, + recovery: { + exclude_shared_libs: [ + "libadb_pairing_auth", + "libadb_pairing_connection", + ], } }, } @@ -477,6 +483,10 @@ cc_library_static { exclude_srcs: [ "daemon/abb_service.cpp", ], + exclude_shared_libs: [ + "libadb_pairing_auth", + "libadb_pairing_connection", + ], }, }, } @@ -512,6 +522,15 @@ cc_library { "libselinux", ], + target: { + recovery: { + exclude_shared_libs: [ + "libadb_pairing_auth", + "libadb_pairing_connection", + ], + } + }, + static_libs: [ "libadbd_services", "libcutils_sockets", @@ -544,6 +563,8 @@ cc_binary { }, static_libs: [ + "libadb_crypto", + "libadb_tls_connection", "libadbconnection_server", "libadbd", "libadbd_services", @@ -561,15 +582,22 @@ cc_binary { ], shared_libs: [ - "libadb_crypto", "libadb_pairing_connection", "libadb_protos", - "libadb_tls_connection", "libadbd_auth", "libadbd_fs", "libcrypto", ], + target: { + recovery: { + exclude_shared_libs: [ + "libadb_pairing_auth", + "libadb_pairing_connection", + ], + } + }, + required: [ "libadbd_auth", "libadbd_fs", diff --git a/adb/crypto/Android.bp b/adb/crypto/Android.bp index b7f75edd2..ce1de4a52 100644 --- a/adb/crypto/Android.bp +++ b/adb/crypto/Android.bp @@ -45,8 +45,6 @@ cc_defaults { host_supported: true, recovery_available: true, - stl: "libc++_static", - shared_libs: [ "libadb_protos", "libbase", diff --git a/adb/pairing_auth/Android.bp b/adb/pairing_auth/Android.bp index 0850047f7..a43f4d034 100644 --- a/adb/pairing_auth/Android.bp +++ b/adb/pairing_auth/Android.bp @@ -47,7 +47,7 @@ cc_defaults { use_version_lib: false, host_supported: true, - recovery_available: true, + recovery_available: false, stl: "libc++_static", diff --git a/adb/pairing_connection/Android.bp b/adb/pairing_connection/Android.bp index c05385475..bcde7b1f2 100644 --- a/adb/pairing_connection/Android.bp +++ b/adb/pairing_connection/Android.bp @@ -52,7 +52,7 @@ cc_defaults { stl: "libc++_static", host_supported: true, - recovery_available: true, + recovery_available: false, static_libs: [ "libbase", @@ -131,7 +131,7 @@ cc_defaults { ], host_supported: true, - recovery_available: true, + recovery_available: false, stl: "libc++_static", diff --git a/adb/tls/Android.bp b/adb/tls/Android.bp index 49833ff4a..f2837e11d 100644 --- a/adb/tls/Android.bp +++ b/adb/tls/Android.bp @@ -42,12 +42,8 @@ cc_defaults { "//system/core/adb:__subpackages__", ], - stl: "libc++_static", - - static_libs: [ - "libbase", - ], shared_libs: [ + "libbase", "libcrypto", "liblog", "libssl", From dd377ccefdcce044b855df0f368e259e469781cc Mon Sep 17 00:00:00 2001 From: Marissa Wall Date: Fri, 28 Feb 2020 10:51:56 -0800 Subject: [PATCH 007/117] libadf: delete libadf & libadfhwc libadf is a helper library for adf (android display framework) kernel drivers. The last Android Common Kernel to support adf was 4.4. Delete this helper library since we do not support any kernels that can use it. If a vendor needs this library, they can fork it. If you have any concerns, please contact adelva@google.com. Bug: 150467766 Test: Compiles Change-Id: Ib6e1ce2db016e97a165a59b28b9fab5e3ef8f255 --- deprecated-adf/OWNERS | 2 - deprecated-adf/libadf/Android.bp | 26 - deprecated-adf/libadf/adf.cpp | 746 ------------------ deprecated-adf/libadf/include/adf/adf.h | 295 ------- deprecated-adf/libadf/include/video/adf.h | 209 ----- .../original-kernel-headers/video/adf.h | 386 --------- deprecated-adf/libadf/tests/Android.bp | 23 - deprecated-adf/libadf/tests/adf_test.cpp | 403 ---------- deprecated-adf/libadfhwc/Android.bp | 29 - deprecated-adf/libadfhwc/adfhwc.cpp | 376 --------- .../libadfhwc/include/adfhwc/adfhwc.h | 140 ---- 11 files changed, 2635 deletions(-) delete mode 100644 deprecated-adf/OWNERS delete mode 100644 deprecated-adf/libadf/Android.bp delete mode 100644 deprecated-adf/libadf/adf.cpp delete mode 100644 deprecated-adf/libadf/include/adf/adf.h delete mode 100644 deprecated-adf/libadf/include/video/adf.h delete mode 100644 deprecated-adf/libadf/original-kernel-headers/video/adf.h delete mode 100644 deprecated-adf/libadf/tests/Android.bp delete mode 100644 deprecated-adf/libadf/tests/adf_test.cpp delete mode 100644 deprecated-adf/libadfhwc/Android.bp delete mode 100644 deprecated-adf/libadfhwc/adfhwc.cpp delete mode 100644 deprecated-adf/libadfhwc/include/adfhwc/adfhwc.h diff --git a/deprecated-adf/OWNERS b/deprecated-adf/OWNERS deleted file mode 100644 index 72b8b5a47..000000000 --- a/deprecated-adf/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -ghackmann@google.com -marissaw@google.com diff --git a/deprecated-adf/libadf/Android.bp b/deprecated-adf/libadf/Android.bp deleted file mode 100644 index 70f0a3ba0..000000000 --- a/deprecated-adf/libadf/Android.bp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2013 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. - -cc_library { - name: "libadf", - recovery_available: true, - vendor_available: true, - vndk: { - enabled: true, - }, - srcs: ["adf.cpp"], - cflags: ["-Werror"], - local_include_dirs: ["include"], - export_include_dirs: ["include"], -} diff --git a/deprecated-adf/libadf/adf.cpp b/deprecated-adf/libadf/adf.cpp deleted file mode 100644 index fd9c20895..000000000 --- a/deprecated-adf/libadf/adf.cpp +++ /dev/null @@ -1,746 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -#include - -#define ADF_BASE_PATH "/dev/" - -static ssize_t adf_id_vector_to_array(const std::vector &in, - adf_id_t **out) -{ - auto size = sizeof(in[0]) * in.size(); - // We can't use new[] since the existing API says the caller should free() - // the returned array - auto ret = static_cast(malloc(size)); - if (!ret) - return -ENOMEM; - - std::copy(in.begin(), in.end(), ret); - *out = ret; - return in.size(); -} - -static ssize_t adf_find_nodes(const char *pattern, adf_id_t **ids_out) -{ - struct dirent *dirent; - std::unique_ptr - dir{opendir(ADF_BASE_PATH), closedir}; - if (!dir) - return -errno; - - std::vector ids; - errno = 0; - while ((dirent = readdir(dir.get()))) { - adf_id_t id; - int matched = sscanf(dirent->d_name, pattern, &id); - - if (matched < 0) - return -errno; - else if (matched == 1) - ids.push_back(id); - } - if (errno) - return -errno; - - return adf_id_vector_to_array(ids, ids_out); -} - -ssize_t adf_devices(adf_id_t **ids) -{ - return adf_find_nodes("adf%u", ids); -} - -int adf_device_open(adf_id_t id, int flags, struct adf_device *dev) -{ - char filename[64]; - - dev->id = id; - - snprintf(filename, sizeof(filename), ADF_BASE_PATH "adf%u", id); - dev->fd = open(filename, flags); - if (dev->fd < 0) - return -errno; - - return 0; -} - -void adf_device_close(struct adf_device *dev) -{ - if (dev->fd >= 0) - close(dev->fd); -} - -int adf_get_device_data(struct adf_device *dev, struct adf_device_data *data) -{ - int err; - int ret = 0; - - memset(data, 0, sizeof(*data)); - - err = ioctl(dev->fd, ADF_GET_DEVICE_DATA, data); - if (err < 0) - return -ENOMEM; - - if (data->n_attachments) - data->attachments = new adf_attachment_config[data->n_attachments]; - - if (data->n_allowed_attachments) - data->allowed_attachments = - new adf_attachment_config[data->n_allowed_attachments]; - - if (data->custom_data_size) - data->custom_data = new char[data->custom_data_size]; - - err = ioctl(dev->fd, ADF_GET_DEVICE_DATA, data); - if (err < 0) { - ret = -errno; - adf_free_device_data(data); - } - return ret; -} - -void adf_free_device_data(struct adf_device_data *data) -{ - delete [] data->attachments; - data->attachments = nullptr; - delete [] data->allowed_attachments; - data->allowed_attachments = nullptr; - delete [] static_cast(data->custom_data); - data->custom_data = nullptr; -} - -int adf_device_post(struct adf_device *dev, - adf_id_t *interfaces, size_t n_interfaces, - struct adf_buffer_config *bufs, size_t n_bufs, - void *custom_data, size_t custom_data_size) -{ - int err; - struct adf_post_config data; - - memset(&data, 0, sizeof(data)); - data.interfaces = interfaces; - data.n_interfaces = n_interfaces; - data.bufs = bufs; - data.n_bufs = n_bufs; - data.custom_data = custom_data; - data.custom_data_size = custom_data_size; - - err = ioctl(dev->fd, ADF_POST_CONFIG, &data); - if (err < 0) - return -errno; - - return (int)data.complete_fence; -} - -int adf_device_post_v2(struct adf_device *dev, - adf_id_t *interfaces, __u32 n_interfaces, - struct adf_buffer_config *bufs, __u32 n_bufs, - void *custom_data, __u64 custom_data_size, - enum adf_complete_fence_type complete_fence_type, - int *complete_fence) -{ - int err; - struct adf_post_config_v2 data; - - memset(&data, 0, sizeof(data)); - data.interfaces = (uintptr_t)interfaces; - data.n_interfaces = n_interfaces; - data.bufs = (uintptr_t)bufs; - data.n_bufs = n_bufs; - data.custom_data = (uintptr_t)custom_data; - data.custom_data_size = custom_data_size; - data.complete_fence_type = complete_fence_type; - - err = ioctl(dev->fd, ADF_POST_CONFIG_V2, &data); - if (err < 0) - return -errno; - - if (complete_fence) - *complete_fence = data.complete_fence; - else if (data.complete_fence >= 0) - close(data.complete_fence); - - return 0; -} - -static int adf_device_attachment(struct adf_device *dev, - adf_id_t overlay_engine, adf_id_t interface, bool attach) -{ - int err; - struct adf_attachment_config data; - - memset(&data, 0, sizeof(data)); - data.overlay_engine = overlay_engine; - data.interface = interface; - - err = ioctl(dev->fd, attach ? ADF_ATTACH : ADF_DETACH, &data); - if (err < 0) - return -errno; - - return 0; -} - -int adf_device_attach(struct adf_device *dev, adf_id_t overlay_engine, - adf_id_t interface) -{ - return adf_device_attachment(dev, overlay_engine, interface, true); -} - -int adf_device_detach(struct adf_device *dev, adf_id_t overlay_engine, - adf_id_t interface) -{ - return adf_device_attachment(dev, overlay_engine, interface, false); -} - -ssize_t adf_interfaces(struct adf_device *dev, adf_id_t **interfaces) -{ - char pattern[64]; - - snprintf(pattern, sizeof(pattern), "adf-interface%u.%%u", dev->id); - return adf_find_nodes(pattern, interfaces); -} - -ssize_t adf_interfaces_for_overlay_engine(struct adf_device *dev, - adf_id_t overlay_engine, adf_id_t **interfaces) -{ - struct adf_device_data data; - auto err = adf_get_device_data(dev, &data); - if (err < 0) - return err; - - std::vector ids; - if (data.allowed_attachments != nullptr) - for (size_t i = 0; i < data.n_allowed_attachments; i++) - if (data.allowed_attachments[i].overlay_engine == overlay_engine) - ids.push_back(data.allowed_attachments[i].interface); - - adf_free_device_data(&data); - return adf_id_vector_to_array(ids, interfaces); -} - -static ssize_t adf_interfaces_filter(struct adf_device *dev, - adf_id_t *in, size_t n_in, adf_id_t **out, - bool (*filter)(struct adf_interface_data *data, __u32 match), - __u32 match) -{ - std::vector ids; - for (size_t i = 0; i < n_in; i++) { - int fd = adf_interface_open(dev, in[i], O_RDONLY); - if (fd < 0) - return fd; - - struct adf_interface_data data; - auto ret = adf_get_interface_data(fd, &data); - close(fd); - if (ret < 0) - return ret; - - if (filter(&data, match)) - ids.push_back(in[i]); - } - - return adf_id_vector_to_array(ids, out); -} - -static bool adf_interface_type_filter(struct adf_interface_data *data, - __u32 type) -{ - return data->type == (enum adf_interface_type)type; -} - -ssize_t adf_interfaces_filter_by_type(struct adf_device *dev, - enum adf_interface_type type, - adf_id_t *in, size_t n_in, adf_id_t **out) -{ - return adf_interfaces_filter(dev, in, n_in, out, adf_interface_type_filter, - type); -} - -static bool adf_interface_flags_filter(struct adf_interface_data *data, - __u32 flag) -{ - return !!(data->flags & flag); -} - -ssize_t adf_interfaces_filter_by_flag(struct adf_device *dev, __u32 flag, - adf_id_t *in, size_t n_in, adf_id_t **out) -{ - return adf_interfaces_filter(dev, in, n_in, out, adf_interface_flags_filter, - flag); -} - -int adf_interface_open(struct adf_device *dev, adf_id_t id, int flags) -{ - char filename[64]; - - snprintf(filename, sizeof(filename), ADF_BASE_PATH "adf-interface%u.%u", - dev->id, id); - - int fd = open(filename, flags); - if (fd < 0) - return -errno; - return fd; -} - -int adf_get_interface_data(int fd, struct adf_interface_data *data) -{ - int err; - int ret = 0; - - memset(data, 0, sizeof(*data)); - - err = ioctl(fd, ADF_GET_INTERFACE_DATA, data); - if (err < 0) - return -errno; - - if (data->n_available_modes) - data->available_modes = new drm_mode_modeinfo[data->n_available_modes]; - - if (data->custom_data_size) - data->custom_data = new char[data->custom_data_size]; - - err = ioctl(fd, ADF_GET_INTERFACE_DATA, data); - if (err < 0) { - ret = -errno; - adf_free_interface_data(data); - } - return ret; -} - -void adf_free_interface_data(struct adf_interface_data *data) -{ - delete [] data->available_modes; - delete [] static_cast(data->custom_data); -} - -int adf_interface_blank(int fd, __u8 mode) -{ - int err = ioctl(fd, ADF_BLANK, mode); - if (err < 0) - return -errno; - return 0; -} - -int adf_interface_set_mode(int fd, struct drm_mode_modeinfo *mode) -{ - int err = ioctl(fd, ADF_SET_MODE, mode); - if (err < 0) - return -errno; - return 0; -} - -int adf_interface_simple_buffer_alloc(int fd, __u32 w, __u32 h, - __u32 format, __u32 *offset, __u32 *pitch) -{ - int err; - struct adf_simple_buffer_alloc data; - - memset(&data, 0, sizeof(data)); - data.w = w; - data.h = h; - data.format = format; - - err = ioctl(fd, ADF_SIMPLE_BUFFER_ALLOC, &data); - if (err < 0) - return -errno; - - *offset = data.offset; - *pitch = data.pitch; - return (int)data.fd; -} - -static void adf_interface_simple_post_config_buf(struct adf_buffer_config *buf, - __u32 overlay_engine, __u32 w, __u32 h, __u32 format, int buf_fd, - __u32 offset, __u32 pitch, int acquire_fence) -{ - buf->overlay_engine = overlay_engine; - buf->w = w; - buf->h = h; - buf->format = format; - buf->fd[0] = buf_fd; - buf->offset[0] = offset; - buf->pitch[0] = pitch; - buf->n_planes = 1; - buf->acquire_fence = acquire_fence; -} - -int adf_interface_simple_post(int fd, __u32 overlay_engine, - __u32 w, __u32 h, __u32 format, int buf_fd, __u32 offset, - __u32 pitch, int acquire_fence) -{ - int ret; - struct adf_simple_post_config data; - - memset(&data, 0, sizeof(data)); - adf_interface_simple_post_config_buf(&data.buf, overlay_engine, w, h, format, - buf_fd, offset, pitch, acquire_fence); - ret = ioctl(fd, ADF_SIMPLE_POST_CONFIG, &data); - if (ret < 0) - return -errno; - - return (int)data.complete_fence; -} - -int adf_interface_simple_post_v2(int fd, adf_id_t overlay_engine, - __u32 w, __u32 h, __u32 format, int buf_fd, __u32 offset, - __u32 pitch, int acquire_fence, - enum adf_complete_fence_type complete_fence_type, - int *complete_fence) -{ - int ret; - struct adf_simple_post_config_v2 data; - - memset(&data, 0, sizeof(data)); - adf_interface_simple_post_config_buf(&data.buf, overlay_engine, w, h, format, - buf_fd, offset, pitch, acquire_fence); - data.complete_fence_type = complete_fence_type; - - ret = ioctl(fd, ADF_SIMPLE_POST_CONFIG_V2, &data); - if (ret < 0) - return -errno; - - if (complete_fence) - *complete_fence = data.complete_fence; - else if (data.complete_fence >= 0) - close(data.complete_fence); - - return 0; -} - -ssize_t adf_overlay_engines(struct adf_device *dev, adf_id_t **overlay_engines) -{ - char pattern[64]; - - snprintf(pattern, sizeof(pattern), "adf-overlay-engine%u.%%u", dev->id); - return adf_find_nodes(pattern, overlay_engines); -} - -ssize_t adf_overlay_engines_for_interface(struct adf_device *dev, - adf_id_t interface, adf_id_t **overlay_engines) -{ - struct adf_device_data data; - auto err = adf_get_device_data(dev, &data); - if (err < 0) - return err; - - std::vector ids; - if (data.allowed_attachments != nullptr) - for (size_t i = 0; i < data.n_allowed_attachments; i++) - if (data.allowed_attachments[i].interface == interface) - ids.push_back(data.allowed_attachments[i].overlay_engine); - - return adf_id_vector_to_array(ids, overlay_engines); -} - -static ssize_t adf_overlay_engines_filter(struct adf_device *dev, - adf_id_t *in, size_t n_in, adf_id_t **out, - bool (*filter)(struct adf_overlay_engine_data *data, void *cookie), - void *cookie) -{ - std::vector ids; - size_t i; - for (i = 0; i < n_in; i++) { - int fd = adf_overlay_engine_open(dev, in[i], O_RDONLY); - if (fd < 0) - return fd; - - struct adf_overlay_engine_data data; - auto ret = adf_get_overlay_engine_data(fd, &data); - close(fd); - if (ret < 0) - return ret; - - if (filter(&data, cookie)) - ids.push_back(in[i]); - } - - return adf_id_vector_to_array(ids, out); -} - -struct format_filter_cookie { - const __u32 *formats; - size_t n_formats; -}; - -static bool adf_overlay_engine_format_filter( - struct adf_overlay_engine_data *data, void *cookie) -{ - auto c = static_cast(cookie); - size_t i; - for (i = 0; i < data->n_supported_formats; i++) { - size_t j; - for (j = 0; j < c->n_formats; j++) - if (data->supported_formats[i] == c->formats[j]) - return true; - } - return false; -} - -ssize_t adf_overlay_engines_filter_by_format(struct adf_device *dev, - const __u32 *formats, size_t n_formats, adf_id_t *in, size_t n_in, - adf_id_t **out) -{ - struct format_filter_cookie cookie = { formats, n_formats }; - return adf_overlay_engines_filter(dev, in, n_in, out, - adf_overlay_engine_format_filter, &cookie); -} - -int adf_overlay_engine_open(struct adf_device *dev, adf_id_t id, int flags) -{ - char filename[64]; - - snprintf(filename, sizeof(filename), - ADF_BASE_PATH "adf-overlay-engine%u.%u", dev->id, id); - - int fd = open(filename, flags); - if (fd < 0) - return -errno; - return fd; -} - -int adf_get_overlay_engine_data(int fd, struct adf_overlay_engine_data *data) -{ - int err; - int ret = 0; - - memset(data, 0, sizeof(*data)); - - err = ioctl(fd, ADF_GET_OVERLAY_ENGINE_DATA, data); - if (err < 0) - return -errno; - - if (data->n_supported_formats) - data->supported_formats = new __u32[data->n_supported_formats]; - - if (data->custom_data_size) - data->custom_data = new char[data->custom_data_size]; - - err = ioctl(fd, ADF_GET_OVERLAY_ENGINE_DATA, data); - if (err < 0) { - ret = -errno; - adf_free_overlay_engine_data(data); - } - return ret; -} - -void adf_free_overlay_engine_data(struct adf_overlay_engine_data *data) -{ - delete [] data->supported_formats; - data->supported_formats = nullptr; - delete [] static_cast(data->custom_data); - data->custom_data = nullptr; -} - -bool adf_overlay_engine_supports_format(int fd, __u32 format) -{ - struct adf_overlay_engine_data data; - bool ret = false; - size_t i; - - int err = adf_get_overlay_engine_data(fd, &data); - if (err < 0) - return false; - - if (data.supported_formats != nullptr) { - for (i = 0; i < data.n_supported_formats; i++) { - if (data.supported_formats[i] == format) { - ret = true; - break; - } - } - } - - adf_free_overlay_engine_data(&data); - return ret; -} - -int adf_set_event(int fd, enum adf_event_type type, bool enabled) -{ - struct adf_set_event data; - - data.type = type; - data.enabled = enabled; - - int err = ioctl(fd, ADF_SET_EVENT, &data); - if (err < 0) - return -errno; - return 0; -} - -int adf_read_event(int fd, struct adf_event **event) -{ - struct adf_event header; - struct event_with_data { - struct adf_event base; - uint8_t data[0]; - }; - using unique_event = std::unique_ptr; - size_t data_size; - - int err = read(fd, &header, sizeof(header)); - if (err < 0) - return -errno; - if ((size_t)err < sizeof(header)) - return -EIO; - if (header.length < sizeof(header)) - return -EIO; - - // Again, we can't use new[] since the existing API says the caller should - // free() the returned event - auto event_ptr = static_cast(malloc(header.length)); - unique_event event_ret{event_ptr, free}; - if (!event_ret) - return -ENOMEM; - data_size = header.length - sizeof(header); - - memcpy(event_ret.get(), &header, sizeof(header)); - ssize_t read_size = read(fd, &event_ret->data, data_size); - if (read_size < 0) - return -errno; - if ((size_t)read_size < data_size) - return -EIO; - - *event = &event_ret.release()->base; - return 0; -} - -void adf_format_str(__u32 format, char buf[ADF_FORMAT_STR_SIZE]) -{ - buf[0] = format & 0xFF; - buf[1] = (format >> 8) & 0xFF; - buf[2] = (format >> 16) & 0xFF; - buf[3] = (format >> 24) & 0xFF; - buf[4] = '\0'; -} - -static bool adf_find_simple_post_overlay_engine(struct adf_device *dev, - const __u32 *formats, size_t n_formats, - adf_id_t interface, adf_id_t *overlay_engine) -{ - adf_id_t *engs = nullptr; - ssize_t n_engs = adf_overlay_engines_for_interface(dev, interface, &engs); - - if (engs == nullptr) - return false; - - adf_id_t *filtered_engs = nullptr; - ssize_t n_filtered_engs = adf_overlay_engines_filter_by_format(dev, - formats, n_formats, engs, n_engs, &filtered_engs); - free(engs); - - if (filtered_engs == nullptr) - return false; - - *overlay_engine = filtered_engs[0]; - free(filtered_engs); - return true; -} - -static const __u32 any_rgb_format[] = { - DRM_FORMAT_C8, - DRM_FORMAT_RGB332, - DRM_FORMAT_BGR233, - DRM_FORMAT_XRGB1555, - DRM_FORMAT_XBGR1555, - DRM_FORMAT_RGBX5551, - DRM_FORMAT_BGRX5551, - DRM_FORMAT_ARGB1555, - DRM_FORMAT_ABGR1555, - DRM_FORMAT_RGBA5551, - DRM_FORMAT_BGRA5551, - DRM_FORMAT_RGB565, - DRM_FORMAT_BGR565, - DRM_FORMAT_RGB888, - DRM_FORMAT_BGR888, - DRM_FORMAT_XRGB8888, - DRM_FORMAT_XBGR8888, - DRM_FORMAT_RGBX8888, - DRM_FORMAT_BGRX8888, - DRM_FORMAT_XRGB2101010, - DRM_FORMAT_XBGR2101010, - DRM_FORMAT_RGBX1010102, - DRM_FORMAT_BGRX1010102, - DRM_FORMAT_ARGB2101010, - DRM_FORMAT_ABGR2101010, - DRM_FORMAT_RGBA1010102, - DRM_FORMAT_BGRA1010102, - DRM_FORMAT_ARGB8888, - DRM_FORMAT_ABGR8888, - DRM_FORMAT_RGBA8888, - DRM_FORMAT_BGRA8888, -}; - -int adf_find_simple_post_configuration(struct adf_device *dev, - const __u32 *formats, size_t n_formats, - adf_id_t *interface, adf_id_t *overlay_engine) -{ - adf_id_t *intfs = NULL; - ssize_t n_intfs = adf_interfaces(dev, &intfs); - - if (n_intfs < 0) - return n_intfs; - else if (!intfs) - return -ENODEV; - - adf_id_t *primary_intfs = nullptr; - ssize_t n_primary_intfs = adf_interfaces_filter_by_flag(dev, - ADF_INTF_FLAG_PRIMARY, intfs, n_intfs, &primary_intfs); - free(intfs); - - if (n_primary_intfs < 0) - return n_primary_intfs; - else if (!primary_intfs) - return -ENODEV; - - if (!formats) { - formats = any_rgb_format; - n_formats = sizeof(any_rgb_format) / sizeof(any_rgb_format[0]); - } - - bool found = false; - ssize_t i = 0; - for (i = 0; i < n_primary_intfs; i++) { - found = adf_find_simple_post_overlay_engine(dev, formats, n_formats, - primary_intfs[i], overlay_engine); - if (found) { - *interface = primary_intfs[i]; - break; - } - } - free(primary_intfs); - - if (!found) - return -ENODEV; - - return 0; -} diff --git a/deprecated-adf/libadf/include/adf/adf.h b/deprecated-adf/libadf/include/adf/adf.h deleted file mode 100644 index e4c7b28cc..000000000 --- a/deprecated-adf/libadf/include/adf/adf.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef _LIBADF_ADF_H_ -#define _LIBADF_ADF_H_ - -#include -#include -#include -#include -#include