Huawei folding screen adaptation

Time:2022-5-7

Huawei folding screen adaptation scheme: Huawei has a system level support scheme for large screen equipment. Huawei has a parallel view and can support folding screen split screen display

Huawei folding screen split screen display effect

Huawei folding screen adaptation

Screenshot_20210527_160252_com.tencent.mm.jpg

Introduction to Huawei parallel vision
Parallel horizon is a technology to display applications on large screen devices such as flat panel, folding screen mobile phone. The parallel horizon takes activity as the basic unit, and takes the left and right window separation display technology, double window life cycle management, double window display mode and switching logic as the core technology to realize the system side solution of split screen in the application. Applications can display different combinations of activities in separate screens according to their own business characteristics, so as to realize the best user experience of single application and multi window in line with the application logic.

Parallel horizon entrance
Mobile system settings – Application – parallel view

Device types that support parallel horizons
Huawei folding screen mobile phones and Huawei tablet M6 series and above (system version emui 10. X and above) support parallel view function.

Specific method of adapting parallel horizon (which can be separated from the scheme implemented by Huawei compiler)
The first step is in androidmanifest Add to XML file

<meta-data android:name="EasyGoClient" android:value="true" />

Step 2: add easygo. Com in the assets directory JSON configuration file

{
  "easyGoVersion": "1.0",
  "Client": "application package name",
  "logicEntities": [
    {
      "head": {
        "function": "magicwindow",
        "required": "true"
      },
      "body": {
        "mode": "1",
        "activityPairs": [
          {
            "From": "mainactivity"
            "To": "*" // trigger the target activity of split screen. Wildcards are supported, "*" indicates any activity
          },
          {
            //The main page activity can have multiple semicolons. When the application is opened, the system will automatically start the relatedpage page on the right screen
            "mainPage": "MainActivity",
            //The default display page activity, mainpages and relatedpage on the right screen can only be configured with 1 pair. Specific activity name is required and wildcards are not supported
            "relatedPage": "MagicWindowActivity"
          }
        ],
        "transActivities": [],
        "UX": {
          "Isdraggable": "false", // true means you can drag, and false means you can't drag
            "Showstatusbar": "true" // whether to display the status bar
        }
      }
    }
  ]
}

As long as the simple two steps support the parallel horizon, is it very simple?

Risk description

  • It only supports some Huawei devices and cannot be popularized to ordinary flat panel and folding screen mobile phones;
  • You need to turn on the parallel view function before you can use it;
  • At present, it only supports the display effect of two-part screen
  • At present, it only supports split screen display with activity as the basic unit, and does not support split screen display of fragment. For applications with single activity and multiple fragments, if you want to support parallel horizons, you can only transform fragment into activity

FAQ
Q: Modify easygo After the JSON configuration file, why does the new configuration not take effect?
A: Modify easygo After the JSON configuration file is, the application version number needs to be upgraded or uninstalled and reinstalled before the new configuration can take effect.
reference resources:https://developer.huawei.com/consumer/cn/forum/topic/0201144059651060174?fid=3467

Q: How to judge whether the device is a Huawei folding screen?
A: It can be judged according to the mobile phone system attribute “ro.config.hw_fold_disp”. If this attribute is not empty, it is Huawei folding screen.
reference resources:https://developer.huawei.com/consumer/cn/forum/topic/0202567316824870264?fid=3467

Q: How to determine whether the device supports parallel horizons?
A: According to the mobile phone system attribute “ro.config.hw_magic_window_enable”, change the attribute to “true” to support Huawei parallel vision.
reference resources:https://developer.huawei.com/consumer/cn/forum/topic/0202567316824870264?fid=3467

Q: Can the app be configured to enable parallel view by default?
A: No, some header applications can enable parallel view by default because Huawei has signed an agreement with Huawei and added these applications to the white list.
reference resources:https://developer.huawei.com/consumer/cn/forum/topic/0204412700180730409?fid=3467

Q: How to judge whether the application runs in parallel view?
A: The following code can be used to judge

    private fun isInMagicWindow(): Boolean {
        val ctx = context ?: return false
        val configuration = ctx.resources.configuration.toString()
        return configuration.contains("hwMultiwindow-magic") || configuration.contains("hw-magic-windows")
    }

reference resources:https://developer.huawei.com/consumer/cn/forum/topic/0201296861975670023?fid=3467