Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73e2faa1 authored by Florence Yang's avatar Florence Yang Committed by Automerger Merge Worker
Browse files

Merge "Send weather data from LS Smartspace to clock" into tm-qpr-dev am: 1d6561cb

parents cdce7c82 1d6561cb
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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 */
+7 −0
Original line number Diff line number Diff line
@@ -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) {
+19 −1
Original line number Diff line number Diff line
@@ -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}
     */
+6 −0
Original line number Diff line number Diff line
@@ -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.
     */
+3 −1
Original line number Diff line number Diff line
@@ -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()
Loading