OpenHarmony application development introductory tutorial (1, opening)

Preface

Huawei officially announced that the Huawei Hongmeng OS Next version released in 2024 will no longer be compatible with Android systems. This major change indicates that Huawei Hongmeng OS is about to enter a new stage.

It is said that technology knows no borders, but this is a lie. Google's Android 12.0 system has been released for a long time, but since it was affected by the United States, Google has refused to provide Huawei with the Android system. If you say it is horizontal or not, it is just a stumbling block for you to prevent you from using it. What can you do? Even for computer win11 and subsequent systems, individuals must agree to report information to the Microsoft backend. Domestic substitution is imperative. The strategy of foreigners is that you can only do low-end products and let them do high-tech to dominate the world. Then sell your expensive chips and harvest you like leeks. Maybe one day it will get stuck in your neck. This is already a bad trick. It is so arrogant and has no moral ethics. Therefore, we support domestic production and domestic systems. If there were no rising domestic products, you might have to buy Samsung and HTC mobile phones that cost several thousand yuan.

To give another example, Huawei will never force developers to use its own payment methods. Apple mobile phones force developers not to use third-party payment methods, because when using Apple payment methods, it can charge a 30% commission. This way of sitting back and reaping the benefits is also used by Google. On September 14, 2021, South Korea officially banned the mandatory use of operator payment methods. Therefore, South Korea became the first country to implement antitrust laws. It is understood that in recent years, Google has been requiring developers to sign contracts prohibiting developers from using their own payment methods, otherwise they will not be able to continue to use Google apps. Moreover, so far, Google's share in South Korea has reached 97%, forming a monopoly.

Huawei has currently released Hongmeng OS version 4.0, and the Hongmeng OS Next developer preview version will be open to developers in the first quarter of 2024. Starting from this version, Hongmeng OS will completely eliminate the Linux kernel and Android AOSP code, and instead It uses Huawei’s self-developed Hongmeng kernel. It began to develop independently and formed a three-legged situation (iOS, Android, Hongmeng) on ​​the end system.

Currently, major domestic Internet companies have begun to cooperate comprehensively with Huawei in aspects such as industrial innovation, technology application, and business development. On September 25 this year, Huawei officially announced HarmonyOS NEXT and announced that it is no longer compatible with Android applications. Since the news was announced, the process of Hongmeng native applications has been officially launched. As the third largest system after iOS and Android, there are currently companies in finance, travel, social networking and other fields. and developers have successively announced their participation in the Hongmeng ecosystem.

Hongmeng’s unique distributed technology, as well as one-time development and multi-deployment,enable services to flow seamlessly on mobile phones, tablets, cars and other devices, Provide users with a new experience of scenario-based and intelligent "services at the right time".

Hongmeng 5.0 and beyond will continue to be updated and iterated. Compared with the system before 4.0, it will become smoother, more intelligent overall, and most importantly, the safety factor will also be improved. We no longer fear that our private data will be peeped by others. At the same time, there is no need to worry about the leakage of mobile phone privacy, and it will be far ahead in the Internet of Everything.

Comparison with Android

Android architecture introduction

Comparing the differences between the two in terms of architecture may bring different gains. First of all, after so many years of end-to-end development, we can review the architecture of Android:

Android software consists of an open source Linux kernel, which contains a large number of C/C++ libraries exposed through the application framework service. The Android architecture consists of five layers, namely the Linux kernel, libraries, application framework, Android runtime and system applications. Among all the components, the Linux kernel provides the main functionalities of the operating system for smartphones, while the Dalvik Virtual Machine (DVM) provides the platform for running Android applications.

Main components of Android architecture:

  • Applications Application fields
  • Application Framework Application Framework
  • Android Runtime Android Runtime
  • Platform Libraries Platform Libraries
  • Linux Kernel Linux Kernel

Linux kernel: It is the core of the Android architecture and exists at the root of the Android architecture. The Linux kernel is responsible for device drivers, power management, memory management, device management and resource access.

Native Libraries: On top of the Linux kernel, there are Native libraries such as WebKit, OpenGL, FreeType, SQLite, Media, and C runtime library (libc). The WebKit library is responsible for browser support, SQLite is responsible for the database, and FreeType is responsible for font support and is used to play and record media in audio and video formats.

Android Runtime: Each app runs in its own process and has its own Android Runtime (ART) instance. ART is written to run multiple virtual machines on low-memory devices by executing DEX files, a bytecode format designed specifically for Android that is optimized to use very little memory. ART mainly includes: AOT and JIT compilation, GC garbage collection and many other optimizations.

Android Framework: On top of the native libraries and Android runtime, there is the Android Framework. The Android framework includes Android APIs such as UI (user interface), telephony, resources, location, content providers (data), and package managers. It provides a large number of classes and interfaces for android application development.

Applications: On top of the android framework, there are applications. All apps (e.g. Home, Contacts, Settings, Games, Browser) use the Android framework, which uses the Android runtime and libraries. The Android runtime and native libraries use the Linux kernel.

Introduction to Hongmeng Architecture

The following is the architecture diagram of Hongmeng:

 

From the architecture, we can see that the Linux kernel is still the kernel, and various hardware drivers are included in the kernel. Abstract the upper layer. On top of this, a system service layer is formed, which is based on distributed design and provides different sets of basic capabilities to the framework layer, such as various frameworks, service systems, APIs, etc.

Hongmeng’s philosophy:

  • One-time development and multiple-terminal deployment: refers to a project that is developed once and put on the shelf, and multiple terminals are deployed on demand. The purpose is to support developers to efficiently develop applications on a variety of terminal devices. Needless to say, this must be a trend.
  • Can be separated and combined for free circulation: Yuan service is a new application form provided by Hongmeng system. It has an independent entrance. Users can directly trigger it by clicking, touching, scanning, etc. without explicit installation. It is controlled by the program framework. It can be used after silent installation in the background, providing users with convenient services. It supports running on 1+8+N devices, allowing users to use it conveniently in appropriate scenarios and on appropriate devices. It can be understood as the mini program model of WeChat. The difference is that it supports native support and cross-device terminals.
  • Unified ecological native intelligence: The cross-platform application development frameworks of mobile operating systems and desktop operating systems are different. From the perspective of rendering methods, they can be summarized into three categories: WebView rendering, native rendering and self-rendering. Hongmeng system provides the corresponding system WebView, The ArkUI framework and XComponent capabilities support the access of three types of cross-platform frameworks. Its purpose is to allow UIs developed with other frameworks to be migrated to Hongmeng at low cost.

At the 2019 conference, Huawei not only demonstrated various new features of Hongmeng system, but also emphasized the differences between Hongmeng system and Android system, especially in terms of architecture and security. At that time, many trolls said that Huawei was a liar and Hongmeng was a shell of Android. Do you still say that now?

Compared with the traditional Android system, the biggest difference between the Hongmeng system and the traditional Android system is its unique distributed architecture.

Traditional operating systems usually adopt a single-core architecture, while Hongmeng OS adopts a distributed architecture, which makes it excellent in multi-device collaboration, resource sharing, and task switching.

The design of this distributed architecture enables the Hongmeng system to better adapt to different types of devices, including mobile phones, tablets, smart wearables and Internet of Things devices.

In addition to the distributed architecture, Huawei Hongmeng system also has unique innovations in security.

Traditional operating systems have some security loopholes and are vulnerable to malware attacks.

By adopting a distributed security architecture, Hongmeng system sinks security functions to the underlying core to achieve full-scenario, full-connection, and full-time security protection.

This means that users’ privacy and data are more solidly protected, whether on mobile phones or other smart devices, reducing the possibility of malicious attacks. However, Huawei at that time could not completely break away from the Android system. After all, many mobile phone software were developed and run based on Android.

Summarize

In fact, many devices can run the Android system, but the synchronization of this experience and data migration needs to be solved by application developers themselves. Big manufacturers may have this capability, but small and medium-sized developers are already having headaches just because of the fragmentation of Android.

In terms of general trends, the growth of traditional mobile Internet has peaked, and the era of Internet of Everything is beginning. Devices have expanded from billions of mobile phones to tens of billions of IoT devices. This is a blue ocean of growth. Different device types mean different sensor capabilities, hardware capabilities, screen sizes, operating systems and development languages, as well as differentiated interaction methods. Devices need to provide AI capabilities, such as language interaction, sensor intelligence, image recognition, etc.

Android is also constantly updated to provide increasingly rich capabilities. Huawei Hongmeng is an architecture directly facing this trend. Who has the advantage and who can unify the world? I don't think we need to worry about this issue, these systems are excellent. As developers, we need to pay attention to who can make development more convenient, provide low-cost access, nanny-level self-adaptation, quickly iterate business, more conveniently reach users, and have more room for growth. This is the king. . I believe everyone will have their own judgment.

I personally have always maintained a wait-and-see attitude towards OpenHarmony. Unexpectedly, Huawei has taken serious measures and announced that it will no longer be compatible with Android in 2024. Think about the extraordinary experience brought by Huawei's smart screens and super terminals (with all kinds of advertisements and membership fees on TV now, you really want to have a smart screen. It is predicted that TVs will be eliminated in the future and smart screens will replace them), the times are changing Call to catch up with the times. I am optimistic about the future of OpenHarmony, an operating system in the true era of the Internet of Everything, and I hope it is not too late to start.

Other resources

Huawei Document Center 

Huawei Developer Alliance - Opening up smart terminal capabilities to jointly build a developer ecosystem

OpenAtom OpenHarmony 

HarmonyOS system Codelabs technical guidance_Huawei HarmonyOS source code - HarmonyOS application development official website

Guess you like

Origin blog.csdn.net/qq8864/article/details/134421229
Recommended