Skip to content
Merged
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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@

### 开发环境

- **DevEco Studio**: 5.0.0 或更高版本
- **HarmonyOS SDK**: API 12 (HarmonyOS 5.0)
- **Node.js**: 16.x 或更高版本
- **DevEco Studio**: 6.1 或更高版本;已验证 HarmonyOS 26.0.0 Beta1 SDK 可进入编译流程
- **HarmonyOS SDK**: 兼容 API 12+;当前 targetSdkVersion 保持 6.1.1(24)
- **Node.js**: 20.x 或更高版本
- **JDK/JBR**: 本地打包 HAP 需要可用的 Java Runtime;可直接使用 DevEco Studio 自带 JBR

> 说明:暂不直接把 targetSdkVersion 升到 API 26。API 26 会启用新的 ArkUI/权限/系统行为门控,当前优先保持运行行为稳定,同时让 CI 和本地 SDK 工具链先识别 HarmonyOS 26.0.0。

### 项目结构

Expand Down
16 changes: 11 additions & 5 deletions ci/normalize-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,18 @@ echo "Target SDK API version: $API_VER"
echo "SDK package version: $SDK_PKG_VERSION"

case "$API_VER" in
24) HOS_PLATFORM_VERSION="6.1.1"; HOS_TARGET_SDK_VERSION="6.1.1(24)" ;;
23) HOS_PLATFORM_VERSION="6.1.0"; HOS_TARGET_SDK_VERSION="6.1.0(23)" ;;
22) HOS_PLATFORM_VERSION="6.0.2"; HOS_TARGET_SDK_VERSION="6.0.2(22)" ;;
20) HOS_PLATFORM_VERSION="6.0.0"; HOS_TARGET_SDK_VERSION="6.0.0(20)" ;;
26) HOS_PLATFORM_VERSION="26.0.0"; HOS_COMPILE_SDK_VERSION="26.0.0"; HOS_TARGET_SDK_VERSION="26.0.0" ;;
24) HOS_PLATFORM_VERSION="6.1.1"; HOS_COMPILE_SDK_VERSION="6.1.1"; HOS_TARGET_SDK_VERSION="6.1.1(24)" ;;
23) HOS_PLATFORM_VERSION="6.1.0"; HOS_COMPILE_SDK_VERSION="6.1.0"; HOS_TARGET_SDK_VERSION="6.1.0(23)" ;;
22) HOS_PLATFORM_VERSION="6.0.2"; HOS_COMPILE_SDK_VERSION="6.0.2"; HOS_TARGET_SDK_VERSION="6.0.2(22)" ;;
20) HOS_PLATFORM_VERSION="6.0.0"; HOS_COMPILE_SDK_VERSION="6.0.0"; HOS_TARGET_SDK_VERSION="6.0.0(20)" ;;
*) echo "ERROR: Unsupported SDK API version: $API_VER"; exit 1 ;;
esac

# GitHub Actions writes this value into both compileSdkVersion and targetSdkVersion.
# Older command-line tools reject decorated values such as 6.1.1(24) for compileSdkVersion.
[ "${GITHUB_ACTIONS:-}" = "true" ] && HOS_TARGET_SDK_VERSION="$HOS_COMPILE_SDK_VERSION"

# ─── Step 1: Flatten nested openharmony/<ver> layout to root ───
# hvigor 6.24 treats a sdk-pkg.json with apiVersion as a platform container and
# expands it into <container>/{openharmony,hms}/<component>. Keep only
Expand Down Expand Up @@ -180,7 +185,7 @@ write_hms_check_package "toolchains" "$SDK_HOME/toolchains/hms/toolchains"
# Some command-line-tools only know HarmonyOS <= 5.1.0 until patched. The real
# platform version stays 6.1.1 in sdk-pkg.json, while this alias lets those
# tools discover the same local platform container before ci/patch-sdk.sh runs.
for platform_alias in "hmscore/$API_VER" "hmscore/$HOS_PLATFORM_VERSION" "HarmonyOS-NEXT2" "HarmonyOS NEXT2"; do
for platform_alias in "hmscore/$API_VER" "hmscore/$HOS_PLATFORM_VERSION" "HarmonyOS-$HOS_PLATFORM_VERSION" "HarmonyOS $HOS_PLATFORM_VERSION" "HarmonyOS-NEXT2" "HarmonyOS NEXT2"; do
rm -rf "$SDK_HOME/$platform_alias"
mkdir -p "$(dirname "$SDK_HOME/$platform_alias")"
ln -sfn "$SDK_HOME/toolchains" "$SDK_HOME/$platform_alias"
Expand All @@ -199,5 +204,6 @@ done
echo "SDK_API_VERSION=$API_VER"
echo "SDK_SOURCE_API_VERSION=$SOURCE_API_VER"
echo "HOS_PLATFORM_VERSION=$HOS_PLATFORM_VERSION"
echo "HOS_COMPILE_SDK_VERSION=$HOS_COMPILE_SDK_VERSION"
echo "HOS_TARGET_SDK_VERSION=$HOS_TARGET_SDK_VERSION"
echo "✅ SDK layout normalized"
93 changes: 89 additions & 4 deletions ci/patch-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 1. Copies type declaration stubs from ci/sdk-stubs/
# 2. Creates missing shared libraries
# 3. Deduplicates id_defined.json
# 4. Patches hos-config.json for HarmonyOS 6.1.1(API 24)
# 4. Patches hos-config.json for HarmonyOS 26.0.0(API 26) / 6.x targets
set -euo pipefail

SDK_HOME="${1:-$HOME/ohos-sdk}"
Expand Down Expand Up @@ -47,6 +47,59 @@ TOOLCHAINS="$OH_TOOLCHAINS"

echo "=== Applying SDK patches ==="

patch_ci_build_profile_versions() {
[ "${GITHUB_ACTIONS:-}" = "true" ] || return 0
[ -f "build-profile.json5" ] || return 0

local target_version
case "${CI_TARGET_API_VERSION:-}" in
26) target_version="26.0.0" ;;
24) target_version="6.1.1(24)" ;;
23) target_version="6.1.0(23)" ;;
22) target_version="6.0.2(22)" ;;
20) target_version="6.0.0(20)" ;;
*) return 0 ;;
esac

TARGET_SDK_VERSION="$target_version" python3 - <<'PY'
import os
import re

path = "build-profile.json5"
with open(path, encoding="utf-8") as f:
text = f.read()

target_version = os.environ["TARGET_SDK_VERSION"]
has_compile_sdk_version = re.search(r'"compileSdkVersion"\s*:', text) is not None
text, compile_hits = re.subn(
r'("compileSdkVersion"\s*:\s*")[^"]+(")',
rf'\g<1>{target_version}\2',
text,
)
text, target_hits = re.subn(
r'("targetSdkVersion"\s*:\s*")[^"]+(")',
rf'\g<1>{target_version}\2',
text,
)
text, compatible_hits = re.subn(
r'("compatibleSdkVersion"\s*:\s*")([0-9]+\.[0-9]+\.[0-9]+)(?:\([0-9]+\))?(")',
r'\g<1>\2(12)\3',
text,
)
if target_hits == 0 or compatible_hits == 0 or (has_compile_sdk_version and compile_hits == 0):
raise SystemExit(
"build-profile.json5 patch failed: "
f"compile_hits={compile_hits}, target_hits={target_hits}, compatible_hits={compatible_hits}"
)

with open(path, "w", encoding="utf-8") as f:
f.write(text)
print(f" Patched CI build-profile.json5 SDK versions: compile={target_version}, target={target_version}")
PY
}

patch_ci_build_profile_versions

kit_decl_exists() {
local kit_name="$1"
[ -f "$OH_ETS_KITS/$kit_name.d.ts" ] || [ -f "$OH_ETS_KITS/$kit_name.d.ets" ] || \
Expand All @@ -72,7 +125,7 @@ loader_patch_roots() {
done
}

# ─── Patch hos-config.json for API 24 targetSdkVersion ───
# ─── Patch hos-config.json for HarmonyOS targetSdkVersion aliases ───
echo "Patching hos-config.json..."
CMDLINE_ROOTS="$(cmdline_tool_roots || true)"
if [ -n "$CMDLINE_ROOTS" ]; then
Expand All @@ -85,10 +138,17 @@ p = os.environ['CONFIG_PATH']
with open(p) as f:
c = json.load(f)
before = json.dumps(c, sort_keys=True)
target_api = os.environ.get('CI_TARGET_API_VERSION', '24')
os_versions = c.setdefault('osVersionMapper', {})
os_names = c.setdefault('osNameMapper', {})
path_versions = c.setdefault('pathVersionMapper', {})

if target_api == '26':
# Keep older CI command-line-tools aware of the latest local HarmonyOS Beta SDK.
os_versions.setdefault('26.0.0', '26')
os_names.setdefault('26.0.0', 'HarmonyOS 26.0.0')
path_versions.setdefault('26.0.0', 'HarmonyOS-26.0.0')

# Keep older CI command-line-tools aware of the API 24 target used by build-profile.json5.
os_versions.setdefault('6.1.1', '24')
os_names.setdefault('6.1.1', 'HarmonyOS NEXT2')
Expand Down Expand Up @@ -276,14 +336,39 @@ fi

# ─── @kit.NetworkBoostKit ───
if ! kit_decl_exists "@kit.NetworkBoostKit"; then
[ ! -f "$HMS_KIT_CONFIGS/@kit.NetworkBoostKit.json" ] && \
cp "$STUBS_DIR/kit.NetworkBoostKit.json" "$HMS_KIT_CONFIGS/@kit.NetworkBoostKit.json"
cp "$STUBS_DIR/kit.NetworkBoostKit.json" "$HMS_KIT_CONFIGS/@kit.NetworkBoostKit.json"
[ ! -f "$HMS_ETS_API/@ohos.networkBoost.netQuality.d.ts" ] && \
cp "$STUBS_DIR/ohos.networkBoost.netQuality.d.ts" "$HMS_ETS_API/@ohos.networkBoost.netQuality.d.ts"
[ ! -f "$HMS_ETS_API/@ohos.networkBoost.netBoost.d.ts" ] && \
cp "$STUBS_DIR/ohos.networkBoost.netBoost.d.ts" "$HMS_ETS_API/@ohos.networkBoost.netBoost.d.ts"
cp "$STUBS_DIR/kit.NetworkBoostKit.d.ts" "$HMS_ETS_API/@kit.NetworkBoostKit.d.ts"
cp "$STUBS_DIR/kit.NetworkBoostKit.d.ts" "$HMS_ETS_KITS/@kit.NetworkBoostKit.d.ts"
echo " Applied NetworkBoostKit stubs"
else
echo " Using SDK NetworkBoostKit declarations"
KIT_NETWORKBOOST_DTS="$HMS_ETS_KITS/@kit.NetworkBoostKit.d.ts"
KIT_NETWORKBOOST_CONFIG="$HMS_KIT_CONFIGS/@kit.NetworkBoostKit.json"
if [ -f "$KIT_NETWORKBOOST_DTS" ] && ! grep -q "netBoost" "$KIT_NETWORKBOOST_DTS"; then
cp "$STUBS_DIR/kit.NetworkBoostKit.d.ts" "$KIT_NETWORKBOOST_DTS"
echo " Patched NetworkBoostKit netBoost export"
fi
if [ -f "$HMS_ETS_API/@kit.NetworkBoostKit.d.ts" ] && ! grep -q "netBoost" "$HMS_ETS_API/@kit.NetworkBoostKit.d.ts"; then
cp "$STUBS_DIR/kit.NetworkBoostKit.d.ts" "$HMS_ETS_API/@kit.NetworkBoostKit.d.ts"
fi
if [ -f "$KIT_NETWORKBOOST_CONFIG" ] && ! grep -q '"netBoost"' "$KIT_NETWORKBOOST_CONFIG"; then
cp "$STUBS_DIR/kit.NetworkBoostKit.json" "$KIT_NETWORKBOOST_CONFIG"
echo " Patched NetworkBoostKit netBoost kit config"
fi
[ ! -f "$HMS_ETS_API/@ohos.networkBoost.netBoost.d.ts" ] && \
cp "$STUBS_DIR/ohos.networkBoost.netBoost.d.ts" "$HMS_ETS_API/@ohos.networkBoost.netBoost.d.ts"
NETBOOST_DTS=""
for candidate in "$HMS_ETS_API/@hms.networkboost.netBoost.d.ts" "$HMS_ETS_API/@ohos.networkBoost.netBoost.d.ts"; do
[ -f "$candidate" ] && NETBOOST_DTS="$candidate" && break
done
if [ -n "$NETBOOST_DTS" ] && ! grep -q "setDataFlowDesc" "$NETBOOST_DTS"; then
cat "$STUBS_DIR/networkboost-dataflow-patch.d.ts" >> "$NETBOOST_DTS"
echo " Patched NetworkBoost data-flow declarations"
fi
fi

# ─── Socket stub (only if SDK is missing the file) ───
Expand Down
1 change: 1 addition & 0 deletions ci/sdk-stubs/kit.NetworkBoostKit.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
declare module '@kit.NetworkBoostKit' {
export { default as netQuality } from '@ohos.networkBoost.netQuality';
export { default as netBoost } from '@ohos.networkBoost.netBoost';
}
4 changes: 4 additions & 0 deletions ci/sdk-stubs/kit.NetworkBoostKit.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"netQuality": {
"source": "@ohos.networkBoost.netQuality.d.ts",
"bindings": "default"
},
"netBoost": {
"source": "@ohos.networkBoost.netBoost.d.ts",
"bindings": "default"
}
}
}
43 changes: 43 additions & 0 deletions ci/sdk-stubs/networkboost-dataflow-patch.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

declare namespace netBoost {
interface DataFlowDesc {
dataFlowInfo: DataFlowInfo | SocketFd;
scene: netQuality.ServiceType;
sceneEvent: SceneEvent;
expectations?: ExpectedDescription;
}

type SocketFd = number;

interface DataFlowInfo {
protocol: ProtocolType;
local: NetAddress;
remote: NetAddress;
}

interface ExpectedDescription {
uplinkBandwidth?: number;
downlinkBandwidth?: number;
latency?: number;
objectSize?: number;
priority?: PriorityLevel;
lowPowerMode?: boolean;
}

interface NetAddress {
address: string;
port: number;
}

enum ProtocolType {
PROTOCOL_UDP = 0,
PROTOCOL_TCP = 1
}

enum PriorityLevel {
PRIO_NORMAL = 0,
PRIO_HIGH = 1
}

function setDataFlowDesc(dataFlowDesc: DataFlowDesc): void;
}
67 changes: 67 additions & 0 deletions ci/sdk-stubs/ohos.networkBoost.netBoost.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @ohos.networkBoost.netBoost stub
* Public OpenHarmony SDK lacks the HMS Network Boost Kit; this stub provides
* the small netBoost surface used by CI builds. Real device runtime loads the
* actual HMS implementation.
*/
import netQuality from '@ohos.networkBoost.netQuality';

declare namespace netBoost {
interface SceneDesc {
scene: netQuality.ServiceType;
sceneEvent: SceneEvent;
startTime?: number;
duration?: number;
}

enum SceneEvent {
SCENE_EVENT_ENTER = 0,
SCENE_EVENT_UPDATE = 1,
SCENE_EVENT_LEAVE = 2
}

interface DataFlowDesc {
dataFlowInfo: DataFlowInfo | SocketFd;
scene: netQuality.ServiceType;
sceneEvent: SceneEvent;
expectations?: ExpectedDescription;
}

type SocketFd = number;

interface DataFlowInfo {
protocol: ProtocolType;
local: NetAddress;
remote: NetAddress;
}

interface ExpectedDescription {
uplinkBandwidth?: number;
downlinkBandwidth?: number;
latency?: number;
objectSize?: number;
priority?: PriorityLevel;
lowPowerMode?: boolean;
}

interface NetAddress {
address: string;
port: number;
}

enum ProtocolType {
PROTOCOL_UDP = 0,
PROTOCOL_TCP = 1
}

enum PriorityLevel {
PRIO_NORMAL = 0,
PRIO_HIGH = 1
}

function setSceneDesc(sceneDesc: SceneDesc): void;
function setDataFlowDesc(dataFlowDesc: DataFlowDesc): void;
function setLowPowerMode(isEnable: boolean): void;
}

export default netBoost;
3 changes: 2 additions & 1 deletion ci/sdk-stubs/ohos.networkBoost.netQuality.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* just enough surface for the codebase to compile under CI. Real device runtime
* loads the actual HMS implementation (richer than this stub).
*
* Field set kept aligned with HarmonyOS NEXT3 SDK 6.0.0 (API 20):
* Field set kept aligned with HarmonyOS NetworkBoostKit APIs used by this repo
* through HarmonyOS 26.0.0 (API 26):
* NetworkQos: linkUp/DownBandwidth, linkUp/DownRate, rttMs,
* linkUpBufferDelayMs, linkUpBufferCongestionPercent.
*/
Expand Down
2 changes: 1 addition & 1 deletion entry/src/main/ets/components/AppCard.ets
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export struct AppCard {
// 运行中指示器
if (this.app.isRunning) {
Row() {
Circle()
Ellipse()
.width(6)
.height(6)
.fill(AppColors.Online)
Expand Down
2 changes: 1 addition & 1 deletion entry/src/main/ets/components/AppListItem.ets
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export struct AppListItem {
@Builder
private RunningIndicator() {
Row() {
Circle()
Ellipse()
.width(6)
.height(6)
.fill(AppColors.Online)
Expand Down
2 changes: 1 addition & 1 deletion entry/src/main/ets/components/ComputerCard.ets
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export struct ComputerCard {

// 第三行:状态圆点 + 状态文本
Row() {
Circle()
Ellipse()
.width(8)
.height(8)
.fill(this.getStatusDotColor())
Expand Down
2 changes: 1 addition & 1 deletion entry/src/main/ets/components/PcListTitleBar.ets
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export struct PcListTitleBar {

if (this.config.totalCount > 0) {
Row() {
Circle()
Ellipse()
.width(6)
.height(6)
.fill(AppColors.Online)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ export struct GameControllerTestView {
Column({ space: 16 }) {
// 状态标题
Row({ space: 8 }) {
Circle()
Ellipse()
.width(12)
.height(12)
.fill(this.isAvailable ? (this.isMonitoring ? AppColors.Success : AppColors.Warning) : AppColors.Error)
Expand Down
Loading
Loading