hmos-multidevice-hardware-access

Guides HarmonyOS hardware capability detection and camera adaptation across foldable and multi-device form factors.

2|Updated Jun 21, 2026
One-click install
npx skills add https://github.com/IsKenKenYa/skills --skill hmos-multidevice-hardware-access-iskenkenya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hmos-multidevice-hardware-access
Source: https://github.com/IsKenKenYa/skills/tree/main/skills/harmonyos/solutions/HMOS-technologies/multi-device/hmos-multidevice-hardware-access
Command: npx skills add https://github.com/IsKenKenYa/skills --skill hmos-multidevice-hardware-access-iskenkenya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? HarmonyOS apps running across phones, tablets, foldables, and 2in1 devices face hardware capability differences that cause crashes, black screens, distorted previews, and wrong photo orientations. This Skill provides a declarative scene-and-resource index that routes hardware adaptation tasks to the correct constraints, code patterns, and verification matrices. ## Core Features & Use Cases - Capability Detection & Degradation (HW-01): Enforces canIUse() SysCap checks paired with module.json5 declarations, with correct SysCap granularity rules and fallback strategies (hide, disable, substitute, or prompt) for unsupported devices. - Camera Adaptation (HW-02): Covers camera enumeration with fallback, foldable state-change camera rebuild via foldStatusChange, stride/rowStride handling to prevent preview artifacts, and preview/photo/video rotation angle calculation using gravity sensors. - Structured Phase Outputs: Routes work through REQ, DEV, FIX, and VAL phases, producing deliverables like device_constraints, code_touchpoints, fix_plan, and verification_matrix. - Use Case: When a foldable device shows a black camera preview after folding, the Skill routes to HW-02-fold, loads the foldable adaptation reference, and prescribes the full rebuild chain: release session, re-enumerate cameras, recreate CameraInput/PreviewOutput/Session, commitConfig, and start. ## Quick Start Ask the assistant to adapt your HarmonyOS camera preview for foldable devices and fix the black screen that appears after folding the phone.

Frequently Asked Questions about hmos-multidevice-hardware-access

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check hardware capability with canIUse in HarmonyOS?

Call canIUse() with a SysCap string exactly as defined in the SDK device-define JSON files, and declare the same capability in module.json5. SysCap is device-level, so do not append fine-grained suffixes like SystemCapability.Sensors.Sensor.Accelerometer.

How to fix camera black screen after folding a HarmonyOS foldable?

Listen to foldStatusChange and fully rebuild the camera chain: release the old session, re-enumerate devices with getSupportedCameras, recreate CameraInput, PreviewOutput, and Session, then commitConfig and start. Skip rebuilds for half-folded transition states.

Why does HarmonyOS camera preview show distorted stacked images?

The preview buffer rowStride differs from width due to memory alignment, so reading width x height directly misaligns rows. Compare component.rowStride with width at runtime and either copy valid pixels per row or use pixelMap.cropSync to remove padding.

How do I set correct photo rotation on HarmonyOS camera?

Read gravity data with sensor.once(SensorId.GRAVITY), compute the device degree, then pass rotation in PhotoCaptureSetting when calling capture(). Rear camera uses lens angle plus gravity direction; front camera uses lens angle minus gravity direction.

Does HarmonyOS camera work on 2in1 devices and foldable outer screens?

Most 2in1 devices and wide-fold outer screens like PuraX only have front cameras. Use findIndex to locate the target camera position and fall back to cameras[0] when it is absent, avoiding crashes from hardcoded camera IDs.