Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6c54fc2 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8249732 from 27dbab9b to tm-d1-release

Change-Id: I16ee76d10d8ab6f171dd8578cc5aedb5d68fef1d
parents 2c6370b5 27dbab9b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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()) {
@@ -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 {
@@ -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;
            }
@@ -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;
    }
+3 −3
Original line number Diff line number Diff line
@@ -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]
+26 −0
Original line number Diff line number Diff line
@@ -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;
@@ -160,6 +161,7 @@ private:
    void scheduleCallbacks();

    ChoreographerFrameCallbackDataImpl createFrameCallbackData(nsecs_t timestamp) const;
    void registerStartTime() const;

    std::mutex mLock;
    // Protected by mLock
@@ -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;
@@ -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),
@@ -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;

@@ -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 */
+5 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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*;