Send weather data from LS Smartspace to clock
Setting up new Clock Event and data flow to handle weather data updates for the custom weather clock. Bug: 265069396 Test: manual Change-Id: I2711660b34935936c9a1d2651a14415c54b551ef
This commit is contained in:
@@ -20,6 +20,7 @@ import android.view.View
|
||||
import com.android.internal.annotations.Keep
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface
|
||||
import com.android.systemui.plugins.log.LogBuffer
|
||||
import com.android.systemui.statusbar.Weather
|
||||
import java.io.PrintWriter
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
@@ -111,6 +112,9 @@ interface ClockEvents {
|
||||
|
||||
/** Call whenever the color palette should update */
|
||||
fun onColorPaletteChanged(resources: Resources) {}
|
||||
|
||||
/** Call whenever the weather data should update */
|
||||
fun onWeatherDataChanged(data: Weather) {}
|
||||
}
|
||||
|
||||
/** Methods which trigger various clock animations */
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.android.systemui.plugins.ClockTickRate
|
||||
import com.android.systemui.plugins.log.LogBuffer
|
||||
import com.android.systemui.plugins.log.LogLevel.DEBUG
|
||||
import com.android.systemui.shared.regionsampling.RegionSampler
|
||||
import com.android.systemui.statusbar.Weather
|
||||
import com.android.systemui.statusbar.policy.BatteryController
|
||||
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController
|
||||
@@ -273,6 +274,12 @@ open class ClockEventController @Inject constructor(
|
||||
override fun onUserSwitchComplete(userId: Int) {
|
||||
clock?.events?.onTimeFormatChanged(DateFormat.is24HourFormat(context))
|
||||
}
|
||||
|
||||
override fun onWeatherDataChanged(data: Weather?) {
|
||||
if (data != null) {
|
||||
clock?.events?.onWeatherDataChanged(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun registerListeners(parent: View) {
|
||||
|
||||
@@ -108,7 +108,6 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.PowerManager;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -153,6 +152,7 @@ import com.android.systemui.settings.UserTracker;
|
||||
import com.android.systemui.shared.system.TaskStackChangeListener;
|
||||
import com.android.systemui.shared.system.TaskStackChangeListeners;
|
||||
import com.android.systemui.statusbar.StatusBarState;
|
||||
import com.android.systemui.statusbar.Weather;
|
||||
import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
||||
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||
import com.android.systemui.telephony.TelephonyListenerManager;
|
||||
@@ -3216,6 +3216,24 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data the weather data (temp, conditions, unit) for weather clock to use
|
||||
*/
|
||||
public void sendWeatherData(Weather data) {
|
||||
mHandler.post(()-> {
|
||||
handleWeatherDataUpdate(data); });
|
||||
}
|
||||
|
||||
private void handleWeatherDataUpdate(Weather data) {
|
||||
Assert.isMainThread();
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||
if (cb != null) {
|
||||
cb.onWeatherDataChanged(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle {@link #MSG_BATTERY_UPDATE}
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.settingslib.fuelgauge.BatteryStatus;
|
||||
import com.android.systemui.statusbar.KeyguardIndicationController;
|
||||
import com.android.systemui.statusbar.Weather;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
||||
@@ -57,6 +58,11 @@ public class KeyguardUpdateMonitorCallback {
|
||||
*/
|
||||
public void onTimeFormatChanged(String timeFormat) { }
|
||||
|
||||
/**
|
||||
* Called when receive new weather data.
|
||||
*/
|
||||
public void onWeatherDataChanged(Weather data) { }
|
||||
|
||||
/**
|
||||
* Called when the carrier PLMN or SPN changes.
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.util.Log
|
||||
import android.view.ContextThemeWrapper
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.android.keyguard.KeyguardUpdateMonitor
|
||||
import com.android.settingslib.Utils
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
@@ -83,6 +84,7 @@ constructor(
|
||||
private val statusBarStateController: StatusBarStateController,
|
||||
private val deviceProvisionedController: DeviceProvisionedController,
|
||||
private val bypassController: KeyguardBypassController,
|
||||
private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
|
||||
private val execution: Execution,
|
||||
@Main private val uiExecutor: Executor,
|
||||
@Background private val bgExecutor: Executor,
|
||||
@@ -175,10 +177,10 @@ constructor(
|
||||
}
|
||||
if (weatherTarget != null) {
|
||||
val weatherData = Weather.fromBundle(weatherTarget.baseAction.extras)
|
||||
keyguardUpdateMonitor.sendWeatherData(weatherData)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private val userTrackerCallback = object : UserTracker.Callback {
|
||||
override fun onUserChanged(newUser: Int, userContext: Context) {
|
||||
execution.assertIsMainThread()
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.provider.Settings
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.keyguard.KeyguardUpdateMonitor
|
||||
import com.android.systemui.SysuiTestCase
|
||||
import com.android.systemui.flags.FeatureFlags
|
||||
import com.android.systemui.flags.Flags
|
||||
@@ -103,6 +104,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
||||
@Mock
|
||||
private lateinit var keyguardBypassController: KeyguardBypassController
|
||||
|
||||
@Mock
|
||||
private lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
|
||||
|
||||
@Mock
|
||||
private lateinit var deviceProvisionedController: DeviceProvisionedController
|
||||
|
||||
@@ -223,6 +227,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
||||
statusBarStateController,
|
||||
deviceProvisionedController,
|
||||
keyguardBypassController,
|
||||
keyguardUpdateMonitor,
|
||||
execution,
|
||||
executor,
|
||||
bgExecutor,
|
||||
|
||||
Reference in New Issue
Block a user