HMOS Lib Porting Guide

android hmos library app development
HMOS Lib Porting Guide

     

     HarmonyOS is an operating systems developed by Huawei. It was described as a microkernel-based, distributed, embedded operating system designed to work on devices from IoT and smart home products to wearables, in-car infotainment systems, and mobile devices - including smartphones.           

 

This document will provide a step-by-step guide to develop libraries for Harmony OS, in order to develop the libraries, it is good to have a fair understanding of Android, HarmonyOS or iOS Architecture.

Initial this document gives us a brief introduction about Android and Harmony Architecture and some deep understanding of the related API. Also, it is good to understand the key difference and information which is needed for developing libraries for HarmonyOS.

Test the developed HarmonyOS library

There are 2 types of testing one and you can try any of the below suitable types.

  1. Junit
  2. Sample Application

Junit

  1. Junit test cases can be written inside entry->src->ohosTest as shown below (Image24)
  • Image 24

  1. I have attached a doc (ExampleOhosTest.java) here which contains the list of sample test cases performed on the CircleImageView library.
  2. Make sure that Junit is added in dependencies inside entry->build.gradle and it also has decc{supportType=['html','xml']} as shown in the screenshot below (Image 25).

Please Note: Device should be connected(Emulator running) (Image 26)

  • Image 25

  • Image 26

  1. Next, we need to Click on Gradle->other->executeOhosTest. Just click and this will start to execute the Junit cases.
  • Image 27

  1. After successful execution the result will be generated inside entry->build->outputs->ohosDeccTest->result->decctest.xml as shown below (Image 28)
  • Image 28

This xml file gives you the details about the test result if it was successful or failed.

Sample Application

  1. After the library is completely ported, we can test it by writing a functionality in the MainAbilitySlice.java of the entry folder. Make sure to add the library in the entry build.gradle also as shown below (Image 29).
  • Image 29

  • Image 30

Note: if you have any third-party libraries referenced then please mention in the build.gradle file.

  1. Once this is completed, we need to "build", you can build this using the "Build" option from the Menu option and "Build HAP".
  2. Once built you can run the sample application on the Emulator. To start the emulator, follow the below procedure.
  • Click on Tools -> HVD Manager.
  • Next it will prompt you to login and once login successfully you will be displayed with the list of emulators as shown below (Image 31).
  • Image 31

  • Choose "Phone" and click on the Play button and this will kick start your emulator.
  • Once the emulator is up, select the module, and the Emulator would be selected and click on "Run" icon as shown below(Image 32).

Image 32

If the porting was successful and the build you should be able to view the Circle Image in Emulator as shown below( Image 33).

Image 33

Discussion

2