Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ See [How it works → Video](docs/architecture.md#video) for details.
| Android 7+ phones / tablets | ✅ | ✅ | Can only be watched until the accessibility service is turned on; the controller connects to one device at a time |
| Android TV / Google TV | — | View only | Operated entirely with the remote |
| iOS / iPadOS 17+ | View only | ✅ | Sharing uses the system screen broadcast; iOS doesn't allow controlling the device |
| HarmonyOS 6.0+ (ARM64) | — | ✅ | [Airhand for HarmonyOS](harmony/README.md) supports foldable layouts and a self-hosted relay |
| Browser (web console) | — | ✅ | Chrome / Edge, Safari 16.4+, Firefox 130+ |

See [Known limitations](docs/limitations.md) for platform-specific caveats.
Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Airhand 是一个**高性能、低延迟**的远程桌面:画面用 GPU 硬件
| Android 7+ 手机 / 平板 | ✅ | ✅ | 开启无障碍服务后才能被操作,否则只能被看;控制端同一时间连一台 |
| Android TV / Google TV | — | 只看画面 | 全部用遥控器操作 |
| iOS / iPadOS 17+ | 只能被看 | ✅ | 共享本机用系统的屏幕广播;iOS 不允许别的应用操作本机 |
| HarmonyOS 6.0+(ARM64) | — | ✅ | [Airhand for HarmonyOS](harmony/README.md) 支持折叠屏布局和自建中继 |
| 浏览器(网页控制台) | — | ✅ | Chrome / Edge、Safari 16.4+、Firefox 130+ |

各平台的已知问题见[已知限制](docs/limitations.zh-CN.md)。
Expand Down
1 change: 1 addition & 0 deletions harmony/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Checks: 'misc-missing-switch-cases,misc-napi-module-name,misc-replace-if-else-with-ternary-operator,misc-unused-local-variable,misc-unused-parameters,modernize-use-auto,readability-system-capabilities,misc-napi-macro-module-name,capi-version-validation'
16 changes: 16 additions & 0 deletions harmony/.clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CompileFlags:
Add: [-Wunreachable-code-aggressive]
Remove: [-fsanitize=hwaddress, -fsanitize=thread]
Diagnostics:
ClangTidy:
Add: [misc-missing-switch-cases,misc-napi-module-name,misc-replace-if-else-with-ternary-operator,misc-unused-local-variable,misc-unused-parameters,modernize-use-auto,readability-system-capabilities,misc-napi-macro-module-name,capi-version-validation]
Remove: []
CheckOptions:
misc-unused-parameters.StrictMode: true
misc-unused-parameters.IgnoreVirtual: true
modernize-use-auto.MinTypeNameLength: 0

UnusedIncludes: Strict
UnusedFunctions: Check
Hover:
ShowNewHover: Yes
16 changes: 16 additions & 0 deletions harmony/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.hvigor/
.idea/
build/
entry/build/
entry/.cxx/
oh_modules/
local.properties
signing.local.json
/build-profile.json5

# Local device signing files
*.p12
*.pfx
*.p7b
*.cer
*.jks
10 changes: 10 additions & 0 deletions harmony/AppScope/app.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"app": {
"bundleName": "app.airhand.harmony",
"vendor": "Airhand",
"versionCode": 12,
"versionName": "0.10.1",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
}
8 changes: 8 additions & 0 deletions harmony/AppScope/resources/base/element/string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "Airhand for HarmonyOS"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions harmony/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Airhand for HarmonyOS

[Airhand](../README.zh-CN.md) 的 HarmonyOS 原生控制端。支持折叠屏布局、触控板和直触、系统输入法、长按离线听写、远端声音和双向文字剪贴板。需要一台 Airhand 中继和已运行 Airhand 的被控设备。

## 连接电脑

1. [部署 Airhand 中继](../docs/deploy.zh-CN.md),让被控电脑连接这台中继。
2. 在手机的「中继设置」中填写服务器地址和证书 SHA-256 指纹。地址格式为 `relay.example.com:4433`,IPv6 地址用方括号括起,例如 `[2001:db8::1]:4433`。证书指纹可从中继启动日志复制。
3. 连接中继后,输入电脑显示的六位控制码。首次连接还需要电脑显示的配对码。

中继配置保存在手机上,设备与配对记录按中继保存。使用旧版客户端配对过的用户,可在填写原中继时勾选「沿用旧版配对」。

## 构建和安装

需要 DevEco Studio、HarmonyOS 6.0(API 20)SDK(含 OpenHarmony Native 工具链),以及装有 `aarch64-unknown-linux-ohos` 目标的 Rust。已在 Apple 芯片的 Mac 上验证构建。

保留完整仓库目录。应用构建时复用 [`ios/native`](../ios/native) 的 Rust 接口,并通过 CMake 下载和校验 Opus 源码。

从仓库根目录执行以下命令,然后用 DevEco Studio 打开 `harmony`。

```sh
rustup target add aarch64-unknown-linux-ohos
cp harmony/build-profile.example.json5 harmony/build-profile.json5
```

在 DevEco Studio 中同步项目并构建 HAP。用命令行构建时,在已配置 DevEco SDK、JDK 和工具路径的环境中执行以下命令。

```sh
cd harmony
ohpm install --all
hvigorw assembleHap --mode module -p product=default -p buildMode=debug --no-daemon
```

模板生成的是未签名 HAP。要安装到真机,请在 DevEco Studio 的项目签名设置中配置自己的调试签名,再构建或直接运行。签名配置由 Git 忽略。

长按听写需要设备支持鸿蒙端侧语音识别,并在首次使用时允许麦克风权限。目前听写语言为简体中文。

## 许可证

项目沿用 [Airhand 的 MIT 许可证](../LICENSE)。内置 Opus 的许可证见 [Opus COPYING](entry/src/main/resources/rawfile/opus-COPYING.txt)。
33 changes: 33 additions & 0 deletions harmony/build-profile.example.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"app": {
"products": [
{
"name": "default",
"compatibleSdkVersion": "6.0.0(20)",
"targetSdkVersion": "6.0.0(20)",
"runtimeOS": "HarmonyOS",
"buildOption": {
"strictMode": {
"caseSensitiveCheck": true,
"useNormalizedOHMUrl": true
},
"nativeCompiler": "BiSheng"
}
}
],
"buildModeSet": [
{ "name": "debug" },
{ "name": "release" }
],
"signingConfigs": []
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{ "name": "default", "applyToProducts": ["default"] }
]
}
]
}
18 changes: 18 additions & 0 deletions harmony/entry/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"apiType": "stageMode",
"buildOption": {
"externalNativeOptions": {
"path": "./src/main/cpp/CMakeLists.txt",
"arguments": "",
"cppFlags": "",
"abiFilters": [
"arm64-v8a"
]
}
},
"targets": [
{
"name": "default"
}
]
}
3 changes: 3 additions & 0 deletions harmony/entry/hvigorfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { hapTasks } from '@ohos/hvigor-ohos-plugin';

export default { system: hapTasks, plugins: [] };
19 changes: 19 additions & 0 deletions harmony/entry/oh-package-lock.json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions harmony/entry/oh-package.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "entry",
"version": "0.1.0",
"dependencies": {
"libairhand.so": "file:./src/main/cpp/types/libairhand"
}
}
54 changes: 54 additions & 0 deletions harmony/entry/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.16)
project(airhand_harmony LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

get_filename_component(AIRHAND_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../../.." ABSOLUTE)
# DevEco may use BiSheng for C++, while Cargo needs the OpenHarmony clang wrapper with its sysroot.
if(EXISTS "${OHOS_SDK_NATIVE}/llvm/bin/aarch64-unknown-linux-ohos-clang")
set(LLVM_BIN "${OHOS_SDK_NATIVE}/llvm/bin")
else()
get_filename_component(LLVM_BIN "${CMAKE_C_COMPILER}" DIRECTORY)
endif()
set(RUST_TARGET aarch64-unknown-linux-ohos)
set(RUST_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/rust")
set(AIRHAND_CORE "${RUST_OUTPUT}/${RUST_TARGET}/release/libairhand_ios.a")
find_program(CARGO_EXECUTABLE cargo HINTS "$ENV{HOME}/.cargo/bin" REQUIRED)

# The mobile C ABI is shared with the iOS client. Cargo tracks the Rust sources.
add_custom_target(airhand_core
COMMAND ${CMAKE_COMMAND} -E env
"CARGO_TARGET_AARCH64_UNKNOWN_LINUX_OHOS_LINKER=${LLVM_BIN}/aarch64-unknown-linux-ohos-clang"
"CC_aarch64_unknown_linux_ohos=${LLVM_BIN}/aarch64-unknown-linux-ohos-clang"
"AR_aarch64_unknown_linux_ohos=${LLVM_BIN}/llvm-ar"
"CARGO_TARGET_DIR=${RUST_OUTPUT}"
"${CARGO_EXECUTABLE}" build --locked --release --target ${RUST_TARGET}
WORKING_DIRECTORY "${AIRHAND_ROOT}/ios/native"
BYPRODUCTS "${AIRHAND_CORE}"
VERBATIM)

include(FetchContent)
# Advanced SIMD is part of the arm64-v8a ABI. No runtime feature probe is needed.
set(OPUS_MAY_HAVE_NEON OFF CACHE BOOL "Probe for optional NEON at runtime" FORCE)
set(OPUS_PRESUME_NEON ON CACHE BOOL "Use the ARM64 NEON baseline" FORCE)
FetchContent_Declare(opus
URL https://downloads.xiph.org/releases/opus/opus-1.6.1.tar.gz
URL_HASH SHA256=6ffcb593207be92584df15b32466ed64bbec99109f007c82205f0194572411a1)
FetchContent_MakeAvailable(opus)
set_target_properties(opus PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(airhand SHARED napi_init.cpp video_decoder.cpp audio_renderer.cpp)
add_dependencies(airhand airhand_core)
target_include_directories(airhand PRIVATE "${AIRHAND_ROOT}/ios/native/include")
target_link_options(airhand PRIVATE -Wl,--no-undefined)
target_link_libraries(airhand PRIVATE
"${AIRHAND_CORE}"
libace_napi.z.so
libnative_media_vdec.so
Opus::opus
libohaudio.so
libnative_media_codecbase.so
libnative_media_core.so
libnative_window.so
libhilog_ndk.z.so)
Loading