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

Commit 257dda74 authored by Surbhi Kadam's avatar Surbhi Kadam
Browse files

Add token tracing for early wakeup request

Bug: 323292798
Test: atest SurfaceFlinger_test libsurfaceflinger_unittest libgui_test
Flag: EXEMPT log only; bugfix

Change-Id: I01a49f8ea5267ee747c326154d0cf17b47a2a155
parent d84d4a60
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -89,12 +89,13 @@ cc_library_headers {
filegroup {
    name: "guiconstants_aidl",
    srcs: [
        "android/gui/BorderSettings.aidl",
        "android/gui/BoxShadowSettings.aidl",
        "android/gui/DropInputMode.aidl",
        "android/gui/EarlyWakeupInfo.aidl",
        "android/gui/StalledTransactionInfo.aidl",
        "android/**/TouchOcclusionMode.aidl",
        "android/gui/TrustedOverlay.aidl",
        "android/gui/BorderSettings.aidl",
        "android/gui/BoxShadowSettings.aidl",
    ],
}

+9 −2
Original line number Diff line number Diff line
@@ -66,7 +66,8 @@ public:
            InputWindowCommands commands, int64_t desiredPresentTime, bool isAutoTimestamp,
            const std::vector<client_cache_t>& uncacheBuffers, bool hasListenerCallbacks,
            const std::vector<ListenerCallbacks>& listenerCallbacks, uint64_t transactionId,
            const std::vector<uint64_t>& mergedTransactionIds) override {
            const std::vector<uint64_t>& mergedTransactionIds,
            const gui::EarlyWakeupInfo& earlyWakeupInfo) override {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());

@@ -107,6 +108,8 @@ public:
            SAFE_PARCEL(data.writeUint64, mergedTransactionId);
        }

        earlyWakeupInfo.writeToParcel(&data);

        if (flags & ISurfaceComposer::eOneWay) {
            return remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE,
                    data, &reply, IBinder::FLAG_ONEWAY);
@@ -197,10 +200,14 @@ status_t BnSurfaceComposer::onTransact(
                SAFE_PARCEL(data.readUint64, &mergedTransactions[i]);
            }

            gui::EarlyWakeupInfo earlyWakeupInfo;
            earlyWakeupInfo.readFromParcel(&data);

            return setTransactionState(frameTimelineInfo, state, displays, stateFlags, applyToken,
                                       std::move(inputWindowCommands), desiredPresentTime,
                                       isAutoTimestamp, uncacheBuffers, hasListenerCallbacks,
                                       listenerCallbacks, transactionId, mergedTransactions);
                                       listenerCallbacks, transactionId, mergedTransactions,
                                       earlyWakeupInfo);
        }
        case GET_SCHEDULING_POLICY: {
            gui::SchedulingPolicy policy;
+24 −8
Original line number Diff line number Diff line
@@ -836,7 +836,8 @@ SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
        mDesiredPresentTime(other.mDesiredPresentTime),
        mIsAutoTimestamp(other.mIsAutoTimestamp),
        mFrameTimelineInfo(other.mFrameTimelineInfo),
        mApplyToken(other.mApplyToken) {
        mApplyToken(other.mApplyToken),
        mEarlyWakeupInfo(other.mEarlyWakeupInfo) {
    mDisplayStates = other.mDisplayStates;
    mComposerStates = other.mComposerStates;
    mInputWindowCommands = other.mInputWindowCommands;
@@ -958,6 +959,9 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
        SAFE_PARCEL(parcel->readUint64, &mergedTransactionIds[i]);
    }

    gui::EarlyWakeupInfo earlyWakeupInfo;
    earlyWakeupInfo.readFromParcel(parcel);

    // Parsing was successful. Update the object.
    mId = transactionId;
    mFlags = flags;
@@ -971,6 +975,7 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
    mApplyToken = applyToken;
    mUncacheBuffers = std::move(uncacheBuffers);
    mMergedTransactionIds = std::move(mergedTransactionIds);
    mEarlyWakeupInfo = earlyWakeupInfo;
    return NO_ERROR;
}

@@ -1031,6 +1036,8 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const
        SAFE_PARCEL(parcel->writeUint64, mergedTransactionId);
    }

    mEarlyWakeupInfo.writeToParcel(parcel);

    return NO_ERROR;
}

@@ -1140,6 +1147,8 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr
             "Transaction %" PRIu64 " merged with transaction %" PRIu64, other.getId(), mId);
    }

    mEarlyWakeupInfo = other.mEarlyWakeupInfo;

    other.clear();
    return *this;
}
@@ -1158,6 +1167,7 @@ void SurfaceComposerClient::Transaction::clear() {
    mMergedTransactionIds.clear();
    mLogCallPoints = false;
    mFlags = 0;
    mEarlyWakeupInfo = {};
}

uint64_t SurfaceComposerClient::Transaction::getId() {
@@ -1176,10 +1186,11 @@ void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) {
    uncacheBuffer.id = cacheId;
    Vector<ComposerState> composerStates;
    Vector<DisplayState> displayStates;
    status_t status = sf->setTransactionState(FrameTimelineInfo{}, composerStates, displayStates,
                                              ISurfaceComposer::eOneWay,
                                              Transaction::getDefaultApplyToken(), {}, systemTime(),
                                              true, {uncacheBuffer}, false, {}, generateId(), {});
    status_t status =
            sf->setTransactionState(FrameTimelineInfo{}, composerStates, displayStates,
                                    ISurfaceComposer::eOneWay, Transaction::getDefaultApplyToken(),
                                    {}, systemTime(), true, {uncacheBuffer}, false, {},
                                    generateId(), {}, {});
    if (status != NO_ERROR) {
        ALOGE_AND_TRACE("SurfaceComposerClient::doUncacheBufferTransaction - %s",
                        strerror(-status));
@@ -1340,7 +1351,8 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous, bool oneWay
            sf->setTransactionState(mFrameTimelineInfo, mComposerStates, mDisplayStates, mFlags,
                                    applyToken, mInputWindowCommands, mDesiredPresentTime,
                                    mIsAutoTimestamp, mUncacheBuffers, hasListenerCallbacks,
                                    listenerCallbacks, mId, mMergedTransactionIds);
                                    listenerCallbacks, mId, mMergedTransactionIds,
                                    mEarlyWakeupInfo);
    mId = generateId();

    // Clear the current states and flags
@@ -1447,11 +1459,15 @@ void SurfaceComposerClient::Transaction::setAnimationTransaction() {
    mFlags |= ISurfaceComposer::eAnimation;
}

void SurfaceComposerClient::Transaction::setEarlyWakeupStart() {
void SurfaceComposerClient::Transaction::setEarlyWakeupStart(
        const gui::EarlyWakeupInfo& earlyWakeupInfo) {
    mEarlyWakeupInfo = earlyWakeupInfo;
    mFlags |= ISurfaceComposer::eEarlyWakeupStart;
}

void SurfaceComposerClient::Transaction::setEarlyWakeupEnd() {
void SurfaceComposerClient::Transaction::setEarlyWakeupEnd(
        const gui::EarlyWakeupInfo& earlyWakeupInfo) {
    mEarlyWakeupInfo = earlyWakeupInfo;
    mFlags |= ISurfaceComposer::eEarlyWakeupEnd;
}

+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ status_t TransactionState::writeToParcel(Parcel* parcel) const {
    SAFE_PARCEL(parcel->writeStrongBinder, mApplyToken);
    SAFE_PARCEL(parcel->writeBool, mMayContainBuffer);
    SAFE_PARCEL(parcel->writeBool, mLogCallPoints);
    mEarlyWakeupInfo.writeToParcel(parcel);

    SAFE_PARCEL(parcel->writeUint32, static_cast<uint32_t>(mDisplayStates.size()));
    for (auto const& displayState : mDisplayStates) {
@@ -73,6 +74,7 @@ status_t TransactionState::readFromParcel(const Parcel* parcel) {
    SAFE_PARCEL(parcel->readNullableStrongBinder, &mApplyToken);
    SAFE_PARCEL(parcel->readBool, &mMayContainBuffer);
    SAFE_PARCEL(parcel->readBool, &mLogCallPoints);
    mEarlyWakeupInfo.readFromParcel(parcel);

    uint32_t count;
    SAFE_PARCEL_READ_SIZE(parcel->readUint32, &count, parcel->dataSize())
@@ -194,6 +196,7 @@ void TransactionState::merge(TransactionState&& other,
    // mApplyToken is explicitly not merged. Token should be set before applying the transactions to
    // make synchronization decisions a bit simpler.
    mergeFrameTimelineInfo(other.mFrameTimelineInfo);
    mEarlyWakeupInfo = other.mEarlyWakeupInfo;
    other.clear();
}

@@ -225,6 +228,7 @@ void TransactionState::clear() {
    mFlags = 0;
    mMayContainBuffer = false;
    mLogCallPoints = false;
    mEarlyWakeupInfo = {};
}

layer_state_t* TransactionState::getLayerState(const sp<SurfaceControl>& sc) {
+25 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2025, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.gui;

import android.os.IBinder;

/** @hide */
parcelable EarlyWakeupInfo {
    @nullable IBinder token;
    @utf8InCpp String trace = "<no trace>";
}
Loading