Loading include/android/sharedmem.h +7 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ /** * @file sharedmem.h * @brief Shared memory buffers that can be shared across process. * @brief Shared memory buffers that can be shared between processes. */ #ifndef ANDROID_SHARED_MEMORY_H Loading Loading @@ -61,11 +61,15 @@ extern "C" { * * Use close() to release the shared memory region. * * Use {@link android.os.ParcelFileDescriptor} to pass the file descriptor to * another process. File descriptors may also be sent to other processes over a Unix domain * socket with sendmsg and SCM_RIGHTS. See sendmsg(3) and cmsg(3) man pages for more information. * * Available since API level 26. * * \param name an optional name. * \param size size of the shared memory region * \return file descriptor that denotes the shared memory; error code on failure. * \return file descriptor that denotes the shared memory; -1 and sets errno on failure, or -EINVAL if the error is that size was 0. */ int ASharedMemory_create(const char *name, size_t size) __INTRODUCED_IN(26); Loading Loading @@ -109,7 +113,7 @@ size_t ASharedMemory_getSize(int fd) __INTRODUCED_IN(26); * \param fd file descriptor of the shared memory region. * \param prot any bitwise-or'ed combination of PROT_READ, PROT_WRITE, PROT_EXEC denoting * updated access. Note access can only be removed, but not added back. * \return 0 for success, error code on failure. * \return 0 for success, -1 and sets errno on failure. */ int ASharedMemory_setProt(int fd, int prot) __INTRODUCED_IN(26); Loading libs/graphicsenv/GraphicsEnv.cpp +2 −6 Original line number Diff line number Diff line Loading @@ -124,12 +124,8 @@ static const std::string getSystemNativeLibraries(NativeLibrary type) { return env; } int GraphicsEnv::getCanLoadSystemLibraries() { if (property_get_bool("ro.debuggable", false) && prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)) { // Return an integer value since this crosses library boundaries return 1; } return 0; bool GraphicsEnv::isDebuggable() { return prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) > 0; } void GraphicsEnv::setDriverPathAndSphalLibraries(const std::string path, Loading libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +10 −2 Original line number Diff line number Diff line Loading @@ -33,8 +33,16 @@ class GraphicsEnv { public: static GraphicsEnv& getInstance(); // Check if device is debuggable. int getCanLoadSystemLibraries(); // Check if the process is debuggable. It returns false except in any of the // following circumstances: // 1. ro.debuggable=1 (global debuggable enabled). // 2. android:debuggable="true" in the manifest for an individual app. // 3. An app which explicitly calls prctl(PR_SET_DUMPABLE, 1). // 4. GraphicsEnv calls prctl(PR_SET_DUMPABLE, 1) in the presence of // <meta-data android:name="com.android.graphics.injectLayers.enable" // android:value="true"/> // in the application manifest. bool isDebuggable(); /* * Apis for updatable driver Loading opengl/libs/EGL/egl_layers.cpp +9 −13 Original line number Diff line number Diff line Loading @@ -337,7 +337,7 @@ void LayerLoader::LoadLayers() { // Only enable the system search path for non-user builds std::string system_path; if (property_get_bool("ro.debuggable", false) && prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)) { if (android::GraphicsEnv::getInstance().isDebuggable()) { system_path = kSystemLayerLibraryDir; } Loading Loading @@ -379,14 +379,12 @@ void LayerLoader::LoadLayers() { // any symbol dependencies will be resolved by system libraries. They // can't safely use libc++_shared, for example. Which is one reason // (among several) we only allow them in non-user builds. void* handle = nullptr; auto app_namespace = android::GraphicsEnv::getInstance().getAppNamespace(); if (app_namespace && !android::base::StartsWith(layer, kSystemLayerLibraryDir)) { bool native_bridge = false; char* error_message = nullptr; handle = OpenNativeLibraryInNamespace( app_namespace, layer.c_str(), &native_bridge, &error_message); if (!handle) { dlhandle_ = OpenNativeLibraryInNamespace( app_namespace, layer.c_str(), &native_bridge_, &error_message); if (!dlhandle_) { ALOGE("Failed to load layer %s with error: %s", layer.c_str(), error_message); android::NativeLoaderFreeErrorMessage(error_message); Loading @@ -394,11 +392,11 @@ void LayerLoader::LoadLayers() { } } else { handle = dlopen(layer.c_str(), RTLD_NOW | RTLD_LOCAL); dlhandle_ = dlopen(layer.c_str(), RTLD_NOW | RTLD_LOCAL); } if (handle) { ALOGV("Loaded layer handle (%llu) for layer %s", (unsigned long long)handle, if (dlhandle_) { ALOGV("Loaded layer handle (%llu) for layer %s", (unsigned long long)dlhandle_, layers[i].c_str()); } else { // If the layer is found but can't be loaded, try setenforce 0 Loading @@ -411,8 +409,7 @@ void LayerLoader::LoadLayers() { std::string init_func = "AndroidGLESLayer_Initialize"; ALOGV("Looking for entrypoint %s", init_func.c_str()); layer_init_func LayerInit = reinterpret_cast<layer_init_func>(dlsym(handle, init_func.c_str())); layer_init_func LayerInit = GetTrampoline<layer_init_func>(init_func.c_str()); if (LayerInit) { ALOGV("Found %s for layer %s", init_func.c_str(), layer.c_str()); layer_init_.push_back(LayerInit); Loading @@ -425,8 +422,7 @@ void LayerLoader::LoadLayers() { std::string setup_func = "AndroidGLESLayer_GetProcAddress"; ALOGV("Looking for entrypoint %s", setup_func.c_str()); layer_setup_func LayerSetup = reinterpret_cast<layer_setup_func>(dlsym(handle, setup_func.c_str())); layer_setup_func LayerSetup = GetTrampoline<layer_setup_func>(setup_func.c_str()); if (LayerSetup) { ALOGV("Found %s for layer %s", setup_func.c_str(), layer.c_str()); layer_setup_.push_back(LayerSetup); Loading opengl/libs/EGL/egl_layers.h +18 −2 Original line number Diff line number Diff line Loading @@ -21,10 +21,15 @@ #include <unordered_map> #include <vector> #include <EGL/egldefs.h> #include <android/dlext.h> #include <dlfcn.h> #include <EGL/egldefs.h> #include "egl_platform_entries.h" #include <nativebridge/native_bridge.h> #include <nativeloader/native_loader.h> typedef __eglMustCastToProperFunctionPointerType EGLFuncPointer; namespace android { Loading Loading @@ -54,10 +59,21 @@ public: std::vector<layer_setup_func> layer_setup_; private: LayerLoader() : layers_loaded_(false), initialized_(false), current_layer_(0){}; LayerLoader() : layers_loaded_(false), initialized_(false), current_layer_(0), dlhandle_(nullptr), native_bridge_(false){}; bool layers_loaded_; bool initialized_; unsigned current_layer_; void* dlhandle_; bool native_bridge_; template<typename Func = void*> Func GetTrampoline(const char* name) const { if (native_bridge_) { return reinterpret_cast<Func>(android::NativeBridgeGetTrampoline( dlhandle_, name, nullptr, 0)); } return reinterpret_cast<Func>(dlsym(dlhandle_, name)); } }; }; // namespace android Loading Loading
include/android/sharedmem.h +7 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ /** * @file sharedmem.h * @brief Shared memory buffers that can be shared across process. * @brief Shared memory buffers that can be shared between processes. */ #ifndef ANDROID_SHARED_MEMORY_H Loading Loading @@ -61,11 +61,15 @@ extern "C" { * * Use close() to release the shared memory region. * * Use {@link android.os.ParcelFileDescriptor} to pass the file descriptor to * another process. File descriptors may also be sent to other processes over a Unix domain * socket with sendmsg and SCM_RIGHTS. See sendmsg(3) and cmsg(3) man pages for more information. * * Available since API level 26. * * \param name an optional name. * \param size size of the shared memory region * \return file descriptor that denotes the shared memory; error code on failure. * \return file descriptor that denotes the shared memory; -1 and sets errno on failure, or -EINVAL if the error is that size was 0. */ int ASharedMemory_create(const char *name, size_t size) __INTRODUCED_IN(26); Loading Loading @@ -109,7 +113,7 @@ size_t ASharedMemory_getSize(int fd) __INTRODUCED_IN(26); * \param fd file descriptor of the shared memory region. * \param prot any bitwise-or'ed combination of PROT_READ, PROT_WRITE, PROT_EXEC denoting * updated access. Note access can only be removed, but not added back. * \return 0 for success, error code on failure. * \return 0 for success, -1 and sets errno on failure. */ int ASharedMemory_setProt(int fd, int prot) __INTRODUCED_IN(26); Loading
libs/graphicsenv/GraphicsEnv.cpp +2 −6 Original line number Diff line number Diff line Loading @@ -124,12 +124,8 @@ static const std::string getSystemNativeLibraries(NativeLibrary type) { return env; } int GraphicsEnv::getCanLoadSystemLibraries() { if (property_get_bool("ro.debuggable", false) && prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)) { // Return an integer value since this crosses library boundaries return 1; } return 0; bool GraphicsEnv::isDebuggable() { return prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) > 0; } void GraphicsEnv::setDriverPathAndSphalLibraries(const std::string path, Loading
libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +10 −2 Original line number Diff line number Diff line Loading @@ -33,8 +33,16 @@ class GraphicsEnv { public: static GraphicsEnv& getInstance(); // Check if device is debuggable. int getCanLoadSystemLibraries(); // Check if the process is debuggable. It returns false except in any of the // following circumstances: // 1. ro.debuggable=1 (global debuggable enabled). // 2. android:debuggable="true" in the manifest for an individual app. // 3. An app which explicitly calls prctl(PR_SET_DUMPABLE, 1). // 4. GraphicsEnv calls prctl(PR_SET_DUMPABLE, 1) in the presence of // <meta-data android:name="com.android.graphics.injectLayers.enable" // android:value="true"/> // in the application manifest. bool isDebuggable(); /* * Apis for updatable driver Loading
opengl/libs/EGL/egl_layers.cpp +9 −13 Original line number Diff line number Diff line Loading @@ -337,7 +337,7 @@ void LayerLoader::LoadLayers() { // Only enable the system search path for non-user builds std::string system_path; if (property_get_bool("ro.debuggable", false) && prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)) { if (android::GraphicsEnv::getInstance().isDebuggable()) { system_path = kSystemLayerLibraryDir; } Loading Loading @@ -379,14 +379,12 @@ void LayerLoader::LoadLayers() { // any symbol dependencies will be resolved by system libraries. They // can't safely use libc++_shared, for example. Which is one reason // (among several) we only allow them in non-user builds. void* handle = nullptr; auto app_namespace = android::GraphicsEnv::getInstance().getAppNamespace(); if (app_namespace && !android::base::StartsWith(layer, kSystemLayerLibraryDir)) { bool native_bridge = false; char* error_message = nullptr; handle = OpenNativeLibraryInNamespace( app_namespace, layer.c_str(), &native_bridge, &error_message); if (!handle) { dlhandle_ = OpenNativeLibraryInNamespace( app_namespace, layer.c_str(), &native_bridge_, &error_message); if (!dlhandle_) { ALOGE("Failed to load layer %s with error: %s", layer.c_str(), error_message); android::NativeLoaderFreeErrorMessage(error_message); Loading @@ -394,11 +392,11 @@ void LayerLoader::LoadLayers() { } } else { handle = dlopen(layer.c_str(), RTLD_NOW | RTLD_LOCAL); dlhandle_ = dlopen(layer.c_str(), RTLD_NOW | RTLD_LOCAL); } if (handle) { ALOGV("Loaded layer handle (%llu) for layer %s", (unsigned long long)handle, if (dlhandle_) { ALOGV("Loaded layer handle (%llu) for layer %s", (unsigned long long)dlhandle_, layers[i].c_str()); } else { // If the layer is found but can't be loaded, try setenforce 0 Loading @@ -411,8 +409,7 @@ void LayerLoader::LoadLayers() { std::string init_func = "AndroidGLESLayer_Initialize"; ALOGV("Looking for entrypoint %s", init_func.c_str()); layer_init_func LayerInit = reinterpret_cast<layer_init_func>(dlsym(handle, init_func.c_str())); layer_init_func LayerInit = GetTrampoline<layer_init_func>(init_func.c_str()); if (LayerInit) { ALOGV("Found %s for layer %s", init_func.c_str(), layer.c_str()); layer_init_.push_back(LayerInit); Loading @@ -425,8 +422,7 @@ void LayerLoader::LoadLayers() { std::string setup_func = "AndroidGLESLayer_GetProcAddress"; ALOGV("Looking for entrypoint %s", setup_func.c_str()); layer_setup_func LayerSetup = reinterpret_cast<layer_setup_func>(dlsym(handle, setup_func.c_str())); layer_setup_func LayerSetup = GetTrampoline<layer_setup_func>(setup_func.c_str()); if (LayerSetup) { ALOGV("Found %s for layer %s", setup_func.c_str(), layer.c_str()); layer_setup_.push_back(LayerSetup); Loading
opengl/libs/EGL/egl_layers.h +18 −2 Original line number Diff line number Diff line Loading @@ -21,10 +21,15 @@ #include <unordered_map> #include <vector> #include <EGL/egldefs.h> #include <android/dlext.h> #include <dlfcn.h> #include <EGL/egldefs.h> #include "egl_platform_entries.h" #include <nativebridge/native_bridge.h> #include <nativeloader/native_loader.h> typedef __eglMustCastToProperFunctionPointerType EGLFuncPointer; namespace android { Loading Loading @@ -54,10 +59,21 @@ public: std::vector<layer_setup_func> layer_setup_; private: LayerLoader() : layers_loaded_(false), initialized_(false), current_layer_(0){}; LayerLoader() : layers_loaded_(false), initialized_(false), current_layer_(0), dlhandle_(nullptr), native_bridge_(false){}; bool layers_loaded_; bool initialized_; unsigned current_layer_; void* dlhandle_; bool native_bridge_; template<typename Func = void*> Func GetTrampoline(const char* name) const { if (native_bridge_) { return reinterpret_cast<Func>(android::NativeBridgeGetTrampoline( dlhandle_, name, nullptr, 0)); } return reinterpret_cast<Func>(dlsym(dlhandle_, name)); } }; }; // namespace android Loading