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

Commit 52d4a81f authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9284490 from 2021d6ce to tm-qpr2-release

Change-Id: I6619156d1c50188809ad1467cac7b0e32db91239
parents 9f00573e 2021d6ce
Loading
Loading
Loading
Loading

motiontoollib/OWNERS

0 → 100644
+3 −0
Original line number Diff line number Diff line
gallmann@google.com
michschn@google.com
cinek@google.com
 No newline at end of file
+0 −1
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ class DdmHandleMotionTool private constructor(
        val CHUNK_MOTO = ChunkHandler.type("MOTO")
        private const val SERVER_VERSION = 1

        @Volatile
        private var INSTANCE: DdmHandleMotionTool? = null

        @Synchronized
+12 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.app.motiontool
import android.util.Log
import android.view.View
import android.view.WindowManagerGlobal
import androidx.annotation.VisibleForTesting
import com.android.app.motiontool.nano.WindowIdentifier
import com.android.app.viewcapture.ViewCapture
import com.android.app.viewcapture.data.nano.ExportedData
@@ -31,7 +32,7 @@ import com.android.app.viewcapture.data.nano.ExportedData
 *
 * To start a trace, use [beginTrace]. The returned handle must be used to terminate tracing and
 * receive the data by calling [endTrace]. While the trace is active, data is buffered, however
 * the buffer size is limited (@see [ViewCapture.MEMORY_SIZE]. Use [pollTrace] periodically to
 * the buffer size is limited (@see [ViewCapture.mMemorySize]. Use [pollTrace] periodically to
 * ensure no data is dropped. Both, [pollTrace] and [endTrace] only return data captured since the
 * last call to either [beginTrace] or [endTrace].
 *
@@ -48,7 +49,6 @@ class MotionToolManager private constructor(
    companion object {
        private const val TAG = "MotionToolManager"

        @Volatile
        private var INSTANCE: MotionToolManager? = null

        @Synchronized
@@ -65,12 +65,14 @@ class MotionToolManager private constructor(
    private var traceIdCounter = 0
    private val traces = mutableMapOf<Int, TraceMetadata>()

    @Synchronized
    fun hasWindow(windowId: WindowIdentifier): Boolean {
        val rootView = getRootView(windowId.rootWindow)
        return rootView != null
    }

    /** Starts [ViewCapture] and returns a traceId. */
    @Synchronized
    fun beginTrace(windowId: String): Int {
        val traceId = ++traceIdCounter
        Log.d(TAG, "Begin Trace for id: $traceId")
@@ -84,6 +86,7 @@ class MotionToolManager private constructor(
     * Ends [ViewCapture] and returns the captured [ExportedData] since the [beginTrace] call or the
     * last [pollTrace] call.
     */
    @Synchronized
    fun endTrace(traceId: Int): ExportedData {
        Log.d(TAG, "End Trace for id: $traceId")
        val traceMetadata = traces.getOrElse(traceId) { throw UnknownTraceIdException(traceId) }
@@ -97,6 +100,7 @@ class MotionToolManager private constructor(
     * Returns the [ExportedData] captured since the [beginTrace] call or the last [pollTrace] call.
     * This function can only be used after [beginTrace] is called and before [endTrace] is called.
     */
    @Synchronized
    fun pollTrace(traceId: Int): ExportedData {
        val traceMetadata = traces.getOrElse(traceId) { throw UnknownTraceIdException(traceId) }
        val exportedData = getExportedDataFromViewCapture(traceMetadata)
@@ -104,6 +108,11 @@ class MotionToolManager private constructor(
        return exportedData
    }

    /**
     * Stops and deletes all active [traces] and resets the [traceIdCounter].
     */
    @VisibleForTesting
    @Synchronized
    fun reset() {
        for (traceMetadata in traces.values) {
            traceMetadata.stopTrace()
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.view.Window;
import android.os.Process;

import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;

import com.android.app.viewcapture.data.nano.ExportedData;
@@ -84,6 +85,7 @@ public class ViewCapture {
        return getInstance(true, DEFAULT_MEMORY_SIZE, DEFAULT_INIT_POOL_SIZE);
    }

    @VisibleForTesting
    public static ViewCapture getInstance(boolean offloadToBackgroundThread, int memorySize,
            int initPoolSize) {
        if (INSTANCE == null) {
+1 −1

File changed.

Contains only whitespace changes.