QSTileLogger: use TileSpec for logbuffer map key
The key used to be of type String, which was inconsistent with the type
of the key in LogModule. This fault resulted in a build failure when
QSTileLogger was being referenced in PolicyModule.
Flag: NONE
Fixes: 310008787
Test: manual. mp droid should not fail when adding a tile that uses
QSTileLogger.
Test: atest QSTileLoggerTest
Change-Id: I546b934309d77e65f56a74dca8a69ae5a392dc49
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/logging/QSTileLogger.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/logging/QSTileLogger.kt
index 2074a14..0a9a6d3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/base/logging/QSTileLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/base/logging/QSTileLogger.kt
@@ -33,7 +33,7 @@
class QSTileLogger
@Inject
constructor(
- @QSTilesLogBuffers logBuffers: Map<String, LogBuffer>,
+ @QSTilesLogBuffers logBuffers: Map<TileSpec, LogBuffer>,
private val factory: LogBufferFactory,
private val mStatusBarStateController: StatusBarStateController,
) {
@@ -162,7 +162,7 @@
private fun TileSpec.getLogBuffer(): LogBuffer =
synchronized(logBufferCache) {
- logBufferCache.getOrPut(this.spec) {
+ logBufferCache.getOrPut(this) {
factory.create(
this.getLogTag(),
BUFFER_MAX_SIZE /* maxSize */,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt
index 8f27e4e..b5e7e2c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt
@@ -55,12 +55,9 @@
fun setup() {
MockitoAnnotations.initMocks(this)
whenever(logBufferFactory.create(any(), any(), any())).thenReturn(logBuffer)
+ val tileSpec: TileSpec = TileSpec.create("chatty_tile")
underTest =
- QSTileLogger(
- mapOf("chatty_tile" to chattyLogBuffer),
- logBufferFactory,
- statusBarController
- )
+ QSTileLogger(mapOf(tileSpec to chattyLogBuffer), logBufferFactory, statusBarController)
}
@Test