@@ -192,6 +192,20 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
192192
193193 private int mUiOptions = 0 ;
194194
195+ private boolean mInvalidatePanelMenuPosted ;
196+ private int mInvalidatePanelMenuFeatures ;
197+ private final Runnable mInvalidatePanelMenuRunnable = new Runnable () {
198+ @ Override public void run () {
199+ for (int i = 0 ; i <= FEATURE_MAX ; i ++) {
200+ if ((mInvalidatePanelMenuFeatures & 1 << i ) != 0 ) {
201+ doInvalidatePanelMenu (i );
202+ }
203+ }
204+ mInvalidatePanelMenuPosted = false ;
205+ mInvalidatePanelMenuFeatures = 0 ;
206+ }
207+ };
208+
195209 static class WindowManagerHolder {
196210 static final IWindowManager sWindowManager = IWindowManager .Stub .asInterface (
197211 ServiceManager .getService ("window" ));
@@ -722,6 +736,15 @@ public final void togglePanel(int featureId, KeyEvent event) {
722736
723737 @ Override
724738 public void invalidatePanelMenu (int featureId ) {
739+ mInvalidatePanelMenuFeatures |= 1 << featureId ;
740+
741+ if (!mInvalidatePanelMenuPosted && mDecor != null ) {
742+ mDecor .postOnAnimation (mInvalidatePanelMenuRunnable );
743+ mInvalidatePanelMenuPosted = true ;
744+ }
745+ }
746+
747+ void doInvalidatePanelMenu (int featureId ) {
725748 PanelFeatureState st = getPanelState (featureId , true );
726749 Bundle savedActionViewStates = null ;
727750 if (st .menu != null ) {
@@ -2842,6 +2865,9 @@ private void installDecor() {
28422865 mDecor .setIsRootNamespace (true );
28432866 mDecor .setLayoutDirection (
28442867 getContext ().getResources ().getConfiguration ().getLayoutDirection ());
2868+ if (!mInvalidatePanelMenuPosted && mInvalidatePanelMenuFeatures != 0 ) {
2869+ mDecor .postOnAnimation (mInvalidatePanelMenuRunnable );
2870+ }
28452871 }
28462872 if (mContentParent == null ) {
28472873 mContentParent = generateLayout (mDecor );
0 commit comments