wms开发常用调试开发技巧之WMShell的实用命令

背景:

在wms窗口开发工程师日常工作中,经常需要和WMShell打交道,比如分屏,自由窗口,startingwindow等都移入到了WMShell中。

WMShell是什么?

Google 将原本集中于 WindowManagerService (WMS) 的许多窗口管理相关功能,尤其是动画和特定窗口状态管理,剥离并重构到了 WMShell 中。这使得 WMS 的核心更加稳定,而将一些与用户交互更紧密、变化较快的功能模块化。

那么在平常开发WMShell相关模块时候,需要一些打印或者调试信息应该怎么看呢?

使用WMShell相关帮助信息:

先看看dumpsys WMShell的help

bash 复制代码
adb shell dumpsys activity service SystemUIService WMShell help

展示如下:

bash 复制代码
SERVICE com.android.systemui/.SystemUIService 69fefe4 pid=786 user=0
  Client:
    Dump starting: 11-30 11:27:35.326

    com.android.systemui.wmshell.WMShell:
    ----------------------------------------------------------------------------
    Window Manager Shell commands:
      compatui
        restartDialogEnabled [0|false|1|true]
          Enable/Disable the restart education dialog for Size Compat Mode
        reachabilityEducationEnabled [0|false|1|true]
          Enable/Disable the restart education dialog for letterbox reachability
          Disable the restart education dialog for letterbox reachability
      protolog
        status
          Get current ProtoLog status.
        start
          Start proto logging.
        stop
          Stop proto logging and flush to file.
        enable [group...]
          Enable proto logging for given groups.
        disable [group...]
          Disable proto logging for given groups.
        enable-text [group...]
          Enable logcat logging for given groups.
        disable-text [group...]
          Disable logcat logging for given groups.
        save-for-bugreport
          Flush proto logging to file, only if it's enabled.
      splitscreen
        moveToSideStage <taskId> <SideStagePosition>
          Move a task with given id in split-screen mode.
        removeFromSideStage <taskId>
          Remove a task with given id in split-screen mode.
        setSideStagePosition <SideStagePosition>
          Sets the position of the side-stage.
        switchSplitPosition
          Reverses the split.
        exitSplitScreen <taskId>
          Exits split screen and leaves the provided split task on top.
      transitions
      help
          Print this help text.
      <no arguments provided>
        Dump all Window Manager Shell internal state

    NORMAL dump took 7ms -- com.android.systemui.wmshell.WMShell

    Dump took 9ms

这里有几个WMShell下面还有若干个子命令compatui,protolog,splitscreen等,可以使用这些子命令进行更加精确的控制WMShell相关的一些给你,当然如果没有输入任何子命令情况下,那就是默认输入所有WMShell的内部dump输出。

常见子命令使用案例

这里经常会有需要打开WMShell相关的一些proto日志,这里以startingwindow为案例进行控制

bash 复制代码
adb shell dumpsys activity service SystemUIService WMShell protolog enable-text  WM_SHELL_STARTING_WINDOW

这里的WM_SHELL_STARTING_WINDOW是来自代码:

bash 复制代码
test@test:~/disk2/aosp14/frameworks/base$ adb shell dumpsys activity service SystemUIService WMShell protolog enable-text  WM_SHELL_STARTING_WINDOW
SERVICE com.android.systemui/.SystemUIService 69fefe4 pid=786 user=0
  Client:
    Dump starting: 11-30 11:48:24.521

    com.android.systemui.wmshell.WMShell:
    ----------------------------------------------------------------------------
    Loaded 679 log definitions
    Starting logging on groups: [WM_SHELL_STARTING_WINDOW]

    NORMAL dump took 9ms -- com.android.systemui.wmshell.WMShell

    Dump took 10ms
    

放开日志后进行日志查看,注意这个时候过滤的TAG又是来自哪里呢?也是可以通过看代码哈:

然后进行过滤这里的ShellStartingWindow字符tag。

bash 复制代码
test@test:~/disk2/aosp14/frameworks/base$ adb logcat -s ShellStartingWindow

11-30 11:48:32.294   786   922 V ShellStartingWindow: preferredStartingWindowType newTask=true, taskSwitch=true, processRunning=false, allowTaskSnapshot=true, activityCreated=false, isSolidColorSplashScreen=false, legacySplashScreen=false, activityDrawn=false, windowless=false, topIsHome=false
11-30 11:48:32.295   786   922 V ShellStartingWindow: addSplashScreen for package: com.android.dialer with theme: 7f12011e for task: 45, suggestType: 1
11-30 11:48:32.303   786   922 V ShellStartingWindow: addSplashScreen: creating context based on task Configuration {1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h798dp 560dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1440, 2960) mAppBounds=Rect(0, 0 - 1440, 2792) mMaxBounds=Rect(0, 0 - 1440, 2960) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} s.2 fontWeightAdjustment=0}
11-30 11:48:32.304   786   922 V ShellStartingWindow: addSplashScreen: apply overrideConfig {1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h798dp 560dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1440, 2960) mAppBounds=Rect(0, 0 - 1440, 2792) mMaxBounds=Rect(0, 0 - 1440, 2960) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} s.2 fontWeightAdjustment=0}
11-30 11:48:32.308   786   923 V ShellStartingWindow: getWindowAttrs: window attributes color: 0, replace icon: false
11-30 11:48:32.310   786   923 V ShellStartingWindow: The icon is not an AdaptiveIconDrawable
11-30 11:48:32.999   786   922 V ShellStartingWindow: Task start finish, remove starting surface for task: 45
11-30 11:48:32.999   786   922 V ShellStartingWindow: applyExitAnimation delayed: 0

默认输出命令WMShell相关内容:

bash 复制代码
adb shell dumpsys activity service SystemUIService WMShell
bash 复制代码
SERVICE com.android.systemui/.SystemUIService 69fefe4 pid=786 user=0
  Client:
    Dump starting: 11-30 11:32:04.329

    com.android.systemui.wmshell.WMShell:
    ----------------------------------------------------------------------------
    BackAnimationController state:
      mEnableAnimations=true
      mBackGestureStarted=false
      mPostCommitAnimationInProgress=false
      mShouldStartOnNextMoveEvent=false
      mPointerPilfered=false
      mRequirePointerPilfer=true
      mCurrentTracker state:
        BackTouchTracker state:
          mState=INITIAL
          mTriggerBack=false
      mQueuedTracker state:
        BackTouchTracker state:
          mState=INITIAL
          mTriggerBack=false

    BubbleController state:
      currentUserId= 0
      isStatusBarShade= true
      isShowingAsBubbleBar= false
      isImeVisible= false

    BubbleData state:
      selected: null
      expanded: false
    Stack bubble count: 0
    Overflow bubble count: 0
    SummaryKeys: 0


    BubbleImpl.CachedState state:
    mIsStackExpanded: false
    mSelectedBubbleKey: null
    mSuppressedBubbleKeys: 0
    mSuppressedGroupToNotifKeys: 0
    mAppBubbleTaskIds: []

    DragAndDropController
      listeners=1
      Per display:
        displayId=0
        hasDrawn=false
        isHandlingDrag=false
        activeDragCount=0
        DragLayout:
          mIsLeftRightSplitInPortrait=false
          mIsLeftRightSplit=false
          mDisplayMargin=56
          mDividerSize=35
          mIsShowing=false
          mHasDropped=false
          mCurrentTarget=null
          mInsets=Insets{left=0, top=0, right=0, bottom=0}
          mTouchableRegion=SkRegion()


    OneHandedController
      mOffSetFraction=0.4
      mLockedDisabled=false
      mUserId=0
      isShortcutEnabled=false
      mIsSwipeToNotificationEnabled=false
    OneHandedDisplayAreaOrganizer
      mDisplayLayout.rotation()=0
      mDisplayAreaTokenMap={}
      mDefaultDisplayBounds=Rect(0, 0 - 1440, 2960)
      mIsReady=false
      mLastVisualDisplayBounds=Rect(0, 0 - 1440, 2960)
      mLastVisualOffset=0.0
    OneHandedAnimationControllerstates: 
      mAnimatorMap={}
    OneHandedSurfaceTransactionHelperstates: 
      mEnableCornerRadius=true
      mCornerRadiusAdjustment=0.0
      mCornerRadius=0.0
    OneHandedTouchHandler
      mLastUpdatedBounds=Rect(0, 0 - 0, 0)
    OneHandedTimeoutHandler
      sTimeout=8
      sListeners=[com.android.wm.shell.onehanded.OneHandedController$$ExternalSyntheticLambda10@99b68c8]
    OneHandedState
      sCurrentState=0
    OneHandedTutorialHandler
      isAttached=false
      mCurrentState=0
      mDisplayBounds=Rect(0, 0 - 1440, 2960)
      mTutorialAreaHeight=1184
      mAlphaTransitionStart=710.4
      mAlphaAnimationDurationMs=600
    BackgroundWindowManager
      mDisplayBounds=Rect(0, 0 - 1440, 2960)
      mViewHost=null
      mLeash=null
      mBackgroundView=null
    OneHandedAccessibilityUtil
      mPackageName=com.android.systemui
      mDescription=null
    OneHandedSettingsUtil
      isOneHandedModeEnable=false
      isSwipeToNotificationEnabled=false
      oneHandedTimeOut=8
      tapsAppToExit=true
      shortcutActivated=false
      tutorialShownCounts=0

    SystemPerformanceHinter:
      Active sessions (0):

    PipController
      PhonePipMenuController
        mMenuState=0
        mPipMenuView=null
        mListeners=1
      PipTouchHandler
        mMenuState=0
        mIsImeShowing=false
        mImeHeight=0
        mIsShelfShowing=false
        mShelfHeight=0
        mSavedSnapFraction=-1.0
        mMovementBoundsExtraOffsets=0
        PipBoundsAlgorithm
          mDefaultAspectRatio=1.777778
          mMinAspectRatio=0.41841003
          mMaxAspectRatio=2.39
          mDefaultStackGravity=85
          mSnapAlgorithmcom.android.wm.shell.common.pip.PipSnapAlgorithm@c801d47
        PipTouchState
          mAllowTouches=true
          mAllowInputEvents=true
          mActivePointerId=0
          mLastTouchDisplayId=-1
          mDownTouch=PointF(0.0, 0.0)
          mDownDelta=PointF(0.0, 0.0)
          mLastTouch=PointF(0.0, 0.0)
          mLastDelta=PointF(0.0, 0.0)
          mVelocity=PointF(0.0, 0.0)
          mIsUserInteracting=false
          mIsDragging=false
          mStartedDragging=false
          mAllowDraggingOffscreen=false
        PipResizeGestureHandler
          mAllowGesture=false
          mIsAttached=false
          mIsEnabled=false
          mEnablePinchResize=true
          mThresholdCrossed=false
          mOhmOffset=0
          mMinSize=Point(672, 378)
          mMaxSize=Point(1328, 746)
      PipBoundsAlgorithm
        mDefaultAspectRatio=1.777778
        mMinAspectRatio=0.41841003
        mMaxAspectRatio=2.39
        mDefaultStackGravity=85
        mSnapAlgorithmcom.android.wm.shell.common.pip.PipSnapAlgorithm@c801d47
      PipTaskOrganizer
        mTaskInfo=null
        mToken=null binder=null
        mLeash=null
        mPipOverlay=null
        mState=0
        mPictureInPictureParams=null
        PipTransition
          mCurrentPipTaskToken=null
          mFinishCallback=null
        PipPerfHintController
          activeSessionCount=0
      PipBoundsState
        mBounds=Rect(0, 0 - 0, 0)
        mNormalBounds=Rect(587, 2288 - 1384, 2736)
        mExpandedBounds=Rect(0, 0 - 797, 448)
        mMovementBounds=Rect(56, 140 - 1384, 2736)
        mNormalMovementBounds=Rect(56, 140 - 587, 2288)
        mExpandedMovementBounds=Rect(56, 140 - 587, 2288)
        mLastPipComponentName=null
        mAspectRatio=1.777778
        mStashedState=0
        mStashOffset=112
        mIsImeShowing=false
        mImeHeight=0
        mIsShelfShowing=false
        mShelfHeight=0
        mHasUserMovedPip=false
        mHasUserResizedPip=false
        mMinSize=Point(672, 378)
        mMaxSize=Point(1328, 746)
        mBoundsScale0.0
        mPipReentryState=null
        PipBoundsState$LauncherState
            getAppIconSizePx=196
        PipBoundsState$MotionBoundsState
          mBoundsInMotion=Rect(0, 0 - 0, 0)
          mAnimatingToBounds=Rect(0, 0 - 0, 0)
          mOverrideMinSize=null
          mOverridableMinSize=168
          mDefaultMinSize=378
          mDefaultSizePercent=0.6
          mMinimumSizePercent=0.5
          mOptimizedAspectRatio=0.5625
      PipInputConsumer
        registered=false
      PipDisplayLayoutState
        mDisplayId=0
        getDisplayBounds=Rect(0, 0 - 1440, 2960)
        mScreenEdgeInsets=Point(56, 56)

    RecentTasksController
     mListener=com.android.wm.shell.recents.RecentTasksController$IRecentTasksImpl$1@7624974
    Tasks:
      Task1: id=42 baseIntent=ComponentInfo{com.android.dialer/com.android.dialer.main.impl.MainActivity} winMode=undefined, Type=TYPE_SINGLE
      Task1: id=41 baseIntent=ComponentInfo{com.android.messaging/com.android.messaging.ui.conversationlist.ConversationListActivity} winMode=undefined, Type=TYPE_SINGLE
      Task1: id=36 baseIntent=ComponentInfo{com.example.android.miwok/com.example.android.miwok.MainActivity} winMode=undefined, Type=TYPE_SINGLE
      Task1: id=35 baseIntent=ComponentInfo{com.android.calendar/com.android.calendar.AllInOneActivity} winMode=undefined, Type=TYPE_SINGLE
      Task1: id=31 baseIntent=ComponentInfo{com.android.documentsui/com.android.documentsui.files.FilesActivity} winMode=undefined, Type=TYPE_SINGLE
      Task1: id=29 baseIntent=ComponentInfo{com.example.audiotrackdemo/com.example.audiotrackdemo.MainActivity} winMode=undefined, Type=TYPE_SINGLE
      Task1: id=28 baseIntent=ComponentInfo{com.android.contacts/com.android.contacts.activities.PeopleActivity} winMode=undefined, Type=TYPE_SINGLE
      Task1: id=27 baseIntent=ComponentInfo{com.android.deskclock/com.android.deskclock.DeskClock} winMode=undefined, Type=TYPE_SINGLE

    ShellController
      mConfigChangeListeners=4
      mLastConfiguration={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h846dp 560dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1440, 2960) mAppBounds=Rect(0, 0 - 1440, 2960) mMaxBounds=Rect(0, 0 - 1440, 2960) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.18 fontWeightAdjustment=0}
      mKeyguardChangeListeners=5
      mUserChangeListeners=2
      mExternalInterfaces={
      	extra_shell_split_screen: com.android.wm.shell.splitscreen.SplitScreenController$ISplitScreenImpl@af2ce9d
      	extra_shell_drag_and_drop: com.android.wm.shell.draganddrop.DragAndDropController$IDragAndDropImpl@ec3ff12
      	extra_shell_shell_transitions: com.android.wm.shell.transition.Transitions$IShellTransitionsImpl@b1746e3
      	extra_shell_one_handed: com.android.wm.shell.onehanded.OneHandedController$IOneHandedImpl@71488e0
      	extra_shell_recent_tasks: com.android.wm.shell.recents.RecentTasksController$IRecentTasksImpl@2b2b799
      	extra_shell_back_animation: com.android.wm.shell.back.BackAnimationController$IBackAnimationImpl@35efa5e
      	extra_shell_pip: com.android.wm.shell.pip.phone.PipController$IPipImpl@26d6e3f
      	extra_shell_starting_window: com.android.wm.shell.startingsurface.StartingWindowController$IStartingWindowImpl@3e9530c
      	extra_shell_bubbles: com.android.wm.shell.bubbles.BubbleController$IBubblesImpl@8ee3455
      }

    ShellTaskOrganizer
      5 Listeners
      #4 taskId#5
      #3 taskId#4
      #2 taskId#3
        StageCoordinator mDisplayId=0
          mDividerVisible=false
          isSplitActive=false
          isSplitVisible=false
          isLeftRightSplit=false
          MainStage
            stagePosition=SPLIT_POSITION_TOP_OR_LEFT
            isActive=false
          MainStageListener
            mHasRootTask=true
            mVisible=false
            mHasChildren=false
          SideStage
            stagePosition=SPLIT_POSITION_BOTTOM_OR_RIGHT
          SideStageListener
            mHasRootTask=true
            mVisible=false
            mHasChildren=false
            SplitLayout:
            	mAllowLeftRightSplitInPortrait=false
            	mIsLeftRightSplit=false
            	mFreezeDividerWindow=false
            	mDimNonImeSide=true
            	mDividerPosition=1463
            	bounds1=[0,0][1440,1463]
            	dividerBounds=[0,1396][1440,1565]
            	bounds2=[0,1498][1440,2960]
      #1 TASK_LISTENER_TYPE_FULLSCREEN
        FullscreenTaskListener:TASK_LISTENER_TYPE_FULLSCREEN
          1 Tasks
      #0 TASK_LISTENER_TYPE_PIP
        PipTaskOrganizer
          mTaskInfo=null
          mToken=null binder=null
          mLeash=null
          mPipOverlay=null
          mState=0
          mPictureInPictureParams=null
          PipTransition
            mCurrentPipTaskToken=null
            mFinishCallback=null
          PipPerfHintController
            activeSessionCount=0

      4 Tasks
      #3 task=5 listener=com.android.wm.shell.splitscreen.SideStage@1c5e6a wmMode=6 pkg= bounds=Rect(0, 2960 - 1440, 4440) running=false visible=false focused=false
      #2 task=4 listener=com.android.wm.shell.splitscreen.MainStage@d4af5b wmMode=6 pkg= bounds=Rect(0, 0 - 1440, 2960) running=false visible=false focused=false
      #1 task=3 listener=com.android.wm.shell.splitscreen.StageCoordinator@ee23815 wmMode=1 pkg= bounds=Rect(0, 0 - 1440, 2960) running=false visible=false focused=false
      #0 task=1 listener=FullscreenTaskListener:TASK_LISTENER_TYPE_FULLSCREEN wmMode=1 pkg=com.android.launcher3 bounds=Rect(0, 0 - 1440, 2960) running=true visible=true focused=true

      0 Launch Cookies

    SplitScreenController
    StageCoordinator mDisplayId=0
      mDividerVisible=false
      isSplitActive=false
      isSplitVisible=false
      isLeftRightSplit=false
      MainStage
        stagePosition=SPLIT_POSITION_TOP_OR_LEFT
        isActive=false
      MainStageListener
        mHasRootTask=true
        mVisible=false
        mHasChildren=false
      SideStage
        stagePosition=SPLIT_POSITION_BOTTOM_OR_RIGHT
      SideStageListener
        mHasRootTask=true
        mVisible=false
        mHasChildren=false
        SplitLayout:
        	mAllowLeftRightSplitInPortrait=false
        	mIsLeftRightSplit=false
        	mFreezeDividerWindow=false
        	mDimNonImeSide=true
        	mDividerPosition=1463
        	bounds1=[0,0][1440,1463]
        	dividerBounds=[0,1396][1440,1565]
        	bounds2=[0,1498][1440,2960]

    ShellTransitions
    Handlers:
      DefaultTransitionHandler (3bb4091)
      RemoteTransitionHandler (8a6772a)
      StageCoordinator (ee23815)
      RecentsTransitionHandler (2600dcc)
      ActivityEmbeddingController (9735bff)
      PipTransition (9b5071e)
      KeyguardTransitionHandler (719ff59)
      DefaultMixedHandler (c7117a0)
    Registered Remotes:
      QuickstepLaunchHome (35e93f8)
    Registered Takeover Remotes:
      none
    Observers:
      TaskStackTransitionObserver
      BubblesTransitionObserver
      HomeTransitionObserver
    Pending Transitions:
      none
    Ready-during-sync Transitions:
      none
    Tracks:
      Track #0
      active=null

    SurfaceControlRegistry
    ----------------------
    Listing oldest 11 of 11
      Task=1 (readFromParcel) [614s ago]
      DefaultTaskDisplayArea (RootTaskDisplayAreaOrganizer.onDisplayAreaAppeared) [614s ago]
      Task=3 (ShellTaskOrganizer.onTaskAppeared) [614s ago]
      Task=4 (ShellTaskOrganizer.onTaskAppeared) [614s ago]
      Task=5 (ShellTaskOrganizer.onTaskAppeared) [614s ago]
      Display 0 name="Built-in Screen" (RootDisplayAreaOrganizer.onDisplayAreaAppeared) [614s ago]
      Dim layer (SurfaceUtils.makeColorLayer) [614s ago]
      Dim layer (SurfaceUtils.makeColorLayer) [614s ago]
      Wallpaper BBQ wrapper (Wallpaper#relayout) [612s ago]
      StatusBar (readFromParcel) [605s ago]
      com.android.systemui.wallpapers.ImageWallpaper (readFromParcel) [604s ago]
    sCallStackDebuggingInitialized=true
    sCallStackDebuggingEnabled=false
    sCallStackDebuggingMatchName=
    sCallStackDebuggingMatchCall=

    NORMAL dump took 10ms -- com.android.systemui.wmshell.WMShell

    Dump took 10ms
test@test:~/disk2/aosp14/frameworks/base$ 

我们比较熟悉的SplitScreen相关,Pip相关,单手模式等都有相关的dump信息输出。

更多framework实战开发干货,请关注下面"千里马学框架"

相关推荐
龙之叶1 小时前
MT8766平台Android 12系统ESIM功能实现指南
android
诸神黄昏EX2 小时前
Android Qualcomm Diag
android
hy15687862 小时前
Flink 延时数据处理
android·java·flink
TeleostNaCl2 小时前
Android TV | 一种不跳出应用指定页面的类 Monkey 的 Android TV 压测脚本
android·经验分享·压力测试
k***08292 小时前
mysql中general_log日志详解
android·数据库·mysql
2501_937154932 小时前
酷秒神马 9.0 版源码系统实测
android·源码·源代码管理·机顶盒
r***11333 小时前
【MySQL】MySQL库的操作
android·数据库·mysql
ljt27249606613 小时前
Compose笔记(五十九)--BadgedBox
android·笔记·android jetpack
用户41659673693553 小时前
ExoPlayer 播放花屏与跳跃?我们如何像 QuickTime 一样优雅处理音频时间戳错误
android