Hongmeng OS atomic service card principle and architecture analysis

introduction

On the evening of June 2, 2021, Huawei officially launched the service card at the HarmonyOS 2 system and full-scenario new product launch conference, subverting people's perception of APP information display and arousing great attention in the industry. This article is about HarmonyOS Analysis of the principle and architecture of service cards. Due to the limited current information, there are inevitably errors and omissions in the content of the article, please understand.

1. Introduction to HarmonyOS service card

Official definition of service card Service
card (hereinafter referred to as "card") is an interface display form of Hongmeng FA (Feature Ability), which puts important information or operations of FA on the card to achieve direct service and reduce the level of experience.

Give an example of what is a service card

Let's take the application of "playing machine skills" as an example to feel the value brought to us by the service card. When we slide up the icon while pressing the icon with our finger, the default card of the application will pop up, click the thumbtack in the upper right corner of the card, and the card will be fixed on the desktop; click the button in the card to start viewing the game skills . In this way, by interacting with the card, the user can realize some operations in the application without opening the application, which is very convenient to use.
insert image description here

The value of the service card

To draw an analogy, imagine:
you can directly run the scan and payment code without opening WeChat; you
can see the latest hotspot information without opening Weibo;
you can see the latest mailing list without opening the mail service;
...
the service card is renewed It opens the door to application innovation and brings new business value and traffic entry to the application.

What is the relationship between service cards and atomized services?

Speaking of service cards, we have to mention the atomic services closely related to them. The official atomic service is a future-oriented service provision method provided by HarmonyOS. It has an independent entrance (users can directly trigger it by clicking, touching, scanning, etc.), installation-free (no explicit installation is required, It can be used after being installed by the background of the system program framework), which can provide users with one or more convenient services. The service card is the display method of Hongmeng OS atomic service. Atomic services are the face, and service cards are the face.
The service card application currently only supports deployment on the closed-source version of HarmonyOS, and this feature is not yet supported on the open-source version of HarmonyOS OpenHarmony 2.0.

2. Service Card Operation Instructions

How to view an app's service card

If a horizontal line is displayed under the app icon, press the icon with your finger and slide up at the same time, the default card of the app will pop up, click the thumbtack in the upper right corner of the card, and the card will be fixed on the desktop; the card supports clicking Interaction, the user can realize some operations in the application without opening the application.
For example, the camera, phone, and Changlian apps in the picture below all support the service card feature.
insert image description here

How to view all cards of an app?

Take the application "Gameplay Skills" as an example, press and hold its icon on the desktop, and click "Service Cards" in the pop-up menu, all the cards of the "Gameplay Skills" app will be displayed.
insert image description here

How to view the list of service cards?

Swipe your finger from the lower left or right corner of the desktop to the center of the screen to bring up "My Services", and you can see the list of service cards supported by the mobile phone.
insert image description here

3. Analysis of Service Card Principles

Through the above introduction, we have a general understanding of the service card. So what is the essence of the service card? Is it an application similar to the WeChat applet? Which type of application is it similar to currently on the market? Where is the difference?
To answer the above questions, we briefly summarize the typical application types and typical representatives in the industry:

typical application technical features typical representative
Native APP iOS app,android app
H5
Hybrid APP Hybrid of Native and H5
Widget iOS widget
Applets Webview rendering WeChat applet
quick app native rendering
light application It has the characteristics of Webapp that can be retrieved and intelligently distributed Baidu application

The following focuses on WeChat applets, quick apps, and widgets.

WeChat applet

The WeChat Mini Program was officially launched in the early morning of January 9, 2017. The WeChat Mini Program is an application that can be used without downloading and installing. It realizes the dream of "accessible" applications. Users can scan or search to open the application. It also embodies the concept of "go away after use", users do not need to care about whether to install too many applications.
The framework of the WeChat applet consists of two parts, the View layer and the App Service logic layer. The View layer is used to render the page structure, and the AppService layer is used for logic processing, data requests, and interface calls. They run in two threads. The view layer is rendered using WebView, and the logic layer is run using JSCore. The view layer and the logic layer communicate through the JSBridage of the system layer. The logic layer notifies the view layer of data changes, triggers the page update of the view layer, and the view layer notifies the triggered events to the logic layer for business processing.

insert image description here

quick app

Quick App is a new application ecology jointly launched by the nine major mobile phone manufacturers based on the hardware platform. Users do not need to download and install, just click and use, and enjoy the performance experience of native applications. On March 20, 2018, the "Quick App" standard was launched in Beijing.
"Quick App" is developed using the front-end technology stack, rendered natively, and has the dual advantages of H5 pages and native applications.

What are Widgets?

The positioning of Widget is actually equivalent to the extension of the application. The key point of using it is that the user can quickly obtain information and even perform simple operations on the screen without opening the application or waiting for loading. Apple has repeatedly emphasized that Widgets are not another shortcut to enter applications. Widgets are a way of displaying information, which is used to quickly provide application data that some users care about. When Widget first entered China, there was no common translated name, and it was named "Weige" by Zhongsou at that time. Until this time iOS 14 did not use the "widget" naming.
insert image description here

Widgets can be divided into information widgets, collection widgets, control widgets, and mixed widgets according to different user usage scenarios. However, iOS has always placed the control of the main screen in the control center for interaction, so the types of widgets are mainly information widgets and collection widgets.
insert image description here

Widget refresh is completely controlled by WidgetCenter. Developers cannot actively refresh the Widget page through any API, they can only inform WidgetCenter that the Timeline needs to be refreshed. Widget can only be developed with SwiftUI. To be precise, the essence of Widget is a SwiftUI view that is updated with the timeline.
insert image description here

widget interaction and display

The Widget UI is stateless. It does not support playing animated gifs, videos, scrolling, or actively refreshing the view. The only supported functions are user clicks and DeepLinks to evoke the main app.

Comprehensive comparison of related features and capabilities, the Hongmeng card service is more like the application form of the standard widget. The English name of the Hongmeng service card is called service widget, which also confirms this point of view from the side.

4. Service Card Features

The Hongmeng OS service card has three major features.

1) Available everywhere

• Service discovery: Atomized services can be discovered and used in the service center.
• Intelligent recommendation: Atomic services can be actively recommended to users based on appropriate scenarios; users can find the services recommended by the system in the service center and Xiaoyi's recommendations.

2) Direct service

• Atomization service supports installation-free use.
• Service card: Support users to obtain the display and dynamic changes of important information in the service without opening the atomized service, such as weather, key affairs notes, and hot news list.

3) Cross-device

• Atomized services support running on 1+8+N devices, such as mobile phones, tablets and other devices.
• Support cross-device sharing: For example, after accessing Huawei Share, the user can share the atomization service with friends, and the friend will open the shared service after confirmation.
• Support cross-terminal migration: For example, unfinished emails on the mobile phone can be migrated to the tablet to continue editing.
• Support multi-terminal collaboration: For example, the mobile phone is used as document page turning and annotation, and the distributed office is completed with the smart screen display; the mobile phone is used as a handle to play games with the smart screen.

According to the above official publicity, based on the distributed capabilities of Hongmeng OS, Hongmeng OS has added cross-device capabilities on the basis of widgets, giving widgets new vitality.
When a user transfers and shares services across devices, the transferred device does not need to pre-install the application, which greatly enhances the applicable scenarios and value of the service card.

5. Atomic service architecture

There are two diagrams for reference about the architecture of Hongmeng OS atomic service.
insert image description here
insert image description here

basic concept
• Card user

The host application that displays the content of the card controls the display position of the card in the host.

• Card Management Services

The resident agent service used to manage the cards added in the system, including the management and use of card objects, and the periodic refresh of cards, etc.

• Card Provider

A HarmonyOS application or atomic service that provides card display content, controls the card display content, control layout, and control click events.

illustrate

The card user and the provider do not require permanent operation. When it is necessary to add/delete/request to update a card, the card management service will pull the card provider to obtain the card information.

Card Management Service includes the following modules:

• Periodic refresh: After the card is added, start the scheduled task to periodically trigger the refresh of the card according to the refresh policy of the card.
• Card cache management: After the card is added to the card management service, the view information of the card is cached, so that the cached data can be returned directly when the card is acquired next time, reducing the delay.
• Card life cycle management: When the card is switched to the background or blocked, the refresh of the card is suspended; and the card data is updated and cleared in the card upgrade/uninstall scenario.
• Card user object management: manage the card user's RPC object, which is used to verify the user's request and handle the callback after the card is updated.
• Communication adaptation layer: responsible for RPC communication with the card user and provider.

The Card Provider contains the following modules:

• Card service: implemented by the developer of the card provider. The developer implements onCreateForm, onUpdateForm, and onDeleteForm to process requests for creating, updating, and deleting cards, and provides corresponding card services.
• Card provider instance management module: implemented by the card provider developer, responsible for persistent management of the card instances assigned by the card management service.
• Communication Adaptation Layer: Provided by HarmonyOS SDK, it is responsible for communicating with the card management service and actively pushing card update data to the card management service.

According to the above architecture description, the contents of personal analysis and reasoning are as follows.

How can service cards be transferred and shared across devices without pre-installing apps?

The Hongmeng OS atomization service adopts an architecture in which the card user and the card provider are separated, and the card user and the card provider can be on the same or different devices. If the transfer is performed on different devices, through RPC communication, Hongmeng OS can realize cross-device transfer and sharing capabilities, and the receiver does not need to pre-install the application.
At the same time, for the risk of the card provider being offline, Hongmeng OS has also effectively dealt with it by supporting the cache mechanism of the card management service in the architecture.

Other Design Discussions

At present, it is not clear how the atomic service timing refresh module is implemented. It is not known whether it is the same as the iOS widget, and the refresh is uniformly scheduled by the system to improve the refresh performance of the whole machine.
When the card user and the card provider are on the same terminal, from the architectural point of view, it seems that it can be optimized as a direct communication without card management services, reducing one link in the middle to avoid performance loss.

6. Prospects for the future of atomized services

Let's compare and analyze the features of the ios14 widget, and what functions the Hongmeng OS service card may launch in the future.

1) Configuration function

Users can configure according to their own preferences. Take weather components as an example. Some users may care about sunny weather, rainy days, temperature and other information, and some users may only care about PM2.5 information. Due to the limited display space of widgets, sometimes you cannot display all the information Within a component, it is therefore a very important feature to let the user select the information he is interested in for the configuration of the widget.

2) Similar to Smart Stack function

The iOS widget has the Smart Stack capability, integrates Siri's intelligent recommendation capability, and can intelligently display components based on factors such as your usage time and location. For example, when you get up in the morning, you can display the weather information; when you arrive at the office, you can display the new WeChat news; At present, Hongmeng OS implements Xiaoyi’s suggestion, but what Xiaoyi recommends is the list of applications, not the ability to display service cards in turn.

3) Expand and collapse functions

The ability to expand and fold service cards is particularly important for list-type service cards. Folding can save desktop space, which is especially suitable for some people who are sensitive to space.

7. Atomized Service Instance

You can refer to Huawei codelab for application development of atomic services:
Clock FA Card Development Sample
https://developer.huawei.com/consumer/cn/codelabsPortal/carddetails/Clock-Card
insert image description here
For more information, please refer to : Hongmeng OS Excellent data collation, continuous updating

Guess you like

Origin blog.csdn.net/qq_31765191/article/details/118725438