Loading cmds/installd/globals.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ static constexpr const char* PROFILES_SUBDIR = "misc/profiles"; // sub-directory static constexpr const char* PRIVATE_APP_SUBDIR = "app-private/"; // sub-directory under // ANDROID_DATA static constexpr const char* STAGING_SUBDIR = "pkg_staging/"; // sub-directory under ANDROID_DATA static constexpr const char* STAGING_SUBDIR = "app-staging/"; // sub-directory under ANDROID_DATA std::string android_app_dir; std::string android_app_ephemeral_dir; Loading data/etc/car_core_hardware.xml +0 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ <feature name="android.software.voice_recognizers" notLowRam="true" /> <feature name="android.software.backup" /> <feature name="android.software.home_screen" /> <feature name="android.software.input_methods" /> <feature name="android.software.print" /> <feature name="android.software.companion_device_setup" /> <feature name="android.software.autofill" /> Loading include/android/choreographer.h +34 −7 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #ifndef ANDROID_CHOREOGRAPHER_H #define ANDROID_CHOREOGRAPHER_H #include <stdint.h> #include <sys/cdefs.h> __BEGIN_DECLS Loading @@ -43,6 +44,16 @@ typedef struct AChoreographer AChoreographer; */ typedef void (*AChoreographer_frameCallback)(long frameTimeNanos, void* data); /** * Prototype of the function that is called when a new frame is being rendered. * It's passed the time that the frame is being rendered as nanoseconds in the * CLOCK_MONOTONIC time base, as well as the data pointer provided by the * application that registered a callback. All callbacks that run as part of * rendering a frame will observe the same frame time, so it should be used * whenever events need to be synchronized (e.g. animations). */ typedef void (*AChoreographer_frameCallback64)(int64_t frameTimeNanos, void* data); #if __ANDROID_API__ >= 24 /** Loading @@ -52,23 +63,39 @@ typedef void (*AChoreographer_frameCallback)(long frameTimeNanos, void* data); AChoreographer* AChoreographer_getInstance() __INTRODUCED_IN(24); /** * Post a callback to be run on the next frame. The data pointer provided will * be passed to the callback function when it's called. * Deprecated: Use AChoreographer_postFrameCallback64 instead. */ void AChoreographer_postFrameCallback(AChoreographer* choreographer, AChoreographer_frameCallback callback, void* data) __INTRODUCED_IN(24); AChoreographer_frameCallback callback, void* data) __INTRODUCED_IN(24) __DEPRECATED_IN(29); /** * Post a callback to be run on the frame following the specified delay. The * data pointer provided will be passed to the callback function when it's * called. * Deprecated: Use AChoreographer_postFrameCallbackDelayed64 instead. */ void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer, AChoreographer_frameCallback callback, void* data, long delayMillis) __INTRODUCED_IN(24); long delayMillis) __INTRODUCED_IN(24) __DEPRECATED_IN(29); #endif /* __ANDROID_API__ >= 24 */ #if __ANDROID_API__ >= 29 /** * Power a callback to be run on the next frame. The data pointer provided will * be passed to the callback function when it's called. */ void AChoreographer_postFrameCallback64(AChoreographer* chroreographer, AChoreographer_frameCallback64 callback, void* data) __INTRODUCED_IN(29); /** * Post a callback to be run on the frame following the specified delay. The * data pointer provided will be passed to the callback function when it's * called. */ void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer, AChoreographer_frameCallback64 callback, void* data, uint32_t delayMillis) __INTRODUCED_IN(29); #endif /* __ANDROID_API__ >= 29 */ __END_DECLS #endif // ANDROID_CHOREOGRAPHER_H Loading include/android/surface_control.h +3 −3 Original line number Diff line number Diff line Loading @@ -40,9 +40,9 @@ __BEGIN_DECLS struct ASurfaceControl; /** * The SurfaceControl API can be used to provide a heirarchy of surfaces for * The SurfaceControl API can be used to provide a hierarchy of surfaces for * composition to the system compositor. ASurfaceControl represents a content node in * this heirarchy. * this hierarchy. */ typedef struct ASurfaceControl ASurfaceControl; Loading Loading @@ -112,7 +112,7 @@ typedef struct ASurfaceTransactionStats ASurfaceTransactionStats; * the callback. * * |stats| is an opaque handle that can be passed to ASurfaceTransactionStats functions to query * information about the transaction. The handle is only valid during the the callback. * information about the transaction. The handle is only valid during the callback. * * THREADING * The transaction completed callback can be invoked on any thread. Loading libs/gui/Surface.cpp +91 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,11 @@ #include <gui/Surface.h> #include <condition_variable> #include <deque> #include <mutex> #include <thread> #include <inttypes.h> #include <android/native_window.h> Loading Loading @@ -450,6 +455,82 @@ int Surface::setSwapInterval(int interval) { return NO_ERROR; } class FenceMonitor { public: explicit FenceMonitor(const char* name) : mName(name), mFencesQueued(0), mFencesSignaled(0) { std::thread thread(&FenceMonitor::loop, this); pthread_setname_np(thread.native_handle(), mName); thread.detach(); } void queueFence(const sp<Fence>& fence) { char message[64]; std::lock_guard<std::mutex> lock(mMutex); if (fence->getSignalTime() != Fence::SIGNAL_TIME_PENDING) { snprintf(message, sizeof(message), "%s fence %u has signaled", mName, mFencesQueued); ATRACE_NAME(message); // Need an increment on both to make the trace number correct. mFencesQueued++; mFencesSignaled++; return; } snprintf(message, sizeof(message), "Trace %s fence %u", mName, mFencesQueued); ATRACE_NAME(message); mQueue.push_back(fence); mCondition.notify_one(); mFencesQueued++; ATRACE_INT(mName, int32_t(mQueue.size())); } private: #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmissing-noreturn" void loop() { while (true) { threadLoop(); } } #pragma clang diagnostic pop void threadLoop() { sp<Fence> fence; uint32_t fenceNum; { std::unique_lock<std::mutex> lock(mMutex); while (mQueue.empty()) { mCondition.wait(lock); } fence = mQueue[0]; fenceNum = mFencesSignaled; } { char message[64]; snprintf(message, sizeof(message), "waiting for %s %u", mName, fenceNum); ATRACE_NAME(message); status_t result = fence->waitForever(message); if (result != OK) { ALOGE("Error waiting for fence: %d", result); } } { std::lock_guard<std::mutex> lock(mMutex); mQueue.pop_front(); mFencesSignaled++; ATRACE_INT(mName, int32_t(mQueue.size())); } } const char* mName; uint32_t mFencesQueued; uint32_t mFencesSignaled; std::deque<sp<Fence>> mQueue; std::condition_variable mCondition; std::mutex mMutex; }; int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) { ATRACE_CALL(); ALOGV("Surface::dequeueBuffer"); Loading Loading @@ -519,6 +600,11 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) { // this should never happen ALOGE_IF(fence == nullptr, "Surface::dequeueBuffer: received null Fence! buf=%d", buf); if (CC_UNLIKELY(atrace_is_tag_enabled(ATRACE_TAG_GRAPHICS))) { static FenceMonitor hwcReleaseThread("HWC release"); hwcReleaseThread.queueFence(fence); } if (result & IGraphicBufferProducer::RELEASE_ALL_BUFFERS) { freeAllBuffers(); } Loading Loading @@ -761,6 +847,11 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { mQueueBufferCondition.broadcast(); if (CC_UNLIKELY(atrace_is_tag_enabled(ATRACE_TAG_GRAPHICS))) { static FenceMonitor gpuCompletionThread("GPU completion"); gpuCompletionThread.queueFence(fence); } return err; } Loading Loading
cmds/installd/globals.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ static constexpr const char* PROFILES_SUBDIR = "misc/profiles"; // sub-directory static constexpr const char* PRIVATE_APP_SUBDIR = "app-private/"; // sub-directory under // ANDROID_DATA static constexpr const char* STAGING_SUBDIR = "pkg_staging/"; // sub-directory under ANDROID_DATA static constexpr const char* STAGING_SUBDIR = "app-staging/"; // sub-directory under ANDROID_DATA std::string android_app_dir; std::string android_app_ephemeral_dir; Loading
data/etc/car_core_hardware.xml +0 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ <feature name="android.software.voice_recognizers" notLowRam="true" /> <feature name="android.software.backup" /> <feature name="android.software.home_screen" /> <feature name="android.software.input_methods" /> <feature name="android.software.print" /> <feature name="android.software.companion_device_setup" /> <feature name="android.software.autofill" /> Loading
include/android/choreographer.h +34 −7 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #ifndef ANDROID_CHOREOGRAPHER_H #define ANDROID_CHOREOGRAPHER_H #include <stdint.h> #include <sys/cdefs.h> __BEGIN_DECLS Loading @@ -43,6 +44,16 @@ typedef struct AChoreographer AChoreographer; */ typedef void (*AChoreographer_frameCallback)(long frameTimeNanos, void* data); /** * Prototype of the function that is called when a new frame is being rendered. * It's passed the time that the frame is being rendered as nanoseconds in the * CLOCK_MONOTONIC time base, as well as the data pointer provided by the * application that registered a callback. All callbacks that run as part of * rendering a frame will observe the same frame time, so it should be used * whenever events need to be synchronized (e.g. animations). */ typedef void (*AChoreographer_frameCallback64)(int64_t frameTimeNanos, void* data); #if __ANDROID_API__ >= 24 /** Loading @@ -52,23 +63,39 @@ typedef void (*AChoreographer_frameCallback)(long frameTimeNanos, void* data); AChoreographer* AChoreographer_getInstance() __INTRODUCED_IN(24); /** * Post a callback to be run on the next frame. The data pointer provided will * be passed to the callback function when it's called. * Deprecated: Use AChoreographer_postFrameCallback64 instead. */ void AChoreographer_postFrameCallback(AChoreographer* choreographer, AChoreographer_frameCallback callback, void* data) __INTRODUCED_IN(24); AChoreographer_frameCallback callback, void* data) __INTRODUCED_IN(24) __DEPRECATED_IN(29); /** * Post a callback to be run on the frame following the specified delay. The * data pointer provided will be passed to the callback function when it's * called. * Deprecated: Use AChoreographer_postFrameCallbackDelayed64 instead. */ void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer, AChoreographer_frameCallback callback, void* data, long delayMillis) __INTRODUCED_IN(24); long delayMillis) __INTRODUCED_IN(24) __DEPRECATED_IN(29); #endif /* __ANDROID_API__ >= 24 */ #if __ANDROID_API__ >= 29 /** * Power a callback to be run on the next frame. The data pointer provided will * be passed to the callback function when it's called. */ void AChoreographer_postFrameCallback64(AChoreographer* chroreographer, AChoreographer_frameCallback64 callback, void* data) __INTRODUCED_IN(29); /** * Post a callback to be run on the frame following the specified delay. The * data pointer provided will be passed to the callback function when it's * called. */ void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer, AChoreographer_frameCallback64 callback, void* data, uint32_t delayMillis) __INTRODUCED_IN(29); #endif /* __ANDROID_API__ >= 29 */ __END_DECLS #endif // ANDROID_CHOREOGRAPHER_H Loading
include/android/surface_control.h +3 −3 Original line number Diff line number Diff line Loading @@ -40,9 +40,9 @@ __BEGIN_DECLS struct ASurfaceControl; /** * The SurfaceControl API can be used to provide a heirarchy of surfaces for * The SurfaceControl API can be used to provide a hierarchy of surfaces for * composition to the system compositor. ASurfaceControl represents a content node in * this heirarchy. * this hierarchy. */ typedef struct ASurfaceControl ASurfaceControl; Loading Loading @@ -112,7 +112,7 @@ typedef struct ASurfaceTransactionStats ASurfaceTransactionStats; * the callback. * * |stats| is an opaque handle that can be passed to ASurfaceTransactionStats functions to query * information about the transaction. The handle is only valid during the the callback. * information about the transaction. The handle is only valid during the callback. * * THREADING * The transaction completed callback can be invoked on any thread. Loading
libs/gui/Surface.cpp +91 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,11 @@ #include <gui/Surface.h> #include <condition_variable> #include <deque> #include <mutex> #include <thread> #include <inttypes.h> #include <android/native_window.h> Loading Loading @@ -450,6 +455,82 @@ int Surface::setSwapInterval(int interval) { return NO_ERROR; } class FenceMonitor { public: explicit FenceMonitor(const char* name) : mName(name), mFencesQueued(0), mFencesSignaled(0) { std::thread thread(&FenceMonitor::loop, this); pthread_setname_np(thread.native_handle(), mName); thread.detach(); } void queueFence(const sp<Fence>& fence) { char message[64]; std::lock_guard<std::mutex> lock(mMutex); if (fence->getSignalTime() != Fence::SIGNAL_TIME_PENDING) { snprintf(message, sizeof(message), "%s fence %u has signaled", mName, mFencesQueued); ATRACE_NAME(message); // Need an increment on both to make the trace number correct. mFencesQueued++; mFencesSignaled++; return; } snprintf(message, sizeof(message), "Trace %s fence %u", mName, mFencesQueued); ATRACE_NAME(message); mQueue.push_back(fence); mCondition.notify_one(); mFencesQueued++; ATRACE_INT(mName, int32_t(mQueue.size())); } private: #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmissing-noreturn" void loop() { while (true) { threadLoop(); } } #pragma clang diagnostic pop void threadLoop() { sp<Fence> fence; uint32_t fenceNum; { std::unique_lock<std::mutex> lock(mMutex); while (mQueue.empty()) { mCondition.wait(lock); } fence = mQueue[0]; fenceNum = mFencesSignaled; } { char message[64]; snprintf(message, sizeof(message), "waiting for %s %u", mName, fenceNum); ATRACE_NAME(message); status_t result = fence->waitForever(message); if (result != OK) { ALOGE("Error waiting for fence: %d", result); } } { std::lock_guard<std::mutex> lock(mMutex); mQueue.pop_front(); mFencesSignaled++; ATRACE_INT(mName, int32_t(mQueue.size())); } } const char* mName; uint32_t mFencesQueued; uint32_t mFencesSignaled; std::deque<sp<Fence>> mQueue; std::condition_variable mCondition; std::mutex mMutex; }; int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) { ATRACE_CALL(); ALOGV("Surface::dequeueBuffer"); Loading Loading @@ -519,6 +600,11 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) { // this should never happen ALOGE_IF(fence == nullptr, "Surface::dequeueBuffer: received null Fence! buf=%d", buf); if (CC_UNLIKELY(atrace_is_tag_enabled(ATRACE_TAG_GRAPHICS))) { static FenceMonitor hwcReleaseThread("HWC release"); hwcReleaseThread.queueFence(fence); } if (result & IGraphicBufferProducer::RELEASE_ALL_BUFFERS) { freeAllBuffers(); } Loading Loading @@ -761,6 +847,11 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { mQueueBufferCondition.broadcast(); if (CC_UNLIKELY(atrace_is_tag_enabled(ATRACE_TAG_GRAPHICS))) { static FenceMonitor gpuCompletionThread("GPU completion"); gpuCompletionThread.queueFence(fence); } return err; } Loading