moonohos_ohos

    HarmonyOS platform packages for MoonOHOS native modules: HiLog, RawFile, task cancellation, XComponent surfaces with Native Drawing and OpenGL ES, and 16 sys/* packages generated from SDK headers (617 functions: display, sensors, drawing, GLES, battery, HiTrace, ...).

    harmonyos
    hilog
    rawfile
    xcomponent
    opengl-es
    native-drawing
    sensor
    Download zip
    Author
    Version
    0.9.0
    License
    Apache-2.0
    Last updated
    yesterday
    Downloads
    97

    No dependencies

    #moonohos_ohos

    HarmonyOS platform packages for MoonOHOS native modules.

    PackagePurposeNDK library
    shop1111/moonohos_ohos/hilogLogger::new(domain, tag) with debug/info/warn/error/fatal; messages are passed as a %{public}s argument, never as the format stringlibhilog_ndk.z.so
    shop1111/moonohos_ohos/rawfileread, read_text, list for packaged resources/rawfile files through a borrowed Manager (adapted from ArkTS resourceManager)librawfile.z.so
    shop1111/moonohos_ohos/taskcancelled() / check() observe the CancelToken of the running MoonOHOS async task—
    shop1111/moonohos_ohos/deviceinfoget(field), snapshot(), sdk_api_version(): device type, brand, model, OS name and version (deviceinfo.h)libdeviceinfo_ndk.z.so
    shop1111/moonohos_ohos/netconnhas_default_network(), is_metered(); needs ohos.permission.GET_NETWORK_INFOlibnet_connection.so
    shop1111/moonohos_ohos/vibratorvibrate(ms, usage=Touch), cancel(); needs ohos.permission.VIBRATElibohvibrator.z.so
    shop1111/moonohos_ohos/surfaceSurface::open(surface_id) for an ArkUI XComponent, present/present_canvas of RGBA 8888 pixels, draw(canvas => ...) with a sys/drawing canvas bound to the window buffer, VSync::request_frame(callback) on the VSync thread (through the MoonOHOS gate), and a host-testable Canvas (0.9, docs/XCOMPONENT.md)libnative_window.so, libnative_vsync.so, libnative_drawing.so
    shop1111/moonohos_ohos/glGlSurface::open(surface_id) creates an EGL window surface and an OpenGL ES 3 context; frame((w, h) => ...) makes it current on the calling thread, sets the viewport, swaps and releases it. Helpers for the GL calls that take pointers (shader_source, link_program, gen_buffer, buffer_data_floats, vertex_attrib_pointer, uniform_matrix, read_pixels, get_integers) and common GL_* constants (0.9, docs/XCOMPONENT.md)libnative_window.so, libEGL.so, libGLESv3.so

    #Generated system bindings (sys/*, 0.8)

    shop1111/moonohos_ohos/sys/<module> packages are generated by moonohos bindgen from the HarmonyOS SDK API 26 headers: accesstoken, battery, bluetooth, deviceinfo, display, drawing (Native Drawing: canvas, brush, pen, path, font, text blob, shader effects), gles (OpenGL ES 3 calls without pointer arguments; use inside @gl.GlSurface::frame), hidebug, hitrace, osaccount, qos, sensor, syscap, timeservice, vibrator, wifi (617 functions). SDK objects are handles (pub type, released by their Destroy function or when garbage collected; use after destroy raises SysError::Closed), and callbacks take MoonBit closures. Each directory's BINDINGS.md lists the bound functions with their MoonBit signatures and the skipped ones with the reason. Functions returning an error-code enum raise SysError; enums keep unknown values as Other(Int). On the host they return zero values (error-code functions report 801).

    let (x, y) = @display.get_display_position(@display.get_default_display_id())
    let zone = @timeservice.get_time_zone()
    let listener = @display.register_display_change_listener(id => println(id))

    Each package carries a moonohos.native.json descriptor, so the MoonOHOS CLI cross-compiles its C stub for arm64-v8a and x86_64 and records it in the package manifest. Without the bridge (moon test on Windows/Linux/macOS) the stubs use host fallbacks: HiLog prints to stderr, rawfile.host_manager(dir) reads a directory, task.host_set_cancelled simulates cancellation, deviceinfo reports placeholders (is_device() is false), netconn.set_host_state sets what is reported, and vibrator.host_observations records calls, and surface fails to open with 801 while Canvas works.

    Errors carry the NDK error code; code 201 (permission denied) names the missing permission.

    /// Counts packaged documents on a worker thread, logging progress.
    pub fn count_documents(resources : @rawfile.Manager, dir : String) -> Int raise {
    let log = @hilog.Logger::new(0x4d4f, "MySearch")
    let mut characters = 0
    for name in @rawfile.list(resources, dir) {
    @task.check()
    characters += @rawfile.read_text(resources, dir + "/" + name).length()
    }
    log.info("indexed " + dir + ": " + characters.to_string() + " characters")
    characters
    }

    Toolchain: moonc >= 0.10.20 (tested with v0.10.20+65efd5b93), HarmonyOS SDK API 26 or newer. License: Apache-2.0.