Skip to content

Commit fd8c388

Browse files
mikejurkaAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug where newly added widget wasn't always shown" into jb-mr1-lockscreen-dev
2 parents 3e66286 + 1413889 commit fd8c388

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,9 @@ public void onScreenTurnedOff() {
790790
// Once the screen turns off, we no longer consider this to be first boot and we want the
791791
// biometric unlock to start next time keyguard is shown.
792792
KeyguardUpdateMonitor.getInstance(mContext).setAlternateUnlockEnabled(true);
793+
// We use mAppWidgetToShow to show a particular widget after you add it-- once the screen
794+
// turns off we reset that behavior
795+
clearAppWidgetToShow();
793796
checkAppWidgetConsistency();
794797
showPrimarySecurityScreen(true);
795798
getSecurityView(mCurrentSecuritySelection).onPause();
@@ -799,6 +802,10 @@ public void onScreenTurnedOff() {
799802
}
800803
}
801804

805+
public void clearAppWidgetToShow() {
806+
mAppWidgetToShow = AppWidgetManager.INVALID_APPWIDGET_ID;
807+
}
808+
802809
@Override
803810
public void show() {
804811
if (DEBUG) Log.d(TAG, "show()");
@@ -1176,6 +1183,7 @@ public void run() {
11761183

11771184
static class SavedState extends BaseSavedState {
11781185
int transportState;
1186+
int appWidgetToShow = AppWidgetManager.INVALID_APPWIDGET_ID;
11791187

11801188
SavedState(Parcelable superState) {
11811189
super(superState);
@@ -1184,12 +1192,14 @@ static class SavedState extends BaseSavedState {
11841192
private SavedState(Parcel in) {
11851193
super(in);
11861194
this.transportState = in.readInt();
1195+
this.appWidgetToShow = in.readInt();
11871196
}
11881197

11891198
@Override
11901199
public void writeToParcel(Parcel out, int flags) {
11911200
super.writeToParcel(out, flags);
11921201
out.writeInt(this.transportState);
1202+
out.writeInt(this.appWidgetToShow);
11931203
}
11941204

11951205
public static final Parcelable.Creator<SavedState> CREATOR
@@ -1210,6 +1220,7 @@ public Parcelable onSaveInstanceState() {
12101220
Parcelable superState = super.onSaveInstanceState();
12111221
SavedState ss = new SavedState(superState);
12121222
ss.transportState = mViewStateManager.getTransportState();
1223+
ss.appWidgetToShow = mAppWidgetToShow;
12131224
return ss;
12141225
}
12151226

@@ -1223,6 +1234,7 @@ public void onRestoreInstanceState(Parcelable state) {
12231234
SavedState ss = (SavedState) state;
12241235
super.onRestoreInstanceState(ss.getSuperState());
12251236
mViewStateManager.setTransportState(ss.transportState);
1237+
mAppWidgetToShow = ss.appWidgetToShow;
12261238
post(mSwitchPageRunnable);
12271239
}
12281240

@@ -1275,7 +1287,6 @@ private int getAppropriateWidgetPage(boolean isMusicPlaying) {
12751287
for (int i = 0; i < childCount; i++) {
12761288
if (mAppWidgetContainer.getWidgetPageAt(i).getContentAppWidgetId()
12771289
== mAppWidgetToShow) {
1278-
mAppWidgetToShow = AppWidgetManager.INVALID_APPWIDGET_ID;
12791290
return i;
12801291
}
12811292
}

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.android.internal.policy.impl.keyguard;
1717

18+
import android.appwidget.AppWidgetManager;
1819
import android.os.Handler;
1920
import android.os.Looper;
2021
import android.view.View;
@@ -115,6 +116,11 @@ public void onPageBeginMoving() {
115116
scl.fadeOutChallenge();
116117
mPageIndexOnPageBeginMoving = mKeyguardWidgetPager.getCurrentPage();
117118
}
119+
// We use mAppWidgetToShow to show a particular widget after you add it--
120+
// once the user swipes a page we clear that behavior
121+
if (mKeyguardHostView != null) {
122+
mKeyguardHostView.clearAppWidgetToShow();
123+
}
118124
if (mHideHintsRunnable != null) {
119125
mMainQueue.removeCallbacks(mHideHintsRunnable);
120126
mHideHintsRunnable = null;

0 commit comments

Comments
 (0)