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

Commit a4514a36 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5180536 from cb5531e3 to pi-platform-release

Change-Id: I371b04b4aaaec81d980678f6315b920d9b5c27ac
parents 82fc86b8 cb5531e3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1536,6 +1536,12 @@ static void DumpstateTelephonyOnly() {
    RunDumpsys("APP SERVICES NON-PLATFORM", {"activity", "service", "all-non-platform"},
            DUMPSYS_COMPONENTS_OPTIONS);

    printf("========================================================\n");
    printf("== Checkins\n");
    printf("========================================================\n");

    RunDumpsys("CHECKIN BATTERYSTATS", {"batterystats", "-c"});

    printf("========================================================\n");
    printf("== dumpstate: done (id %d)\n", ds.id_);
    printf("========================================================\n");
+4 −4
Original line number Diff line number Diff line
@@ -325,8 +325,8 @@ void VelocityTracker::addMovement(const MotionEvent* event) {
        eventTime = event->getHistoricalEventTime(h);
        for (size_t i = 0; i < pointerCount; i++) {
            uint32_t index = pointerIndex[i];
            positions[index].x = event->getHistoricalRawX(i, h);
            positions[index].y = event->getHistoricalRawY(i, h);
            positions[index].x = event->getHistoricalX(i, h);
            positions[index].y = event->getHistoricalY(i, h);
        }
        addMovement(eventTime, idBits, positions);
    }
@@ -334,8 +334,8 @@ void VelocityTracker::addMovement(const MotionEvent* event) {
    eventTime = event->getEventTime();
    for (size_t i = 0; i < pointerCount; i++) {
        uint32_t index = pointerIndex[i];
        positions[index].x = event->getRawX(i);
        positions[index].y = event->getRawY(i);
        positions[index].x = event->getX(i);
        positions[index].y = event->getY(i);
    }
    addMovement(eventTime, idBits, positions);
}
+8 −2
Original line number Diff line number Diff line
@@ -4417,6 +4417,12 @@ void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index,
    mEventThread->dump(result);
    result.append("\n");

    /*
     * Tracing state
     */
    mTracing.dump(result);
    result.append("\n");

    /*
     * HWC layer minidump
     */
@@ -4764,12 +4770,12 @@ status_t SurfaceFlinger::onTransact(
            case 1025: { // Set layer tracing
                n = data.readInt32();
                if (n) {
                    ALOGV("LayerTracing enabled");
                    ALOGD("LayerTracing enabled");
                    mTracing.enable();
                    doTracing("tracing.enable");
                    reply->writeInt32(NO_ERROR);
                } else {
                    ALOGV("LayerTracing disabled");
                    ALOGD("LayerTracing disabled");
                    status_t err = mTracing.disable();
                    reply->writeInt32(err);
                }
+34 −12
Original line number Diff line number Diff line
@@ -27,52 +27,67 @@
namespace android {

void SurfaceTracing::enable() {
    ATRACE_CALL();
    std::lock_guard<std::mutex> protoGuard(mTraceMutex);

    if (mEnabled) {
        return;
    }
    ATRACE_CALL();
    mEnabled = true;
    std::lock_guard<std::mutex> protoGuard(mTraceMutex);

    mTrace.set_magic_number(uint64_t(LayersTraceFileProto_MagicNumber_MAGIC_NUMBER_H) << 32 |
    mTrace = std::make_unique<LayersTraceFileProto>();
    mTrace->set_magic_number(uint64_t(LayersTraceFileProto_MagicNumber_MAGIC_NUMBER_H) << 32 |
                             LayersTraceFileProto_MagicNumber_MAGIC_NUMBER_L);
}

status_t SurfaceTracing::disable() {
    ATRACE_CALL();
    std::lock_guard<std::mutex> protoGuard(mTraceMutex);

    if (!mEnabled) {
        return NO_ERROR;
    }
    ATRACE_CALL();
    std::lock_guard<std::mutex> protoGuard(mTraceMutex);
    mEnabled = false;
    status_t err(writeProtoFileLocked());
    ALOGE_IF(err == PERMISSION_DENIED, "Could not save the proto file! Permission denied");
    ALOGE_IF(err == NOT_ENOUGH_DATA, "Could not save the proto file! There are missing fields");
    mTrace.Clear();
    mTrace.reset();
    return err;
}

bool SurfaceTracing::isEnabled() {
bool SurfaceTracing::isEnabled() const {
    std::lock_guard<std::mutex> protoGuard(mTraceMutex);
    return mEnabled;
}

void SurfaceTracing::traceLayers(const char* where, LayersProto layers) {
    std::lock_guard<std::mutex> protoGuard(mTraceMutex);

    LayersTraceProto* entry = mTrace.add_entry();
    if (!mEnabled) {
        return;
    }
    LayersTraceProto* entry = mTrace->add_entry();
    entry->set_elapsed_realtime_nanos(elapsedRealtimeNano());
    entry->set_where(where);
    entry->mutable_layers()->Swap(&layers);

    constexpr int maxBufferedEntryCount = 3600;
    if (mTrace->entry_size() >= maxBufferedEntryCount) {
        // TODO: flush buffered entries without disabling tracing
        ALOGE("too many buffered frames; force disable tracing");
        mEnabled = false;
        writeProtoFileLocked();
        mTrace.reset();
    }
}

status_t SurfaceTracing::writeProtoFileLocked() {
    ATRACE_CALL();

    if (!mTrace.IsInitialized()) {
    if (!mTrace->IsInitialized()) {
        return NOT_ENOUGH_DATA;
    }
    std::string output;
    if (!mTrace.SerializeToString(&output)) {
    if (!mTrace->SerializeToString(&output)) {
        return PERMISSION_DENIED;
    }
    if (!android::base::WriteStringToFile(output, mOutputFileName, true)) {
@@ -82,4 +97,11 @@ status_t SurfaceTracing::writeProtoFileLocked() {
    return NO_ERROR;
}

void SurfaceTracing::dump(String8& result) const {
    std::lock_guard<std::mutex> protoGuard(mTraceMutex);

    result.appendFormat("Tracing state: %s\n", mEnabled ? "enabled" : "disabled");
    result.appendFormat("  number of entries: %d\n", mTrace ? mTrace->entry_size() : 0);
}

} // namespace android
+6 −3
Original line number Diff line number Diff line
@@ -18,7 +18,9 @@

#include <layerproto/LayerProtoHeader.h>
#include <utils/Errors.h>
#include <utils/String8.h>

#include <memory>
#include <mutex>

using namespace android::surfaceflinger;
@@ -32,9 +34,10 @@ class SurfaceTracing {
public:
    void enable();
    status_t disable();
    bool isEnabled();
    bool isEnabled() const;

    void traceLayers(const char* where, LayersProto);
    void dump(String8& result) const;

private:
    static constexpr auto DEFAULT_FILENAME = "/data/misc/wmtrace/layers_trace.pb";
@@ -43,8 +46,8 @@ private:

    bool mEnabled = false;
    std::string mOutputFileName = DEFAULT_FILENAME;
    std::mutex mTraceMutex;
    LayersTraceFileProto mTrace;
    mutable std::mutex mTraceMutex;
    std::unique_ptr<LayersTraceFileProto> mTrace;
};

} // namespace android
Loading