public MagnificationSpec getMagnificationSpecForWindowLocked(WindowState windowState) {
   MagnificationSpec spec = mMagnifedViewport.getMagnificationSpecLocked();
   if (spec != null && !spec.isNop()) {
     WindowManagerPolicy policy = mWindowManagerService.mPolicy;
     final int windowType = windowState.mAttrs.type;
     if (!policy.isTopLevelWindow(windowType)
         && windowState.mAttachedWindow != null
         && !policy.canMagnifyWindow(windowType)) {
       return null;
     }
     if (!policy.canMagnifyWindow(windowState.mAttrs.type)) {
       return null;
     }
   }
   return spec;
 }
Example #2
0
  private void updateWindowsAndWallpaperLocked() {
    ++mAnimTransactionSequence;

    ArrayList<WindowStateAnimator> unForceHiding = null;
    boolean wallpaperInUnForceHiding = false;

    for (int i = mService.mWindows.size() - 1; i >= 0; i--) {
      WindowState win = mService.mWindows.get(i);
      WindowStateAnimator winAnimator = win.mWinAnimator;
      final int flags = winAnimator.mAttrFlags;

      if (winAnimator.mSurface != null) {
        final boolean wasAnimating = winAnimator.mWasAnimating;
        final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);

        if (WindowManagerService.DEBUG_WALLPAPER) {
          Slog.v(TAG, win + ": wasAnimating=" + wasAnimating + ", nowAnimating=" + nowAnimating);
        }

        // If this window is animating, make a note that we have
        // an animating window and take care of a request to run
        // a detached wallpaper animation.
        if (nowAnimating) {
          if (winAnimator.mAnimation != null) {
            if ((flags & FLAG_SHOW_WALLPAPER) != 0 && winAnimator.mAnimation.getDetachWallpaper()) {
              mDetachedWallpaper = win;
            }
            final int backgroundColor = winAnimator.mAnimation.getBackgroundColor();
            if (backgroundColor != 0) {
              if (mWindowAnimationBackground == null
                  || (winAnimator.mAnimLayer
                      < mWindowAnimationBackground.mWinAnimator.mAnimLayer)) {
                mWindowAnimationBackground = win;
                mWindowAnimationBackgroundColor = backgroundColor;
              }
            }
          }
          mAnimating = true;
        }

        // If this window's app token is running a detached wallpaper
        // animation, make a note so we can ensure the wallpaper is
        // displayed behind it.
        final AppWindowAnimator appAnimator =
            win.mAppToken == null ? null : win.mAppToken.mAppAnimator;
        if (appAnimator != null && appAnimator.animation != null && appAnimator.animating) {
          if ((flags & FLAG_SHOW_WALLPAPER) != 0 && appAnimator.animation.getDetachWallpaper()) {
            mDetachedWallpaper = win;
          }
          final int backgroundColor = appAnimator.animation.getBackgroundColor();
          if (backgroundColor != 0) {
            if (mWindowAnimationBackground == null
                || (winAnimator.mAnimLayer < mWindowAnimationBackground.mWinAnimator.mAnimLayer)) {
              mWindowAnimationBackground = win;
              mWindowAnimationBackgroundColor = backgroundColor;
            }
          }
        }

        if (wasAnimating && !winAnimator.mAnimating && mService.mWallpaperTarget == win) {
          mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
          mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
          if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
            mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 2", mPendingLayoutChanges);
          }
        }

        if (mPolicy.doesForceHide(win, win.mAttrs)) {
          if (!wasAnimating && nowAnimating) {
            if (WindowManagerService.DEBUG_ANIM || WindowManagerService.DEBUG_VISIBILITY)
              Slog.v(TAG, "Animation started that could impact force hide: " + win);
            mBulkUpdateParams |= SET_FORCE_HIDING_CHANGED;
            mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
            if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
              mService.debugLayoutRepeats(
                  "updateWindowsAndWallpaperLocked 3", mPendingLayoutChanges);
            }
            mService.mFocusMayChange = true;
          }
          if (win.isReadyForDisplay() && winAnimator.mAnimationIsEntrance) {
            mForceHiding = true;
          }
          if (WindowManagerService.DEBUG_VISIBILITY)
            Slog.v(
                TAG,
                "Force hide "
                    + mForceHiding
                    + " hasSurface="
                    + win.mHasSurface
                    + " policyVis="
                    + win.mPolicyVisibility
                    + " destroying="
                    + win.mDestroying
                    + " attHidden="
                    + win.mAttachedHidden
                    + " vis="
                    + win.mViewVisibility
                    + " hidden="
                    + win.mRootToken.hidden
                    + " anim="
                    + win.mWinAnimator.mAnimation);
        } else if (mPolicy.canBeForceHidden(win, win.mAttrs)) {
          final boolean changed;
          if (mForceHiding
              && (!winAnimator.isAnimating()
                  || (winAnimator.mAttrFlags & FLAG_SHOW_WHEN_LOCKED) == 0)) {
            changed = win.hideLw(false, false);
            if (WindowManagerService.DEBUG_VISIBILITY && changed)
              Slog.v(TAG, "Now policy hidden: " + win);
          } else {
            changed = win.showLw(false, false);
            if (WindowManagerService.DEBUG_VISIBILITY && changed)
              Slog.v(TAG, "Now policy shown: " + win);
            if (changed) {
              if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0
                  && win.isVisibleNow() /*w.isReadyForDisplay()*/) {
                if (unForceHiding == null) {
                  unForceHiding = new ArrayList<WindowStateAnimator>();
                }
                unForceHiding.add(winAnimator);
                if ((win.mAttrs.flags & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
                  wallpaperInUnForceHiding = true;
                }
              }
              if (mCurrentFocus == null || mCurrentFocus.mLayer < win.mLayer) {
                // We are showing on to of the current
                // focus, so re-evaluate focus to make
                // sure it is correct.
                mService.mFocusMayChange = true;
              }
            }
          }
          if (changed && (flags & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
            mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
            mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
            if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
              mService.debugLayoutRepeats(
                  "updateWindowsAndWallpaperLocked 4", mPendingLayoutChanges);
            }
          }
        }
      }

      final AppWindowToken atoken = win.mAppToken;
      if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) {
        if (atoken == null || atoken.allDrawn) {
          if (winAnimator.performShowLocked()) {
            mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
            if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
              mService.debugLayoutRepeats(
                  "updateWindowsAndWallpaperLocked 5", mPendingLayoutChanges);
            }
          }
        }
      }
      final AppWindowAnimator appAnimator = atoken == null ? null : atoken.mAppAnimator;
      if (appAnimator != null && appAnimator.thumbnail != null) {
        if (appAnimator.thumbnailTransactionSeq != mAnimTransactionSequence) {
          appAnimator.thumbnailTransactionSeq = mAnimTransactionSequence;
          appAnimator.thumbnailLayer = 0;
        }
        if (appAnimator.thumbnailLayer < winAnimator.mAnimLayer) {
          appAnimator.thumbnailLayer = winAnimator.mAnimLayer;
        }
      }
    } // end forall windows

    // If we have windows that are being show due to them no longer
    // being force-hidden, apply the appropriate animation to them.
    if (unForceHiding != null) {
      for (int i = unForceHiding.size() - 1; i >= 0; i--) {
        Animation a = mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding);
        if (a != null) {
          final WindowStateAnimator winAnimator = unForceHiding.get(i);
          winAnimator.setAnimation(a);
          winAnimator.mAnimationIsEntrance = true;
        }
      }
    }
  }