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

Commit 054340d0 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Show statusbar clock based on lockscreen status.

Keep track of lockscreen clock visibility, and only hide statusbar
clock when one is provided by lockscreen.  This fixes bug where widget
would hide all clocks.

Bug: 5242065
Change-Id: I48de98ecb956c7f22bd40b54d771c78c1a80c14c
parent 52f159c7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -20,4 +20,6 @@ public interface LockScreenWidgetInterface {

    public void setCallback(LockScreenWidgetCallback callback);

    public boolean providesClock();

}
+4 −0
Original line number Diff line number Diff line
@@ -381,4 +381,8 @@ public class TransportControlView extends FrameLayout implements OnClickListener
        mWidgetCallbacks = callback;
    }

    public boolean providesClock() {
        return false;
    }

}
+5 −0
Original line number Diff line number Diff line
@@ -589,6 +589,11 @@ class KeyguardStatusViewManager implements OnClickListener {
        public void onPhoneStateChanged(String newState) {
            updateEmergencyCallButtonState();
        }

        /** {@inheritDoc} */
        public void onClockVisibilityChanged() {
            // ignored
        }
    };

    private SimStateCallback mSimStateCallback = new SimStateCallback() {
+28 −0
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ public class KeyguardUpdateMonitor {

    private int mFailedAttempts = 0;

    private boolean mClockVisible;

    private Handler mHandler;

    private ArrayList<InfoCallback> mInfoCallbacks = Lists.newArrayList();
@@ -94,6 +96,7 @@ public class KeyguardUpdateMonitor {
    private static final int MSG_SIM_STATE_CHANGE = 304;
    private static final int MSG_RINGER_MODE_CHANGED = 305;
    private static final int MSG_PHONE_STATE_CHANGED = 306;
    private static final int MSG_CLOCK_VISIBILITY_CHANGED = 307;

    /**
     * When we receive a
@@ -170,6 +173,9 @@ public class KeyguardUpdateMonitor {
                    case MSG_PHONE_STATE_CHANGED:
                        handlePhoneStateChanged((String)msg.obj);
                        break;
                    case MSG_CLOCK_VISIBILITY_CHANGED:
                        handleClockVisibilityChanged();
                        break;
                }
            }
        };
@@ -334,6 +340,13 @@ public class KeyguardUpdateMonitor {
        }
    }

    private void handleClockVisibilityChanged() {
        if (DEBUG) Log.d(TAG, "handleClockVisibilityChanged()");
        for (int i = 0; i < mInfoCallbacks.size(); i++) {
            mInfoCallbacks.get(i).onClockVisibilityChanged();
        }
    }

    /**
     * @param status One of the statuses of {@link android.os.BatteryManager}
     * @return Whether the status maps to a status for being plugged in.
@@ -448,6 +461,12 @@ public class KeyguardUpdateMonitor {
         */
        void onPhoneStateChanged(String newState);

        /**
         * Called when visibility of lockscreen clock changes, such as when
         * obscured by a widget.
         */
        void onClockVisibilityChanged();

    }

    /**
@@ -484,6 +503,11 @@ public class KeyguardUpdateMonitor {
        }
    }

    public void reportClockVisible(boolean visible) {
        mClockVisible = visible;
        mHandler.obtainMessage(MSG_CLOCK_VISIBILITY_CHANGED).sendToTarget();
    }

    public IccCard.State getSimState() {
        return mSimState;
    }
@@ -546,4 +570,8 @@ public class KeyguardUpdateMonitor {
        mFailedAttempts++;
    }

    public boolean isClockVisible() {
        return mClockVisible;
    }

}
+37 −3
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ import android.view.WindowManagerPolicy;
 * thread of the keyguard.
 */
public class KeyguardViewMediator implements KeyguardViewCallback,
        KeyguardUpdateMonitor.SimStateCallback {
        KeyguardUpdateMonitor.InfoCallback, KeyguardUpdateMonitor.SimStateCallback {
    private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000;
    private final static boolean DEBUG = false;
    private final static boolean DBG_WAKE = false;
@@ -284,6 +284,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,

        mUpdateMonitor = new KeyguardUpdateMonitor(context);

        mUpdateMonitor.registerInfoCallback(this);
        mUpdateMonitor.registerSimStateCallback(this);

        mLockPatternUtils = new LockPatternUtils(mContext);
@@ -1190,10 +1191,13 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
                flags |= StatusBarManager.DISABLE_NAVIGATION;
                if (!mHidden) {
                    // showing lockscreen exclusively (no activities in front of it)
                    // disable clock and back button too
                    // disable back button too
                    flags |= StatusBarManager.DISABLE_BACK;
                    if (mUpdateMonitor.isClockVisible()) {
                        // lockscreen showing a clock, so hide statusbar clock
                        flags |= StatusBarManager.DISABLE_CLOCK;
                    }
                }
                if (isSecure() || !ENABLE_INSECURE_STATUS_BAR_EXPAND) {
                    // showing secure lockscreen; disable expanding.
                    flags |= StatusBarManager.DISABLE_EXPAND;
@@ -1283,4 +1287,34 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
            mKeyguardViewManager.onScreenTurnedOn();
        }
    }

    /** {@inheritDoc} */
    public void onClockVisibilityChanged() {
        adjustStatusBarLocked();
    }

    /** {@inheritDoc} */
    public void onPhoneStateChanged(String newState) {
        // ignored
    }

    /** {@inheritDoc} */
    public void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn, int batteryLevel) {
        // ignored
    }

    /** {@inheritDoc} */
    public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) {
        // ignored
    }

    /** {@inheritDoc} */
    public void onRingerModeChanged(int state) {
        // ignored
    }

    /** {@inheritDoc} */
    public void onTimeChanged() {
        // ignored
    }
}
Loading