Merge "Show statusbar clock based on lockscreen status."

This commit is contained in:
Jeff Sharkey
2011-09-02 15:07:19 -07:00
committed by Android (Google) Code Review
6 changed files with 84 additions and 3 deletions

View File

@@ -20,4 +20,6 @@ public interface LockScreenWidgetInterface {
public void setCallback(LockScreenWidgetCallback callback); public void setCallback(LockScreenWidgetCallback callback);
public boolean providesClock();
} }

View File

@@ -381,4 +381,8 @@ public class TransportControlView extends FrameLayout implements OnClickListener
mWidgetCallbacks = callback; mWidgetCallbacks = callback;
} }
public boolean providesClock() {
return false;
}
} }

View File

@@ -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() {

View File

@@ -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;
}
} }

View File

@@ -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,9 +1191,12 @@ 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;
flags |= StatusBarManager.DISABLE_CLOCK; if (mUpdateMonitor.isClockVisible()) {
// lockscreen showing a clock, so hide statusbar 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.
@@ -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
}
} }

View File

@@ -21,6 +21,7 @@ import com.android.internal.policy.impl.LockPatternKeyguardView.UnlockMode;
import com.android.internal.telephony.IccCard; import com.android.internal.telephony.IccCard;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockScreenWidgetCallback; import com.android.internal.widget.LockScreenWidgetCallback;
import com.android.internal.widget.LockScreenWidgetInterface;
import com.android.internal.widget.TransportControlView; import com.android.internal.widget.TransportControlView;
import android.accounts.Account; import android.accounts.Account;
@@ -191,11 +192,17 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
public void requestShow(View view) { public void requestShow(View view) {
if (DEBUG) Log.v(TAG, "View " + view + " requested show transports"); if (DEBUG) Log.v(TAG, "View " + view + " requested show transports");
view.setVisibility(View.VISIBLE); view.setVisibility(View.VISIBLE);
// TODO: examine all widgets to derive clock status
mUpdateMonitor.reportClockVisible(false);
} }
public void requestHide(View view) { public void requestHide(View view) {
if (DEBUG) Log.v(TAG, "View " + view + " requested hide transports"); if (DEBUG) Log.v(TAG, "View " + view + " requested hide transports");
view.setVisibility(View.GONE); view.setVisibility(View.GONE);
// TODO: examine all widgets to derive clock status
mUpdateMonitor.reportClockVisible(true);
} }
}; };
@@ -743,6 +750,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
if (tcv == null) { if (tcv == null) {
if (DEBUG) Log.w(TAG, "Couldn't find transport control widget"); if (DEBUG) Log.w(TAG, "Couldn't find transport control widget");
} else { } else {
mUpdateMonitor.reportClockVisible(true);
tcv.setVisibility(View.GONE); // hide tcv until we get the callback below to show it. tcv.setVisibility(View.GONE); // hide tcv until we get the callback below to show it.
tcv.setCallback(mWidgetCallback); tcv.setCallback(mWidgetCallback);
} }