Loading packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContent.kt +6 −16 Original line number Diff line number Diff line Loading @@ -66,13 +66,13 @@ constructor( interactionHandler = interactionHandler, dialogFactory = dialogFactory, widgetSection = widgetSection, modifier = Modifier.element(Communal.Elements.Grid) modifier = Modifier.element(Communal.Elements.Grid), ) } with(lockSection) { LockIcon( overrideColor = MaterialTheme.colorScheme.onPrimaryContainer, modifier = Modifier.element(Communal.Elements.LockIcon) modifier = Modifier.element(Communal.Elements.LockIcon), ) } with(bottomAreaSection) { Loading @@ -80,17 +80,13 @@ constructor( Modifier.element(Communal.Elements.IndicationArea).fillMaxWidth() ) } } }, ) { measurables, constraints -> val communalGridMeasurable = measurables[0] val lockIconMeasurable = measurables[1] val bottomAreaMeasurable = measurables[2] val noMinConstraints = constraints.copy( minWidth = 0, minHeight = 0, ) val noMinConstraints = constraints.copy(minWidth = 0, minHeight = 0) val lockIconPlaceable = lockIconMeasurable.measure(noMinConstraints) val lockIconBounds = Loading @@ -109,14 +105,8 @@ constructor( ) layout(constraints.maxWidth, constraints.maxHeight) { communalGridPlaceable.place( x = 0, y = 0, ) lockIconPlaceable.place( x = lockIconBounds.left, y = lockIconBounds.top, ) communalGridPlaceable.place(x = 0, y = 0) lockIconPlaceable.place(x = lockIconBounds.left, y = lockIconBounds.top) bottomAreaPlaceable.place( x = 0, y = constraints.maxHeight - bottomAreaPlaceable.height, Loading packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +0 −1 Original line number Diff line number Diff line Loading @@ -807,7 +807,6 @@ private fun BoxScope.CommunalHubLazyGrid( ) { ResizeableItemFrameViewModel() } if (viewModel.isEditMode && dragDropState != null) { val isItemDragging = dragDropState.draggingItemKey == item.key val outlineAlpha by Loading packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/ContentListState.kt +11 −2 Original line number Diff line number Diff line Loading @@ -59,7 +59,14 @@ internal constructor( private val onAddWidget: (componentName: ComponentName, user: UserHandle, rank: Int) -> Unit, private val onDeleteWidget: (id: Int, componentName: ComponentName, rank: Int) -> Unit, private val onReorderWidgets: (widgetIdToRankMap: Map<Int, Int>) -> Unit, private val onResizeWidget: (id: Int, spanY: Int, widgetIdToRankMap: Map<Int, Int>) -> Unit, private val onResizeWidget: ( id: Int, spanY: Int, widgetIdToRankMap: Map<Int, Int>, componentName: ComponentName, rank: Int, ) -> Unit, ) { var list = communalContent.toMutableStateList() private set Loading Loading @@ -105,7 +112,9 @@ internal constructor( } else { emptyMap() } onResizeWidget(item.appWidgetId, newSpan, widgetIdToRankMap) val componentName = item.componentName val rank = item.rank onResizeWidget(item.appWidgetId, newSpan, widgetIdToRankMap, componentName, rank) } /** Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/log/CommunalMetricsLoggerTest.kt +48 −27 Original line number Diff line number Diff line Loading @@ -47,20 +47,14 @@ class CommunalMetricsLoggerTest : SysuiTestCase() { @Test fun logAddWidget_componentNotLoggable_doNotLog() { underTest.logAddWidget( componentName = "com.green.package/my_test_widget", rank = 1, ) underTest.logAddWidget(componentName = "com.green.package/my_test_widget", rank = 1) verify(statsLogProxy, never()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt(), anyInt()) } @Test fun logAddWidget_componentLoggable_logAddEvent() { underTest.logAddWidget( componentName = "com.blue.package/my_test_widget", rank = 1, ) underTest.logAddWidget(componentName = "com.blue.package/my_test_widget", rank = 1) verify(statsLogProxy) .writeCommunalHubWidgetEventReported( SysUiStatsLog.COMMUNAL_HUB_WIDGET_EVENT_REPORTED__ACTION__ADD, Loading @@ -71,20 +65,14 @@ class CommunalMetricsLoggerTest : SysuiTestCase() { @Test fun logRemoveWidget_componentNotLoggable_doNotLog() { underTest.logRemoveWidget( componentName = "com.yellow.package/my_test_widget", rank = 2, ) underTest.logRemoveWidget(componentName = "com.yellow.package/my_test_widget", rank = 2) verify(statsLogProxy, never()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt(), anyInt()) } @Test fun logRemoveWidget_componentLoggable_logRemoveEvent() { underTest.logRemoveWidget( componentName = "com.red.package/my_test_widget", rank = 2, ) underTest.logRemoveWidget(componentName = "com.red.package/my_test_widget", rank = 2) verify(statsLogProxy) .writeCommunalHubWidgetEventReported( SysUiStatsLog.COMMUNAL_HUB_WIDGET_EVENT_REPORTED__ACTION__REMOVE, Loading @@ -95,20 +83,14 @@ class CommunalMetricsLoggerTest : SysuiTestCase() { @Test fun logTapWidget_componentNotLoggable_doNotLog() { underTest.logTapWidget( componentName = "com.yellow.package/my_test_widget", rank = 2, ) underTest.logTapWidget(componentName = "com.yellow.package/my_test_widget", rank = 2) verify(statsLogProxy, never()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt(), anyInt()) } @Test fun logTapWidget_componentLoggable_logRemoveEvent() { underTest.logTapWidget( componentName = "com.red.package/my_test_widget", rank = 2, ) underTest.logTapWidget(componentName = "com.red.package/my_test_widget", rank = 2) verify(statsLogProxy) .writeCommunalHubWidgetEventReported( SysUiStatsLog.COMMUNAL_HUB_WIDGET_EVENT_REPORTED__ACTION__TAP, Loading Loading @@ -140,4 +122,43 @@ class CommunalMetricsLoggerTest : SysuiTestCase() { ) assertThat(statsEvents).hasSize(1) } @Test fun logResizeWidget_componentNotLoggable_doNotLog() { underTest.logResizeWidget( componentName = "com.green.package/my_test_widget", rank = 1, spanY = 2, ) verify(statsLogProxy, never()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt(), anyInt()) } @Test fun logResizeWidget_componentLoggable_logResizeEvent() { underTest.logResizeWidget( componentName = "com.blue.package/my_test_widget", rank = 1, spanY = 2, ) verify(statsLogProxy) .writeCommunalHubWidgetEventReported( SysUiStatsLog.COMMUNAL_HUB_WIDGET_EVENT_REPORTED__ACTION__RESIZE, "com.blue.package/my_test_widget", rank = 1, spanY = 2, ) } @Test fun logResizeWidget_defaultSpanY_usesDefaultValue() { underTest.logResizeWidget(componentName = "com.blue.package/my_test_widget", rank = 1) verify(statsLogProxy) .writeCommunalHubWidgetEventReported( SysUiStatsLog.COMMUNAL_HUB_WIDGET_EVENT_REPORTED__ACTION__RESIZE, "com.blue.package/my_test_widget", rank = 1, spanY = 0, ) } } packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt +26 −0 Original line number Diff line number Diff line Loading @@ -353,6 +353,32 @@ class CommunalEditModeViewModelTest : SysuiTestCase() { assertThat(event.contentDescription).isEqualTo("Test Clock widget added to lock screen") } @Test fun onResizeWidget_logsMetrics() = testScope.runTest { val appWidgetId = 123 val spanY = 2 val widgetIdToRankMap = mapOf(appWidgetId to 1) val componentName = ComponentName("test.package", "TestWidget") val rank = 1 underTest.onResizeWidget( appWidgetId = appWidgetId, spanY = spanY, widgetIdToRankMap = widgetIdToRankMap, componentName = componentName, rank = rank, ) verify(communalInteractor).resizeWidget(appWidgetId, spanY, widgetIdToRankMap) verify(metricsLogger) .logResizeWidget( componentName = componentName.flattenToString(), rank = rank, spanY = spanY, ) } private companion object { val MAIN_USER_INFO = UserInfo(0, "primary", UserInfo.FLAG_MAIN) const val WIDGET_PICKER_PACKAGE_NAME = "widget_picker_package_name" Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContent.kt +6 −16 Original line number Diff line number Diff line Loading @@ -66,13 +66,13 @@ constructor( interactionHandler = interactionHandler, dialogFactory = dialogFactory, widgetSection = widgetSection, modifier = Modifier.element(Communal.Elements.Grid) modifier = Modifier.element(Communal.Elements.Grid), ) } with(lockSection) { LockIcon( overrideColor = MaterialTheme.colorScheme.onPrimaryContainer, modifier = Modifier.element(Communal.Elements.LockIcon) modifier = Modifier.element(Communal.Elements.LockIcon), ) } with(bottomAreaSection) { Loading @@ -80,17 +80,13 @@ constructor( Modifier.element(Communal.Elements.IndicationArea).fillMaxWidth() ) } } }, ) { measurables, constraints -> val communalGridMeasurable = measurables[0] val lockIconMeasurable = measurables[1] val bottomAreaMeasurable = measurables[2] val noMinConstraints = constraints.copy( minWidth = 0, minHeight = 0, ) val noMinConstraints = constraints.copy(minWidth = 0, minHeight = 0) val lockIconPlaceable = lockIconMeasurable.measure(noMinConstraints) val lockIconBounds = Loading @@ -109,14 +105,8 @@ constructor( ) layout(constraints.maxWidth, constraints.maxHeight) { communalGridPlaceable.place( x = 0, y = 0, ) lockIconPlaceable.place( x = lockIconBounds.left, y = lockIconBounds.top, ) communalGridPlaceable.place(x = 0, y = 0) lockIconPlaceable.place(x = lockIconBounds.left, y = lockIconBounds.top) bottomAreaPlaceable.place( x = 0, y = constraints.maxHeight - bottomAreaPlaceable.height, Loading
packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +0 −1 Original line number Diff line number Diff line Loading @@ -807,7 +807,6 @@ private fun BoxScope.CommunalHubLazyGrid( ) { ResizeableItemFrameViewModel() } if (viewModel.isEditMode && dragDropState != null) { val isItemDragging = dragDropState.draggingItemKey == item.key val outlineAlpha by Loading
packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/ContentListState.kt +11 −2 Original line number Diff line number Diff line Loading @@ -59,7 +59,14 @@ internal constructor( private val onAddWidget: (componentName: ComponentName, user: UserHandle, rank: Int) -> Unit, private val onDeleteWidget: (id: Int, componentName: ComponentName, rank: Int) -> Unit, private val onReorderWidgets: (widgetIdToRankMap: Map<Int, Int>) -> Unit, private val onResizeWidget: (id: Int, spanY: Int, widgetIdToRankMap: Map<Int, Int>) -> Unit, private val onResizeWidget: ( id: Int, spanY: Int, widgetIdToRankMap: Map<Int, Int>, componentName: ComponentName, rank: Int, ) -> Unit, ) { var list = communalContent.toMutableStateList() private set Loading Loading @@ -105,7 +112,9 @@ internal constructor( } else { emptyMap() } onResizeWidget(item.appWidgetId, newSpan, widgetIdToRankMap) val componentName = item.componentName val rank = item.rank onResizeWidget(item.appWidgetId, newSpan, widgetIdToRankMap, componentName, rank) } /** Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/log/CommunalMetricsLoggerTest.kt +48 −27 Original line number Diff line number Diff line Loading @@ -47,20 +47,14 @@ class CommunalMetricsLoggerTest : SysuiTestCase() { @Test fun logAddWidget_componentNotLoggable_doNotLog() { underTest.logAddWidget( componentName = "com.green.package/my_test_widget", rank = 1, ) underTest.logAddWidget(componentName = "com.green.package/my_test_widget", rank = 1) verify(statsLogProxy, never()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt(), anyInt()) } @Test fun logAddWidget_componentLoggable_logAddEvent() { underTest.logAddWidget( componentName = "com.blue.package/my_test_widget", rank = 1, ) underTest.logAddWidget(componentName = "com.blue.package/my_test_widget", rank = 1) verify(statsLogProxy) .writeCommunalHubWidgetEventReported( SysUiStatsLog.COMMUNAL_HUB_WIDGET_EVENT_REPORTED__ACTION__ADD, Loading @@ -71,20 +65,14 @@ class CommunalMetricsLoggerTest : SysuiTestCase() { @Test fun logRemoveWidget_componentNotLoggable_doNotLog() { underTest.logRemoveWidget( componentName = "com.yellow.package/my_test_widget", rank = 2, ) underTest.logRemoveWidget(componentName = "com.yellow.package/my_test_widget", rank = 2) verify(statsLogProxy, never()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt(), anyInt()) } @Test fun logRemoveWidget_componentLoggable_logRemoveEvent() { underTest.logRemoveWidget( componentName = "com.red.package/my_test_widget", rank = 2, ) underTest.logRemoveWidget(componentName = "com.red.package/my_test_widget", rank = 2) verify(statsLogProxy) .writeCommunalHubWidgetEventReported( SysUiStatsLog.COMMUNAL_HUB_WIDGET_EVENT_REPORTED__ACTION__REMOVE, Loading @@ -95,20 +83,14 @@ class CommunalMetricsLoggerTest : SysuiTestCase() { @Test fun logTapWidget_componentNotLoggable_doNotLog() { underTest.logTapWidget( componentName = "com.yellow.package/my_test_widget", rank = 2, ) underTest.logTapWidget(componentName = "com.yellow.package/my_test_widget", rank = 2) verify(statsLogProxy, never()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt(), anyInt()) } @Test fun logTapWidget_componentLoggable_logRemoveEvent() { underTest.logTapWidget( componentName = "com.red.package/my_test_widget", rank = 2, ) underTest.logTapWidget(componentName = "com.red.package/my_test_widget", rank = 2) verify(statsLogProxy) .writeCommunalHubWidgetEventReported( SysUiStatsLog.COMMUNAL_HUB_WIDGET_EVENT_REPORTED__ACTION__TAP, Loading Loading @@ -140,4 +122,43 @@ class CommunalMetricsLoggerTest : SysuiTestCase() { ) assertThat(statsEvents).hasSize(1) } @Test fun logResizeWidget_componentNotLoggable_doNotLog() { underTest.logResizeWidget( componentName = "com.green.package/my_test_widget", rank = 1, spanY = 2, ) verify(statsLogProxy, never()) .writeCommunalHubWidgetEventReported(anyInt(), any(), anyInt(), anyInt()) } @Test fun logResizeWidget_componentLoggable_logResizeEvent() { underTest.logResizeWidget( componentName = "com.blue.package/my_test_widget", rank = 1, spanY = 2, ) verify(statsLogProxy) .writeCommunalHubWidgetEventReported( SysUiStatsLog.COMMUNAL_HUB_WIDGET_EVENT_REPORTED__ACTION__RESIZE, "com.blue.package/my_test_widget", rank = 1, spanY = 2, ) } @Test fun logResizeWidget_defaultSpanY_usesDefaultValue() { underTest.logResizeWidget(componentName = "com.blue.package/my_test_widget", rank = 1) verify(statsLogProxy) .writeCommunalHubWidgetEventReported( SysUiStatsLog.COMMUNAL_HUB_WIDGET_EVENT_REPORTED__ACTION__RESIZE, "com.blue.package/my_test_widget", rank = 1, spanY = 0, ) } }
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalEditModeViewModelTest.kt +26 −0 Original line number Diff line number Diff line Loading @@ -353,6 +353,32 @@ class CommunalEditModeViewModelTest : SysuiTestCase() { assertThat(event.contentDescription).isEqualTo("Test Clock widget added to lock screen") } @Test fun onResizeWidget_logsMetrics() = testScope.runTest { val appWidgetId = 123 val spanY = 2 val widgetIdToRankMap = mapOf(appWidgetId to 1) val componentName = ComponentName("test.package", "TestWidget") val rank = 1 underTest.onResizeWidget( appWidgetId = appWidgetId, spanY = spanY, widgetIdToRankMap = widgetIdToRankMap, componentName = componentName, rank = rank, ) verify(communalInteractor).resizeWidget(appWidgetId, spanY, widgetIdToRankMap) verify(metricsLogger) .logResizeWidget( componentName = componentName.flattenToString(), rank = rank, spanY = spanY, ) } private companion object { val MAIN_USER_INFO = UserInfo(0, "primary", UserInfo.FLAG_MAIN) const val WIDGET_PICKER_PACKAGE_NAME = "widget_picker_package_name" Loading