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

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

Merge changes from topic "remove-java-flush-api" into main

* changes:
  Remove redundant flush
  Update nativeFlush API name and usage for clarity
parents 42fc8d15 a0c6bfc2
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);
@@ -180,4 +180,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);

+0 −2
Original line number Diff line number Diff line
@@ -191,8 +191,6 @@ public class PerfettoProtoLogImpl implements IProtoLog {
                }

                os.end(outProtologViewerConfigToken);

                ctx.flush();
            } catch (IOException e) {
                Log.e(LOG_TAG, "Failed to read ProtoLog viewer config to dump on tracing end", e);
            }
+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);
}
@@ -435,11 +435,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},
+0 −2
Original line number Diff line number Diff line
@@ -674,8 +674,6 @@ public class DataSourceTest {
                            protoOutputStream.write(SINGLE_INT, singleIntValue);
                            protoOutputStream.end(payloadToken);
                            protoOutputStream.end(forTestingToken);

                            ctx.flush();
                        }),
                        (args) -> {}
                );
Loading