1.systemserver
startotherservice->wms.main->am.setwindowmanager->wm.oninitready->wm.displayready->wm.systemready->
与inputmanager关联 inputmanager.setwindowmanagercallbacks(wm.getinputmonitor)
####2.wms.main
953 public static WindowManagerService main(final Context context, final InputManagerService im,
954 final boolean haveInputMethods, final boolean showBootMsgs, final boolean onlyCore,
955 WindowManagerPolicy policy) {
956 DisplayThread.getHandler().runWithScissors(() ->
957 sInstance = new WindowManagerService(context, im, haveInputMethods, showBootMsgs,
958 onlyCore, policy), 0);
959 return sInstance;
960 }
runwithscissors是将system_server线程等待android.display线程将wms new出来
3.wms.new
978 private WindowManagerService(Context context, InputManagerService inputManager,
979 boolean haveInputMethods, boolean showBootMsgs, boolean onlyCore,
980 WindowManagerPolicy policy) {
...
1000 mInputManager = inputManager; // Must be before createDisplayContentLocked.
1001 mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
1002 mDisplaySettings = new DisplaySettings();
1003 mDisplaySettings.readSettingsLocked();
1005 mPolicy = policy;
1006 mAnimator = new WindowAnimator(this);//window动画的
1007 mRoot = new RootWindowContainer(this);
....
1057 mAppTransition = new AppTransition(context, this);
1058 mAppTransition.registerListenerLocked(mActivityManagerAppTransitionNotifier);
....
1064 mActivityManager = ActivityManager.getService();
... 注册了appops和pms的监听
####4.wm.oninitready
1134 public void onInitReady() {
1135 initPolicy();//初始化phonewindowmanager
5.wm.initpolicy
962 private void initPolicy() {
963 UiThread.getHandler().runWithScissors(new Runnable() {
964 @Override
965 public void run() {
966 WindowManagerPolicyThread.set(Thread.currentThread(), Looper.myLooper());
967 mPolicy.init(mContext, WindowManagerService.this, WindowManagerService.this);
968 }
969 }, 0);
970 }
6.phonewindowmanager.init
略(配置了相关的phone策略)
7.wm.displayready
4800 public void displayReady() {
4801 final int displayCount = mRoot.mChildren.size();
4802 for (int i = 0; i < displayCount; ++i) {
4803 final DisplayContent display = mRoot.mChildren.get(i);
4804 displayReady(display.getDisplayId());
4805 }
4806
4807
4808 synchronized(mWindowMap) {
4809 final DisplayContent displayContent = getDefaultDisplayContentLocked();
4810 if (mMaxUiWidth > 0) {
4811 displayContent.setMaxUiWidth(mMaxUiWidth);
4812 }
4813 readForcedDisplayPropertiesLocked(displayContent);
4814 mDisplayReady = true;
4815 }
4816
4817 try {
4818 mActivityManager.updateConfiguration(null);
4819 } catch (RemoteException e) {
4820 }
4821
4822 synchronized(mWindowMap) {
4823 mIsTouchDevice = mContext.getPackageManager().hasSystemFeature(
4824 PackageManager.FEATURE_TOUCHSCREEN);
4825 getDefaultDisplayContentLocked().configureDisplayPolicy();
4826 }
4827
4828 try {
4829 mActivityManager.updateConfiguration(null);
4830 } catch (RemoteException e) {
4831 }
4832
4833 updateCircularDisplayMaskIfNeeded();
4834 }
8.wm.displayready
4847 public void systemReady() {
4848 mPolicy.systemReady();
4849 mTaskSnapshotController.systemReady();
4850 mHasWideColorGamutSupport = queryWideColorGamutSupport();
4854 }
9.pwm.systemready
7922 public void systemReady() {
7923 // In normal flow, systemReady is called before other system services are ready.
7924 // So it is better not to bind keyguard here.
7925 mKeyguardDelegate.onSystemReady();
7926
7927 mVrManagerInternal = LocalServices.getService(VrManagerInternal.class);
7928 if (mVrManagerInternal != null) {
7929 mVrManagerInternal.addPersistentVrModeStateListener(mPersistentVrModeListener);
7930 }
7931
7932 readCameraLensCoverState();
7933 updateUiMode();
7934 synchronized (mLock) {
7935 updateOrientationListenerLp();
7936 mSystemReady = true;
7937 mHandler.post(new Runnable() {
7938 @Override
7939 public void run() {
7940 updateSettings();
7941 }
7942 });
7943 // If this happens, for whatever reason, systemReady came later than systemBooted.
7944 // And keyguard should be already bound from systemBooted
7945 if (mSystemBooted) {
7946 mKeyguardDelegate.onBootCompleted();
7947 }
7948 }
7949
7950 mSystemGestures.systemReady();
7951 mImmersiveModeConfirmation.systemReady();
7952
7953 mAutofillManagerInternal = LocalServices.getService(AutofillManagerInternal.class);
7954 }