Loading motiontoollib/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -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" } Loading motiontoollib/src/com/android/app/motiontool/DdmHandleMotionTool.kt +2 −2 Original line number Diff line number Diff line Loading @@ -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() Loading @@ -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() Loading motiontoollib/src/com/android/app/motiontool/MotionToolManager.kt +25 −27 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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 } /** Loading @@ -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() Loading @@ -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 } } } Loading motiontoollib/src/com/android/app/motiontool/proto/motion_tool.proto +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; } motiontoollib/tests/AndroidManifest.xml +3 −3 Original line number Diff line number Diff line Loading @@ -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" /> Loading @@ -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
motiontoollib/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -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" } Loading
motiontoollib/src/com/android/app/motiontool/DdmHandleMotionTool.kt +2 −2 Original line number Diff line number Diff line Loading @@ -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() Loading @@ -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() Loading
motiontoollib/src/com/android/app/motiontool/MotionToolManager.kt +25 −27 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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 } /** Loading @@ -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() Loading @@ -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 } } } Loading
motiontoollib/src/com/android/app/motiontool/proto/motion_tool.proto +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; }
motiontoollib/tests/AndroidManifest.xml +3 −3 Original line number Diff line number Diff line Loading @@ -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" /> Loading @@ -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>