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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CMake embeds a digest of these exact source bytes into the prebuilt reader.
# Keep checkouts identical on Windows and Linux so the artifact check is stable.
ohos/entry/src/main/cpp/** text eol=lf
8 changes: 8 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ jobs:

- name: Test
run: flutter test

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Test watch protocol, signing configuration and feedback recovery
run: node --test harmonyos_watch/scripts/*.test.cjs harmonyos_watch/scripts/*.test.mjs web/feedback/test/*.test.mjs
110 changes: 110 additions & 0 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,116 @@ jobs:
exit 1
fi

# Prebuilt plugin JNI can remain 4 KB aligned even with a new NDK.
python3 - "$apk" --zipalign "$(dirname "$aapt")/zipalign" <<'PY_16KB'
#!/usr/bin/env python3
"""Check 64-bit ELF LOAD alignment and uncompressed APK library offsets.

Read-only; uses Python's standard library. Optionally also run SDK zipalign.
This verifies packaging/linker alignment, not runtime page-size assumptions.
"""

import argparse
import struct
import subprocess
import sys
import zipfile
from pathlib import Path

PAGE_SIZE = 16384
MACHINES = {"arm64-v8a": 183, "x86_64": 62}


def check_elf(stream, abi):
header = stream.read(64)
if (len(header) < 64 or header[:4] != b"\x7fELF" or
header[4:6] != b"\x02\x01"):
raise ValueError("expected little-endian ELF64")
if struct.unpack_from("<H", header, 18)[0] != MACHINES[abi]:
raise ValueError("ELF machine does not match APK ABI")
offset = struct.unpack_from("<Q", header, 32)[0]
size, count = struct.unpack_from("<HH", header, 54)
if size < 56 or not 0 < count <= 4096:
raise ValueError("invalid program header table")
stream.seek(offset)
loads = []
for _ in range(count):
entry = stream.read(size)
if len(entry) != size:
raise ValueError("truncated program header table")
if struct.unpack_from("<I", entry)[0] != 1: # PT_LOAD
continue
file_offset, address = struct.unpack_from("<QQ", entry, 8)
alignment = struct.unpack_from("<Q", entry, 48)[0]
if alignment < PAGE_SIZE or alignment & (alignment - 1):
raise ValueError(f"PT_LOAD alignment {alignment} is not 16 KB compatible")
if file_offset % PAGE_SIZE != address % PAGE_SIZE:
raise ValueError("PT_LOAD file offset and virtual address are not congruent")
loads.append(alignment)
if not loads:
raise ValueError("no PT_LOAD segments")
return min(loads)


def library_offset(apk, info):
with apk.open("rb") as stream:
stream.seek(info.header_offset)
header = stream.read(30)
if len(header) != 30 or header[:4] != b"PK\x03\x04":
raise ValueError("invalid ZIP local header")
name_length, extra_length = struct.unpack_from("<HH", header, 26)
return info.header_offset + 30 + name_length + extra_length


def inspect(apk):
failures = []
checked = 0
with zipfile.ZipFile(apk) as archive:
for info in archive.infolist():
parts = info.filename.split("/")
if (len(parts) != 3 or parts[0] != "lib" or
parts[1] not in MACHINES or not parts[2].endswith(".so")):
continue
checked += 1
try:
with archive.open(info) as stream:
alignment = check_elf(stream, parts[1])
packaging = "compressed (extracted at install)"
if info.compress_type == zipfile.ZIP_STORED:
offset = library_offset(apk, info)
if offset % PAGE_SIZE:
raise ValueError(f"uncompressed ZIP data offset {offset} is not 16 KB aligned")
packaging = "ZIP aligned"
print(f"PASS {info.filename}: ELF {alignment}, {packaging}")
except (ValueError, OSError, struct.error) as error:
failures.append(f"FAIL {info.filename}: {error}")
for failure in failures:
print(failure, file=sys.stderr)
print(f"Checked {checked} 64-bit libraries; failures={len(failures)}")
# ARM32-only splits legitimately have no 64-bit libraries.
return not failures


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("apk", type=Path)
parser.add_argument("--zipalign", type=Path, help="SDK Build-Tools 35+ zipalign executable")
args = parser.parse_args()
try:
passed = inspect(args.apk)
if args.zipalign:
result = subprocess.run([str(args.zipalign), "-c", "-P", "16", "4", str(args.apk)], check=False)
passed = passed and result.returncode == 0
return 0 if passed else 1
except (OSError, ValueError, zipfile.BadZipFile) as error:
print(f"Cannot check APK: {error}", file=sys.stderr)
return 1


if __name__ == "__main__":
sys.exit(main())
PY_16KB

cp "$apk" "dist/TechPie-${RELEASE_NAME}-android-${token}.apk"
}

Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/linux-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ jobs:
liblzma-dev \
libwebkit2gtk-4.1-dev \
libsecret-1-dev \
libjsoncpp-dev
libjsoncpp-dev \
libjson-glib-dev \
qt6-base-dev \
qt6-declarative-dev

- name: Set up Flutter
uses: subosito/flutter-action@v2
Expand Down Expand Up @@ -131,6 +134,14 @@ jobs:
# platform's artifact, with the file left in whatever shape the build
# produced. The archive holds `bundle/` itself, so it extracts to one
# directory — the runner, its libraries and data/ next to each other.
cmake -S linux/widgets -B build/linux-widgets -DCMAKE_BUILD_TYPE=Release
cmake --build build/linux-widgets --parallel 2
mkdir -p build/linux/x64/release/bundle/widgets
cp assets/icon/icon.png build/linux/x64/release/bundle/techpie.png
cp -R build/linux-widgets/kde linux/widgets/gnome linux/widgets/common \
build/linux/x64/release/bundle/widgets/
cp linux/widgets/install.py linux/widgets/README.md \
build/linux/x64/release/bundle/widgets/
mkdir -p dist
tar -czf "dist/TechPie-${RELEASE_NAME}-linux-x86-64.tar.gz" \
-C build/linux/x64/release bundle
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ jobs:
flutter analyze --no-pub
flutter test

- name: Set up Node for product checks
if: steps.plan.outputs.skip == 'false'
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Verify watch and feedback behavior before release
if: steps.plan.outputs.skip == 'false'
run: node --test harmonyos_watch/scripts/*.test.cjs harmonyos_watch/scripts/*.test.mjs web/feedback/test/*.test.mjs

tag:
name: Tag the release
needs: plan
Expand Down
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,23 @@ dist/

# Local agent/editor state (omp)
.omp/

# Local notes and verification tools produced during watch development
/android/WEAR_ENGINE.md
/harmonyos_watch/README.md
/harmonyos_watch/docs/
/scripts/check-android-16kb.py

# Local Huawei service credentials
/android/app/agconnect-services.json

# Local platform operation audit logs
/.local/

# Local HarmonyOS watch development artifacts
/harmonyos_watch/README.md
/harmonyos_watch/docs/
/harmonyos_watch/.gitignore
/harmonyos_watch/build-profile.json5

/outputs/
14 changes: 13 additions & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ android {
applicationId = "club.geekpie.techpie"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
// Wear Engine 5.0.3.300 requires Android 6.0 (API 23).
minSdk = maxOf(flutter.minSdkVersion, 23)
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
Expand All @@ -146,3 +147,14 @@ tasks.named("preBuild") { dependsOn(prepareEcardWidgetResources) }
flutter {
source = "../.."
}

dependencies {
implementation("com.huawei.agconnect:agconnect-core:1.5.2.300")
implementation("com.huawei.hms:wearengine:5.0.3.300")
implementation("androidx.work:work-runtime:2.9.1")
}

// Local AGConnect settings contain credentials and are not checked into Git.
if (file("agconnect-services.json").isFile) {
apply(plugin = "com.huawei.agconnect")
}
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:usesCleartextTraffic="false">
<!-- Huawei HMS App ID -->
<meta-data android:name="com.huawei.hms.client.appid" android:value="appid=119331345" />
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down Expand Up @@ -78,6 +80,7 @@

In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<package android:name="com.huawei.health" />
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.provider.CalendarContract.Events
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import club.geekpie.techpie.ecardbind.EcardBindVpnService
import club.geekpie.techpie.wear.WearEngineBridge
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodCall
Expand All @@ -25,13 +26,15 @@ class MainActivity : FlutterActivity() {
private val mainHandler = Handler(Looper.getMainLooper())
private var ecardWidgets: EcardWidgetBridge? = null
private var ecardFeedback: EcardFeedback? = null
private var wearEngine: WearEngineBridge? = null

override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
ecardWidgets = EcardWidgetBridge(this, flutterEngine.dartExecutor.binaryMessenger).also {
it.capture(intent, notifyFlutter = false)
}
ecardFeedback = EcardFeedback(this, flutterEngine.dartExecutor.binaryMessenger)
wearEngine = WearEngineBridge(this, flutterEngine.dartExecutor.binaryMessenger)

MethodChannel(
flutterEngine.dartExecutor.binaryMessenger,
Expand Down Expand Up @@ -82,6 +85,8 @@ class MainActivity : FlutterActivity() {
ecardWidgets = null
ecardFeedback?.dispose()
ecardFeedback = null
wearEngine?.dispose()
wearEngine = null
super.cleanUpFlutterEngine(flutterEngine)
}

Expand Down
Loading