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

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

Snap for 9891612 from 4f6f615c to udc-release

Change-Id: Ib6cf7b205f912970a215d1965de9e5c86adbe6fd
parents 68ee021c 4f6f615c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ final String PROTOS_DIR = "${ANDROID_TOP}/frameworks/libs/systemui/motiontoollib

android {
    namespace = "com.android.app.motiontool"
    testNamespace = "com.android.app.motiontool.tests"
    defaultConfig {
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
+2 −2
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ class DdmHandleMotionTool private constructor(
        MotionToolsResponse.newBuilder().apply {
            tryCatchingMotionToolManagerExceptions {
                setPollTrace(PollTraceResponse.newBuilder()
                        .setExportedData(motionToolManager.pollTrace(pollTraceRequest.traceId)))
                        .setData(motionToolManager.pollTrace(pollTraceRequest.traceId)))
            }
        }.build()

@@ -115,7 +115,7 @@ class DdmHandleMotionTool private constructor(
        MotionToolsResponse.newBuilder().apply {
            tryCatchingMotionToolManagerExceptions {
                setEndTrace(EndTraceResponse.newBuilder()
                        .setExportedData(motionToolManager.endTrace(endTraceRequest.traceId)))
                        .setData(motionToolManager.endTrace(endTraceRequest.traceId)))
            }
        }.build()

+25 −27
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import android.view.View
import android.view.WindowManagerGlobal
import androidx.annotation.VisibleForTesting
import com.android.app.viewcapture.ViewCapture
import com.android.app.viewcapture.data.ExportedData
import com.android.app.viewcapture.data.MotionWindowData

/**
 * Singleton to manage motion tracing sessions.
@@ -77,29 +77,29 @@ class MotionToolManager private constructor(private val windowManagerGlobal: Win
    }

    /**
     * Ends [ViewCapture] and returns the captured [ExportedData] since the [beginTrace] call or the
     * last [pollTrace] call.
     * Ends [ViewCapture] and returns the captured [MotionWindowData] since the [beginTrace] call or
     * the last [pollTrace] call.
     */
    @Synchronized
    fun endTrace(traceId: Int): ExportedData {
    fun endTrace(traceId: Int): MotionWindowData {
        Log.d(TAG, "End Trace for id: $traceId")
        val traceMetadata = traces.getOrElse(traceId) { throw UnknownTraceIdException(traceId) }
        val exportedData = pollTrace(traceId)
        val data = pollTrace(traceId)
        traceMetadata.stopTrace()
        traces.remove(traceId)
        return exportedData
        return data
    }

    /**
     * Returns the [ExportedData] captured since the [beginTrace] call or the last [pollTrace] call.
     * Returns the [MotionWindowData] captured since the [beginTrace] call or last [pollTrace] call.
     * This function can only be used after [beginTrace] is called and before [endTrace] is called.
     */
    @Synchronized
    fun pollTrace(traceId: Int): ExportedData {
    fun pollTrace(traceId: Int): MotionWindowData {
        val traceMetadata = traces.getOrElse(traceId) { throw UnknownTraceIdException(traceId) }
        val exportedData = getExportedDataFromViewCapture(traceMetadata)
        traceMetadata.updateLastPolledTime(exportedData)
        return exportedData
        val data = getDataFromViewCapture(traceMetadata)
        traceMetadata.updateLastPolledTime(data)
        return data
    }

    /**
@@ -115,20 +115,18 @@ class MotionToolManager private constructor(private val windowManagerGlobal: Win
        traceIdCounter = 0
    }

    private fun getExportedDataFromViewCapture(traceMetadata: TraceMetadata): ExportedData {
    private fun getDataFromViewCapture(traceMetadata: TraceMetadata): MotionWindowData {
        val rootView =
            getRootView(traceMetadata.windowId)
                ?: throw WindowNotFoundException(traceMetadata.windowId)

        val exportedData = viewCapture
            .getDumpTask(rootView)
            ?.orElse(null)
            ?.get() ?: return ExportedData.newBuilder().build()

        val filteredFrameData = exportedData.frameDataList
                ?.filter { it.timestamp > traceMetadata.lastPolledTime }

        return exportedData.toBuilder()
        val data: MotionWindowData = viewCapture
            .getDumpTask(rootView).get()
            ?.orElse(null) ?: return MotionWindowData.newBuilder().build()
        val filteredFrameData = data.frameDataList.filter {
            it.timestamp > traceMetadata.lastPolledTime
        }
        return data.toBuilder()
            .clearFrameData()
            .addAllFrameData(filteredFrameData)
            .build()
@@ -148,9 +146,9 @@ private data class TraceMetadata(
    var lastPolledTime: Long,
    var stopTrace: () -> Unit
) {
    fun updateLastPolledTime(exportedData: ExportedData?) {
        exportedData?.frameDataList?.maxOfOrNull { it.timestamp }?.let { maxFrameTimestamp ->
            lastPolledTime = maxFrameTimestamp
    fun updateLastPolledTime(data: MotionWindowData?) {
        data?.frameDataList?.maxOfOrNull { it.timestamp }?.let {
            lastPolledTime = it
        }
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ message EndTraceRequest {
}

message EndTraceResponse {
  optional com.android.app.viewcapture.data.ExportedData exported_data = 1;
  optional com.android.app.viewcapture.data.MotionWindowData data = 1;
}

// Polls collected motion trace data collected since the last PollTraceRequest (or the
@@ -108,6 +108,6 @@ message PollTraceRequest {
}

message PollTraceResponse {
  optional com.android.app.viewcapture.data.ExportedData exported_data = 1;
  optional com.android.app.viewcapture.data.MotionWindowData data = 1;
}
+3 −3
Original line number Diff line number Diff line
@@ -15,14 +15,14 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.app.motiontool">
    package="com.android.app.motiontool.tests">

    <application
        android:debuggable="true"
        android:theme="@android:style/Theme.NoTitleBar">

        <activity
            android:name=".util.TestActivity"
            android:name="com.android.app.motiontool.util.TestActivity"
            android:exported="false" />

        <uses-library android:name="android.test.runner" />
@@ -32,6 +32,6 @@
    <instrumentation
        android:name="android.testing.TestableInstrumentation"
        android:label="Tests for MotionTool Lib"
        android:targetPackage="com.android.app.motiontool"/>
        android:targetPackage="com.android.app.motiontool.tests"/>

</manifest>
Loading