OSDN Git Service

Merge "Allow to keep screen on only if window can be seen" into nyc-mr1-dev
authorChong Zhang <chz@google.com>
Fri, 12 Aug 2016 00:42:56 +0000 (00:42 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Fri, 12 Aug 2016 00:42:57 +0000 (00:42 +0000)
1  2 
services/core/java/com/android/server/wm/WindowSurfacePlacer.java

@@@ -1097,26 -1097,6 +1097,26 @@@ class WindowSurfacePlacer 
          boolean fullscreenAnim = false;
          boolean voiceInteraction = false;
  
 +        int i;
 +        for (i = 0; i < appsCount; i++) {
 +            final AppWindowToken wtoken = mService.mOpeningApps.valueAt(i);
 +            // Clearing the mAnimatingExit flag before entering animation. It's set to
 +            // true if app window is removed, or window relayout to invisible.
 +            // This also affects window visibility. We need to clear it *before*
 +            // maybeUpdateTransitToWallpaper() as the transition selection depends on
 +            // wallpaper target visibility.
 +            wtoken.clearAnimatingFlags();
 +
 +        }
 +        // Adjust wallpaper before we pull the lower/upper target, since pending changes
 +        // (like the clearAnimatingFlags() above) might affect wallpaper target result.
 +        final DisplayContent displayContent = mService.getDefaultDisplayContentLocked();
 +        if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0 &&
 +                mWallpaperControllerLocked.adjustWallpaperWindows()) {
 +            mService.mLayersController.assignLayersLocked(windows);
 +            displayContent.layoutNeeded = true;
 +        }
 +
          final WindowState lowerWallpaperTarget =
                  mWallpaperControllerLocked.getLowerWallpaperTarget();
          final WindowState upperWallpaperTarget =
              upperWallpaperAppToken = upperWallpaperTarget.mAppToken;
          }
  
 -        int i;
          // Do a first pass through the tokens for two
          // things:
          // (1) Determine if both the closing and opening
                  if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) {
                      openingAppHasWallpaper = true;
                  }
 -                // Clearing the mAnimatingExit flag before entering animation. It's set to
 -                // true if app window is removed, or window relayout to invisible.
 -                // This also affects window visibility. We need to clear it *before*
 -                // maybeUpdateTransitToWallpaper() as the transition selection depends on
 -                // wallpaper target visibility.
 -                wtoken.clearAnimatingFlags();
              }
  
              voiceInteraction |= wtoken.voiceInteraction;
          final AppWindowToken topOpeningApp = handleOpeningApps(transit,
                  animLp, voiceInteraction, topClosingLayer);
  
 +        mService.mAppTransition.setLastAppTransition(transit, topOpeningApp, topClosingApp);
 +
          final AppWindowAnimator openingAppAnimator = (topOpeningApp == null) ?  null :
                  topOpeningApp.mAppAnimator;
          final AppWindowAnimator closingAppAnimator = (topClosingApp == null) ? null :
  
          // This has changed the visibility of windows, so perform
          // a new layout to get them all up-to-date.
 -        mService.getDefaultDisplayContentLocked().layoutNeeded = true;
 +        displayContent.layoutNeeded = true;
  
          // TODO(multidisplay): IMEs are only supported on the default display.
          if (windows == mService.getDefaultWindowListLocked()
              mObscured = true;
          }
  
-         if (w.mHasSurface) {
+         if (w.mHasSurface && canBeSeen) {
              if ((attrFlags&FLAG_KEEP_SCREEN_ON) != 0) {
                  mHoldScreen = w.mSession;
                  mHoldScreenWindow = w;
              }
  
              final int type = attrs.type;
-             if (canBeSeen
-                     && (type == TYPE_SYSTEM_DIALOG
-                      || type == TYPE_SYSTEM_ERROR
-                      || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0)) {
+             if (type == TYPE_SYSTEM_DIALOG || type == TYPE_SYSTEM_ERROR
+                     || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
                  mSyswin = true;
              }
  
-             if (canBeSeen) {
-                 // This function assumes that the contents of the default display are
-                 // processed first before secondary displays.
-                 final DisplayContent displayContent = w.getDisplayContent();
-                 if (displayContent != null && displayContent.isDefaultDisplay) {
-                     // While a dream or keyguard is showing, obscure ordinary application
-                     // content on secondary displays (by forcibly enabling mirroring unless
-                     // there is other content we want to show) but still allow opaque
-                     // keyguard dialogs to be shown.
-                     if (type == TYPE_DREAM || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
-                         mObscureApplicationContentOnSecondaryDisplays = true;
-                     }
-                     mDisplayHasContent = true;
-                 } else if (displayContent != null &&
-                         (!mObscureApplicationContentOnSecondaryDisplays
-                         || (mObscured && type == TYPE_KEYGUARD_DIALOG))) {
-                     // Allow full screen keyguard presentation dialogs to be seen.
-                     mDisplayHasContent = true;
-                 }
-                 if (mPreferredRefreshRate == 0
-                         && w.mAttrs.preferredRefreshRate != 0) {
-                     mPreferredRefreshRate = w.mAttrs.preferredRefreshRate;
-                 }
-                 if (mPreferredModeId == 0
-                         && w.mAttrs.preferredDisplayModeId != 0) {
-                     mPreferredModeId = w.mAttrs.preferredDisplayModeId;
-                 }
-                 if ((privateflags & PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE) != 0) {
-                     mSustainedPerformanceModeCurrent = true;
+             // This function assumes that the contents of the default display are
+             // processed first before secondary displays.
+             final DisplayContent displayContent = w.getDisplayContent();
+             if (displayContent != null && displayContent.isDefaultDisplay) {
+                 // While a dream or keyguard is showing, obscure ordinary application
+                 // content on secondary displays (by forcibly enabling mirroring unless
+                 // there is other content we want to show) but still allow opaque
+                 // keyguard dialogs to be shown.
+                 if (type == TYPE_DREAM || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
+                     mObscureApplicationContentOnSecondaryDisplays = true;
                  }
+                 mDisplayHasContent = true;
+             } else if (displayContent != null &&
+                     (!mObscureApplicationContentOnSecondaryDisplays
+                             || (mObscured && type == TYPE_KEYGUARD_DIALOG))) {
+                 // Allow full screen keyguard presentation dialogs to be seen.
+                 mDisplayHasContent = true;
+             }
+             if (mPreferredRefreshRate == 0
+                     && w.mAttrs.preferredRefreshRate != 0) {
+                 mPreferredRefreshRate = w.mAttrs.preferredRefreshRate;
+             }
+             if (mPreferredModeId == 0
+                     && w.mAttrs.preferredDisplayModeId != 0) {
+                 mPreferredModeId = w.mAttrs.preferredDisplayModeId;
+             }
+             if ((privateflags & PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE) != 0) {
+                 mSustainedPerformanceModeCurrent = true;
              }
          }
      }