Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt +9 −2 Original line number Diff line number Diff line Loading @@ -127,12 +127,19 @@ constructor( false, ) private val displayId = bundle.getInt(KEY_DISPLAY_ID, DEFAULT_DISPLAY) private val display: Display? = displayManager.getDisplay(displayId) /** * Returns a key that should make the KeyguardPreviewRenderer unique and if two of them have the * same key they will be treated as the same KeyguardPreviewRenderer. Primary this is used to * prevent memory leaks by allowing removal of the old KeyguardPreviewRenderer. */ val id = Pair(hostToken, displayId) /** [shouldHideClock] here means that we never create and bind the clock views */ private val shouldHideClock: Boolean = bundle.getBoolean(ClockPreviewConstants.KEY_HIDE_CLOCK, false) private val wallpaperColors: WallpaperColors? = bundle.getParcelable(KEY_COLORS) private val displayId = bundle.getInt(KEY_DISPLAY_ID, DEFAULT_DISPLAY) private val display: Display? = displayManager.getDisplay(displayId) private var host: SurfaceControlViewHost Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardRemotePreviewManager.kt +10 −10 Original line number Diff line number Diff line Loading @@ -44,8 +44,8 @@ constructor( @Main private val mainDispatcher: CoroutineDispatcher, @Background private val backgroundHandler: Handler, ) { private val activePreviews: ArrayMap<IBinder, PreviewLifecycleObserver> = ArrayMap<IBinder, PreviewLifecycleObserver>() private val activePreviews: ArrayMap<Pair<IBinder?, Int>, PreviewLifecycleObserver> = ArrayMap<Pair<IBinder?, Int>, PreviewLifecycleObserver>() fun preview(request: Bundle?): Bundle? { if (request == null) { Loading @@ -56,8 +56,6 @@ constructor( return try { val renderer = previewRendererFactory.create(request) // Destroy any previous renderer associated with this token. activePreviews[renderer.hostToken]?.let { destroyObserver(it) } observer = PreviewLifecycleObserver( renderer, Loading @@ -65,7 +63,9 @@ constructor( mainDispatcher, ::destroyObserver, ) activePreviews[renderer.hostToken] = observer // Destroy any previous renderer associated with this token. activePreviews[renderer.id]?.let { destroyObserver(it) } activePreviews[renderer.id] = observer renderer.render() renderer.hostToken?.linkToDeath(observer, 0) val result = Bundle() Loading @@ -92,9 +92,9 @@ constructor( } private fun destroyObserver(observer: PreviewLifecycleObserver) { observer.onDestroy()?.let { hostToken -> if (activePreviews[hostToken] === observer) { activePreviews.remove(hostToken) observer.onDestroy()?.let { identifier -> if (activePreviews[identifier] === observer) { activePreviews.remove(identifier) } } } Loading Loading @@ -134,7 +134,7 @@ constructor( requestDestruction(this) } fun onDestroy(): IBinder? { fun onDestroy(): Pair<IBinder?, Int>? { if (isDestroyedOrDestroying) { return null } Loading @@ -143,7 +143,7 @@ constructor( val hostToken = renderer.hostToken hostToken?.unlinkToDeath(this, 0) scope.launch(mainDispatcher) { renderer.destroy() } return hostToken return renderer.id } } Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt +9 −2 Original line number Diff line number Diff line Loading @@ -127,12 +127,19 @@ constructor( false, ) private val displayId = bundle.getInt(KEY_DISPLAY_ID, DEFAULT_DISPLAY) private val display: Display? = displayManager.getDisplay(displayId) /** * Returns a key that should make the KeyguardPreviewRenderer unique and if two of them have the * same key they will be treated as the same KeyguardPreviewRenderer. Primary this is used to * prevent memory leaks by allowing removal of the old KeyguardPreviewRenderer. */ val id = Pair(hostToken, displayId) /** [shouldHideClock] here means that we never create and bind the clock views */ private val shouldHideClock: Boolean = bundle.getBoolean(ClockPreviewConstants.KEY_HIDE_CLOCK, false) private val wallpaperColors: WallpaperColors? = bundle.getParcelable(KEY_COLORS) private val displayId = bundle.getInt(KEY_DISPLAY_ID, DEFAULT_DISPLAY) private val display: Display? = displayManager.getDisplay(displayId) private var host: SurfaceControlViewHost Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardRemotePreviewManager.kt +10 −10 Original line number Diff line number Diff line Loading @@ -44,8 +44,8 @@ constructor( @Main private val mainDispatcher: CoroutineDispatcher, @Background private val backgroundHandler: Handler, ) { private val activePreviews: ArrayMap<IBinder, PreviewLifecycleObserver> = ArrayMap<IBinder, PreviewLifecycleObserver>() private val activePreviews: ArrayMap<Pair<IBinder?, Int>, PreviewLifecycleObserver> = ArrayMap<Pair<IBinder?, Int>, PreviewLifecycleObserver>() fun preview(request: Bundle?): Bundle? { if (request == null) { Loading @@ -56,8 +56,6 @@ constructor( return try { val renderer = previewRendererFactory.create(request) // Destroy any previous renderer associated with this token. activePreviews[renderer.hostToken]?.let { destroyObserver(it) } observer = PreviewLifecycleObserver( renderer, Loading @@ -65,7 +63,9 @@ constructor( mainDispatcher, ::destroyObserver, ) activePreviews[renderer.hostToken] = observer // Destroy any previous renderer associated with this token. activePreviews[renderer.id]?.let { destroyObserver(it) } activePreviews[renderer.id] = observer renderer.render() renderer.hostToken?.linkToDeath(observer, 0) val result = Bundle() Loading @@ -92,9 +92,9 @@ constructor( } private fun destroyObserver(observer: PreviewLifecycleObserver) { observer.onDestroy()?.let { hostToken -> if (activePreviews[hostToken] === observer) { activePreviews.remove(hostToken) observer.onDestroy()?.let { identifier -> if (activePreviews[identifier] === observer) { activePreviews.remove(identifier) } } } Loading Loading @@ -134,7 +134,7 @@ constructor( requestDestruction(this) } fun onDestroy(): IBinder? { fun onDestroy(): Pair<IBinder?, Int>? { if (isDestroyedOrDestroying) { return null } Loading @@ -143,7 +143,7 @@ constructor( val hostToken = renderer.hostToken hostToken?.unlinkToDeath(this, 0) scope.launch(mainDispatcher) { renderer.destroy() } return hostToken return renderer.id } } Loading