The characteristics of Hongmeng

1. HongMeng => super applet

  • Hongmeng application supports the use of Java development, also support the use of JS development;
  • Use JS development to support calls to system level APIs, such as camera, microphone, Wi-Fi, etc.
  • HML, CSS and JS are encapsulated by Hongmeng itself

2. Hongmeng => clippable system (microkernel)

  • Supported memory: 128Kb-128Mb-4GB

3. Modify the communication protocol

  • Unified standard language for IoT connectivity

Is Hongmeng an Android shell?

1. Android

2. Hongmeng system

So although the Android Runtime is covered, but not a simple shell, but added a lot of their own functions and the Runtime. In addition, it has also defined its own SDK (especially JS SDK) in the application development level, which will completely kill Android Runtime when the ecosystem matures.

What knowledge do you need to learn Hongmeng Development?

  1. Front-end technology stack: HTML\CSS\JS, Web-like paradigm programming; The system has no built-in browser environment, but in order to reduce the cost of learning; Hongmun encapsulates its own HML tags, JS, CSS, etc., which are similar to the Web-side syntax (these features are awesome already!). .
  2. Familiar with WeChat applet: page structure, API, configuration and so on are similar to applet.
  3. Familiar with Vue2.0: Hongmeng has implemented the MVVM pattern similar to Vue2.0D (Observer, Data Hijack).
  4. Android development experience: Because it must be compatible with Android first.

The system architecture of Hongmeng

1. The application layer

  • Hongmeng applications consist of one or more FA (Feature Ability) or PA (Particle Ability), supporting on-demand download and loading
  • FA is the function point of the UI interface that provides the ability to interact with the user; It’s like a micro front end.
  • PA has no function point of UI interface and provides the ability to run tasks in the background. It’s like a microservice.

2. The framework layer

  • It provides user programming frameworks such as Java /C/C++/JS and Ability frameworks
  • Two UI frameworks (Java UI framework, JS UI framework)

3. The service layer

  • The core competence of Hongmeng system

4. The kernel layer

  • Multicore design, microkernel architecture

Three types of function points (abilities) of Hongmeng

1. FA supports Page Ability:

  • Page Ability is the only template supported by the FA to provide the Ability to interact with users. A Page instance can contain a set of related pages, each represented by an AbilitySlice instance.

2. PA supports Service Ability and Data Ability:

  • Service Ability: Provides the Ability to run tasks in the background.
  • Data Ability: Used to provide a unified Data access abstraction externally.

The front-end architecture of Hongmeng

Hongmeng JS UI = VUE2.0 + applet;

1. JS UI framework: Web-like programming UI interface display, using HML tags to write UI; Detailed reference: https://gitee.com/openharmony…

  • The Application the Application layer
  • Framework front-end Framework layer
  • Engine Engine layer
  • Porting Layer

2. JS application development framework: implemented lightweight MVVM(similar to VUE2), including two-way binding; You can also use ES6 partial syntax, etc. Detailed reference: https://gitee.com/openharmony…

  • JS Data Binding: The JS Data Binding framework uses the JavaScript language to provide a basic set of Data binding capabilities.
  • JS Runtime: The JS runtime supports parsing and execution of JS code. (JS parsing engine: JerryScript, lightweight engine; Not a V8)
  • JS Framework: The JS Framework uses the C++ language to provide the framework mechanism for JS APIs and components.

3. JS native (NAPI) : realize JS and C/C ++ code access to each other, such as: data storage is implemented by C ++, and then provide API for JS to use.

  • NativeEngine: JS engine abstraction layer, unify the interface behavior of JS engine in the NAPI layer. (Engine: QuickJS)
  • ModuleManager: Manages modules for module loading and module information caching.
  • ScopeManager: Manages the lifecycle of the nativeValue.
  • ReferenceManager: Manages the lifecycle of the Reference.

Hongmeng Application Development

1. The application online experience: https://playground.harmonyos… 2. Application development tools download (DevEco Device Tool, need to download the 2.0) : https://device.harmonyos.com/… 3. Front-end development of the file structure of HongMeng application, including JS, CSS and HML; But the execution of these files is not a browser environment, just Web-like syntax; At present, only some basic functions are implemented.

  • HML is a label developed by Hongmeng;
  • JS supports partial ES6 syntax, but does not support the latest full ES6 + syntax.
  • CSS is also a bit different from the browser side, refer to the official documentation for details.
For example: Currently console.log() only prints strings, not objects.

4. JS API usage, for example:

  • @System. Fetch => @System has a lot of APIs, which are implemented through TS.
  • Detailed reference: https://developer.harmonyos.c…
import fetch from '@system.fetch' export default { data: { responseData: 'NA', url: "test_url", }, fetch: function () { var that = this; fetch.fetch({ url: that.url, success: function(response) { console.info("fetch success"); that.responseData = JSON.stringify(response); }, fail: function() { console.info("fetch fail"); }}); }}

Development environment setup

1. When creating a project, you can select some simple page templates

2. After the project is created, the entry is app.js, where config.json is the configuration file

Official document of Hongmeng:

https://developer.harmonyos.c…

Special thanks: pull gou education front-end high salary training camp