Skip to content

Commit 890aaea

Browse files
jsharkeyAndroid (Google) Code Review
authored andcommitted
Merge "Show statusbar clock based on lockscreen status."
2 parents f7315dd + 054340d commit 890aaea

File tree

6 files changed

+84
-3
lines changed

6 files changed

+84
-3
lines changed

core/java/com/android/internal/widget/LockScreenWidgetInterface.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ public interface LockScreenWidgetInterface {
2020

2121
public void setCallback(LockScreenWidgetCallback callback);
2222

23+
public boolean providesClock();
24+
2325
}

core/java/com/android/internal/widget/TransportControlView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,4 +381,8 @@ public void setCallback(LockScreenWidgetCallback callback) {
381381
mWidgetCallbacks = callback;
382382
}
383383

384+
public boolean providesClock() {
385+
return false;
386+
}
387+
384388
}

policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,11 @@ public void onRingerModeChanged(int state) {
589589
public void onPhoneStateChanged(String newState) {
590590
updateEmergencyCallButtonState();
591591
}
592+
593+
/** {@inheritDoc} */
594+
public void onClockVisibilityChanged() {
595+
// ignored
596+
}
592597
};
593598

594599
private SimStateCallback mSimStateCallback = new SimStateCallback() {

policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public class KeyguardUpdateMonitor {
8181

8282
private int mFailedAttempts = 0;
8383

84+
private boolean mClockVisible;
85+
8486
private Handler mHandler;
8587

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

98101
/**
99102
* When we receive a
@@ -170,6 +173,9 @@ public void handleMessage(Message msg) {
170173
case MSG_PHONE_STATE_CHANGED:
171174
handlePhoneStateChanged((String)msg.obj);
172175
break;
176+
case MSG_CLOCK_VISIBILITY_CHANGED:
177+
handleClockVisibilityChanged();
178+
break;
173179
}
174180
}
175181
};
@@ -334,6 +340,13 @@ private void handleSimStateChange(SimArgs simArgs) {
334340
}
335341
}
336342

343+
private void handleClockVisibilityChanged() {
344+
if (DEBUG) Log.d(TAG, "handleClockVisibilityChanged()");
345+
for (int i = 0; i < mInfoCallbacks.size(); i++) {
346+
mInfoCallbacks.get(i).onClockVisibilityChanged();
347+
}
348+
}
349+
337350
/**
338351
* @param status One of the statuses of {@link android.os.BatteryManager}
339352
* @return Whether the status maps to a status for being plugged in.
@@ -448,6 +461,12 @@ interface InfoCallback {
448461
*/
449462
void onPhoneStateChanged(String newState);
450463

464+
/**
465+
* Called when visibility of lockscreen clock changes, such as when
466+
* obscured by a widget.
467+
*/
468+
void onClockVisibilityChanged();
469+
451470
}
452471

453472
/**
@@ -484,6 +503,11 @@ public void registerSimStateCallback(SimStateCallback callback) {
484503
}
485504
}
486505

506+
public void reportClockVisible(boolean visible) {
507+
mClockVisible = visible;
508+
mHandler.obtainMessage(MSG_CLOCK_VISIBILITY_CHANGED).sendToTarget();
509+
}
510+
487511
public IccCard.State getSimState() {
488512
return mSimState;
489513
}
@@ -546,4 +570,8 @@ public void reportFailedAttempt() {
546570
mFailedAttempts++;
547571
}
548572

573+
public boolean isClockVisible() {
574+
return mClockVisible;
575+
}
576+
549577
}

policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
* thread of the keyguard.
9393
*/
9494
public class KeyguardViewMediator implements KeyguardViewCallback,
95-
KeyguardUpdateMonitor.SimStateCallback {
95+
KeyguardUpdateMonitor.InfoCallback, KeyguardUpdateMonitor.SimStateCallback {
9696
private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000;
9797
private final static boolean DEBUG = false;
9898
private final static boolean DBG_WAKE = false;
@@ -284,6 +284,7 @@ public KeyguardViewMediator(Context context, PhoneWindowManager callback,
284284

285285
mUpdateMonitor = new KeyguardUpdateMonitor(context);
286286

287+
mUpdateMonitor.registerInfoCallback(this);
287288
mUpdateMonitor.registerSimStateCallback(this);
288289

289290
mLockPatternUtils = new LockPatternUtils(mContext);
@@ -1190,9 +1191,12 @@ private void adjustStatusBarLocked() {
11901191
flags |= StatusBarManager.DISABLE_NAVIGATION;
11911192
if (!mHidden) {
11921193
// showing lockscreen exclusively (no activities in front of it)
1193-
// disable clock and back button too
1194+
// disable back button too
11941195
flags |= StatusBarManager.DISABLE_BACK;
1195-
flags |= StatusBarManager.DISABLE_CLOCK;
1196+
if (mUpdateMonitor.isClockVisible()) {
1197+
// lockscreen showing a clock, so hide statusbar clock
1198+
flags |= StatusBarManager.DISABLE_CLOCK;
1199+
}
11961200
}
11971201
if (isSecure() || !ENABLE_INSECURE_STATUS_BAR_EXPAND) {
11981202
// showing secure lockscreen; disable expanding.
@@ -1283,4 +1287,34 @@ private void handleNotifyScreenOn() {
12831287
mKeyguardViewManager.onScreenTurnedOn();
12841288
}
12851289
}
1290+
1291+
/** {@inheritDoc} */
1292+
public void onClockVisibilityChanged() {
1293+
adjustStatusBarLocked();
1294+
}
1295+
1296+
/** {@inheritDoc} */
1297+
public void onPhoneStateChanged(String newState) {
1298+
// ignored
1299+
}
1300+
1301+
/** {@inheritDoc} */
1302+
public void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn, int batteryLevel) {
1303+
// ignored
1304+
}
1305+
1306+
/** {@inheritDoc} */
1307+
public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) {
1308+
// ignored
1309+
}
1310+
1311+
/** {@inheritDoc} */
1312+
public void onRingerModeChanged(int state) {
1313+
// ignored
1314+
}
1315+
1316+
/** {@inheritDoc} */
1317+
public void onTimeChanged() {
1318+
// ignored
1319+
}
12861320
}

policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.android.internal.telephony.IccCard;
2222
import com.android.internal.widget.LockPatternUtils;
2323
import com.android.internal.widget.LockScreenWidgetCallback;
24+
import com.android.internal.widget.LockScreenWidgetInterface;
2425
import com.android.internal.widget.TransportControlView;
2526

2627
import android.accounts.Account;
@@ -191,11 +192,17 @@ public void userActivity(View self) {
191192
public void requestShow(View view) {
192193
if (DEBUG) Log.v(TAG, "View " + view + " requested show transports");
193194
view.setVisibility(View.VISIBLE);
195+
196+
// TODO: examine all widgets to derive clock status
197+
mUpdateMonitor.reportClockVisible(false);
194198
}
195199

196200
public void requestHide(View view) {
197201
if (DEBUG) Log.v(TAG, "View " + view + " requested hide transports");
198202
view.setVisibility(View.GONE);
203+
204+
// TODO: examine all widgets to derive clock status
205+
mUpdateMonitor.reportClockVisible(true);
199206
}
200207
};
201208

@@ -743,6 +750,7 @@ private void initializeTransportControlView(View view) {
743750
if (tcv == null) {
744751
if (DEBUG) Log.w(TAG, "Couldn't find transport control widget");
745752
} else {
753+
mUpdateMonitor.reportClockVisible(true);
746754
tcv.setVisibility(View.GONE); // hide tcv until we get the callback below to show it.
747755
tcv.setCallback(mWidgetCallback);
748756
}

0 commit comments

Comments
 (0)