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

Commit 890aaea2 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Show statusbar clock based on lockscreen status."

parents f7315dd1 054340d0
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -20,4 +20,6 @@ public interface LockScreenWidgetInterface {


    public void setCallback(LockScreenWidgetCallback callback);
    public void setCallback(LockScreenWidgetCallback callback);


    public boolean providesClock();

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


    public boolean providesClock() {
        return false;
    }

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

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


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


    private int mFailedAttempts = 0;
    private int mFailedAttempts = 0;


    private boolean mClockVisible;

    private Handler mHandler;
    private Handler mHandler;


    private ArrayList<InfoCallback> mInfoCallbacks = Lists.newArrayList();
    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_SIM_STATE_CHANGE = 304;
    private static final int MSG_RINGER_MODE_CHANGED = 305;
    private static final int MSG_RINGER_MODE_CHANGED = 305;
    private static final int MSG_PHONE_STATE_CHANGED = 306;
    private static final int MSG_PHONE_STATE_CHANGED = 306;
    private static final int MSG_CLOCK_VISIBILITY_CHANGED = 307;


    /**
    /**
     * When we receive a
     * When we receive a
@@ -170,6 +173,9 @@ public class KeyguardUpdateMonitor {
                    case MSG_PHONE_STATE_CHANGED:
                    case MSG_PHONE_STATE_CHANGED:
                        handlePhoneStateChanged((String)msg.obj);
                        handlePhoneStateChanged((String)msg.obj);
                        break;
                        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}
     * @param status One of the statuses of {@link android.os.BatteryManager}
     * @return Whether the status maps to a status for being plugged in.
     * @return Whether the status maps to a status for being plugged in.
@@ -448,6 +461,12 @@ public class KeyguardUpdateMonitor {
         */
         */
        void onPhoneStateChanged(String newState);
        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() {
    public IccCard.State getSimState() {
        return mSimState;
        return mSimState;
    }
    }
@@ -546,4 +570,8 @@ public class KeyguardUpdateMonitor {
        mFailedAttempts++;
        mFailedAttempts++;
    }
    }


    public boolean isClockVisible() {
        return mClockVisible;
    }

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


        mUpdateMonitor = new KeyguardUpdateMonitor(context);
        mUpdateMonitor = new KeyguardUpdateMonitor(context);


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


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