Android6.0 旋转屏幕(五)WMS启动应用流程(屏幕方向相关)

摘要:
在传递WindowManager.addView时,将相应的LayoutParams传递给WMS。WindowManager.LayoutParams。屏幕方向II。屏幕旋转2.1活动-使用ActivityStack中设置的屏幕方向启动活动。在startActivityLocked中,AMS将向WMS添加与ActivityRecord相关的令牌。此方法中只有令牌。阿托肯。requestedOrientation=请求的方向;当WMS获取相关AppOrientation=null){next.frozenBeforeDestroy=true;}时,此AppToken将发挥作用updated=mService。updateConfigurationLocked;}WMS。updateOrientationFroemAppTokens将直接调用updateOrientation FromAppTokensLocked1。要调用updateOriginationFromAppTokens Locked来执行真正的updateOriental工作。如果返回true,则表示方向已更改,您需要执行应用程序的屏幕翻转操作。

一、强制设置方向

1.Activity

如果要强制设置一个Activity的横竖屏可以通过Manifest去设置,跟Activity相关的信息都会保存在ActivityInfo当中。

  1. android:screenOrientation=["unspecified" | "user" | "behind" |
  2. "landscape" | "portrait" |
  3. "reverseLandscape" | "reversePortrait" |
  4. "sensorLandscape" | "sensorPortrait" |
  5. "sensor" | "fullSensor" | "nosensor"]

2.Window

如果是要强制设置一个Window的横竖屏可以通过 LayoutParams.screenOrientation来设置。在通过WindowManager.addView的时候把对应的LayoutParams传递给WMS。

WindowManager.LayoutParams.screenOrientation

二、屏幕转屏

2.1 Activity -- 启动一个有设置screenOrientation的Activity

在ActivityStack.startActivityLocked中,AMS会把ActivityRecord相关的Token加到WMS中,有且仅在这个方法中。这时候会把screenOrientation传递过去。

        atoken.requestedOrientation = requestedOrientation; 这个AppToken会在WMS获取相关App Orientation的时候其作用。

  1. mService.mWindowManager.addAppToken(addPos, r.userId, r.appToken,
  2. r.task.taskId, r.info.screenOrientation, r.fullscreen,
  3. (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0);
  1. public void addAppToken(int addPos, int userId, IApplicationToken token,
  2. int groupId, int requestedOrientation, boolean fullscreen, boolean showWhenLocked) {
  3. ... ...
  4. synchronized(mWindowMap) {
  5. AppWindowToken atoken = findAppWindowToken(token.asBinder());
  6. if (atoken != null) {
  7. Slog.w(TAG, "Attempted to add existing app token: " + token);
  8. return;
  9. }
  10. atoken = new AppWindowToken(this, userId, token);
  11. atoken.inputDispatchingTimeoutNanos = inputDispatchingTimeoutNanos;
  12. atoken.groupId = groupId;
  13. atoken.appFullscreen = fullscreen;
  14. atoken.showWhenLocked = showWhenLocked;
  15. atoken.requestedOrientation = requestedOrientation;//方向赋值
  16. if (DEBUG_TOKEN_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "addAppToken: " + atoken
  17. + " at " + addPos);
  18. mAppTokens.add(addPos, atoken);
  19. addAppTokenToAnimating(addPos, atoken);
  20. mTokenMap.put(token.asBinder(), atoken);
  21.  
  22. // Application tokens start out hidden.
  23. atoken.hidden = true;
  24. atoken.hiddenRequested = true;
  25.  
  26. //dump();
  27. }
  28. }


2.2 在启动Activity之前去获取当前WMS中的Orientation的Config

      在resumeTopActivityLocked和realStartActivityLocked中回去获取最新的Orientation的config

       1. 通过mWindowManager.updateOrientationFromAppTokens去更新当前WMS中的Orientation值,把WMS中的config返回给AMS ,这个我们在之前http://blog.csdn.net/kc58236582/article/details/53741445博客分析过了

       2. 通过updateConfigurationLocked去更新AMS中的config,发给每一个ActiviytThread。(会调用每个ActivityThread的onConfigurationChanged函数)

  1. synchronized (mService) {
  2. Configuration config = mService.mWindowManager.updateOrientationFromAppTokens(
  3. mService.mConfiguration,
  4. next.mayFreezeScreenLocked(next.app) ? next.appToken : null);
  5. if (config != null) {
  6. next.frozenBeforeDestroy = true;
  7. }
  8. updated = mService.updateConfigurationLocked(config, next, false, false);
  9. }


WMS.updateOrientationFroemAppTokens 会直接去调updateOrientationFromAppTokensLocked

          1. 去调用updateOrientationFromAppTokensLocked(false) 做真正的update Orientation的工作,如果返回是true,说明方向发生了变化,就需要去做app的转屏动作。

          2. 如果freezeThisOneIfNeed不为null,说明要做屏幕的转屏操做,就会把当前的atoken freeze掉。

          3. computeNewConfigurationLocked()  计算当前的Configuration,然后返回给AMS。

  1. private Configuration updateOrientationFromAppTokensLocked(
  2. Configuration currentConfig, IBinder freezeThisOneIfNeeded) {
  3. Configuration config = null;
  4.  
  5. if (updateOrientationFromAppTokensLocked(false)) {
  6. if (freezeThisOneIfNeeded != null) {
  7. AppWindowToken atoken = findAppWindowToken(
  8. freezeThisOneIfNeeded);
  9. if (atoken != null) {
  10. startAppFreezingScreenLocked(atoken,
  11. ActivityInfo.CONFIG_ORIENTATION);
  12. }
  13. }
  14. config = computeNewConfigurationLocked();
  15.  
  16. } else if (currentConfig != null) {
  17. // No obvious action we need to take, but if our current
  18. // state mismatches the activity manager's, update it,
  19. // disregarding font scale, which should remain set to
  20. // the value of the previous configuration.
  21. mTempConfiguration.setToDefaults();
  22. mTempConfiguration.fontScale = currentConfig.fontScale;
  23. if (computeScreenConfigurationLocked(mTempConfiguration)) {
  24. if (currentConfig.diff(mTempConfiguration) != 0) {
  25. mWaitingForConfig = true;
  26. getDefaultDisplayContentLocked().layoutNeeded = true;
  27. startFreezingDisplayLocked(false, 0, 0);
  28. config = new Configuration(mTempConfiguration);
  29. }
  30. }
  31. }
  32.  
  33. return config;
  34. }

updateOrientationFromAppTokensLocked 会查找出当前是否有需要强制Orientation的App或者Window
         1. computeForcedAppOrientationLocked  //goto 3.2.1.1.1

         2. 如果ForcedAppOrientation发生了变化, 就会去通知WindowPolicy去设置当前的Sensor的状态。//goto 3.2.1.1.2

         3. updateRotationUncheckedLocked(inTransaction),由于Orientation可能发生变化,所以需要去重新获取一下Rotation;具体就可以参照前一节了。

             如果Rotation发生了变化就返回true。跟configuration相关的东西,大多都在这个函数中进行。

  1. boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {
  2. long ident = Binder.clearCallingIdentity();
  3. try {
  4. int req = computeForcedAppOrientationLocked();
  5.  
  6. if (req != mForcedAppOrientation) {
  7. mForcedAppOrientation = req;
  8. //send a message to Policy indicating orientation change to take
  9. //action like disabling/enabling sensors etc.,
  10. mPolicy.setCurrentOrientationLw(req);
  11. if (updateRotationUncheckedLocked(inTransaction)) {
  12. // changed
  13. return true;
  14. }
  15. }
  16.  
  17. return false;
  18. } finally {
  19. Binder.restoreCallingIdentity(ident);
  20. }
  21. }

 computeForcedAppOrientationLocked

     这个函数的作用就是去查询当前即将要显示的Activity或者Window有没有需要强制Orientation的

     1. 先通过 getOrientationFromWindowsLocked去遍历WMS中的WindowList。

          1)如果在最上面的Window是一个AppWindow就直接返回mLastWindowForcedOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED

          2)如果不是AppWindow,判断这个Window是否可见,如果不可见就continue

          3)最后如果这个Window既不是AppWindow又要是可见的,并且他是有指定ScreenOrientation的,就返回这个window的orientatin。mLastWindowForcedOrientation=req

    2. 如果getOrientationFromWindowsLocked找到的是一个AppWindow或者当前没有指定Orientation的Window,就会走到getOrientationFromAppTokensLocked();

        1)这个函数会去遍历AppWindowToken List去查找需要强制Orientation的Token,这个时候就是根据我们之前在AMS中传递进来的atoken.requestedOrientation;来进行判断,如果设置了就返回回去给req。

  1. int computeForcedAppOrientationLocked() {
  2. int req = getOrientationFromWindowsLocked();
  3. if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
  4. req = getOrientationFromAppTokensLocked();
  5. }
  6. if (mForceLandScape &&
  7. req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
  8. req = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
  9. }
  10. return req;
  11. }

PhoneWindowManager.setCurrentOrientationLw()

     1. 用mCurrentAppOrientation保存当前新的Orientation.

     2. updateOrientationListenerLp,通过名字就知道他只是去管理是否启动Sensor Listener的。

  1. public void setCurrentOrientationLw(int newOrientation) {
  2. synchronized (mLock) {
  3. if (newOrientation != mCurrentAppOrientation) {
  4. mCurrentAppOrientation = newOrientation;
  5. updateOrientationListenerLp();
  6. }
  7. }
  8. }

WMS. computeNewConfiguration()

      通过computeNewConfigurationLocked() 计算出一个新的configuration.随后就会在AMS中调用ActivityThread把这个数据最后传到应用进程

  1. public Configuration computeNewConfiguration() {
  2. synchronized (mWindowMap) {
  3. Configuration config = computeNewConfigurationLocked();
  4. if (config == null && mWaitingForConfig) {
  5. // Nothing changed but we are waiting for something... stop that!
  6. mWaitingForConfig = false;
  7. performLayoutAndPlaceSurfacesLocked();
  8. }
  9. return config;
  10. }
  11. }


2.3 AMS端的工作完成之后,就到ActivityThread和ViewRootImpl的工作了

 2.3.1 在ActivityThread的handleResume的时候会把Activity对应的DectorView加到WMS中,在WMS中会调用addWindow.

如果我们自己添加一个Window的话也是走到这边。 在AddWindow的时候有可能对Orietation和Configuration, 前提是这个win的isVisibleOrAdding的条件。不过一般都不会满足这个条件。

sendNewConfiguration最后会到AMS的updateConfiguration函数然后调用updateConfigurationLocked函数之前博客分析过了。

  1. if (win.isVisibleOrAdding() && updateOrientationFromAppTokensLocked(false)) {
  2. reportNewConfig = true;
  3. }
  4. }
  5.  
  6. if (reportNewConfig) {
  7. sendNewConfiguration();
  8. }


2.3.2 当addWindow完成之后,ViewRootImpl就会去requestLayout,而requestLayout实际上就是去做scheduleTraversals 

             1. 在performTraversals中会先去做一次measureHierarchy计算一下View所需的大小。

             2. 然后会调用relayoutWindow去请求WMS帮助实际计算当前Window的布局,创建一个Surface,并且返回对应的Frame。

2.3.4 WMS.relayoutWindow()

       1. 根据传进来的requestWidth和requestHeight 或者attrChange的变化来决定是不是真的要relayout,并且把win.mLayoutNeeded设置为true。在performLayoutAndPlaceSurfacesLocked的会根据这个值做判断。

       2. 如果当前的WindowState还没有Surface就调用 winAnimator.createSurfaceLocked();去创建一个Surface会带回给ViewRootImpl

       3. 如果focus window发生变化了就updateFocusedWindowLocked

           如果Layer变化了就调用assignLayersLocked

       4. 再次调用updateOrientationFromAppTokensLocked去判断当前的Orietation是不是发生变化了。//在这个调用中如果有Orientation发生了变化,如果有变化就会调用computeNewConfigurationLocked()去更新DisplayContent相关的信息并且计算出一个新的Configuration

       5. 调用performLayoutAndPlaceSurfacesLocked

       6. 把WindowState中的三个Frame返回给Client端。

  1. public int relayoutWindow(Session session, IWindow client, int seq,
  2. WindowManager.LayoutParams attrs, int requestedWidth,
  3. int requestedHeight, int viewVisibility, int flags,
  4. Rect outFrame, Rect outContentInsets,
  5. Rect outVisibleInsets, Configuration outConfig, Surface outSurface) {
  6. boolean toBeDisplayed = false;
  7. boolean inTouchMode;
  8. boolean configChanged;
  9. boolean surfaceChanged = false;
  10. boolean animating;
  11. ... ...
  12. synchronized(mWindowMap) {
  13. // TODO(cmautner): synchronize on mAnimator or win.mWinAnimator.
  14. WindowState win = windowForClientLocked(session, client, false);
  15. ... ...
  16. WindowStateAnimator winAnimator = win.mWinAnimator;
  17. if (win.mRequestedWidth != requestedWidth
  18. || win.mRequestedHeight != requestedHeight) {
  19. win.mLayoutNeeded = true;
  20. win.mRequestedWidth = requestedWidth;
  21. win.mRequestedHeight = requestedHeight;
  22. }
  23. if (attrs != null && seq == win.mSeq) {
  24. win.mSystemUiVisibility = systemUiVisibility;
  25. }
  26.  
  27. if (attrs != null) {
  28. mPolicy.adjustWindowParamsLw(attrs);
  29. }
  30.  
  31. winAnimator.mSurfaceDestroyDeferred =
  32. (flags&WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY) != 0;
  33.  
  34. int attrChanges = 0;
  35. int flagChanges = 0;
  36. if (attrs != null) {
  37.  
  38. flagChanges = win.mAttrs.flags ^= attrs.flags;
  39. attrChanges = win.mAttrs.copyFrom(attrs);
  40. if ((attrChanges & (WindowManager.LayoutParams.LAYOUT_CHANGED
  41. | WindowManager.LayoutParams.SYSTEM_UI_VISIBILITY_CHANGED)) != 0) {
  42. win.mLayoutNeeded = true;
  43. }
  44. }
  45. ... ...
  46. if (viewVisibility == View.VISIBLE &&
  47. (win.mAppToken == null || !win.mAppToken.clientHidden)) {
  48. toBeDisplayed = !win.isVisibleLw();
  49.  
  50.  
  51. if ((attrChanges&WindowManager.LayoutParams.FORMAT_CHANGED) != 0) {
  52. // To change the format, we need to re-build the surface.
  53. winAnimator.destroySurfaceLocked(false);
  54. toBeDisplayed = true;
  55. surfaceChanged = true;
  56. }
  57. try {
  58. if (!win.mHasSurface) {
  59. surfaceChanged = true;
  60. }
  61. Surface surface = winAnimator.createSurfaceLocked();
  62. if (surface != null) {
  63. outSurface.copyFrom(surface);
  64. if (SHOW_TRANSACTIONS) Slog.i(TAG,
  65. " OUT SURFACE " + outSurface + ": copied");
  66. } else {
  67. // For some reason there isn't a surface. Clear the
  68. // caller's object so they see the same state.
  69. outSurface.release();
  70. }
  71. } catch (Exception e) {
  72.  
  73. }
  74. if (toBeDisplayed) {
  75. focusMayChange = isDefaultDisplay;
  76. }
  77. if (win.mAttrs.type == TYPE_INPUT_METHOD
  78. && mInputMethodWindow == null) {
  79. mInputMethodWindow = win;
  80. imMayMove = true;
  81. }
  82. if (win.mAttrs.type == TYPE_BASE_APPLICATION
  83. && win.mAppToken != null
  84. && win.mAppToken.startingWindow != null) {
  85. // Special handling of starting window over the base
  86. // window of the app: propagate lock screen flags to it,
  87. // to provide the correct semantics while starting.
  88. final int mask =
  89. WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
  90. | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
  91. | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON;
  92. WindowManager.LayoutParams sa = win.mAppToken.startingWindow.mAttrs;
  93. sa.flags = (sa.flags&~mask) | (win.mAttrs.flags&mask);
  94. }
  95. } else {
  96. winAnimator.mEnterAnimationPending = false;
  97. if (winAnimator.mSurface != null) {
  98. if (DEBUG_VISIBILITY) Slog.i(TAG, "Relayout invis " + win
  99. + ": mExiting=" + win.mExiting);
  100. // If we are not currently running the exit animation, we
  101. // need to see about starting one.
  102. if (!win.mExiting) {
  103. surfaceChanged = true;
  104. // Try starting an animation; if there isn't one, we
  105. // can destroy the surface right away.
  106. int transit = WindowManagerPolicy.TRANSIT_EXIT;
  107. if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
  108. transit = WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
  109. }
  110. if (win.isWinVisibleLw() &&
  111. winAnimator.applyAnimationLocked(transit, false)) {
  112. focusMayChange = isDefaultDisplay;
  113. win.mExiting = true;
  114. } else if (win.mWinAnimator.isAnimating()) {
  115. // Currently in a hide animation... turn this into
  116. // an exit.
  117. win.mExiting = true;
  118. } else if (win == mWallpaperTarget) {
  119. // If the wallpaper is currently behind this
  120. // window, we need to change both of them inside
  121. // of a transaction to avoid artifacts.
  122. win.mExiting = true;
  123. win.mWinAnimator.mAnimating = true;
  124. } else {
  125. if (mInputMethodWindow == win) {
  126. mInputMethodWindow = null;
  127. }
  128. winAnimator.destroySurfaceLocked(false);
  129. }
  130. scheduleNotifyWindowTranstionIfNeededLocked(win, transit);
  131. }
  132. }
  133.  
  134. outSurface.release();
  135. if (DEBUG_VISIBILITY) Slog.i(TAG, "Releasing surface in: " + win);
  136. }
  137.  
  138. if (focusMayChange) {
  139. //System.out.println("Focus may change: " + win.mAttrs.getTitle());
  140. if (updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
  141. false /*updateInputWindows*/)) {
  142. imMayMove = false;
  143. }
  144. //System.out.println("Relayout " + win + ": focus=" + mCurrentFocus);
  145. }
  146.  
  147. // updateFocusedWindowLocked() already assigned layers so we only need to
  148. // reassign them at this point if the IM window state gets shuffled
  149. boolean assignLayers = false;
  150. ... ...
  151. if (assignLayers) {
  152. assignLayersLocked(win.getWindowList());
  153. }
  154. configChanged = updateOrientationFromAppTokensLocked(false);
  155. performLayoutAndPlaceSurfacesLocked();
  156. if (toBeDisplayed && win.mIsWallpaper) {
  157. DisplayInfo displayInfo = getDefaultDisplayInfoLocked();
  158. updateWallpaperOffsetLocked(win,
  159. displayInfo.appWidth, displayInfo.appHeight, false);
  160. }
  161. if (win.mAppToken != null) {
  162. win.mAppToken.updateReportedVisibilityLocked();
  163. }
  164. outFrame.set(win.mCompatFrame);
  165. outContentInsets.set(win.mContentInsets);
  166. outVisibleInsets.set(win.mVisibleInsets);
  167. ... ...
  168.  
  169. mInputMonitor.updateInputWindowsLw(true /*force*/);
  170.  
  171. }
  172.  
  173. if (configChanged) {
  174. sendNewConfiguration();
  175. }

WMS.performLayoutAndPlaceSurfacesLockedLoop()

        performLayoutAndPlaceSurfacesLocked直接去调performLayoutAndPlaceSurfacesLockedLoop, 在performLayoutAndPlaceSurfacesLockedLoop里面做两个最主要的操作。

        1. performLayoutAndPlaceSurfacesLockedInner();

        2. requestTraversalLocked();

  1. private final void performLayoutAndPlaceSurfacesLockedLoop() {
  2. ... ...
  3.  
  4. mInLayout = true;
  5. boolean recoveringMemory = false;
  6. ... ...
  7. try {
  8. performLayoutAndPlaceSurfacesLockedInner(recoveringMemory);
  9.  
  10. mInLayout = false;
  11.  
  12. if (needsLayout()) {
  13. if (++mLayoutRepeatCount < 6) {
  14. requestTraversalLocked();
  15. } else {
  16. Slog.e(TAG, "Performed 6 layouts in a row. Skipping");
  17. mLayoutRepeatCount = 0;
  18. }
  19. } else {
  20. mLayoutRepeatCount = 0;
  21. }
  22.  
  23. if (mWindowsChanged && !mWindowChangeListeners.isEmpty()) {
  24. mH.removeMessages(H.REPORT_WINDOWS_CHANGE);
  25. mH.sendMessage(mH.obtainMessage(H.REPORT_WINDOWS_CHANGE));
  26. }
  27. } catch (RuntimeException e) {
  28. mInLayout = false;
  29. Log.wtf(TAG, "Unhandled exception while laying out windows", e);
  30. }
  31.  
  32. Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
  33. }


WMS.performLayoutAndPlaceSurfacesLockedInner(false)

         1. 首先会获取当前的一个DsiplayContent,由于这个DisplayContent在updateOrientationFromAppTokensLocked的时候已经根据最新的window状态进行跟新过,所以现在的DsiplayContent应该是最新的值。

         2. performLayoutLockedInner; 这个函数回去遍历每一个Window,然后根据当前的DisplayContent去更新Layout.             

              这个方法会根据最新的DisplayContent去判断所有的window是否需要重新layout

              第一步,通过mPolicy.beginLayoutLw去给policy设置一个标准把当前的Content信息设置进去

              第二步, mPolicy.layoutWindowLw(win, win.mAttrs, null); 给win做真正的layout,layout主要做了什么?有几个重要的变量?

                               在layoutWindow中会通过computeFrameLw去计算WindowState的中的Frame,有三个Frame;

         3. updateResizingWindows(w);

              如果WindowState其中的w.mContentInsetsChanged || w.mVisibleInsetsChanged  || winAnimator.mSurfaceResized|| configChanged 任意的一个发生变化了就会加入到mResizingWindows数组中。并且把对应的Window Freezing。

         4. 遍历mResizingWindows, 调用win.mClient.resized通过IPC告诉Clinet端要做resize

             最终ViewRootImpl就会发送一个MSG_RESIZED去处理,WMS会把里面的三个Frame和Configuration发回给Clinet。ViewRoot会保存最新的三个Frame和updateConfiguration,最后 requestLayout();

    1. private final void performLayoutAndPlaceSurfacesLockedInner(boolean recoveringMemory) {
    2. ... ...
    3. Surface.openTransaction();
    4. try {
    5.  
    6. boolean focusDisplayed = false;
    7. boolean updateAllDrawn = false;
    8.  
    9. DisplayContentsIterator iterator = new DisplayContentsIterator();
    10. while (iterator.hasNext()) {
    11. final DisplayContent displayContent = iterator.next();
    12. WindowList windows = displayContent.getWindowList();
    13. DisplayInfo displayInfo = displayContent.getDisplayInfo();
    14. final int displayId = displayContent.getDisplayId();
    15. final int dw = displayInfo.logicalWidth;
    16. final int dh = displayInfo.logicalHeight;
    17. final int innerDw = displayInfo.appWidth;
    18. final int innerDh = displayInfo.appHeight;
    19. final boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY);
    20.  
    21. // Reset for each display unless we are forcing mirroring.
    22. if (mInnerFields.mDisplayHasContent != LayoutFields.DISPLAY_CONTENT_MIRROR) {
    23. mInnerFields.mDisplayHasContent = LayoutFields.DISPLAY_CONTENT_UNKNOWN;
    24. }
    25. ... ...
    26. int repeats = 0;
    27. do {
    28. repeats++;
    29. ... ...
    30. // FIRST LOOP: Perform a layout, if needed.
    31. if (repeats < 4) {
    32. performLayoutLockedInner(displayContent, repeats == 1,
    33. false /*updateInputWindows*/);
    34. } else {
    35. Slog.w(TAG, "Layout repeat skipped after too many iterations");
    36. }
    37. ... ...
    38. } while (displayContent.pendingLayoutChanges != 0);
    39.  
    40. // Only used if default window
    41. final boolean someoneLosingFocus = !mLosingFocus.isEmpty();
    42.  
    43. final int N = windows.size();
    44. for (i=N-1; i>=0; i--) {
    45. WindowState w = windows.get(i);
    46. ... ...
    47.  
    48. //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing");
    49. w.mContentChanged = false;
    50.  
    51. // Moved from updateWindowsAndWallpaperLocked().
    52. if (w.mHasSurface) {
    53. // Take care of the window being ready to display.
    54. ... ...
    55. }
    56. ... ...
    57. }
    58. }
    59.  
    60. if (isDefaultDisplay && someoneLosingFocus && (w == mCurrentFocus)
    61. && w.isDisplayedLw()) {
    62. focusDisplayed = true;
    63. }
    64.  
    65. updateResizingWindows(w);
    66. }
    67.  
    68. ... ...
    69.  
    70. for (i = mResizingWindows.size() - 1; i >= 0; i--) {
    71. WindowState win = mResizingWindows.get(i);
    72. if (win.mAppFreezing) {
    73. // Don't remove this window until rotation has completed.
    74. continue;
    75. }
    76. final WindowStateAnimator winAnimator = win.mWinAnimator;
    77. try {
    78. if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG,
    79. "Reporting new frame to " + win + ": " + win.mCompatFrame);
    80. int diff = 0;
    81. boolean configChanged = win.isConfigChanged();
    82. if ((DEBUG_RESIZE || DEBUG_ORIENTATION || DEBUG_CONFIGURATION)
    83. && configChanged) {
    84. Slog.i(TAG, "Sending new config to window " + win + ": "
    85. + winAnimator.mSurfaceW + "x" + winAnimator.mSurfaceH
    86. + " / " + mCurConfiguration + " / 0x"
    87. + Integer.toHexString(diff));
    88. }
    89. win.setConfiguration(mCurConfiguration);
    90. if (DEBUG_ORIENTATION &&
    91. winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING) Slog.i(
    92. TAG, "Resizing " + win + " WITH DRAW PENDING");
    93. win.mClient.resized(win.mFrame, win.mLastContentInsets, win.mLastVisibleInsets,
    94. winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING,
    95. configChanged ? win.mConfiguration : null);
    96. win.mContentInsetsChanged = false;
    97. win.mVisibleInsetsChanged = false;
    98. winAnimator.mSurfaceResized = false;
    99. } catch (RemoteException e) {
    100. win.mOrientationChanging = false;
    101. }
    102. mResizingWindows.remove(i);
    103. }
    104.  
    105. ... ...
    106.  
    107. // Finally update all input windows now that the window changes have stabilized.
    108. mInputMonitor.updateInputWindowsLw(true /*force*/);
    109. ... ...
    110. }
    111.  
    112. // Check to see if we are now in a state where the screen should
    113. // be enabled, because the window obscured flags have changed.
    114. enableScreenIfNeededLocked();
    115.  
    116. updateLayoutToAnimationLocked();
    117. ... ...
    118. }

免责声明:文章转载自《Android6.0 旋转屏幕(五)WMS启动应用流程(屏幕方向相关)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇SAP MM 事务代码MI31之思考NCC参照开发2下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Java 处理PDF图章(印章)——图片图章、动态图章

图章(印章)是一种在合同、票据、公文等文件中表明法律效应、部门机关权威的重要指示物,常见于各种格式的文件、文档中。对于纸质文档可以手动盖章,但对于电子文档,则需要通过特定的方法来实现。本篇文档分享通过Java代码在PDF文档中添加图章的方法。内容将分两部分介绍: 1. 添加图片图章。即通过加载现有的图章(以图片形式),添加到PDF指定页面位置 2. 添加动...

华为EC321CDMA PCMICA 无线网卡Ubuntu下使用

工作性质的原因,公司配备了华为EC321 CDMA无线网卡,PCMCIA接口。Windows环境下安装好驱动然后通过华为自带的软件可以拨号上网。 Linux下面能不能使用这块网卡呢,答案是肯定的。linux内核中已经包含了很多标准CDMA无线网卡芯片的驱动,只要你使用的CDMA卡是兼容的标准芯片那么在linux环境中使用的可能性很大。其中华为EC321这款...

火狐无法启动,如何恢复数据、书签、密码

今天火狐在更新时被金山卫士干扰,导致更新后无法再启动。 我一时没考虑太多,重新安装了一下火狐,后来一想,妈的,我的书签和网站密码之类的会不会全丢了,太蛋疼了。 网上找了许多资料,总结了一下找回数据的方式。 只要你不是选择卸掉火狐选择了删除数据的话,问题就不大的。 我这里只有WINDOWS的解决办 最好操作前先关掉杀软之类的东西,别的程序也关掉,免得干扰。...

在线office文档编辑NTKO使用心得

目录 前言 什么是ntko 准备工作 实战演练 总结 一、前言 Web开发中经常需要用到在线处理office文档的功能,现在市面上有一些常用的Web页面调用显示Office的控件技术,用起来很方便。有一些第三方ActiveX浏览器控件:比如科瀚的SOAOffice中间件、卓正软件的pageoffice控件、WebOffice控件还有我这篇文章所要说到的...

微服务架构介绍

作者:老刘链接:https://www.zhihu.com/question/55511712/answer/860169294来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 一、微服务架构介绍 微服务架构(Microservice Architecture)是一种架构概念,旨在通过将功能分解到各个离散的服务中以实现对解决方...

利用 Charles Proxy 下载旧版本 iOS App

一、软件准备 1、旧版本 iTunes1.IPSW Downloads:https://ipsw.me/2.百度网盘链接:https://pan.baidu.com/s/11kdHbhqP_6wvcMWDa3HZNg 提取码:hj81 2、抓包工具 Charles Proxy1.Charles官网链接:https://www.charlesproxy.co...