From 9e53281dc01f5fd9a32b27086a4cdebc258a2ad0 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Tue, 29 Aug 2023 15:04:50 +0000 Subject: [PATCH] Don't use String8 path functions [cas hidl] Ideally, we should migrate to std::filesystem, but libc++fs is not available for vendor binaries until b/175635923 lands. Bug: 295394788 Test: m checkbuild Change-Id: Ifaec2f93331c780b96f7be5d50655a79aa935457 --- cas/1.0/default/FactoryLoader.h | 5 +++-- cas/1.1/default/FactoryLoader.h | 5 +++-- cas/1.2/default/FactoryLoader.h | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cas/1.0/default/FactoryLoader.h b/cas/1.0/default/FactoryLoader.h index 45e515afbf..70b7fa7f76 100644 --- a/cas/1.0/default/FactoryLoader.h +++ b/cas/1.0/default/FactoryLoader.h @@ -17,6 +17,7 @@ #ifndef ANDROID_HARDWARE_CAS_V1_0_FACTORY_LOADER_H_ #define ANDROID_HARDWARE_CAS_V1_0_FACTORY_LOADER_H_ +#include #include #include #include "SharedLibrary.h" @@ -108,7 +109,7 @@ bool FactoryLoader::findFactoryForScheme( struct dirent* pEntry; while ((pEntry = readdir(pDir))) { String8 pluginPath = dirPath + "/" + pEntry->d_name; - if (pluginPath.getPathExtension() == ".so") { + if (base::EndsWith(pluginPath.c_str(), ".so")) { if (loadFactoryForSchemeFromPath( pluginPath, CA_system_id, library, factory)) { mCASystemIdToLibraryPathMap.add(CA_system_id, pluginPath); @@ -150,7 +151,7 @@ bool FactoryLoader::enumeratePlugins( struct dirent* pEntry; while ((pEntry = readdir(pDir))) { String8 pluginPath = dirPath + "/" + pEntry->d_name; - if (pluginPath.getPathExtension() == ".so") { + if (base::EndsWith(pluginPath.c_str(), ".so")) { queryPluginsFromPath(pluginPath, results); } } diff --git a/cas/1.1/default/FactoryLoader.h b/cas/1.1/default/FactoryLoader.h index 121f90c333..828f0c64c6 100644 --- a/cas/1.1/default/FactoryLoader.h +++ b/cas/1.1/default/FactoryLoader.h @@ -17,6 +17,7 @@ #ifndef ANDROID_HARDWARE_CAS_V1_1_FACTORY_LOADER_H_ #define ANDROID_HARDWARE_CAS_V1_1_FACTORY_LOADER_H_ +#include #include #include #include @@ -100,7 +101,7 @@ bool FactoryLoader::findFactoryForScheme(int32_t CA_system_id, spd_name; - if (pluginPath.getPathExtension() == ".so") { + if (base::EndsWith(pluginPath.c_str(), ".so")) { if (loadFactoryForSchemeFromPath(pluginPath, CA_system_id, library, factory)) { mCASystemIdToLibraryPathMap.add(CA_system_id, pluginPath); closedir(pDir); @@ -139,7 +140,7 @@ bool FactoryLoader::enumeratePlugins(vector* results struct dirent* pEntry; while ((pEntry = readdir(pDir))) { String8 pluginPath = dirPath + "/" + pEntry->d_name; - if (pluginPath.getPathExtension() == ".so") { + if (base::EndsWith(pluginPath.c_str(), ".so")) { queryPluginsFromPath(pluginPath, results); } } diff --git a/cas/1.2/default/FactoryLoader.h b/cas/1.2/default/FactoryLoader.h index a374b31891..ecc0b14a60 100644 --- a/cas/1.2/default/FactoryLoader.h +++ b/cas/1.2/default/FactoryLoader.h @@ -17,6 +17,7 @@ #ifndef ANDROID_HARDWARE_CAS_V1_1_FACTORY_LOADER_H_ #define ANDROID_HARDWARE_CAS_V1_1_FACTORY_LOADER_H_ +#include #include #include #include @@ -100,7 +101,7 @@ bool FactoryLoader::findFactoryForScheme(int32_t CA_system_id, spd_name; - if (pluginPath.getPathExtension() == ".so") { + if (base::EndsWith(pluginPath.c_str(), ".so")) { if (loadFactoryForSchemeFromPath(pluginPath, CA_system_id, library, factory)) { mCASystemIdToLibraryPathMap.add(CA_system_id, pluginPath); closedir(pDir); @@ -139,7 +140,7 @@ bool FactoryLoader::enumeratePlugins(vector* results struct dirent* pEntry; while ((pEntry = readdir(pDir))) { String8 pluginPath = dirPath + "/" + pEntry->d_name; - if (pluginPath.getPathExtension() == ".so") { + if (base::EndsWith(pluginPath.c_str(), ".so")) { queryPluginsFromPath(pluginPath, results); } }