Loading cmds/installd/InstalldNativeService.cpp +0 −20 Original line number Diff line number Diff line Loading @@ -2250,26 +2250,6 @@ binder::Status InstalldNativeService::compileLayouts(const std::string& apkPath, return *_aidl_return ? ok() : error("viewcompiler failed"); } binder::Status InstalldNativeService::markBootComplete(const std::string& instructionSet) { ENFORCE_UID(AID_SYSTEM); std::lock_guard<std::recursive_mutex> lock(mLock); const char* instruction_set = instructionSet.c_str(); char boot_marker_path[PKG_PATH_MAX]; sprintf(boot_marker_path, "%s/%s/%s/.booting", android_data_dir.c_str(), DALVIK_CACHE, instruction_set); ALOGV("mark_boot_complete : %s", boot_marker_path); if (unlink(boot_marker_path) != 0) { return error(StringPrintf("Failed to unlink %s", boot_marker_path)); } return ok(); } binder::Status InstalldNativeService::linkNativeLibraryDirectory( const std::unique_ptr<std::string>& uuid, const std::string& packageName, const std::string& nativeLibPath32, int32_t userId) { Loading cmds/installd/InstalldNativeService.h +0 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,6 @@ public: const std::string& profileName); binder::Status rmPackageDir(const std::string& packageDir); binder::Status markBootComplete(const std::string& instructionSet); binder::Status freeCache(const std::unique_ptr<std::string>& uuid, int64_t targetFreeBytes, int64_t cacheReservedBytes, int32_t flags); binder::Status linkNativeLibraryDirectory(const std::unique_ptr<std::string>& uuid, Loading cmds/installd/binder/android/os/IInstalld.aidl +0 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,6 @@ interface IInstalld { void destroyProfileSnapshot(@utf8InCpp String packageName, @utf8InCpp String profileName); void rmPackageDir(@utf8InCpp String packageDir); void markBootComplete(@utf8InCpp String instructionSet); void freeCache(@nullable @utf8InCpp String uuid, long targetFreeBytes, long cacheReservedBytes, int flags); void linkNativeLibraryDirectory(@nullable @utf8InCpp String uuid, Loading libs/gui/Surface.cpp +130 −7 Original line number Diff line number Diff line Loading @@ -50,6 +50,17 @@ namespace android { using ui::ColorMode; using ui::Dataspace; namespace { bool isInterceptorRegistrationOp(int op) { return op == NATIVE_WINDOW_SET_CANCEL_INTERCEPTOR || op == NATIVE_WINDOW_SET_DEQUEUE_INTERCEPTOR || op == NATIVE_WINDOW_SET_PERFORM_INTERCEPTOR || op == NATIVE_WINDOW_SET_QUEUE_INTERCEPTOR; } } // namespace Surface::Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp) : mGraphicBufferProducer(bufferProducer), mCrop(Rect::EMPTY_RECT), Loading Loading @@ -366,18 +377,58 @@ int Surface::hook_setSwapInterval(ANativeWindow* window, int interval) { int Surface::hook_dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd) { Surface* c = getSelf(window); { std::shared_lock<std::shared_mutex> lock(c->mInterceptorMutex); if (c->mDequeueInterceptor != nullptr) { auto interceptor = c->mDequeueInterceptor; auto data = c->mDequeueInterceptorData; return interceptor(window, Surface::dequeueBufferInternal, data, buffer, fenceFd); } } return c->dequeueBuffer(buffer, fenceFd); } int Surface::dequeueBufferInternal(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd) { Surface* c = getSelf(window); return c->dequeueBuffer(buffer, fenceFd); } int Surface::hook_cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { Surface* c = getSelf(window); { std::shared_lock<std::shared_mutex> lock(c->mInterceptorMutex); if (c->mCancelInterceptor != nullptr) { auto interceptor = c->mCancelInterceptor; auto data = c->mCancelInterceptorData; return interceptor(window, Surface::cancelBufferInternal, data, buffer, fenceFd); } } return c->cancelBuffer(buffer, fenceFd); } int Surface::cancelBufferInternal(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { Surface* c = getSelf(window); return c->cancelBuffer(buffer, fenceFd); } int Surface::hook_queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { Surface* c = getSelf(window); { std::shared_lock<std::shared_mutex> lock(c->mInterceptorMutex); if (c->mQueueInterceptor != nullptr) { auto interceptor = c->mQueueInterceptor; auto data = c->mQueueInterceptorData; return interceptor(window, Surface::queueBufferInternal, data, buffer, fenceFd); } } return c->queueBuffer(buffer, fenceFd); } int Surface::queueBufferInternal(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { Surface* c = getSelf(window); return c->queueBuffer(buffer, fenceFd); } Loading Loading @@ -420,20 +471,37 @@ int Surface::hook_queueBuffer_DEPRECATED(ANativeWindow* window, return c->queueBuffer(buffer, -1); } int Surface::hook_query(const ANativeWindow* window, int what, int* value) { const Surface* c = getSelf(window); return c->query(what, value); } int Surface::hook_perform(ANativeWindow* window, int operation, ...) { va_list args; va_start(args, operation); Surface* c = getSelf(window); int result = c->perform(operation, args); int result; // Don't acquire shared ownership of the interceptor mutex if we're going to // do interceptor registration, as otherwise we'll deadlock on acquiring // exclusive ownership. if (!isInterceptorRegistrationOp(operation)) { std::shared_lock<std::shared_mutex> lock(c->mInterceptorMutex); if (c->mPerformInterceptor != nullptr) { result = c->mPerformInterceptor(window, Surface::performInternal, c->mPerformInterceptorData, operation, args); va_end(args); return result; } } result = c->perform(operation, args); va_end(args); return result; } int Surface::performInternal(ANativeWindow* window, int operation, va_list args) { Surface* c = getSelf(window); return c->perform(operation, args); } int Surface::hook_query(const ANativeWindow* window, int what, int* value) { const Surface* c = getSelf(window); return c->query(what, value); } int Surface::setSwapInterval(int interval) { ATRACE_CALL(); Loading Loading @@ -1096,6 +1164,22 @@ int Surface::perform(int operation, va_list args) case NATIVE_WINDOW_SET_FRAME_RATE: res = dispatchSetFrameRate(args); break; case NATIVE_WINDOW_SET_CANCEL_INTERCEPTOR: res = dispatchAddCancelInterceptor(args); break; case NATIVE_WINDOW_SET_DEQUEUE_INTERCEPTOR: res = dispatchAddDequeueInterceptor(args); break; case NATIVE_WINDOW_SET_PERFORM_INTERCEPTOR: res = dispatchAddPerformInterceptor(args); break; case NATIVE_WINDOW_SET_QUEUE_INTERCEPTOR: res = dispatchAddQueueInterceptor(args); break; case NATIVE_WINDOW_ALLOCATE_BUFFERS: allocateBuffers(); res = NO_ERROR; break; default: res = NAME_NOT_FOUND; break; Loading Loading @@ -1329,6 +1413,45 @@ int Surface::dispatchSetFrameRate(va_list args) { return setFrameRate(frameRate); } int Surface::dispatchAddCancelInterceptor(va_list args) { ANativeWindow_cancelBufferInterceptor interceptor = va_arg(args, ANativeWindow_cancelBufferInterceptor); void* data = va_arg(args, void*); std::lock_guard<std::shared_mutex> lock(mInterceptorMutex); mCancelInterceptor = interceptor; mCancelInterceptorData = data; return NO_ERROR; } int Surface::dispatchAddDequeueInterceptor(va_list args) { ANativeWindow_dequeueBufferInterceptor interceptor = va_arg(args, ANativeWindow_dequeueBufferInterceptor); void* data = va_arg(args, void*); std::lock_guard<std::shared_mutex> lock(mInterceptorMutex); mDequeueInterceptor = interceptor; mDequeueInterceptorData = data; return NO_ERROR; } int Surface::dispatchAddPerformInterceptor(va_list args) { ANativeWindow_performInterceptor interceptor = va_arg(args, ANativeWindow_performInterceptor); void* data = va_arg(args, void*); std::lock_guard<std::shared_mutex> lock(mInterceptorMutex); mPerformInterceptor = interceptor; mPerformInterceptorData = data; return NO_ERROR; } int Surface::dispatchAddQueueInterceptor(va_list args) { ANativeWindow_queueBufferInterceptor interceptor = va_arg(args, ANativeWindow_queueBufferInterceptor); void* data = va_arg(args, void*); std::lock_guard<std::shared_mutex> lock(mInterceptorMutex); mQueueInterceptor = interceptor; mQueueInterceptorData = data; return NO_ERROR; } bool Surface::transformToDisplayInverse() { return (mTransform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY) == NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY; Loading libs/gui/include/gui/Surface.h +25 −3 Original line number Diff line number Diff line Loading @@ -21,16 +21,15 @@ #include <gui/HdrMetadata.h> #include <gui/IGraphicBufferProducer.h> #include <gui/IProducerListener.h> #include <system/window.h> #include <ui/ANativeObjectBase.h> #include <ui/GraphicTypes.h> #include <ui/Region.h> #include <utils/Condition.h> #include <utils/Mutex.h> #include <utils/RefBase.h> #include <system/window.h> #include <shared_mutex> namespace android { Loading Loading @@ -205,6 +204,13 @@ private: ANativeWindowBuffer* buffer, int fenceFd); static int hook_setSwapInterval(ANativeWindow* window, int interval); static int cancelBufferInternal(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); static int dequeueBufferInternal(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd); static int performInternal(ANativeWindow* window, int operation, va_list args); static int queueBufferInternal(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); static int hook_cancelBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); static int hook_dequeueBuffer_DEPRECATED(ANativeWindow* window, Loading Loading @@ -252,6 +258,10 @@ private: int dispatchGetLastDequeueDuration(va_list args); int dispatchGetLastQueueDuration(va_list args); int dispatchSetFrameRate(va_list args); int dispatchAddCancelInterceptor(va_list args); int dispatchAddDequeueInterceptor(va_list args); int dispatchAddPerformInterceptor(va_list args); int dispatchAddQueueInterceptor(va_list args); bool transformToDisplayInverse(); protected: Loading Loading @@ -457,6 +467,18 @@ protected: // member variables are accessed. mutable Mutex mMutex; // mInterceptorMutex is the mutex guarding interceptors. std::shared_mutex mInterceptorMutex; ANativeWindow_cancelBufferInterceptor mCancelInterceptor = nullptr; void* mCancelInterceptorData = nullptr; ANativeWindow_dequeueBufferInterceptor mDequeueInterceptor = nullptr; void* mDequeueInterceptorData = nullptr; ANativeWindow_performInterceptor mPerformInterceptor = nullptr; void* mPerformInterceptorData = nullptr; ANativeWindow_queueBufferInterceptor mQueueInterceptor = nullptr; void* mQueueInterceptorData = nullptr; // must be used from the lock/unlock thread sp<GraphicBuffer> mLockedBuffer; sp<GraphicBuffer> mPostedBuffer; Loading Loading
cmds/installd/InstalldNativeService.cpp +0 −20 Original line number Diff line number Diff line Loading @@ -2250,26 +2250,6 @@ binder::Status InstalldNativeService::compileLayouts(const std::string& apkPath, return *_aidl_return ? ok() : error("viewcompiler failed"); } binder::Status InstalldNativeService::markBootComplete(const std::string& instructionSet) { ENFORCE_UID(AID_SYSTEM); std::lock_guard<std::recursive_mutex> lock(mLock); const char* instruction_set = instructionSet.c_str(); char boot_marker_path[PKG_PATH_MAX]; sprintf(boot_marker_path, "%s/%s/%s/.booting", android_data_dir.c_str(), DALVIK_CACHE, instruction_set); ALOGV("mark_boot_complete : %s", boot_marker_path); if (unlink(boot_marker_path) != 0) { return error(StringPrintf("Failed to unlink %s", boot_marker_path)); } return ok(); } binder::Status InstalldNativeService::linkNativeLibraryDirectory( const std::unique_ptr<std::string>& uuid, const std::string& packageName, const std::string& nativeLibPath32, int32_t userId) { Loading
cmds/installd/InstalldNativeService.h +0 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,6 @@ public: const std::string& profileName); binder::Status rmPackageDir(const std::string& packageDir); binder::Status markBootComplete(const std::string& instructionSet); binder::Status freeCache(const std::unique_ptr<std::string>& uuid, int64_t targetFreeBytes, int64_t cacheReservedBytes, int32_t flags); binder::Status linkNativeLibraryDirectory(const std::unique_ptr<std::string>& uuid, Loading
cmds/installd/binder/android/os/IInstalld.aidl +0 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,6 @@ interface IInstalld { void destroyProfileSnapshot(@utf8InCpp String packageName, @utf8InCpp String profileName); void rmPackageDir(@utf8InCpp String packageDir); void markBootComplete(@utf8InCpp String instructionSet); void freeCache(@nullable @utf8InCpp String uuid, long targetFreeBytes, long cacheReservedBytes, int flags); void linkNativeLibraryDirectory(@nullable @utf8InCpp String uuid, Loading
libs/gui/Surface.cpp +130 −7 Original line number Diff line number Diff line Loading @@ -50,6 +50,17 @@ namespace android { using ui::ColorMode; using ui::Dataspace; namespace { bool isInterceptorRegistrationOp(int op) { return op == NATIVE_WINDOW_SET_CANCEL_INTERCEPTOR || op == NATIVE_WINDOW_SET_DEQUEUE_INTERCEPTOR || op == NATIVE_WINDOW_SET_PERFORM_INTERCEPTOR || op == NATIVE_WINDOW_SET_QUEUE_INTERCEPTOR; } } // namespace Surface::Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp) : mGraphicBufferProducer(bufferProducer), mCrop(Rect::EMPTY_RECT), Loading Loading @@ -366,18 +377,58 @@ int Surface::hook_setSwapInterval(ANativeWindow* window, int interval) { int Surface::hook_dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd) { Surface* c = getSelf(window); { std::shared_lock<std::shared_mutex> lock(c->mInterceptorMutex); if (c->mDequeueInterceptor != nullptr) { auto interceptor = c->mDequeueInterceptor; auto data = c->mDequeueInterceptorData; return interceptor(window, Surface::dequeueBufferInternal, data, buffer, fenceFd); } } return c->dequeueBuffer(buffer, fenceFd); } int Surface::dequeueBufferInternal(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd) { Surface* c = getSelf(window); return c->dequeueBuffer(buffer, fenceFd); } int Surface::hook_cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { Surface* c = getSelf(window); { std::shared_lock<std::shared_mutex> lock(c->mInterceptorMutex); if (c->mCancelInterceptor != nullptr) { auto interceptor = c->mCancelInterceptor; auto data = c->mCancelInterceptorData; return interceptor(window, Surface::cancelBufferInternal, data, buffer, fenceFd); } } return c->cancelBuffer(buffer, fenceFd); } int Surface::cancelBufferInternal(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { Surface* c = getSelf(window); return c->cancelBuffer(buffer, fenceFd); } int Surface::hook_queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { Surface* c = getSelf(window); { std::shared_lock<std::shared_mutex> lock(c->mInterceptorMutex); if (c->mQueueInterceptor != nullptr) { auto interceptor = c->mQueueInterceptor; auto data = c->mQueueInterceptorData; return interceptor(window, Surface::queueBufferInternal, data, buffer, fenceFd); } } return c->queueBuffer(buffer, fenceFd); } int Surface::queueBufferInternal(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { Surface* c = getSelf(window); return c->queueBuffer(buffer, fenceFd); } Loading Loading @@ -420,20 +471,37 @@ int Surface::hook_queueBuffer_DEPRECATED(ANativeWindow* window, return c->queueBuffer(buffer, -1); } int Surface::hook_query(const ANativeWindow* window, int what, int* value) { const Surface* c = getSelf(window); return c->query(what, value); } int Surface::hook_perform(ANativeWindow* window, int operation, ...) { va_list args; va_start(args, operation); Surface* c = getSelf(window); int result = c->perform(operation, args); int result; // Don't acquire shared ownership of the interceptor mutex if we're going to // do interceptor registration, as otherwise we'll deadlock on acquiring // exclusive ownership. if (!isInterceptorRegistrationOp(operation)) { std::shared_lock<std::shared_mutex> lock(c->mInterceptorMutex); if (c->mPerformInterceptor != nullptr) { result = c->mPerformInterceptor(window, Surface::performInternal, c->mPerformInterceptorData, operation, args); va_end(args); return result; } } result = c->perform(operation, args); va_end(args); return result; } int Surface::performInternal(ANativeWindow* window, int operation, va_list args) { Surface* c = getSelf(window); return c->perform(operation, args); } int Surface::hook_query(const ANativeWindow* window, int what, int* value) { const Surface* c = getSelf(window); return c->query(what, value); } int Surface::setSwapInterval(int interval) { ATRACE_CALL(); Loading Loading @@ -1096,6 +1164,22 @@ int Surface::perform(int operation, va_list args) case NATIVE_WINDOW_SET_FRAME_RATE: res = dispatchSetFrameRate(args); break; case NATIVE_WINDOW_SET_CANCEL_INTERCEPTOR: res = dispatchAddCancelInterceptor(args); break; case NATIVE_WINDOW_SET_DEQUEUE_INTERCEPTOR: res = dispatchAddDequeueInterceptor(args); break; case NATIVE_WINDOW_SET_PERFORM_INTERCEPTOR: res = dispatchAddPerformInterceptor(args); break; case NATIVE_WINDOW_SET_QUEUE_INTERCEPTOR: res = dispatchAddQueueInterceptor(args); break; case NATIVE_WINDOW_ALLOCATE_BUFFERS: allocateBuffers(); res = NO_ERROR; break; default: res = NAME_NOT_FOUND; break; Loading Loading @@ -1329,6 +1413,45 @@ int Surface::dispatchSetFrameRate(va_list args) { return setFrameRate(frameRate); } int Surface::dispatchAddCancelInterceptor(va_list args) { ANativeWindow_cancelBufferInterceptor interceptor = va_arg(args, ANativeWindow_cancelBufferInterceptor); void* data = va_arg(args, void*); std::lock_guard<std::shared_mutex> lock(mInterceptorMutex); mCancelInterceptor = interceptor; mCancelInterceptorData = data; return NO_ERROR; } int Surface::dispatchAddDequeueInterceptor(va_list args) { ANativeWindow_dequeueBufferInterceptor interceptor = va_arg(args, ANativeWindow_dequeueBufferInterceptor); void* data = va_arg(args, void*); std::lock_guard<std::shared_mutex> lock(mInterceptorMutex); mDequeueInterceptor = interceptor; mDequeueInterceptorData = data; return NO_ERROR; } int Surface::dispatchAddPerformInterceptor(va_list args) { ANativeWindow_performInterceptor interceptor = va_arg(args, ANativeWindow_performInterceptor); void* data = va_arg(args, void*); std::lock_guard<std::shared_mutex> lock(mInterceptorMutex); mPerformInterceptor = interceptor; mPerformInterceptorData = data; return NO_ERROR; } int Surface::dispatchAddQueueInterceptor(va_list args) { ANativeWindow_queueBufferInterceptor interceptor = va_arg(args, ANativeWindow_queueBufferInterceptor); void* data = va_arg(args, void*); std::lock_guard<std::shared_mutex> lock(mInterceptorMutex); mQueueInterceptor = interceptor; mQueueInterceptorData = data; return NO_ERROR; } bool Surface::transformToDisplayInverse() { return (mTransform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY) == NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY; Loading
libs/gui/include/gui/Surface.h +25 −3 Original line number Diff line number Diff line Loading @@ -21,16 +21,15 @@ #include <gui/HdrMetadata.h> #include <gui/IGraphicBufferProducer.h> #include <gui/IProducerListener.h> #include <system/window.h> #include <ui/ANativeObjectBase.h> #include <ui/GraphicTypes.h> #include <ui/Region.h> #include <utils/Condition.h> #include <utils/Mutex.h> #include <utils/RefBase.h> #include <system/window.h> #include <shared_mutex> namespace android { Loading Loading @@ -205,6 +204,13 @@ private: ANativeWindowBuffer* buffer, int fenceFd); static int hook_setSwapInterval(ANativeWindow* window, int interval); static int cancelBufferInternal(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); static int dequeueBufferInternal(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd); static int performInternal(ANativeWindow* window, int operation, va_list args); static int queueBufferInternal(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); static int hook_cancelBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); static int hook_dequeueBuffer_DEPRECATED(ANativeWindow* window, Loading Loading @@ -252,6 +258,10 @@ private: int dispatchGetLastDequeueDuration(va_list args); int dispatchGetLastQueueDuration(va_list args); int dispatchSetFrameRate(va_list args); int dispatchAddCancelInterceptor(va_list args); int dispatchAddDequeueInterceptor(va_list args); int dispatchAddPerformInterceptor(va_list args); int dispatchAddQueueInterceptor(va_list args); bool transformToDisplayInverse(); protected: Loading Loading @@ -457,6 +467,18 @@ protected: // member variables are accessed. mutable Mutex mMutex; // mInterceptorMutex is the mutex guarding interceptors. std::shared_mutex mInterceptorMutex; ANativeWindow_cancelBufferInterceptor mCancelInterceptor = nullptr; void* mCancelInterceptorData = nullptr; ANativeWindow_dequeueBufferInterceptor mDequeueInterceptor = nullptr; void* mDequeueInterceptorData = nullptr; ANativeWindow_performInterceptor mPerformInterceptor = nullptr; void* mPerformInterceptorData = nullptr; ANativeWindow_queueBufferInterceptor mQueueInterceptor = nullptr; void* mQueueInterceptorData = nullptr; // must be used from the lock/unlock thread sp<GraphicBuffer> mLockedBuffer; sp<GraphicBuffer> mPostedBuffer; Loading