diff options
| -rw-r--r-- | packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt | 31 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/ClockEventController.kt | 8 |
2 files changed, 28 insertions, 11 deletions
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt b/packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt index 2dd146c5134d..a4b1ceeebfa3 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt @@ -1,6 +1,7 @@ package com.android.systemui.plugins import android.os.Bundle +import android.util.Log import androidx.annotation.VisibleForTesting class WeatherData @@ -11,6 +12,7 @@ constructor( val temperature: Int, ) { companion object { + const val DEBUG = true private const val TAG = "WeatherData" @VisibleForTesting const val DESCRIPTION_KEY = "description" @VisibleForTesting const val STATE_KEY = "state" @@ -23,20 +25,29 @@ constructor( val state = WeatherStateIcon.fromInt(extras.getInt(STATE_KEY, INVALID_WEATHER_ICON_STATE)) val temperature = readIntFromBundle(extras, TEMPERATURE_KEY) - return if ( + if ( description == null || state == null || !extras.containsKey(USE_CELSIUS_KEY) || temperature == null - ) - null - else - WeatherData( - description = description, - state = state, - useCelsius = extras.getBoolean(USE_CELSIUS_KEY), - temperature = temperature - ) + ) { + if (DEBUG) { + Log.w(TAG, "Weather data did not parse from $extras") + } + return null + } else { + val result = + WeatherData( + description = description, + state = state, + useCelsius = extras.getBoolean(USE_CELSIUS_KEY), + temperature = temperature + ) + if (DEBUG) { + Log.i(TAG, "Weather data parsed $result from $extras") + } + return result + } } private fun readIntFromBundle(extras: Bundle, key: String): Int? = diff --git a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt index a8f280429105..8ea4c31a5ac9 100644 --- a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +++ b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt @@ -23,6 +23,7 @@ import android.content.IntentFilter import android.content.res.Resources import android.text.format.DateFormat import android.util.TypedValue +import android.util.Log import android.view.View import android.view.View.OnAttachStateChangeListener import android.view.ViewTreeObserver @@ -101,7 +102,12 @@ constructor( } updateFontSizes() updateTimeListeners() - cachedWeatherData?.let { value.events.onWeatherDataChanged(it) } + cachedWeatherData?.let { + if (WeatherData.DEBUG) { + Log.i(TAG, "Pushing cached weather data to new clock: $it") + } + value.events.onWeatherDataChanged(it) + } value.smallClock.view.addOnAttachStateChangeListener( object : OnAttachStateChangeListener { override fun onViewAttachedToWindow(p0: View?) { |