@@ -792,6 +792,9 @@ public void onScreenTurnedOff() {
792792 // Once the screen turns off, we no longer consider this to be first boot and we want the
793793 // biometric unlock to start next time keyguard is shown.
794794 KeyguardUpdateMonitor .getInstance (mContext ).setAlternateUnlockEnabled (true );
795+ // We use mAppWidgetToShow to show a particular widget after you add it-- once the screen
796+ // turns off we reset that behavior
797+ clearAppWidgetToShow ();
795798 checkAppWidgetConsistency ();
796799 showPrimarySecurityScreen (true );
797800 getSecurityView (mCurrentSecuritySelection ).onPause ();
@@ -801,6 +804,10 @@ public void onScreenTurnedOff() {
801804 }
802805 }
803806
807+ public void clearAppWidgetToShow () {
808+ mAppWidgetToShow = AppWidgetManager .INVALID_APPWIDGET_ID ;
809+ }
810+
804811 @ Override
805812 public void show () {
806813 if (DEBUG ) Log .d (TAG , "show()" );
@@ -1178,6 +1185,7 @@ public void run() {
11781185
11791186 static class SavedState extends BaseSavedState {
11801187 int transportState ;
1188+ int appWidgetToShow = AppWidgetManager .INVALID_APPWIDGET_ID ;
11811189
11821190 SavedState (Parcelable superState ) {
11831191 super (superState );
@@ -1186,12 +1194,14 @@ static class SavedState extends BaseSavedState {
11861194 private SavedState (Parcel in ) {
11871195 super (in );
11881196 this .transportState = in .readInt ();
1197+ this .appWidgetToShow = in .readInt ();
11891198 }
11901199
11911200 @ Override
11921201 public void writeToParcel (Parcel out , int flags ) {
11931202 super .writeToParcel (out , flags );
11941203 out .writeInt (this .transportState );
1204+ out .writeInt (this .appWidgetToShow );
11951205 }
11961206
11971207 public static final Parcelable .Creator <SavedState > CREATOR
@@ -1212,6 +1222,7 @@ public Parcelable onSaveInstanceState() {
12121222 Parcelable superState = super .onSaveInstanceState ();
12131223 SavedState ss = new SavedState (superState );
12141224 ss .transportState = mViewStateManager .getTransportState ();
1225+ ss .appWidgetToShow = mAppWidgetToShow ;
12151226 return ss ;
12161227 }
12171228
@@ -1225,6 +1236,7 @@ public void onRestoreInstanceState(Parcelable state) {
12251236 SavedState ss = (SavedState ) state ;
12261237 super .onRestoreInstanceState (ss .getSuperState ());
12271238 mViewStateManager .setTransportState (ss .transportState );
1239+ mAppWidgetToShow = ss .appWidgetToShow ;
12281240 post (mSwitchPageRunnable );
12291241 }
12301242
@@ -1277,7 +1289,6 @@ private int getAppropriateWidgetPage(boolean isMusicPlaying) {
12771289 for (int i = 0 ; i < childCount ; i ++) {
12781290 if (mAppWidgetContainer .getWidgetPageAt (i ).getContentAppWidgetId ()
12791291 == mAppWidgetToShow ) {
1280- mAppWidgetToShow = AppWidgetManager .INVALID_APPWIDGET_ID ;
12811292 return i ;
12821293 }
12831294 }
0 commit comments