关于Multi display和Multi window, Google文档中都说了些什么

3 篇文章 1 订阅

目录

一、Multi-display 多屏幕

Recommended Practices

Restricting access to displays

Configuring display windowing settings and system decorations

Testing and Development Environment

Multi-Resume

二、Multi-window多窗口

Validation:

CDD要求:

How to config:

支持的三种类型:

Picture-in-picture画中画

Split-screen interactions分屏交互

Freeform 

APP开发文档:

Multi-Window Lifecycle

Configuring Your App for Multi-Window Mode

Multi-window change notification and querying

Launch New Activities in Multi-Window Mode

5 tips for preparing for Multi-Window in Android N

Sample demo


今天主要学习https://source.android.com/devices/tech/display 

一、Multi-display 多屏幕

Google官方文档:https://source.android.com/devices/tech/display/multi_display

Android 10 enables multi-screen and foldable handheld devices, utilization of external displays, and other form-factors. Multi- display also enables a number of Automotive-specific features such as driver screens, passenger screens, and rear-seat entertainment.

Android 10 支持跨屏和可折叠的手持设备,利用外部屏幕和其他设备类型。多屏幕还支持很多 Automotive 专用功能,如司机屏幕、乘客屏幕以及后座娱乐系统。

Recommended Practices

https://source.android.com/devices/tech/display/multi_display/recommended-practices

Restricting access to displays

If the device configuration requires the restriction of access to one or more displays, the recommendation is to use the Display#FLAG_PRIVATE flag to designate such displays as private. Doing so restricts all but the owner from adding content to the display. Any attempt to launch an activity or to add a window by anyone but the owner results in a SecurityException. If the system owns the display, the system can add windows and launch activities.

  • Display#FLAG_PRIVATE:

In addition, more restrictions are added to virtual(虚拟) displays because any app can create one without making it visible to the user. If the virtual display isn't owned by the system, then only activities with allowEmbedded are permitted and the caller should have the ACTIVITY_EMBEDDING permission.

  • ACTIVITY_EMBEDDING :

For more information, see:

  • ActivityStackSupervisor#isCallerAllowedToLaunchOnDisplay()
  • ActivityDisplay#isUidPresent()
  • DisplayManagerService#isUidPresentOnDisplay()

To conditionally control activity launches, use LaunchParamsController, which intercepts all activity launches and allows a system component to modify the parameters used for launch. This is available in system_server.

  • LaunchParamsController

Configuring display windowing settings and system decorations

System decorations can be configured per display in DisplayWindowSettings. A device implementation can provide a default configuration in /data/system/display_settings.xml.

  • DisplayWindowSettings
  • /data/system/display_settings.xml

Testing and Development Environment

https://source.android.com/devices/tech/display/multi_display/testing-dev-environment

When device manufacturers want to provide a desktop-like experience, use this feature to showcase the recommended way to implement some of the windowing features.

  1. Enable the Force desktop mode developer option.
  2. Reboot the phone.
  3. Connect the mouse (via USB or Bluetooth).
  4. Create a simulated display from the developer options or use a hardware display.
  5. Launch activities from the launcher on that display and use the mouse to interact.

MD Launcher (platform/development/samples/MultiDisplay) is useful for testing a targeted activity launch and to request a new instance.

Multi-Resume

https://source.android.com/devices/tech/display/multi_display/multi-resume

In Android 10, the activity lifecycle state is determined by visibility and Z-order. To ensure that the correct state after visibility updates on an activity and evaluate which lifecycle state is applicable, invoke the ActivityRecord#makeActiveIfNeeded() method from different locations. In Android 10, active means either RESUMED or PAUSED and works only in these two instances.

In Android 10, resuming an activity is separately tracked in each stack instead of in the single location in the system. This is because several activity transitions can be performed simultaneously in multi-window modes. For details, see ActivityStack#mInResumeTopActivity.

二、Multi-window多窗口

Google 官方文档:https://source.android.com/devices/tech/display/multi-window

In Android 7.0 and later, users can have multiple apps simultaneously displayed on their device screen with the new platform feature, multi-window. In addition to the default implementation of multi-window, Android also supports a few varieties of multi-window.

在 Android 7.0 及更高版本中,用户可以借助新的平台功能(多窗口模式)在设备屏幕上同时显示多个应用。除了多窗口模式的默认实现方式外,Android 还支持多窗口模式的几个变体。

Validation:

CTS

CDD要求:

https://source.android.com/compatibility/android-cdd#3814-multi-windows 3.8.14. Multi-windows 

How to config:

Multi-window support is enabled by default in Android 7.0 and higher. To disable it, set the config_supportsMultiWindow flag to false in your device's config.xml file.

Multi-window is disabled by default on all low-RAM devices (devices that declare ActivityManager.isLowRam()). Low-RAM devices ignore the value of the config_supportsMultiWindow flag.

 <!-- True if the device supports at least one form of multi-window.
         E.g. freeform, split-screen, picture-in-picture. -->
    <bool name="config_supportsMultiWindow">true</bool>

支持的三种类型:

  • Picture-in-picture画中画

Android 8.0 includes support for picture-in-picture (PIP) for Android handheld devices. PIP allows users to resize an app with an ongoing activity into a small window.

Android 8.0 支持在 Android 手持设备上使用画中画 (PIP) 功能。借助画中画功能,用户可以将有正在进行的活动的应用调整到一个小窗口中。

关于画中画的简介:https://developer.android.com/guide/topics/ui/picture-in-picture 应用如何支持画中画,demo等。

PIP的细节:https://source.android.com/devices/tech/display/pip

  • Split-screen interactions分屏交互

In Android 7.0 and later, users can have multiple apps simultaneously displayed on their device screen with the platform feature multi-window. Android 8.0 improves split-screen by refining the feature and adding more functionality to it. 

The default mode is split-screen, which provides two activity panes for users to place apps.

Launcher相关的修改可以在这里找到:https://source.android.com/devices/tech/display/split-screen 里面列了所有的Changed-id。

  • Freeform 

Freeform allows users to dynamically resize the activity panes and have more than two apps visible on their screen.

After enabling multi-window mode with the config_supportsMultiWindow flag, device manufacturers can allow freeform windowing. This mode is most useful on larger devices, such as tablets.

To support freeform mode, enable the PackageManager#FEATURE_FREEFORM_WINDOW_MANAGEMENT system feature in/android/frameworks/base/core/java/android/content/pm/PackageManager.java and set config_freeformWindowManagement to true in config.xml.

 <bool name="config_freeformWindowManagement">true</bool>

APP开发文档:

https://developer.android.com/guide/topics/ui/multi-window.html

The user can switch into multi-window mode in the following ways:

  • If the user opens the Overview screen and performs a long press on an activity title, they can drag that activity to a highlighted portion of the screen to put the activity in multi-window mode.
  • If the user performs a long press on the Overview button, the device puts the current activity in multi-window mode, and opens the Overview screen to let the user choose another activity to share the screen.

Users can drag and drop data from one activity to another while the activities are sharing the screen.

Multi-Window Lifecycle

Multi-window mode does not change the activity lifecycle.

Resumed和Stared两个状态的设计:

In multi-window mode, only the activity the user has most recently interacted with is active at a given time. This activity is considered topmost, and is the only activity in the RESUMED state. All other visible activities are STARTED but are not RESUMED. However, the system gives these visible-but-not-resumed activities higher priority than activities that are not visible. If the user interacts with one of the visible activities, that activity is resumed, and the previously topmost activity enters the STARTED state.

When the user puts an app into multi-window mode, the system notifies the activity of a configuration change, as specified in Handling Configuration Changes

Configuring Your App for Multi-Window Mode

If your app targets API level 24 or higher,if the root activity has android:resizeableActivity set to true, then all activities in the task stack are resizable.

The system does not resize fixed-orientation apps; if the user attempts to open a fixed-orientation app under multi-window mode, the app takes over the whole screen.

Multi-window change notification and querying

Activity offers the following methods to support multi-window display. 

isInMultiWindowMode()

Call to find out if the activity is in multi-window mode.

isInPictureInPictureMode()

Call to find out if the activity is in picture-in-picture mode.

onMultiWindowModeChanged()

The system calls this method whenever the activity goes into or out of multi-window mode. The system passes the method a value of true if the activity is entering multi-window mode, and false if the activity is leaving multi-window mode.

onPictureInPictureModeChanged()

The system calls this method whenever the activity goes into or out of picture-in-picture mode. The system passes the method a value of true if the activity is entering picture-in-picture mode, and false if the activity is leaving picture-in-picture mode.

The Fragment class exposes versions of many of these methods, for example Fragment.onMultiWindowModeChanged().

Launch New Activities in Multi-Window Mode

When you launch a new activity, you can indicate that the new activity should be displayed adjacent(相临) to the current one if possible. To do this use the intent flag FLAG_ACTIVITY_LAUNCH_ADJACENT. This flag tells the system to try to create the new activity next to the activity that launched it, so the two activities share the screen. The system makes a best effort to do this, but it is not guaranteed to happen.

If a device is in freeform mode and you are launching a new activity, you can specify the new activity's dimensions and screen location by calling ActivityOptions.setLaunchBounds(). This method has no effect if the device is not in multi-window mode.

5 tips for preparing for Multi-Window in Android N

https://medium.com/androiddevelopers/5-tips-for-preparing-for-multi-window-in-android-n-7bed803dda64

Sample demo

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值