Loading libs/binder/Parcel.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -200,7 +200,6 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) { } flat_binder_object obj; obj.flags = FLAT_BINDER_FLAG_ACCEPTS_FDS; int schedBits = 0; if (!IPCThreadState::self()->backgroundSchedulingDisabled()) { Loading @@ -221,6 +220,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) { const int32_t handle = proxy ? proxy->getPrivateAccessor().binderHandle() : 0; obj.hdr.type = BINDER_TYPE_HANDLE; obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */ obj.flags = 0; obj.handle = handle; obj.cookie = 0; } else { Loading @@ -231,6 +231,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) { // override value, since it is set explicitly schedBits = schedPolicyMask(policy, priority); } obj.flags = FLAT_BINDER_FLAG_ACCEPTS_FDS; if (local->isRequestingSid()) { obj.flags |= FLAT_BINDER_FLAG_TXN_SECURITY_CTX; } Loading @@ -243,6 +244,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) { } } else { obj.hdr.type = BINDER_TYPE_BINDER; obj.flags = 0; obj.binder = 0; obj.cookie = 0; } Loading libs/binder/rust/tests/integration.rs +3 −3 Original line number Diff line number Diff line Loading @@ -924,9 +924,9 @@ mod tests { BinderFeatures::default(), ); assert!(!(service1 < service1)); assert!(!(service1 > service1)); assert_eq!(service1 < service2, !(service2 < service1)); assert!((service1 >= service1)); assert!((service1 <= service1)); assert_eq!(service1 < service2, (service2 >= service1)); } #[test] Loading libs/nativedisplay/AChoreographer.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,7 @@ struct ChoreographerFrameCallbackDataImpl { struct { std::mutex lock; std::vector<Choreographer*> ptrs GUARDED_BY(lock); std::map<AVsyncId, int64_t> startTimes GUARDED_BY(lock); bool registeredToDisplayManager GUARDED_BY(lock) = false; std::atomic<nsecs_t> mLastKnownVsync = -1; Loading Loading @@ -160,6 +161,7 @@ private: void scheduleCallbacks(); ChoreographerFrameCallbackDataImpl createFrameCallbackData(nsecs_t timestamp) const; void registerStartTime() const; std::mutex mLock; // Protected by mLock Loading @@ -172,6 +174,9 @@ private: const sp<Looper> mLooper; const std::thread::id mThreadId; // Approximation of num_threads_using_choreographer * num_frames_of_history with leeway. static constexpr size_t kMaxStartTimes = 250; }; static thread_local Choreographer* gChoreographer; Loading Loading @@ -392,6 +397,7 @@ void Choreographer::dispatchVsync(nsecs_t timestamp, PhysicalDisplayId, uint32_t if (cb.vsyncCallback != nullptr) { const ChoreographerFrameCallbackDataImpl frameCallbackData = createFrameCallbackData(timestamp); registerStartTime(); mInCallback = true; cb.vsyncCallback(reinterpret_cast<const AChoreographerFrameCallbackData*>( &frameCallbackData), Loading Loading @@ -452,6 +458,16 @@ ChoreographerFrameCallbackDataImpl Choreographer::createFrameCallbackData(nsecs_ .choreographer = this}; } void Choreographer::registerStartTime() const { std::scoped_lock _l(gChoreographers.lock); for (VsyncEventData::FrameTimeline frameTimeline : mLastVsyncEventData.frameTimelines) { while (gChoreographers.startTimes.size() >= kMaxStartTimes) { gChoreographers.startTimes.erase(gChoreographers.startTimes.begin()); } gChoreographers.startTimes[frameTimeline.vsyncId] = systemTime(SYSTEM_TIME_MONOTONIC); } } } // namespace android using namespace android; Loading Loading @@ -566,6 +582,16 @@ int64_t AChoreographer_getFrameInterval(const AChoreographer* choreographer) { return AChoreographer_to_Choreographer(choreographer)->getFrameInterval(); } int64_t AChoreographer_getStartTimeNanosForVsyncId(AVsyncId vsyncId) { std::scoped_lock _l(gChoreographers.lock); const auto iter = gChoreographers.startTimes.find(vsyncId); if (iter == gChoreographers.startTimes.end()) { ALOGW("Start time was not found for vsync id: %" PRId64, vsyncId); return 0; } return iter->second; } } // namespace android /* Glue for the NDK interface */ Loading libs/nativedisplay/include-private/private/android/choreographer.h +5 −0 Original line number Diff line number Diff line Loading @@ -71,4 +71,9 @@ int64_t AChoreographerFrameCallbackData_routeGetFrameTimelineExpectedPresentatio int64_t AChoreographerFrameCallbackData_routeGetFrameTimelineDeadlineNanos( const AChoreographerFrameCallbackData* data, size_t index); // Gets the start time (dispatch time) in nanos of the callback, given a vsync ID. This does not // account for clients that use multiple choreographers, because callbacks that give the same vsync // ID may be dispatched at different times. int64_t AChoreographer_getStartTimeNanosForVsyncId(AVsyncId vsyncId); } // namespace android libs/nativedisplay/libnativedisplay.map.txt +1 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ LIBNATIVEDISPLAY_PLATFORM { android::AChoreographerFrameCallbackData_routeGetFrameTimelineVsyncId*; android::AChoreographerFrameCallbackData_routeGetFrameTimelineExpectedPresentationTimeNanos*; android::AChoreographerFrameCallbackData_routeGetFrameTimelineDeadlineNanos*; android::AChoreographer_getStartTimeNanosForVsyncId*; android::AChoreographer_signalRefreshRateCallbacks*; android::AChoreographer_getFrameInterval*; android::ADisplay_acquirePhysicalDisplays*; Loading Loading
libs/binder/Parcel.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -200,7 +200,6 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) { } flat_binder_object obj; obj.flags = FLAT_BINDER_FLAG_ACCEPTS_FDS; int schedBits = 0; if (!IPCThreadState::self()->backgroundSchedulingDisabled()) { Loading @@ -221,6 +220,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) { const int32_t handle = proxy ? proxy->getPrivateAccessor().binderHandle() : 0; obj.hdr.type = BINDER_TYPE_HANDLE; obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */ obj.flags = 0; obj.handle = handle; obj.cookie = 0; } else { Loading @@ -231,6 +231,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) { // override value, since it is set explicitly schedBits = schedPolicyMask(policy, priority); } obj.flags = FLAT_BINDER_FLAG_ACCEPTS_FDS; if (local->isRequestingSid()) { obj.flags |= FLAT_BINDER_FLAG_TXN_SECURITY_CTX; } Loading @@ -243,6 +244,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) { } } else { obj.hdr.type = BINDER_TYPE_BINDER; obj.flags = 0; obj.binder = 0; obj.cookie = 0; } Loading
libs/binder/rust/tests/integration.rs +3 −3 Original line number Diff line number Diff line Loading @@ -924,9 +924,9 @@ mod tests { BinderFeatures::default(), ); assert!(!(service1 < service1)); assert!(!(service1 > service1)); assert_eq!(service1 < service2, !(service2 < service1)); assert!((service1 >= service1)); assert!((service1 <= service1)); assert_eq!(service1 < service2, (service2 >= service1)); } #[test] Loading
libs/nativedisplay/AChoreographer.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,7 @@ struct ChoreographerFrameCallbackDataImpl { struct { std::mutex lock; std::vector<Choreographer*> ptrs GUARDED_BY(lock); std::map<AVsyncId, int64_t> startTimes GUARDED_BY(lock); bool registeredToDisplayManager GUARDED_BY(lock) = false; std::atomic<nsecs_t> mLastKnownVsync = -1; Loading Loading @@ -160,6 +161,7 @@ private: void scheduleCallbacks(); ChoreographerFrameCallbackDataImpl createFrameCallbackData(nsecs_t timestamp) const; void registerStartTime() const; std::mutex mLock; // Protected by mLock Loading @@ -172,6 +174,9 @@ private: const sp<Looper> mLooper; const std::thread::id mThreadId; // Approximation of num_threads_using_choreographer * num_frames_of_history with leeway. static constexpr size_t kMaxStartTimes = 250; }; static thread_local Choreographer* gChoreographer; Loading Loading @@ -392,6 +397,7 @@ void Choreographer::dispatchVsync(nsecs_t timestamp, PhysicalDisplayId, uint32_t if (cb.vsyncCallback != nullptr) { const ChoreographerFrameCallbackDataImpl frameCallbackData = createFrameCallbackData(timestamp); registerStartTime(); mInCallback = true; cb.vsyncCallback(reinterpret_cast<const AChoreographerFrameCallbackData*>( &frameCallbackData), Loading Loading @@ -452,6 +458,16 @@ ChoreographerFrameCallbackDataImpl Choreographer::createFrameCallbackData(nsecs_ .choreographer = this}; } void Choreographer::registerStartTime() const { std::scoped_lock _l(gChoreographers.lock); for (VsyncEventData::FrameTimeline frameTimeline : mLastVsyncEventData.frameTimelines) { while (gChoreographers.startTimes.size() >= kMaxStartTimes) { gChoreographers.startTimes.erase(gChoreographers.startTimes.begin()); } gChoreographers.startTimes[frameTimeline.vsyncId] = systemTime(SYSTEM_TIME_MONOTONIC); } } } // namespace android using namespace android; Loading Loading @@ -566,6 +582,16 @@ int64_t AChoreographer_getFrameInterval(const AChoreographer* choreographer) { return AChoreographer_to_Choreographer(choreographer)->getFrameInterval(); } int64_t AChoreographer_getStartTimeNanosForVsyncId(AVsyncId vsyncId) { std::scoped_lock _l(gChoreographers.lock); const auto iter = gChoreographers.startTimes.find(vsyncId); if (iter == gChoreographers.startTimes.end()) { ALOGW("Start time was not found for vsync id: %" PRId64, vsyncId); return 0; } return iter->second; } } // namespace android /* Glue for the NDK interface */ Loading
libs/nativedisplay/include-private/private/android/choreographer.h +5 −0 Original line number Diff line number Diff line Loading @@ -71,4 +71,9 @@ int64_t AChoreographerFrameCallbackData_routeGetFrameTimelineExpectedPresentatio int64_t AChoreographerFrameCallbackData_routeGetFrameTimelineDeadlineNanos( const AChoreographerFrameCallbackData* data, size_t index); // Gets the start time (dispatch time) in nanos of the callback, given a vsync ID. This does not // account for clients that use multiple choreographers, because callbacks that give the same vsync // ID may be dispatched at different times. int64_t AChoreographer_getStartTimeNanosForVsyncId(AVsyncId vsyncId); } // namespace android
libs/nativedisplay/libnativedisplay.map.txt +1 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ LIBNATIVEDISPLAY_PLATFORM { android::AChoreographerFrameCallbackData_routeGetFrameTimelineVsyncId*; android::AChoreographerFrameCallbackData_routeGetFrameTimelineExpectedPresentationTimeNanos*; android::AChoreographerFrameCallbackData_routeGetFrameTimelineDeadlineNanos*; android::AChoreographer_getStartTimeNanosForVsyncId*; android::AChoreographer_signalRefreshRateCallbacks*; android::AChoreographer_getFrameInterval*; android::ADisplay_acquirePhysicalDisplays*; Loading