Loading packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +10 −1 Original line number Diff line number Diff line Loading @@ -176,7 +176,6 @@ public class LogModule { return factory.create("MediaTttReceiver", 20); } /** * Provides a logging buffer for logs related to the media mute-await connections. See * {@link com.android.systemui.media.muteawait.MediaMuteAwaitConnectionManager}. Loading @@ -199,6 +198,16 @@ public class LogModule { return factory.create("NearbyMediaDevicesLog", 20); } /** * Provides a buffer for logs related to media view events */ @Provides @SysUISingleton @MediaViewLog public static LogBuffer provideMediaViewLogBuffer(LogBufferFactory factory) { return factory.create("MediaView", 100); } /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */ @Provides @SysUISingleton Loading packages/SystemUI/src/com/android/systemui/log/dagger/MediaViewLog.java 0 → 100644 +35 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.log.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.systemui.log.LogBuffer; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import javax.inject.Qualifier; /** * A {@link LogBuffer} for {@link com.android.systemui.media.MediaViewLogger} */ @Qualifier @Documented @Retention(RUNTIME) public @interface MediaViewLog { } packages/SystemUI/src/com/android/systemui/media/MediaViewController.kt +8 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,8 @@ import javax.inject.Inject class MediaViewController @Inject constructor( private val context: Context, private val configurationController: ConfigurationController, private val mediaHostStatesManager: MediaHostStatesManager private val mediaHostStatesManager: MediaHostStatesManager, private val logger: MediaViewLogger ) { /** Loading Loading @@ -330,6 +331,7 @@ class MediaViewController @Inject constructor( // is cheap setGutsViewState(result) viewStates[cacheKey] = result logger.logMediaSize("measured new viewState", result.width, result.height) } else { // This is an interpolated state val startState = state.copy().also { it.expansion = 0.0f } Loading @@ -344,6 +346,7 @@ class MediaViewController @Inject constructor( startViewState, endViewState, state.expansion) logger.logMediaSize("interpolated viewState", result.width, result.height) } if (state.squishFraction < 1f) { return squishViewState(result, state.squishFraction) Loading Loading @@ -371,6 +374,7 @@ class MediaViewController @Inject constructor( */ fun attach(transitionLayout: TransitionLayout, type: TYPE) { updateMediaViewControllerType(type) logger.logMediaLocation("attach", currentStartLocation, currentEndLocation) this.transitionLayout = transitionLayout layoutController.attach(transitionLayout) if (currentEndLocation == -1) { Loading Loading @@ -409,6 +413,7 @@ class MediaViewController @Inject constructor( currentEndLocation = endLocation currentStartLocation = startLocation currentTransitionProgress = transitionProgress logger.logMediaLocation("setCurrentState", startLocation, endLocation) val shouldAnimate = animateNextStateChange && !applyImmediately Loading Loading @@ -461,6 +466,7 @@ class MediaViewController @Inject constructor( result = layoutController.getInterpolatedState(startViewState, endViewState, transitionProgress, tmpState) } logger.logMediaSize("setCurrentState", result.width, result.height) layoutController.setState(result, applyImmediately, shouldAnimate, animationDuration, animationDelay) } Loading @@ -478,6 +484,7 @@ class MediaViewController @Inject constructor( result.height = Math.max(it.measuredHeight, result.height) result.width = Math.max(it.measuredWidth, result.width) } logger.logMediaSize("update to carousel", result.width, result.height) return result } Loading packages/SystemUI/src/com/android/systemui/media/MediaViewLogger.kt 0 → 100644 +63 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.media import com.android.systemui.dagger.SysUISingleton import com.android.systemui.log.LogBuffer import com.android.systemui.log.LogLevel import com.android.systemui.log.dagger.MediaViewLog import javax.inject.Inject private const val TAG = "MediaView" /** * A buffered log for media view events that are too noisy for regular logging */ @SysUISingleton class MediaViewLogger @Inject constructor( @MediaViewLog private val buffer: LogBuffer ) { fun logMediaSize(reason: String, width: Int, height: Int) { buffer.log( TAG, LogLevel.DEBUG, { str1 = reason int1 = width int2 = height }, { "size ($str1): $int1 x $int2" } ) } fun logMediaLocation(reason: String, startLocation: Int, endLocation: Int) { buffer.log( TAG, LogLevel.DEBUG, { str1 = reason int1 = startLocation int2 = endLocation }, { "location ($str1): $int1 -> $int2" } ) } } No newline at end of file packages/SystemUI/tests/src/com/android/systemui/media/MediaViewControllerTest.kt +13 −2 Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ import junit.framework.Assert.assertTrue import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoAnnotations /** * Tests for {@link MediaViewController}. Loading @@ -20,16 +22,25 @@ import org.junit.runner.RunWith @RunWith(AndroidTestingRunner::class) @TestableLooper.RunWithLooper class MediaViewControllerTest : SysuiTestCase() { @Mock private lateinit var logger: MediaViewLogger private val configurationController = com.android.systemui.statusbar.phone.ConfigurationControllerImpl(context) private val mediaHostStatesManager = MediaHostStatesManager() private val mediaViewController = MediaViewController(context, configurationController, mediaHostStatesManager) private lateinit var mediaViewController: MediaViewController private val mediaHostStateHolder = MediaHost.MediaHostStateHolder() private var transitionLayout = TransitionLayout(context, /* attrs */ null, /* defStyleAttr */ 0) @Before fun setUp() { MockitoAnnotations.initMocks(this) mediaViewController = MediaViewController( context, configurationController, mediaHostStatesManager, logger ) mediaViewController.attach(transitionLayout, MediaViewController.TYPE.PLAYER) } Loading Loading
packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +10 −1 Original line number Diff line number Diff line Loading @@ -176,7 +176,6 @@ public class LogModule { return factory.create("MediaTttReceiver", 20); } /** * Provides a logging buffer for logs related to the media mute-await connections. See * {@link com.android.systemui.media.muteawait.MediaMuteAwaitConnectionManager}. Loading @@ -199,6 +198,16 @@ public class LogModule { return factory.create("NearbyMediaDevicesLog", 20); } /** * Provides a buffer for logs related to media view events */ @Provides @SysUISingleton @MediaViewLog public static LogBuffer provideMediaViewLogBuffer(LogBufferFactory factory) { return factory.create("MediaView", 100); } /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */ @Provides @SysUISingleton Loading
packages/SystemUI/src/com/android/systemui/log/dagger/MediaViewLog.java 0 → 100644 +35 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.log.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.systemui.log.LogBuffer; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import javax.inject.Qualifier; /** * A {@link LogBuffer} for {@link com.android.systemui.media.MediaViewLogger} */ @Qualifier @Documented @Retention(RUNTIME) public @interface MediaViewLog { }
packages/SystemUI/src/com/android/systemui/media/MediaViewController.kt +8 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,8 @@ import javax.inject.Inject class MediaViewController @Inject constructor( private val context: Context, private val configurationController: ConfigurationController, private val mediaHostStatesManager: MediaHostStatesManager private val mediaHostStatesManager: MediaHostStatesManager, private val logger: MediaViewLogger ) { /** Loading Loading @@ -330,6 +331,7 @@ class MediaViewController @Inject constructor( // is cheap setGutsViewState(result) viewStates[cacheKey] = result logger.logMediaSize("measured new viewState", result.width, result.height) } else { // This is an interpolated state val startState = state.copy().also { it.expansion = 0.0f } Loading @@ -344,6 +346,7 @@ class MediaViewController @Inject constructor( startViewState, endViewState, state.expansion) logger.logMediaSize("interpolated viewState", result.width, result.height) } if (state.squishFraction < 1f) { return squishViewState(result, state.squishFraction) Loading Loading @@ -371,6 +374,7 @@ class MediaViewController @Inject constructor( */ fun attach(transitionLayout: TransitionLayout, type: TYPE) { updateMediaViewControllerType(type) logger.logMediaLocation("attach", currentStartLocation, currentEndLocation) this.transitionLayout = transitionLayout layoutController.attach(transitionLayout) if (currentEndLocation == -1) { Loading Loading @@ -409,6 +413,7 @@ class MediaViewController @Inject constructor( currentEndLocation = endLocation currentStartLocation = startLocation currentTransitionProgress = transitionProgress logger.logMediaLocation("setCurrentState", startLocation, endLocation) val shouldAnimate = animateNextStateChange && !applyImmediately Loading Loading @@ -461,6 +466,7 @@ class MediaViewController @Inject constructor( result = layoutController.getInterpolatedState(startViewState, endViewState, transitionProgress, tmpState) } logger.logMediaSize("setCurrentState", result.width, result.height) layoutController.setState(result, applyImmediately, shouldAnimate, animationDuration, animationDelay) } Loading @@ -478,6 +484,7 @@ class MediaViewController @Inject constructor( result.height = Math.max(it.measuredHeight, result.height) result.width = Math.max(it.measuredWidth, result.width) } logger.logMediaSize("update to carousel", result.width, result.height) return result } Loading
packages/SystemUI/src/com/android/systemui/media/MediaViewLogger.kt 0 → 100644 +63 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.media import com.android.systemui.dagger.SysUISingleton import com.android.systemui.log.LogBuffer import com.android.systemui.log.LogLevel import com.android.systemui.log.dagger.MediaViewLog import javax.inject.Inject private const val TAG = "MediaView" /** * A buffered log for media view events that are too noisy for regular logging */ @SysUISingleton class MediaViewLogger @Inject constructor( @MediaViewLog private val buffer: LogBuffer ) { fun logMediaSize(reason: String, width: Int, height: Int) { buffer.log( TAG, LogLevel.DEBUG, { str1 = reason int1 = width int2 = height }, { "size ($str1): $int1 x $int2" } ) } fun logMediaLocation(reason: String, startLocation: Int, endLocation: Int) { buffer.log( TAG, LogLevel.DEBUG, { str1 = reason int1 = startLocation int2 = endLocation }, { "location ($str1): $int1 -> $int2" } ) } } No newline at end of file
packages/SystemUI/tests/src/com/android/systemui/media/MediaViewControllerTest.kt +13 −2 Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ import junit.framework.Assert.assertTrue import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoAnnotations /** * Tests for {@link MediaViewController}. Loading @@ -20,16 +22,25 @@ import org.junit.runner.RunWith @RunWith(AndroidTestingRunner::class) @TestableLooper.RunWithLooper class MediaViewControllerTest : SysuiTestCase() { @Mock private lateinit var logger: MediaViewLogger private val configurationController = com.android.systemui.statusbar.phone.ConfigurationControllerImpl(context) private val mediaHostStatesManager = MediaHostStatesManager() private val mediaViewController = MediaViewController(context, configurationController, mediaHostStatesManager) private lateinit var mediaViewController: MediaViewController private val mediaHostStateHolder = MediaHost.MediaHostStateHolder() private var transitionLayout = TransitionLayout(context, /* attrs */ null, /* defStyleAttr */ 0) @Before fun setUp() { MockitoAnnotations.initMocks(this) mediaViewController = MediaViewController( context, configurationController, mediaHostStatesManager, logger ) mediaViewController.attach(transitionLayout, MediaViewController.TYPE.PLAYER) } Loading