@@ -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 }
0 commit comments