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

Commit b4c51200 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Send time zone changed event to clock plugin."

parents 1f75782a 9c1074fb
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ import android.view.View;

import com.android.systemui.plugins.annotations.ProvidesInterface;

import java.util.TimeZone;

/**
 * This plugin is used to replace main clock in keyguard.
 */
@@ -55,4 +57,9 @@ public interface ClockPlugin extends Plugin {
     * @param darkAmount Amount of transition to doze: 1f for doze and 0f for awake.
     */
    default void setDarkAmount(float darkAmount) {}

    /**
     * Notifies that the time zone has changed.
     */
    default void onTimeZoneChanged(TimeZone timeZone) {}
}
+10 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ import com.android.systemui.plugins.PluginListener;
import com.android.systemui.shared.plugins.PluginManager;

import java.util.Objects;
import java.util.TimeZone;

/**
 * Switch to show plugin clock when plugin is connected, otherwise it will show default clock.
@@ -161,6 +162,15 @@ public class KeyguardClockSwitch extends FrameLayout {
        }
    }

    /**
     * Notifies that the time zone has changed.
     */
    public void onTimeZoneChanged(TimeZone timeZone) {
        if (mClockPlugin != null) {
            mClockPlugin.onTimeZoneChanged(timeZone);
        }
    }

    /**
     * When plugin changes, set all kept parameters into newer plugin.
     */
+10 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController;
import com.google.android.collect.Sets;

import java.util.Locale;
import java.util.TimeZone;

public class KeyguardStatusView extends GridLayout implements
        ConfigurationController.ConfigurationListener, View.OnLayoutChangeListener {
@@ -84,6 +85,11 @@ public class KeyguardStatusView extends GridLayout implements
            refreshTime();
        }

        @Override
        public void onTimeZoneChanged(TimeZone timeZone) {
            updateTimeZone(timeZone);
        }

        @Override
        public void onKeyguardVisibilityChanged(boolean showing) {
            if (showing) {
@@ -282,6 +288,10 @@ public class KeyguardStatusView extends GridLayout implements
        mClockView.refresh();
    }

    private void updateTimeZone(TimeZone timeZone) {
        mClockView.onTimeZoneChanged(timeZone);
    }

    private void refreshFormat() {
        Patterns.update(mContext);
        mClockView.setFormat12Hour(Patterns.clockView12);
+25 −2
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.TimeZone;

/**
 * Watches for updates that may be interesting to the keyguard, and provides
@@ -151,6 +152,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private static final int MSG_BIOMETRIC_AUTHENTICATION_CONTINUE = 336;
    private static final int MSG_DEVICE_POLICY_MANAGER_STATE_CHANGED = 337;
    private static final int MSG_TELEPHONY_CAPABLE = 338;
    private static final int MSG_TIMEZONE_UPDATE = 339;

    /** Biometric authentication state: Not listening. */
    private static final int BIOMETRIC_STATE_STOPPED = 0;
@@ -260,6 +262,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                case MSG_TIME_UPDATE:
                    handleTimeUpdate();
                    break;
                case MSG_TIMEZONE_UPDATE:
                    handleTimeZoneUpdate((String) msg.obj);
                    break;
                case MSG_BATTERY_UPDATE:
                    handleBatteryUpdate((BatteryStatus) msg.obj);
                    break;
@@ -964,9 +969,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            if (DEBUG) Log.d(TAG, "received broadcast " + action);

            if (Intent.ACTION_TIME_TICK.equals(action)
                    || Intent.ACTION_TIME_CHANGED.equals(action)
                    || Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
                    || Intent.ACTION_TIME_CHANGED.equals(action)) {
                mHandler.sendEmptyMessage(MSG_TIME_UPDATE);
            } else if (Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
                final Message msg = mHandler.obtainMessage(
                        MSG_TIMEZONE_UPDATE, intent.getStringExtra("time-zone"));
                mHandler.sendMessage(msg);
            } else if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
                final int status = intent.getIntExtra(EXTRA_STATUS, BATTERY_STATUS_UNKNOWN);
                final int plugged = intent.getIntExtra(EXTRA_PLUGGED, 0);
@@ -1859,6 +1867,21 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        }
    }

    /**
     * Handle (@line #MSG_TIMEZONE_UPDATE}
     */
    private void handleTimeZoneUpdate(String timeZone) {
        if (DEBUG) Log.d(TAG, "handleTimeZoneUpdate");
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onTimeZoneChanged(TimeZone.getTimeZone(timeZone));
                // Also notify callbacks about time change to remain compatible.
                cb.onTimeChanged();
            }
        }
    }

    /**
     * Handle {@link #MSG_BATTERY_UPDATE}
     */
+9 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.view.WindowManagerPolicyConstants;
import com.android.internal.telephony.IccCardConstants;
import com.android.systemui.statusbar.KeyguardIndicationController;

import java.util.TimeZone;

/**
 * Callback for general information relevant to lock screen.
 */
@@ -48,6 +50,13 @@ public class KeyguardUpdateMonitorCallback {
     */
    public void onTimeChanged() { }

    /**
     * Called when time zone changes.
     *
     * @note When time zone changes, onTimeChanged will be called too.
     */
    public void onTimeZoneChanged(TimeZone timeZone) { }

    /**
     * Called when the carrier PLMN or SPN changes.
     */