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

Commit 20c6d9ff authored by Pablo Gamito's avatar Pablo Gamito Committed by Android (Google) Code Review
Browse files

Merge "Add listener callback to keep track of tracing state in SCC"

parents 65122458 6ee484df
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -30,6 +30,12 @@ cc_library_headers {
    min_sdk_version: "29",
}

filegroup {
    name: "libgui_aidl",
    srcs: ["aidl/**/*.aidl"],
    path: "aidl/",
}

cc_library_shared {
    name: "libgui",
    vendor_available: false,
@@ -42,6 +48,7 @@ cc_library_shared {

    srcs: [
        ":framework_native_aidl",
        ":libgui_aidl",
        ":libgui_bufferqueue_sources",

        "BitTube.cpp",
@@ -74,6 +81,7 @@ cc_library_shared {
        "SurfaceControl.cpp",
        "SurfaceComposerClient.cpp",
        "SyncFeatures.cpp",
        "TransactionTracing.cpp",
        "view/Surface.cpp",
        "bufferqueue/1.0/B2HProducerListener.cpp",
        "bufferqueue/1.0/H2BGraphicBufferProducer.cpp",
@@ -145,6 +153,7 @@ cc_library_static {
    defaults: ["libgui_bufferqueue-defaults"],

    srcs: [
        ":libgui_aidl",
        ":libgui_bufferqueue_sources",
    ],
}
+18 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
#include <stdint.h>
#include <sys/types.h>

#include <android/gui/ITransactionTraceListener.h>

#include <binder/Parcel.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
@@ -1197,6 +1199,15 @@ public:

        return reply.readInt32();
    }

    virtual status_t addTransactionTraceListener(
            const sp<gui::ITransactionTraceListener>& listener) {
        Parcel data, reply;
        SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());
        SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));

        return remote()->transact(BnSurfaceComposer::ADD_TRANSACTION_TRACE_LISTENER, data, &reply);
    }
};

// Out-of-line virtual method definition to trigger vtable emission in this
@@ -2026,6 +2037,13 @@ status_t BnSurfaceComposer::onTransact(
            reply->writeInt32(result);
            return NO_ERROR;
        }
        case ADD_TRANSACTION_TRACE_LISTENER: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<gui::ITransactionTraceListener> listener;
            SAFE_PARCEL(data.readStrongBinder, &listener);

            return addTransactionTraceListener(listener);
        }
        default: {
            return BBinder::onTransact(code, data, reply, flags);
        }
+53 −0
Original line number Diff line number Diff line
/*
 * Copyright 2020 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.
 */

#include "gui/TransactionTracing.h"
#include "gui/ISurfaceComposer.h"

#include <private/gui/ComposerService.h>

namespace android {

sp<TransactionTraceListener> TransactionTraceListener::sInstance = nullptr;
std::mutex TransactionTraceListener::sMutex;

TransactionTraceListener::TransactionTraceListener() {}

sp<TransactionTraceListener> TransactionTraceListener::getInstance() {
    const std::lock_guard<std::mutex> lock(sMutex);

    if (sInstance == nullptr) {
        sInstance = new TransactionTraceListener;

        sp<ISurfaceComposer> sf(ComposerService::getComposerService());
        sf->addTransactionTraceListener(sInstance);
    }

    return sInstance;
}

binder::Status TransactionTraceListener::onToggled(bool enabled) {
    ALOGD("TransactionTraceListener: onToggled listener called");
    mTracingEnabled = enabled;

    return binder::Status::ok();
}

bool TransactionTraceListener::isTracingEnabled() {
    return mTracingEnabled;
}

} // namespace android
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
package android.gui;

/** @hide */
interface ITransactionTraceListener {
   void onToggled(boolean enabled);
}
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <binder/IBinder.h>
#include <binder/IInterface.h>

#include <android/gui/ITransactionTraceListener.h>
#include <gui/IScreenCaptureListener.h>
#include <gui/ITransactionCompletedListener.h>

@@ -486,6 +487,12 @@ public:
     */
    virtual status_t setFrameTimelineVsync(const sp<IGraphicBufferProducer>& surface,
                                           int64_t frameTimelineVsyncId) = 0;

    /*
     * Adds a TransactionTraceListener to listen for transaction tracing state updates.
     */
    virtual status_t addTransactionTraceListener(
            const sp<gui::ITransactionTraceListener>& listener) = 0;
};

// ----------------------------------------------------------------------------
@@ -546,6 +553,7 @@ public:
        SET_FRAME_RATE,
        ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN,
        SET_FRAME_TIMELINE_VSYNC,
        ADD_TRANSACTION_TRACE_LISTENER,
        // Always append new enum to the end.
    };

Loading