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

Commit 68eda440 authored by Winson Chung's avatar Winson Chung
Browse files

Inline framework class that isn't visible via the shared lib

Bug: 144854916
Test: Make shared lib and ensure ag/10217912 builds
Change-Id: I110834d24c6f08299050e925bef9a4e738d700ac
parent fe830f97
Loading
Loading
Loading
Loading
+21 −17
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ import java.util.function.Consumer;
 * @param <R> The proto class type of the entry root proto in the buffer
 */
public class FrameProtoTracer<P, S extends P, T extends P, R>
        implements TraceBuffer.ProtoProvider<P, S, T>, Choreographer.FrameCallback {
        implements Choreographer.FrameCallback {

    private static final String TAG = "FrameProtoTracer";
    private static final int BUFFER_CAPACITY = 1024 * 1024;
@@ -57,6 +57,25 @@ public class FrameProtoTracer<P, S extends P, T extends P, R>
    private volatile boolean mEnabled;
    private boolean mFrameScheduled;

    private final TraceBuffer.ProtoProvider<P, S, T> mProvider =
            new TraceBuffer.ProtoProvider<P, S, T>() {
        @Override
        public int getItemSize(P proto) {
            return mParams.getProtoSize(proto);
        }

        @Override
        public byte[] getBytes(P proto) {
            return mParams.getProtoBytes(proto);
        }

        @Override
        public void write(S encapsulatingProto, Queue<T> buffer, OutputStream os)
                throws IOException {
            os.write(mParams.serializeEncapsulatingProto(encapsulatingProto, buffer));
        }
    };

    public interface ProtoTraceParams<P, S, T, R> {
        File getTraceFile();
        S getEncapsulatingTraceProto();
@@ -68,7 +87,7 @@ public class FrameProtoTracer<P, S extends P, T extends P, R>

    public FrameProtoTracer(ProtoTraceParams<P, S, T, R> params) {
        mParams = params;
        mBuffer = new TraceBuffer<>(BUFFER_CAPACITY, this, new Consumer<T>() {
        mBuffer = new TraceBuffer<>(BUFFER_CAPACITY, mProvider, new Consumer<T>() {
            @Override
            public void accept(T t) {
                onProtoDequeued(t);
@@ -78,21 +97,6 @@ public class FrameProtoTracer<P, S extends P, T extends P, R>
        mChoreographer = Choreographer.getMainThreadInstance();
    }

    @Override
    public int getItemSize(P proto) {
        return mParams.getProtoSize(proto);
    }

    @Override
    public byte[] getBytes(P proto) {
        return mParams.getProtoBytes(proto);
    }

    @Override
    public void write(S encapsulatingProto, Queue<T> buffer, OutputStream os) throws IOException {
        os.write(mParams.serializeEncapsulatingProto(encapsulatingProto, buffer));
    }

    public void start() {
        synchronized (mLock) {
            if (mEnabled) {