Analyze picture in picture
This article based on AOSP 9.0. PIP is another multi-window feature I used very much when watching videos. This article will analyze its logic to show its details. Enter picture-in-picture(pip) We can enter pip by API Activity.enterPictureInPictureMode. If the activity supports pip, it will call ActivityManagerService.enterPictureInPictureMode to do the real work. ActivityManagerService.enterPictureInPictureMode // Adjust the source bounds by the insets for the transition down final Rect sourceBounds = new Rect(r.pictureInPictureArgs.getSourceRectHint()); mStackSupervisor.moveActivityToPinnedStackLocked(r, sourceBounds, aspectRatio, "enterPictureInPictureMode"); final PinnedActivityStack stack = r.getStack(); stack.setPictureInPictureAspectRatio(aspectRatio); stack.setPictureInPictureActions(actions); The ActivityManagerService.enterPictureInPictureMode will move activity to pinned stack, and...