Introduction: A “future-oriented” distributed operating system for all scenarios (mobile office, sports health, social communication, media entertainment, etc.). Now open source as OpenHarmony.

On August 9, 2019, Huawei officially released Hongmeng System at the HDC Developer Conference.

On September 10, 2020, Huawei released Hongmeng 2.0 at the HDC Developer Conference as promised, and released the Beta version for application developers. Next year, Hongmeng will fully support Huawei mobile phones.

It is worth mentioning that HarmonyOS is officially open source and will first release a beta version of HarmonyOS for smartphones to Chinese developers at the end of this year.

Yu stressed that the world’s third largest mobile app ecosystem is emerging. “Huawei will build an open ecosystem and fully open its core technologies, hardware and software capabilities to developers and ecological partners.”

It is reported that HiLink intelligent hardware ecosystem based on Hongmeng operating system has 800 partners, among which HiCar has cooperated with more than 150 models of vehicles and plans to pre-install more than 5 million units in 2021. HMS Core has evolved to version 5.0, with more than 96,000 applications integrating with HMS Core and 490 million active users.

Huawei is known to have endured a crackdown, but at the conference, Yu said that even after three rounds of attacks, Huawei still achieved growth. In the first half of this year, its consumer business sales revenue of 255.8 billion yuan, consumer business mobile phone global shipments reached 105 million.

Huawei is known to have endured a crackdown, but at the conference, Yu said that even after three rounds of attacks, Huawei still achieved growth. In the first half of this year, its consumer business sales revenue of 255.8 billion yuan, consumer business mobile phone global shipments reached 105 million.

In fact, all this is just a gimmick, and there is still a long way to go. I often see people voting in Blink that Huawei Hongmeng operating system will replace Android operating system. It is impossible to replace the situation of tripartite confrontation at most. Why? Eat your melon in the comments section.

The source code is hosted on the well-known open source platform cloud: gitee.com/openharmony

As a programmer, I also downloaded the source code, studied it for two nights, and wrote a Hello World program along the way.

The official description is “lightweight JS core development framework”.

When I looked at the source code it was really light. The core code only has 5 JS files.

runtime-core\src\core\index.jsruntime-core\src\observer\observer.jsruntime-core\src\observer\subject.jsruntime-core\src\ observer\utils.jsruntime-core\src\profiler\index.jsCopy the code

As the name suggests, this code implements an observer pattern. It implements a very lightweight MVVM pattern (MVC for the back end). A responsive system is implemented using a similar attribute hijacking technique to VUe2.

When we are developing, we compile and package the HML, CSS and JS files written by developers into JS bundles through Toolkit, and then parse the JS Bundle into View components of C++ native UI for rendering.

“By supporting three-party developers to use declarative APIS for application development, data-driven view changes can avoid a lot of view operations, greatly reduce the difficulty of application development, and improve the development experience of developers”. It’s basically a small program development experience.

Js Runtime chose JerryScript as an ultra-lightweight JavaScript engine for the Internet of Things. It can execute ECMAScript 5.1 source code on devices with less than 64 KB of memory. This is why it is stated in the documentation that the HONGmeng JS framework supports ECMAScript 5.1.

The packages in the SDK are just for loaders, presumably for parsing HTM components when webpack is packed, and compiling HTML templates into JS code.

Four features of Hongmeng advertised by Huawei:

“Distributed architecture was first used in terminal OS to achieve seamless collaborative experience across terminals; Determine the delay engine and high-performance IPC, technology to achieve the system naturally smooth; Reconstructing the trusted security of terminal devices based on microkernel architecture; Through the unified IDE to support the one-time development, multi-terminal deployment, achieve cross-terminal ecological sharing”

“Distributed architecture, across the terminal seamless coordination experience” mean, huawei have a great underlying OS (” distributed OS architecture “and” distributed soft bus technology “, public communication platform, distributed data management, a distributed scheduling and virtual peripheral four), summed up the characteristics of the different terminal can accommodate in a unified framework. In this way, for developers and consumers, different end products can be developed and used in a unified platform. The reason why we can do this is because Hongmeng OS has redesigned the entire architecture in a way that Android and iOS can’t. This is from the system architecture level.

“Determine the delay engine and high-performance IPC technology to achieve the system naturally smooth” is to say that Hongmeng made a very good process scheduling algorithm, process communication mechanism naturally good. A process is a task of different programs. Several apps on a mobile phone run at the same time, requiring scheduling algorithms to allocate system time to run in rotation. “Deterministic latency” is the scheduling algorithm that ensures that a process does not get stuck because its CPU is occupied by another process and that it can always execute on its own time. Because the architecture is new, the app response time is a quarter lower, which android and iOS can’t do because of the architecture. IPC stands for Inter Process Communication. Processes need Communication to deliver messages and data for cooperation. Due to the good microkernel architecture, THE IPC efficiency of Hongmeng can be increased by 5 times, which is impossible for Android and iOS due to the limitations of system architecture. This is a pitch to users who care about performance.

“Reinventing the trusted security of terminal devices based on the microkernel architecture” means that the Hongmeng system is more secure, because the kernel code is less, the chance of vulnerability is also less, unlike Android and iOS code pile easy to find vulnerabilities. Apple offered a $1 million reward for finding a bug that was hacked. Hongmeng has designed a set of safety mechanism for the whole system. As long as we do according to this mechanism, the safety performance can be greatly improved. This security mechanism is not based on attack test, but based on mathematical model algorithm. It is theoretically safe to prove formally, which is a higher level than the traditional security verification method. This appeals to users who are concerned about system security.

“Support one development, multiple deployment, and cross-terminal ecosystem sharing through a unified IDE” echoes the first feature. The first feature is that Hongmeng makes unified development across terminals possible from the system architecture. Unified IDE is to say that Huawei development tools are ready, this ark compiler as the core of the toolkit is very cattle, visual programming, later also several languages mixed development can be unified compilation, directly out of efficient machine code. The bottom line is that it’s easier and more efficient than the current android and iOS development tools. This is a shout out to programmers and developers.

From these “characteristics” of Hongmeng, we can see that Hongmeng is really facing the future of the next generation of operating system, there are many advantages. Hongmeng is not a replacement for Android or iOS on mobile phones, but a new cross-platform system. In mind, at least, It’s not really a rival to Android or iOS, but to Google’s Fuchsia (which is also microcored). The four features of The Android operating system can also explain why Google is pursuing Fuchsia. The technical potential of android architecture is limited, and the next generation of operating system will have to be a whole new ecosystem.

An overview of the

Before a front-end developer, can develop web, android and IOS systems, can be said to be a qualified front-end programmer. But the appearance of Hongmeng also forces you to master the development of a new system. If you’re already a front end, fortunately, you can develop a cloud system without making too many changes.

Introduction to the

OpenHarmony means “open and harmonious” in Chinese, which represents the tolerance and modesty of the Chinese nation. It is a huge step for China in the field of mobile terminal underlying operating system. From then on, in the whole world, we can say: “China has its own mobile terminal underlying operating system!”

The official description: sale.vmall.com/hwharmony.h…

OpenHarmony technology architecture

The whole complies with the hierarchical design, from bottom to top: kernel layer, system service layer, framework layer and application layer. System functions are displayed by choosing System > Subsystem > Components. In multi-device deployment scenarios, some unnecessary components can be tailored based on actual requirements. The core of the front-end domain is to build services by expanding applications and creating third-party applications at the application layer. In the future, we individual developers or enterprise developers will continue to improve the Hongmeng ecosystem in the application layer of “expanded application, tripartite application” section.

Application Layer Introduction

The application layer includes system applications and third-party non-system applications. Applications consist of one or more FA (Feature Ability) or PA (Particle Ability). FA has A UI interface to provide the ability to interact with users. While PA has no UI, it provides the ability to run tasks in the background and a unified data access abstraction. Applications developed based on FA/PA can implement specific service functions, support cross-device scheduling and distribution, and provide consistent and efficient application experience for users. Obviously, the core of our front-end development partners’ learning lies in the DEVELOPMENT of THE UI level in FA.

The UI part (FA) supports both pure JavaScript development and pure Java development, as well as Java and JavaScript mixed development. FA supports UI development using Java and JavaScript. If you use Java, like Android, you can use XML to define the layout or Java code to define the layout. Each page is a PageAbility. If you use Java to write business code, you still use IntEnts to transfer data between different pages.

The JavaScript UI framework is basically the same as Vue + applets, supporting data, props, computed, watch, and Functions (methods), and creating custom components. In this way, it is easy for web front-end engineers to transform into UI development engineers of Hongmeng. It has to be said that Huawei’s integration on the existing concepts is quite fierce.

Try to build a development environment and output hello, Hong Meng!

The official summary: developer.huawei.com/consumer/cn…

DevEco Studio 2.1 Release development tools download: developer.harmonyos.com/cn/develop/…

It supports Windows and MAC operating systems. I use Windows and downloaded the last one.

HUAWEI DevEco Studio 1.0 is an integrated development environment (IDE) for developing EMUI applications. It aims to help developers quickly, conveniently and efficiently use HUAWEI EMUI open capabilities. To develop the HarmonyOS application, download HUAWEI DevEco Studio 2.0.

This project relies on node.js development environment, non-front-end partners can download node: nodejs.org/en/

As for IDEA:developer.harmonyos.com/cn/develop/…

Application experience

Step 1: After the application is started, the system prompts you whether to create an initiator script for subsequent template selection.

In order to meet the development needs of applications running on multiple devices, DevEco Studio 2.1 Release added 11 cross-device project templates to the original single-device project templates. Developers can easily create cross-device projects by selecting templates and device types according to the project wizard, and automatically generate sample code and related resources.

  • Step 2: Use the Huawei cloud NPM package management tool.
  • Step 3: Create an OR import project.
  • Step 4: Select project type and template.
  • Step 5: Create the project.
  • Step 6: Review and close the development tips.
  • Step 7: the project automatically downloads the corresponding dependencies and files. Click “Run” directly in this step and there will be an error message.
  • Step 8: On the DevEco Studio menu bar, click Tools > SDK Manager to configure the corresponding SDK version.
  • Step 9: Click Sign in in the upper right corner to log in to huawei account. Enter the user name and password of a huawei account that has been authenticated with real name to log in. After successful login on the web page, complete authorization.
  • Step 10: into the SRC/main/js/default/pages/index page, open the view – > Tool Windows – > Previewer to preview.
  • Step 11: Go to Tools -> Devices Manager to view the emulator management page. In this step, you must log in to the emulator using a huawei account with real name authentication, select the corresponding device, and start the device.
  • Step 12: After starting the device, click the green run button again to run the project on the simulation device.

Introduction to development Catalog

The development directory structure of JS FA application JS modules (Entry/SRC /main/ JS /module) is as follows:

Introduction to Hongmeng components

Components are the core of building a page. Each Component realizes an independent visual and interactive unit of functionality through simple encapsulation of data and methods. Components are independent of each other, available on demand, and can be reused where requirements are the same.

The official component is introduced: developer.harmonyos.com/cn/docs/doc…

Basic ability of JS UI framework

  • Declarative programming
  • The JavaScript UI framework uses HTML and CSS declarative programming language as the development language of page layout and page style, while the page business logic supports JavaScript language of ECMAScript specification. JS UI framework provides declarative programming, can let developers avoid writing UI state switch code, view configuration information more intuitive.
  • Across the device
  • The development framework supports the ability to display UI across devices, automatically maps to different device types during runtime, without the awareness of developers, and reduces the cost of multi-device adaptation for developers.
  • A high performance
  • The framework includes many core controls, such as lists, images, and various container components, and optimizes the rendering process for declarative syntax.

JS UI framework overall architecture

  • The Application layer Application
  • Application layer represents the FA application developed by developers using JS UI framework, and THE FA application here refers to JS FA application in particular.
  • Front-end Framework layer Framework
  • The front-end framework layer mainly completes the front-end page parsing, and provides MVVM (Model-view-ViewModel) development mode, page routing mechanism and custom components.
  • Engine layer Engine
  • The engine layer mainly provides animation parsing, DOM (Document Object Model) tree construction, layout calculation, rendering command construction and drawing, event management and other capabilities.
  • The platform Porting Layer
  • The adaptation layer mainly abstracts the platform layer and provides abstract interfaces, which can be connected to the system platform. For example: event docking, rendering pipeline docking and system life cycle docking.

Front-end Framework Layer Framework API Overview

1. Basic functions

Application context, log printing, page routing, pop-ups, application configuration, and timers

  • 2. Network access

    Upload and download, data request

  • 3. File data

    Data storage, file storage

  • 4. Distributed capabilities

    Distributed pull-up, distributed migration, and distributed API positions in the FA lifecycle

  • 5. System capability

    Notification messages, vibration, sensor, location, network status, device information, screen brightness, battery information, application management, media query, internationalization

Use storage to implement data storage (does the code look similar to vUE and applets?)

import storage from '@system.storage'; exportdefault {    data: {    TodoList}, onInit() {storage.get({key: 'todo', success: data => {console.log(' storage succeeded '+ data); //this.todoList = JSON.parse(data) } }); }, setStorage() { storage.set({ key: 'todoList', value: JSON.stringify(this.todoList) }); }, remove(index) { this.todoList.splice(index, 1); this.setStorage(); }, addTodo() {this.todolist.push ({info: 'keyboard input ', status: false}) this.setStorage(); }, checkStatus(index) { this.todoList[index].status = ! this.todoList[index].status; this.setStorage(); }}
Copy the code

More developers data refer to: developer.harmonyos.com/cn/docs/doc…

Well, this issue is shared here, front-end partners can easily download an IDEA to experience, it is really very simple, support the birth of Huawei Hongmeng whole ecosystem bottom operating system!!

 

[this article is to participate in “prize essay | HarmonyOS essay contest” activities 】 : marketing.csdn.net/p/ad3879b53…