@@ -2314,7 +2314,7 @@ public void removeWindowLocked(Session session, WindowState win) {
23142314 // to hold off on removing the window until the animation is done.
23152315 // If the display is frozen, just remove immediately, since the
23162316 // animation wouldn't be seen.
2317- if (win .mWinAnimator . mSurface != null && okToDisplay ()) {
2317+ if (win .mHasSurface && okToDisplay ()) {
23182318 // If we are not currently running the exit animation, we
23192319 // need to see about starting one.
23202320 wasVisible = win .isWinVisibleLw ();
@@ -2458,8 +2458,7 @@ private void removeWindowInnerLocked(Session session, WindowState win) {
24582458 }
24592459
24602460 static void logSurface (WindowState w , String msg , RuntimeException where ) {
2461- String str = " SURFACE " + Integer .toHexString (w .hashCode ())
2462- + ": " + msg + " / " + w .mAttrs .getTitle ();
2461+ String str = " SURFACE " + msg + ": " + w ;
24632462 if (where != null ) {
24642463 Slog .i (TAG , str , where );
24652464 } else {
@@ -2481,15 +2480,14 @@ void setTransparentRegionWindow(Session session, IWindow client, Region region)
24812480 try {
24822481 synchronized (mWindowMap ) {
24832482 WindowState w = windowForClientLocked (session , client , false );
2484- WindowStateAnimator winAnimator = w .mWinAnimator ;
2485- if ((w != null ) && (winAnimator .mSurface != null )) {
2483+ if ((w != null ) && w .mHasSurface ) {
24862484 if (SHOW_LIGHT_TRANSACTIONS ) Slog .i (TAG ,
24872485 ">>> OPEN TRANSACTION setTransparentRegion" );
24882486 Surface .openTransaction ();
24892487 try {
24902488 if (SHOW_TRANSACTIONS ) logSurface (w ,
24912489 "transparentRegionHint=" + region , null );
2492- winAnimator .mSurface .setTransparentRegionHint (region );
2490+ w . mWinAnimator .mSurface .setTransparentRegionHint (region );
24932491 } finally {
24942492 Surface .closeTransaction ();
24952493 if (SHOW_LIGHT_TRANSACTIONS ) Slog .i (TAG ,
@@ -2618,10 +2616,10 @@ public int relayoutWindow(Session session, IWindow client, int seq,
26182616
26192617 synchronized (mWindowMap ) {
26202618 WindowState win = windowForClientLocked (session , client , false );
2621- WindowStateAnimator winAnimator = win .mWinAnimator ;
26222619 if (win == null ) {
26232620 return 0 ;
26242621 }
2622+ WindowStateAnimator winAnimator = win .mWinAnimator ;
26252623 if (win .mRequestedWidth != requestedWidth
26262624 || win .mRequestedHeight != requestedHeight ) {
26272625 win .mLayoutNeeded = true ;
@@ -2702,6 +2700,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
27022700 displayed = !win .isVisibleLw ();
27032701 if (win .mExiting ) {
27042702 winAnimator .cancelExitAnimationForNextAnimationLocked ();
2703+ win .mExiting = false ;
27052704 }
27062705 if (win .mDestroying ) {
27072706 win .mDestroying = false ;
@@ -2740,7 +2739,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
27402739 surfaceChanged = true ;
27412740 }
27422741 try {
2743- if (winAnimator . mSurface == null ) {
2742+ if (! win . mHasSurface ) {
27442743 surfaceChanged = true ;
27452744 }
27462745 Surface surface = winAnimator .createSurfaceLocked ();
@@ -3416,15 +3415,13 @@ public int getOrientationFromWindowsLocked() {
34163415 }
34173416
34183417 public int getOrientationFromAppTokensLocked () {
3419- int pos = mAppTokens .size () - 1 ;
34203418 int curGroup = 0 ;
34213419 int lastOrientation = ActivityInfo .SCREEN_ORIENTATION_UNSPECIFIED ;
34223420 boolean findingBehind = false ;
34233421 boolean haveGroup = false ;
34243422 boolean lastFullscreen = false ;
3425- while ( pos >= 0 ) {
3423+ for ( int pos = mAppTokens . size () - 1 ; pos >= 0 ; pos -- ) {
34263424 AppWindowToken wtoken = mAppTokens .get (pos );
3427- pos --;
34283425
34293426 if (DEBUG_APP_ORIENTATION ) Slog .v (TAG , "Checking app orientation: " + wtoken );
34303427
@@ -4138,7 +4135,7 @@ void unsetAppFreezingScreenLocked(AppWindowToken wtoken,
41384135 WindowState w = wtoken .allAppWindows .get (i );
41394136 if (w .mAppFreezing ) {
41404137 w .mAppFreezing = false ;
4141- if (w .mWinAnimator . mSurface != null && !w .mOrientationChanging ) {
4138+ if (w .mHasSurface && !w .mOrientationChanging ) {
41424139 if (DEBUG_ORIENTATION ) Slog .v (TAG , "set mOrientationChanging of " + w );
41434140 w .mOrientationChanging = true ;
41444141 }
@@ -4726,7 +4723,7 @@ public void closeSystemDialogs(String reason) {
47264723 synchronized (mWindowMap ) {
47274724 for (int i =mWindows .size ()-1 ; i >=0 ; i --) {
47284725 WindowState w = mWindows .get (i );
4729- if (w .mWinAnimator . mSurface != null ) {
4726+ if (w .mHasSurface ) {
47304727 try {
47314728 w .mClient .closeSystemDialogs (reason );
47324729 } catch (RemoteException e ) {
@@ -5198,7 +5195,7 @@ public Bitmap screenshotApplications(IBinder appToken, int width, int height) {
51985195 boolean including = false ;
51995196 for (int i =mWindows .size ()-1 ; i >=0 ; i --) {
52005197 WindowState ws = mWindows .get (i );
5201- if (ws .mWinAnimator . mSurface == null ) {
5198+ if (! ws .mHasSurface ) {
52025199 continue ;
52035200 }
52045201 if (ws .mLayer >= aboveAppLayer ) {
@@ -5512,7 +5509,7 @@ public boolean updateRotationUncheckedLocked(boolean inTransaction) {
55125509
55135510 for (int i =mWindows .size ()-1 ; i >=0 ; i --) {
55145511 WindowState w = mWindows .get (i );
5515- if (w .mWinAnimator . mSurface != null ) {
5512+ if (w .mHasSurface ) {
55165513 if (DEBUG_ORIENTATION ) Slog .v (TAG , "Set mOrientationChanging of " + w );
55175514 w .mOrientationChanging = true ;
55185515 }
@@ -8027,7 +8024,7 @@ private int animateAwayWallpaperLocked() {
80278024 mAnimator .mForceHiding = false ;
80288025 for (int i =mWindows .size ()-1 ; i >=0 ; i --) {
80298026 WindowState w = mWindows .get (i );
8030- if (w .mWinAnimator . mSurface != null ) {
8027+ if (w .mHasSurface ) {
80318028 final WindowManager .LayoutParams attrs = w .mAttrs ;
80328029 if (mPolicy .doesForceHide (w , attrs ) && w .isVisibleLw ()) {
80338030 if (DEBUG_FOCUS ) Slog .i (TAG , "win=" + w + " force hides other windows" );
@@ -8127,7 +8124,7 @@ private void handleNotObscuredLocked(final WindowState w, final long currentTime
81278124 final int attrFlags = attrs .flags ;
81288125 final boolean canBeSeen = w .isDisplayedLw ();
81298126
8130- if (w .mWinAnimator . mSurface != null ) {
8127+ if (w .mHasSurface ) {
81318128 if ((attrFlags &FLAG_KEEP_SCREEN_ON ) != 0 ) {
81328129 mInnerFields .mHoldScreen = w .mSession ;
81338130 }
@@ -8279,7 +8276,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
82798276 mPolicy .beginAnimationLw (dw , dh );
82808277 for (i = mWindows .size () - 1 ; i >= 0 ; i --) {
82818278 WindowState w = mWindows .get (i );
8282- if (w .mWinAnimator . mSurface != null ) {
8279+ if (w .mHasSurface ) {
82838280 mPolicy .animatingWindowLw (w , w .mAttrs );
82848281 }
82858282 }
@@ -8397,7 +8394,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
83978394 updateResizingWindows (w );
83988395
83998396 // Moved from updateWindowsAndWallpaperLocked().
8400- if (winAnimator . mSurface != null ) {
8397+ if (w . mHasSurface ) {
84018398 // Take care of the window being ready to display.
84028399 if (winAnimator .commitFinishDrawingLocked (currentTime )) {
84038400 if ((w .mAttrs .flags
@@ -8456,10 +8453,8 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
84568453 stopFreezingDisplayLocked ();
84578454 }
84588455
8459- i = mResizingWindows .size ();
8460- if (i > 0 ) {
8461- do {
8462- i --;
8456+ if (!mResizingWindows .isEmpty ()) {
8457+ for (i = mResizingWindows .size () - 1 ; i >= 0 ; i --) {
84638458 WindowState win = mResizingWindows .get (i );
84648459 final WindowStateAnimator winAnimator = win .mWinAnimator ;
84658460 try {
@@ -8490,7 +8485,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
84908485 } catch (RemoteException e ) {
84918486 win .mOrientationChanging = false ;
84928487 }
8493- } while ( i > 0 );
8488+ }
84948489 mResizingWindows .clear ();
84958490 }
84968491
@@ -8725,6 +8720,7 @@ boolean reclaimSomeSurfaceMemoryLocked(WindowStateAnimator winAnimator, String o
87258720 wsa .mSurface .destroy ();
87268721 wsa .mSurfaceShown = false ;
87278722 wsa .mSurface = null ;
8723+ ws .mHasSurface = false ;
87288724 mForceRemoves .add (ws );
87298725 i --;
87308726 N --;
@@ -8737,6 +8733,7 @@ boolean reclaimSomeSurfaceMemoryLocked(WindowStateAnimator winAnimator, String o
87378733 wsa .mSurface .destroy ();
87388734 wsa .mSurfaceShown = false ;
87398735 wsa .mSurface = null ;
8736+ ws .mHasSurface = false ;
87408737 leakedSurface = true ;
87418738 }
87428739 }
@@ -8775,6 +8772,7 @@ boolean reclaimSomeSurfaceMemoryLocked(WindowStateAnimator winAnimator, String o
87758772 surface .destroy ();
87768773 winAnimator .mSurfaceShown = false ;
87778774 winAnimator .mSurface = null ;
8775+ winAnimator .mWin .mHasSurface = false ;
87788776 }
87798777
87808778 try {
0 commit comments