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

Commit 65060ae8 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Update nativeFlush API name and usage for clarity

The name nativeFlush caused a bit of confusion so renaming it for clarity.

Test: n/a
Change-Id: Ib1bc566567e2e012a12bcbc9b44b26430b7d181a
parent 79b37bdb
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ public abstract class DataSource<DataSourceInstanceType extends DataSourceInstan
                        new TracingContext<>(this, instanceIndex);
                fun.trace(ctx);

                ctx.flush();
                nativeWritePackets(mNativeObj, ctx.getAndClearAllPendingTracePackets());
            } while (nativePerfettoDsTraceIterateNext(mNativeObj));
        } finally {
            nativePerfettoDsTraceIterateBreak(mNativeObj);
@@ -179,4 +179,6 @@ public abstract class DataSource<DataSourceInstanceType extends DataSourceInstan
    private static native boolean nativePerfettoDsTraceIterateNext(long dataSourcePtr);
    private static native void nativePerfettoDsTraceIterateBreak(long dataSourcePtr);
    private static native int nativeGetPerfettoDsInstanceIndex(long dataSourcePtr);

    private static native void nativeWritePackets(long dataSourcePtr, byte[][] packetData);
}
+1 −16
Original line number Diff line number Diff line
@@ -58,19 +58,6 @@ public class TracingContext<DataSourceInstanceType extends DataSourceInstance, T
        return os;
    }

    /**
     * Forces a commit of the thread-local tracing data written so far to the
     * service. This is almost never required (tracing data is periodically
     * committed as trace pages are filled up) and has a non-negligible
     * performance hit (requires an IPC + refresh of the current thread-local
     * chunk). The only case when this should be used is when handling OnStop()
     * asynchronously, to ensure sure that the data is committed before the
     * Stop timeout expires.
     */
    public void flush() {
        nativeFlush(mDataSource.mNativeObj, getAndClearAllPendingTracePackets());
    }

    /**
     * Can optionally be used to store custom per-sequence
     * session data, which is not reset when incremental state is cleared
@@ -109,7 +96,7 @@ public class TracingContext<DataSourceInstanceType extends DataSourceInstance, T
        return incrementalState;
    }

    private byte[][] getAndClearAllPendingTracePackets() {
    protected byte[][] getAndClearAllPendingTracePackets() {
        byte[][] res = new byte[mTracePackets.size()][];
        for (int i = 0; i < mTracePackets.size(); i++) {
            ProtoOutputStream tracePacket = mTracePackets.get(i);
@@ -120,8 +107,6 @@ public class TracingContext<DataSourceInstanceType extends DataSourceInstance, T
        return res;
    }

    private static native void nativeFlush(long dataSourcePtr, byte[][] packetData);

    private static native Object nativeGetCustomTls(long nativeDsPtr);
    private static native void nativeSetCustomTls(long nativeDsPtr, Object tlsState);

+5 −4
Original line number Diff line number Diff line
@@ -244,8 +244,8 @@ static jlong nativeGetFinalizer(JNIEnv* /* env */, jclass /* clazz */) {
    return static_cast<jlong>(reinterpret_cast<uintptr_t>(&nativeDestroy));
}

void nativeFlush(JNIEnv* env, jclass clazz, jlong ds_ptr, jobjectArray packets) {
    ALOG(LOG_DEBUG, LOG_TAG, "nativeFlush(%p)", (void*)ds_ptr);
void nativeWritePackets(JNIEnv* env, jclass clazz, jlong ds_ptr, jobjectArray packets) {
    ALOG(LOG_DEBUG, LOG_TAG, "nativeWritePackets(%p)", (void*)ds_ptr);
    sp<PerfettoDataSource> datasource = reinterpret_cast<PerfettoDataSource*>(ds_ptr);
    datasource->WritePackets(env, packets);
}
@@ -431,11 +431,12 @@ const JNINativeMethod gMethods[] = {
        {"nativePerfettoDsTraceIterateBegin", "(J)Z", (void*)nativePerfettoDsTraceIterateBegin},
        {"nativePerfettoDsTraceIterateNext", "(J)Z", (void*)nativePerfettoDsTraceIterateNext},
        {"nativePerfettoDsTraceIterateBreak", "(J)V", (void*)nativePerfettoDsTraceIterateBreak},
        {"nativeGetPerfettoDsInstanceIndex", "(J)I", (void*)nativeGetPerfettoDsInstanceIndex}};
        {"nativeGetPerfettoDsInstanceIndex", "(J)I", (void*)nativeGetPerfettoDsInstanceIndex},

        {"nativeWritePackets", "(J[[B)V", (void*)nativeWritePackets}};

const JNINativeMethod gMethodsTracingContext[] = {
        /* name, signature, funcPtr */
        {"nativeFlush", "(J[[B)V", (void*)nativeFlush},
        {"nativeGetCustomTls", "(J)Ljava/lang/Object;", (void*)nativeGetCustomTls},
        {"nativeGetIncrementalState", "(J)Ljava/lang/Object;", (void*)nativeGetIncrementalState},
        {"nativeSetCustomTls", "(JLjava/lang/Object;)V", (void*)nativeSetCustomTls},