Compare commits
5 Commits
0.4.0
...
360b57e3e2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
360b57e3e2 | ||
|
|
c5f4f854bf | ||
|
|
551022215c | ||
|
|
7323021aec | ||
|
|
a85ce0b4a2 |
52
README.md
@@ -1,10 +1,11 @@
|
|||||||
# Tauri Demo (SvelteKit + TypeScript)
|
# JE-Skin (SvelteKit + Tauri)
|
||||||
|
|
||||||
## 环境要求
|
## 环境要求
|
||||||
|
|
||||||
- Node.js 18+(建议 LTS)
|
- Node.js 18+(建议 LTS)
|
||||||
- Rust stable(`rustup` + `cargo`)
|
- Rust stable(`rustup` + `cargo`)
|
||||||
- Windows 下请确保已安装 WebView2 Runtime 和 MSVC C++ 构建工具
|
- Windows 下请确保已安装 WebView2 Runtime 和 MSVC C++ 构建工具
|
||||||
|
- Android 构建需要 Android SDK + NDK
|
||||||
|
|
||||||
## 安装依赖
|
## 安装依赖
|
||||||
|
|
||||||
@@ -42,12 +43,61 @@ npm run build
|
|||||||
npm run tauri build
|
npm run tauri build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
构建 Android APK / AAB:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npx tauri android build
|
||||||
|
```
|
||||||
|
|
||||||
|
产物路径:
|
||||||
|
- APK: `src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk`
|
||||||
|
- AAB: `src-tauri/gen/android/app/build/outputs/bundle/universalRelease/app-universal-release.aab`
|
||||||
|
|
||||||
|
Release APK 默认使用 debug keystore 签名(`src-tauri/gen/android/app/je-skin-debug.keystore`),可直接 `adb install` 到设备。
|
||||||
|
|
||||||
## 代码检查
|
## 代码检查
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm run check
|
npm run check
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## v0.5.0 修改记录
|
||||||
|
|
||||||
|
### Android USB 串口接入
|
||||||
|
|
||||||
|
- **Tauri 插件注册**:Android 端通过 Rust builder 注册 `usb-serial` 插件,移除 `MainActivity` 中的手动加载逻辑
|
||||||
|
- **USB 设备枚举**:使用 `usb-serial-for-android` 的 `UsbSerialProber` 识别串口设备,并返回设备名、厂商 ID、产品 ID、权限状态等信息
|
||||||
|
- **USB 权限申请**:完善 Android USB 授权回调,支持按设备名、vendorId/productId 解析设备并处理授权后的打开流程
|
||||||
|
- **串口数据桥接**:Kotlin 端打开 USB serial port 后通过 Unix socketpair 将 fd 交给 Rust,Rust 端继续复用 `serial_connect_fd` 数据采集链路
|
||||||
|
- **资源释放**:关闭连接时同步释放桥接 fd、USB serial port 和 `UsbDeviceConnection`,避免重复打开后的资源残留
|
||||||
|
|
||||||
|
### Tauri 权限与构建
|
||||||
|
|
||||||
|
- 新增 `src-tauri/permissions/usb-serial/default.toml`,声明 Android USB serial 插件命令和前端所需本地命令权限
|
||||||
|
- `default.json` 增加 USB serial 与本地命令权限,兼容 snake_case / camelCase 插件命令名
|
||||||
|
- Android Gradle 仓库加入 JitPack,用于解析 USB serial 驱动依赖
|
||||||
|
- ProGuard 增加 Tauri 插件注解、`UsbSerialPlugin` 和 `com.hoho.android.usbserial` 保留规则,避免 release 包混淆后插件命令失效
|
||||||
|
- Android 构建下 `serial_enum` 返回空列表,并仅保留 fd 连接入口,避免桌面串口枚举依赖进入 Android 编译路径
|
||||||
|
|
||||||
|
## v0.4.0 修改记录
|
||||||
|
|
||||||
|
### 移动端性能优化
|
||||||
|
|
||||||
|
- **SignalChart / SummaryCurve**:在 `@media (max-width: 900px)` 下移除 SVG 路径上的 `filter: drop-shadow()`,避免移动端 GPU 软件回流导致卡顿
|
||||||
|
- **SignalChart**:隐藏 `.scan-haze`(`mix-blend-mode: screen` 合成开销大),简化面板 `background` / `box-shadow`
|
||||||
|
- **SummaryCurve**:移动端移除 `.summary-line` 和 `.summary-dot` 的 drop-shadow 滤镜
|
||||||
|
- **页面级**:移动端隐藏 `.hud-noise`(`feTurbulence` SVG 滤镜是最大性能杀手),降低 `.hud-vignette` 透明度,简化 `.hud-gradient`
|
||||||
|
- 移除 inactive 面板的 `filter: blur()` 过渡动画
|
||||||
|
- 移除 transition 中的 `filter` 属性,添加 `will-change: d` 优化路径更新
|
||||||
|
|
||||||
|
### 移动端 UI 调整
|
||||||
|
|
||||||
|
- **隐藏三大金刚**:`@media (max-width: 900px)` 下隐藏标题栏右侧的最小化/最大化/关闭按钮(Android 系统自带窗口管理)
|
||||||
|
|
||||||
|
### Android 打包
|
||||||
|
|
||||||
|
- Release 构建配置使用 debug keystore 签名,输出签名 APK 而非 unsigned
|
||||||
|
|
||||||
## 推荐 IDE 插件
|
## 推荐 IDE 插件
|
||||||
|
|
||||||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
|
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
|
||||||
|
|||||||
56
package-lock.json
generated
@@ -6,7 +6,7 @@
|
|||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "JE-Skin",
|
"name": "JE-Skin",
|
||||||
"version": "0.3.0",
|
"version": "0.4.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tauri-apps/api": "^2",
|
"@tauri-apps/api": "^2",
|
||||||
@@ -625,9 +625,6 @@
|
|||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -642,9 +639,6 @@
|
|||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -659,9 +653,6 @@
|
|||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -676,9 +667,6 @@
|
|||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -693,9 +681,6 @@
|
|||||||
"loong64"
|
"loong64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -710,9 +695,6 @@
|
|||||||
"loong64"
|
"loong64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -727,9 +709,6 @@
|
|||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -744,9 +723,6 @@
|
|||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -761,9 +737,6 @@
|
|||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -778,9 +751,6 @@
|
|||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -795,9 +765,6 @@
|
|||||||
"s390x"
|
"s390x"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -812,9 +779,6 @@
|
|||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -829,9 +793,6 @@
|
|||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -1130,9 +1091,6 @@
|
|||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 OR MIT",
|
"license": "Apache-2.0 OR MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -1150,9 +1108,6 @@
|
|||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 OR MIT",
|
"license": "Apache-2.0 OR MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -1170,9 +1125,6 @@
|
|||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 OR MIT",
|
"license": "Apache-2.0 OR MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -1190,9 +1142,6 @@
|
|||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 OR MIT",
|
"license": "Apache-2.0 OR MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -1210,9 +1159,6 @@
|
|||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0 OR MIT",
|
"license": "Apache-2.0 OR MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
|
|||||||
11
src-tauri/.gitignore
vendored
@@ -7,3 +7,14 @@
|
|||||||
# will have schema files for capabilities auto-completion
|
# will have schema files for capabilities auto-completion
|
||||||
/gen/schemas
|
/gen/schemas
|
||||||
*log*
|
*log*
|
||||||
|
|
||||||
|
# Android build artifacts
|
||||||
|
/gen/android/app/build/
|
||||||
|
/gen/android/build/
|
||||||
|
/gen/android/.gradle/
|
||||||
|
/gen/android/.tauri/
|
||||||
|
/gen/android/local.properties
|
||||||
|
/gen/android/key.properties
|
||||||
|
/gen/android/keystore.properties
|
||||||
|
/gen/android/tauri.settings.gradle
|
||||||
|
/gen/android/app/src/main/jniLibs/
|
||||||
|
|||||||
1
src-tauri/Cargo.lock
generated
@@ -17,6 +17,7 @@ dependencies = [
|
|||||||
"fern",
|
"fern",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"humantime",
|
"humantime",
|
||||||
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"ndarray",
|
"ndarray",
|
||||||
"prost",
|
"prost",
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ uuid = { version = "1", features = ["v4", "serde"] }
|
|||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
|
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
|
||||||
ndarray = { version = "0.15", optional = true }
|
ndarray = { version = "0.15", optional = true }
|
||||||
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
|
libc = "0.2"
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||||
tauri-plugin-updater = "2"
|
tauri-plugin-updater = "2"
|
||||||
|
|||||||
@@ -12,6 +12,12 @@
|
|||||||
"core:window:allow-start-dragging",
|
"core:window:allow-start-dragging",
|
||||||
"opener:default",
|
"opener:default",
|
||||||
"process:default",
|
"process:default",
|
||||||
"updater:default"
|
"allow-usb-serial-list",
|
||||||
|
"allow-usb-serial-open",
|
||||||
|
"allow-usb-serial-close",
|
||||||
|
"allow-usb-serial-list-camel",
|
||||||
|
"allow-usb-serial-open-camel",
|
||||||
|
"allow-usb-serial-close-camel",
|
||||||
|
"allow-local-commands"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
12
src-tauri/gen/android/.editorconfig
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# EditorConfig is awesome: https://EditorConfig.org
|
||||||
|
|
||||||
|
# top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
insert_final_newline = false
|
||||||
20
src-tauri/gen/android/.gitignore
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
local.properties
|
||||||
|
key.properties
|
||||||
|
keystore.properties
|
||||||
|
|
||||||
|
/.tauri
|
||||||
|
/tauri.settings.gradle
|
||||||
6
src-tauri/gen/android/app/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/src/main/**/generated
|
||||||
|
/src/main/jniLibs/**/*.so
|
||||||
|
/src/main/assets/tauri.conf.json
|
||||||
|
/tauri.build.gradle.kts
|
||||||
|
/proguard-tauri.pro
|
||||||
|
/tauri.properties
|
||||||
73
src-tauri/gen/android/app/build.gradle.kts
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import java.util.Properties
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("com.android.application")
|
||||||
|
id("org.jetbrains.kotlin.android")
|
||||||
|
id("rust")
|
||||||
|
}
|
||||||
|
|
||||||
|
val tauriProperties = Properties().apply {
|
||||||
|
val propFile = file("tauri.properties")
|
||||||
|
if (propFile.exists()) {
|
||||||
|
propFile.inputStream().use { load(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdk = 36
|
||||||
|
namespace = "com.lenn.tauri_serial"
|
||||||
|
defaultConfig {
|
||||||
|
manifestPlaceholders["usesCleartextTraffic"] = "false"
|
||||||
|
applicationId = "com.lenn.tauri_serial"
|
||||||
|
minSdk = 24
|
||||||
|
targetSdk = 36
|
||||||
|
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
|
||||||
|
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
getByName("debug") {
|
||||||
|
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
||||||
|
isDebuggable = true
|
||||||
|
isJniDebuggable = true
|
||||||
|
isMinifyEnabled = false
|
||||||
|
packaging { jniLibs.keepDebugSymbols.add("*/arm64-v8a/*.so")
|
||||||
|
jniLibs.keepDebugSymbols.add("*/armeabi-v7a/*.so")
|
||||||
|
jniLibs.keepDebugSymbols.add("*/x86/*.so")
|
||||||
|
jniLibs.keepDebugSymbols.add("*/x86_64/*.so")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getByName("release") {
|
||||||
|
isMinifyEnabled = true
|
||||||
|
proguardFiles(
|
||||||
|
*fileTree(".") { include("**/*.pro") }
|
||||||
|
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
|
||||||
|
.toList().toTypedArray()
|
||||||
|
)
|
||||||
|
signingConfig = signingConfigs.getByName("debug")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
buildFeatures {
|
||||||
|
buildConfig = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rust {
|
||||||
|
rootDirRel = "../../../"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("androidx.webkit:webkit:1.14.0")
|
||||||
|
implementation("androidx.appcompat:appcompat:1.7.1")
|
||||||
|
implementation("androidx.activity:activity-ktx:1.10.1")
|
||||||
|
implementation("com.google.android.material:material:1.12.0")
|
||||||
|
implementation("androidx.lifecycle:lifecycle-process:2.10.0")
|
||||||
|
implementation("com.github.mik3y:usb-serial-for-android:3.9.0")
|
||||||
|
testImplementation("junit:junit:4.13.2")
|
||||||
|
androidTestImplementation("androidx.test.ext:junit:1.1.4")
|
||||||
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(from = "tauri.build.gradle.kts")
|
||||||
BIN
src-tauri/gen/android/app/je-skin-debug.keystore
Normal file
34
src-tauri/gen/android/app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
|
|
||||||
|
-keepattributes RuntimeVisibleAnnotations,RuntimeInvisibleAnnotations,*Annotation*,Signature,InnerClasses,EnclosingMethod
|
||||||
|
|
||||||
|
-keep class app.tauri.annotation.** { *; }
|
||||||
|
-keep class app.tauri.plugin.** { *; }
|
||||||
|
|
||||||
|
-keep class com.lenn.tauri_serial.MainActivity { *; }
|
||||||
|
-keep class com.lenn.tauri_serial.UsbSerialPlugin { *; }
|
||||||
|
-keepclassmembers class com.lenn.tauri_serial.UsbSerialPlugin {
|
||||||
|
public *;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep class com.hoho.android.usbserial.** { *; }
|
||||||
47
src-tauri/gen/android/app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<!-- USB Host support for serial devices -->
|
||||||
|
<uses-feature android:name="android.hardware.usb.host" android:required="true" />
|
||||||
|
|
||||||
|
<!-- AndroidTV support -->
|
||||||
|
<uses-feature android:name="android.software.leanback" android:required="false" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/Theme.je_skin"
|
||||||
|
android:usesCleartextTraffic="${usesCleartextTraffic}">
|
||||||
|
<activity
|
||||||
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:label="@string/main_activity_title"
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
<!-- AndroidTV support -->
|
||||||
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- Auto-launch when USB device is attached -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data
|
||||||
|
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
|
||||||
|
android:resource="@xml/usb_device_filter" />
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths" />
|
||||||
|
</provider>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.lenn.tauri_serial
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
|
||||||
|
class MainActivity : TauriActivity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
enableEdgeToEdge()
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,388 @@
|
|||||||
|
package com.lenn.tauri_serial
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
|
import android.hardware.usb.UsbDevice
|
||||||
|
import android.hardware.usb.UsbDeviceConnection
|
||||||
|
import android.hardware.usb.UsbManager
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.ParcelFileDescriptor
|
||||||
|
import android.system.Os
|
||||||
|
import android.system.OsConstants
|
||||||
|
import app.tauri.annotation.Command
|
||||||
|
import app.tauri.annotation.TauriPlugin
|
||||||
|
import app.tauri.plugin.Invoke
|
||||||
|
import app.tauri.plugin.JSObject
|
||||||
|
import app.tauri.plugin.Plugin
|
||||||
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
|
import com.hoho.android.usbserial.driver.UsbSerialPort
|
||||||
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
|
import java.io.FileDescriptor
|
||||||
|
import java.io.FileInputStream
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
import org.json.JSONArray
|
||||||
|
|
||||||
|
@TauriPlugin
|
||||||
|
class UsbSerialPlugin(private val activity: Activity) : Plugin(activity) {
|
||||||
|
companion object {
|
||||||
|
private const val ACTION_USB_PERMISSION = "com.lenn.tauri_serial.USB_PERMISSION"
|
||||||
|
private const val BAUD_RATE = 921600
|
||||||
|
private const val READ_TIMEOUT_MS = 100
|
||||||
|
private const val WRITE_TIMEOUT_MS = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
private var pendingConnectInvoke: Invoke? = null
|
||||||
|
private var pendingConnectDeviceName: String? = null
|
||||||
|
private var activeBridge: SerialBridge? = null
|
||||||
|
|
||||||
|
private val usbPermissionReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
if (ACTION_USB_PERMISSION != intent.action) return
|
||||||
|
|
||||||
|
synchronized(this@UsbSerialPlugin) {
|
||||||
|
val device = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
intent.getParcelableExtra(UsbManager.EXTRA_DEVICE, UsbDevice::class.java)
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
intent.getParcelableExtra(UsbManager.EXTRA_DEVICE)
|
||||||
|
}
|
||||||
|
|
||||||
|
val granted = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)
|
||||||
|
val invoke = pendingConnectInvoke
|
||||||
|
val targetDeviceName = pendingConnectDeviceName
|
||||||
|
|
||||||
|
pendingConnectInvoke = null
|
||||||
|
pendingConnectDeviceName = null
|
||||||
|
|
||||||
|
if (invoke == null || device == null) return
|
||||||
|
|
||||||
|
if (!granted) {
|
||||||
|
invoke.reject("USB permission denied")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetDeviceName != null && device.deviceName == targetDeviceName) {
|
||||||
|
openAndReturn(invoke, device.deviceName)
|
||||||
|
} else {
|
||||||
|
invoke.reject("USB device mismatch")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun load(webView: android.webkit.WebView) {
|
||||||
|
super.load(webView)
|
||||||
|
val filter = IntentFilter(ACTION_USB_PERMISSION)
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
activity.applicationContext.registerReceiver(
|
||||||
|
usbPermissionReceiver,
|
||||||
|
filter,
|
||||||
|
Context.RECEIVER_NOT_EXPORTED
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
activity.applicationContext.registerReceiver(usbPermissionReceiver, filter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
activeBridge?.close()
|
||||||
|
activeBridge = null
|
||||||
|
try {
|
||||||
|
activity.applicationContext.unregisterReceiver(usbPermissionReceiver)
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
fun usb_serial_list(invoke: Invoke) {
|
||||||
|
listDevices(invoke)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
fun usbSerialList(invoke: Invoke) {
|
||||||
|
listDevices(invoke)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun listDevices(invoke: Invoke) {
|
||||||
|
val usbManager = activity.getSystemService(Context.USB_SERVICE) as? UsbManager
|
||||||
|
if (usbManager == null) {
|
||||||
|
invoke.reject("USB service not available")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val result = JSObject()
|
||||||
|
val serialDevices = JSONArray()
|
||||||
|
|
||||||
|
for (driver in UsbSerialProber.getDefaultProber().findAllDrivers(usbManager)) {
|
||||||
|
val device = driver.device
|
||||||
|
val obj = JSObject()
|
||||||
|
obj.put("name", device.deviceName)
|
||||||
|
obj.put("vendorId", device.vendorId)
|
||||||
|
obj.put("productId", device.productId)
|
||||||
|
obj.put("manufacturer", safeDeviceString { device.manufacturerName })
|
||||||
|
obj.put("product", safeDeviceString { device.productName })
|
||||||
|
obj.put("serial", safeDeviceString { device.serialNumber })
|
||||||
|
obj.put("hasPermission", usbManager.hasPermission(device))
|
||||||
|
serialDevices.put(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
result.put("devices", serialDevices)
|
||||||
|
invoke.resolve(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
fun usb_serial_open(invoke: Invoke) {
|
||||||
|
openDevice(invoke)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
fun usbSerialOpen(invoke: Invoke) {
|
||||||
|
openDevice(invoke)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun openDevice(invoke: Invoke) {
|
||||||
|
val args = invoke.parseArgs(JSObject::class.java)
|
||||||
|
val deviceName = args.optString("name", "")
|
||||||
|
val vendorId = if (args.has("vendorId")) args.optInt("vendorId") else null
|
||||||
|
val productId = if (args.has("productId")) args.optInt("productId") else null
|
||||||
|
|
||||||
|
val usbManager = activity.getSystemService(Context.USB_SERVICE) as? UsbManager
|
||||||
|
if (usbManager == null) {
|
||||||
|
invoke.reject("USB service not available")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val device = resolveDevice(usbManager, deviceName, vendorId, productId)
|
||||||
|
if (device == null) {
|
||||||
|
val available = usbManager.deviceList.values.joinToString(", ") { it.deviceName }
|
||||||
|
invoke.reject("USB device not found: $deviceName; available: $available")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!usbManager.hasPermission(device)) {
|
||||||
|
synchronized(this) {
|
||||||
|
pendingConnectInvoke = invoke
|
||||||
|
pendingConnectDeviceName = device.deviceName
|
||||||
|
}
|
||||||
|
|
||||||
|
val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
|
||||||
|
} else {
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
}
|
||||||
|
val permissionRequest = Intent(ACTION_USB_PERMISSION).setPackage(activity.packageName)
|
||||||
|
val permissionIntent = PendingIntent.getBroadcast(
|
||||||
|
activity,
|
||||||
|
0,
|
||||||
|
permissionRequest,
|
||||||
|
flags
|
||||||
|
)
|
||||||
|
usbManager.requestPermission(device, permissionIntent)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
openAndReturn(invoke, device.deviceName)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
fun usb_serial_close(invoke: Invoke) {
|
||||||
|
closeBridge()
|
||||||
|
invoke.resolve(JSObject())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
fun usbSerialClose(invoke: Invoke) {
|
||||||
|
closeBridge()
|
||||||
|
invoke.resolve(JSObject())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun closeBridge() {
|
||||||
|
activeBridge?.close()
|
||||||
|
activeBridge = null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun openAndReturn(invoke: Invoke, deviceName: String) {
|
||||||
|
val usbManager = activity.getSystemService(Context.USB_SERVICE) as? UsbManager
|
||||||
|
if (usbManager == null) {
|
||||||
|
invoke.reject("USB service not available")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val driver = findDriver(usbManager, deviceName)
|
||||||
|
if (driver == null) {
|
||||||
|
invoke.reject("USB serial driver not found: $deviceName")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val connection = usbManager.openDevice(driver.device)
|
||||||
|
if (connection == null) {
|
||||||
|
invoke.reject("Failed to open USB device")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val port = driver.ports.firstOrNull()
|
||||||
|
if (port == null) {
|
||||||
|
connection.close()
|
||||||
|
invoke.reject("No serial port found on USB device")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
port.open(connection)
|
||||||
|
port.setParameters(
|
||||||
|
BAUD_RATE,
|
||||||
|
UsbSerialPort.DATABITS_8,
|
||||||
|
UsbSerialPort.STOPBITS_1,
|
||||||
|
UsbSerialPort.PARITY_NONE
|
||||||
|
)
|
||||||
|
|
||||||
|
val rustSide = FileDescriptor()
|
||||||
|
val bridgeSide = FileDescriptor()
|
||||||
|
Os.socketpair(OsConstants.AF_UNIX, OsConstants.SOCK_STREAM, 0, rustSide, bridgeSide)
|
||||||
|
val rustFd = ParcelFileDescriptor.dup(rustSide).detachFd()
|
||||||
|
Os.close(rustSide)
|
||||||
|
|
||||||
|
activeBridge?.close()
|
||||||
|
activeBridge = SerialBridge(bridgeSide, port, connection).also { it.start() }
|
||||||
|
|
||||||
|
val result = JSObject()
|
||||||
|
result.put("fd", rustFd)
|
||||||
|
result.put("name", driver.device.deviceName)
|
||||||
|
result.put("vendorId", driver.device.vendorId)
|
||||||
|
result.put("productId", driver.device.productId)
|
||||||
|
invoke.resolve(result)
|
||||||
|
} catch (error: Exception) {
|
||||||
|
try {
|
||||||
|
port.close()
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
connection.close()
|
||||||
|
invoke.reject(error.message ?: "Failed to open USB serial port")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun findDriver(usbManager: UsbManager, deviceName: String): UsbSerialDriver? {
|
||||||
|
return UsbSerialProber.getDefaultProber()
|
||||||
|
.findAllDrivers(usbManager)
|
||||||
|
.firstOrNull { it.device.deviceName == deviceName || it.device.deviceName.equals(deviceName, ignoreCase = true) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun resolveDevice(
|
||||||
|
usbManager: UsbManager,
|
||||||
|
deviceName: String,
|
||||||
|
vendorId: Int?,
|
||||||
|
productId: Int?
|
||||||
|
): UsbDevice? {
|
||||||
|
usbManager.deviceList[deviceName]?.let { return it }
|
||||||
|
|
||||||
|
val devices = usbManager.deviceList.values.toList()
|
||||||
|
devices.firstOrNull { it.deviceName.equals(deviceName, ignoreCase = true) }?.let { return it }
|
||||||
|
|
||||||
|
if (vendorId != null && productId != null) {
|
||||||
|
devices.firstOrNull { it.vendorId == vendorId && it.productId == productId }?.let { return it }
|
||||||
|
}
|
||||||
|
|
||||||
|
val drivers = UsbSerialProber.getDefaultProber().findAllDrivers(usbManager)
|
||||||
|
drivers.firstOrNull {
|
||||||
|
it.device.deviceName == deviceName || it.device.deviceName.equals(deviceName, ignoreCase = true)
|
||||||
|
}?.device?.let { return it }
|
||||||
|
|
||||||
|
if (drivers.size == 1) {
|
||||||
|
return drivers.first().device
|
||||||
|
}
|
||||||
|
|
||||||
|
if (devices.size == 1) {
|
||||||
|
return devices.first()
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun safeDeviceString(read: () -> String?): String {
|
||||||
|
return try {
|
||||||
|
read() ?: ""
|
||||||
|
} catch (_: SecurityException) {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SerialBridge(
|
||||||
|
private val bridgeFd: FileDescriptor,
|
||||||
|
private val port: UsbSerialPort,
|
||||||
|
private val connection: UsbDeviceConnection
|
||||||
|
) {
|
||||||
|
private val running = AtomicBoolean(false)
|
||||||
|
private lateinit var serialToRustThread: Thread
|
||||||
|
private lateinit var rustToSerialThread: Thread
|
||||||
|
|
||||||
|
fun start() {
|
||||||
|
running.set(true)
|
||||||
|
serialToRustThread = Thread(::copySerialToRust, "JE-Skin-usb-serial-rx")
|
||||||
|
rustToSerialThread = Thread(::copyRustToSerial, "JE-Skin-usb-serial-tx")
|
||||||
|
serialToRustThread.start()
|
||||||
|
rustToSerialThread.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun close() {
|
||||||
|
if (!running.getAndSet(false)) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
Os.close(bridgeFd)
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
port.close()
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
connection.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun copySerialToRust() {
|
||||||
|
val output = FileOutputStream(bridgeFd)
|
||||||
|
val buffer = ByteArray(4096)
|
||||||
|
|
||||||
|
while (running.get()) {
|
||||||
|
try {
|
||||||
|
val count = port.read(buffer, READ_TIMEOUT_MS)
|
||||||
|
if (count > 0) {
|
||||||
|
output.write(buffer, 0, count)
|
||||||
|
output.flush()
|
||||||
|
}
|
||||||
|
} catch (_: IOException) {
|
||||||
|
close()
|
||||||
|
} catch (_: Exception) {
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun copyRustToSerial() {
|
||||||
|
val input = FileInputStream(bridgeFd)
|
||||||
|
val buffer = ByteArray(4096)
|
||||||
|
|
||||||
|
while (running.get()) {
|
||||||
|
try {
|
||||||
|
val count = input.read(buffer)
|
||||||
|
if (count < 0) {
|
||||||
|
close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (count > 0) {
|
||||||
|
port.write(buffer.copyOf(count), WRITE_TIMEOUT_MS)
|
||||||
|
}
|
||||||
|
} catch (_: IOException) {
|
||||||
|
close()
|
||||||
|
} catch (_: Exception) {
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Hello World!"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.je_skin" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
10
src-tauri/gen/android/app/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="purple_200">#FFBB86FC</color>
|
||||||
|
<color name="purple_500">#FF6200EE</color>
|
||||||
|
<color name="purple_700">#FF3700B3</color>
|
||||||
|
<color name="teal_200">#FF03DAC5</color>
|
||||||
|
<color name="teal_700">#FF018786</color>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">JE-Skin</string>
|
||||||
|
<string name="main_activity_title">JE-Skin</string>
|
||||||
|
</resources>
|
||||||
6
src-tauri/gen/android/app/src/main/res/values/themes.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.je_skin" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<external-path name="my_images" path="." />
|
||||||
|
<cache-path name="my_cache_images" path="." />
|
||||||
|
</paths>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- CH340 / CH341 USB-Serial -->
|
||||||
|
<usb-device vendor-id="1a86" product-id="7523" />
|
||||||
|
<!-- CP2102 / CP2104 -->
|
||||||
|
<usb-device vendor-id="10c4" product-id="ea60" />
|
||||||
|
<usb-device vendor-id="10c4" product-id="ea70" />
|
||||||
|
<!-- FTDI FT232R / FT232H -->
|
||||||
|
<usb-device vendor-id="0403" product-id="6001" />
|
||||||
|
<usb-device vendor-id="0403" product-id="6014" />
|
||||||
|
<!-- PL2303 -->
|
||||||
|
<usb-device vendor-id="067b" product-id="2303" />
|
||||||
|
<usb-device vendor-id="067b" product-id="23a3" />
|
||||||
|
<!-- CDC ACM (generic USB serial) -->
|
||||||
|
<usb-device vendor-id="2341" product-id="0001" />
|
||||||
|
<usb-device vendor-id="2341" product-id="0043" />
|
||||||
|
<usb-device vendor-id="2341" product-id="0042" />
|
||||||
|
<!-- Allow any USB device (catch-all) -->
|
||||||
|
<usb-device />
|
||||||
|
</resources>
|
||||||
22
src-tauri/gen/android/build.gradle.kts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("com.android.tools.build:gradle:8.11.0")
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
maven(url = "https://jitpack.io")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("clean").configure {
|
||||||
|
delete("build")
|
||||||
|
}
|
||||||
23
src-tauri/gen/android/buildSrc/build.gradle.kts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
plugins {
|
||||||
|
`kotlin-dsl`
|
||||||
|
}
|
||||||
|
|
||||||
|
gradlePlugin {
|
||||||
|
plugins {
|
||||||
|
create("pluginsForCoolKids") {
|
||||||
|
id = "rust"
|
||||||
|
implementationClass = "RustPlugin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly(gradleApi())
|
||||||
|
implementation("com.android.tools.build:gradle:8.11.0")
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import java.io.File
|
||||||
|
import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.GradleException
|
||||||
|
import org.gradle.api.logging.LogLevel
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
|
open class BuildTask : DefaultTask() {
|
||||||
|
@Input
|
||||||
|
var rootDirRel: String? = null
|
||||||
|
@Input
|
||||||
|
var target: String? = null
|
||||||
|
@Input
|
||||||
|
var release: Boolean? = null
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
fun assemble() {
|
||||||
|
val executable = """cargo""";
|
||||||
|
try {
|
||||||
|
runTauriCli(executable)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||||
|
// Try different Windows-specific extensions
|
||||||
|
val fallbacks = listOf(
|
||||||
|
"$executable.exe",
|
||||||
|
"$executable.cmd",
|
||||||
|
"$executable.bat",
|
||||||
|
)
|
||||||
|
|
||||||
|
var lastException: Exception = e
|
||||||
|
for (fallback in fallbacks) {
|
||||||
|
try {
|
||||||
|
runTauriCli(fallback)
|
||||||
|
return
|
||||||
|
} catch (fallbackException: Exception) {
|
||||||
|
lastException = fallbackException
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw lastException
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun runTauriCli(executable: String) {
|
||||||
|
val rootDirRel = rootDirRel ?: throw GradleException("rootDirRel cannot be null")
|
||||||
|
val target = target ?: throw GradleException("target cannot be null")
|
||||||
|
val release = release ?: throw GradleException("release cannot be null")
|
||||||
|
val args = listOf("tauri", "android", "android-studio-script");
|
||||||
|
|
||||||
|
project.exec {
|
||||||
|
workingDir(File(project.projectDir, rootDirRel))
|
||||||
|
executable(executable)
|
||||||
|
args(args)
|
||||||
|
if (project.logger.isEnabled(LogLevel.DEBUG)) {
|
||||||
|
args("-vv")
|
||||||
|
} else if (project.logger.isEnabled(LogLevel.INFO)) {
|
||||||
|
args("-v")
|
||||||
|
}
|
||||||
|
if (release) {
|
||||||
|
args("--release")
|
||||||
|
}
|
||||||
|
args(listOf("--target", target))
|
||||||
|
}.assertNormalExitValue()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
import com.android.build.api.dsl.ApplicationExtension
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.configure
|
||||||
|
import org.gradle.kotlin.dsl.get
|
||||||
|
|
||||||
|
const val TASK_GROUP = "rust"
|
||||||
|
|
||||||
|
open class Config {
|
||||||
|
lateinit var rootDirRel: String
|
||||||
|
}
|
||||||
|
|
||||||
|
open class RustPlugin : Plugin<Project> {
|
||||||
|
private lateinit var config: Config
|
||||||
|
|
||||||
|
override fun apply(project: Project) = with(project) {
|
||||||
|
config = extensions.create("rust", Config::class.java)
|
||||||
|
|
||||||
|
val defaultAbiList = listOf("arm64-v8a", "armeabi-v7a", "x86", "x86_64");
|
||||||
|
val abiList = (findProperty("abiList") as? String)?.split(',') ?: defaultAbiList
|
||||||
|
|
||||||
|
val defaultArchList = listOf("arm64", "arm", "x86", "x86_64");
|
||||||
|
val archList = (findProperty("archList") as? String)?.split(',') ?: defaultArchList
|
||||||
|
|
||||||
|
val targetsList = (findProperty("targetList") as? String)?.split(',') ?: listOf("aarch64", "armv7", "i686", "x86_64")
|
||||||
|
|
||||||
|
extensions.configure<ApplicationExtension> {
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
flavorDimensions.add("abi")
|
||||||
|
productFlavors {
|
||||||
|
create("universal") {
|
||||||
|
dimension = "abi"
|
||||||
|
ndk {
|
||||||
|
abiFilters += abiList
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defaultArchList.forEachIndexed { index, arch ->
|
||||||
|
create(arch) {
|
||||||
|
dimension = "abi"
|
||||||
|
ndk {
|
||||||
|
abiFilters.add(defaultAbiList[index])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
for (profile in listOf("debug", "release")) {
|
||||||
|
val profileCapitalized = profile.replaceFirstChar { it.uppercase() }
|
||||||
|
val buildTask = tasks.maybeCreate(
|
||||||
|
"rustBuildUniversal$profileCapitalized",
|
||||||
|
DefaultTask::class.java
|
||||||
|
).apply {
|
||||||
|
group = TASK_GROUP
|
||||||
|
description = "Build dynamic library in $profile mode for all targets"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks["mergeUniversal${profileCapitalized}JniLibFolders"].dependsOn(buildTask)
|
||||||
|
|
||||||
|
for (targetPair in targetsList.withIndex()) {
|
||||||
|
val targetName = targetPair.value
|
||||||
|
val targetArch = archList[targetPair.index]
|
||||||
|
val targetArchCapitalized = targetArch.replaceFirstChar { it.uppercase() }
|
||||||
|
val targetBuildTask = project.tasks.maybeCreate(
|
||||||
|
"rustBuild$targetArchCapitalized$profileCapitalized",
|
||||||
|
BuildTask::class.java
|
||||||
|
).apply {
|
||||||
|
group = TASK_GROUP
|
||||||
|
description = "Build dynamic library in $profile mode for $targetArch"
|
||||||
|
rootDirRel = config.rootDirRel
|
||||||
|
target = targetName
|
||||||
|
release = profile == "release"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTask.dependsOn(targetBuildTask)
|
||||||
|
tasks["merge$targetArchCapitalized${profileCapitalized}JniLibFolders"].dependsOn(
|
||||||
|
targetBuildTask
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src-tauri/gen/android/gradle.properties
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app"s APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
|
kotlin.code.style=official
|
||||||
|
# Enables namespacing of each library's R class so that its R class includes only the
|
||||||
|
# resources declared in the library itself and none from the library's dependencies,
|
||||||
|
# thereby reducing the size of the R class for that library
|
||||||
|
android.nonTransitiveRClass=true
|
||||||
|
android.nonFinalResIds=false
|
||||||
BIN
src-tauri/gen/android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
src-tauri/gen/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#Tue May 10 19:22:52 CST 2022
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
185
src-tauri/gen/android/gradlew
vendored
Executable file
@@ -0,0 +1,185 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=`expr $i + 1`
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
0) set -- ;;
|
||||||
|
1) set -- "$args0" ;;
|
||||||
|
2) set -- "$args0" "$args1" ;;
|
||||||
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
89
src-tauri/gen/android/gradlew.bat
vendored
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
3
src-tauri/gen/android/settings.gradle
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
include ':app'
|
||||||
|
|
||||||
|
apply from: 'tauri.settings.gradle'
|
||||||
66
src-tauri/permissions/usb-serial/default.toml
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
[default]
|
||||||
|
description = "Allows Android USB serial plugin commands."
|
||||||
|
permissions = [
|
||||||
|
"allow-usb-serial-list",
|
||||||
|
"allow-usb-serial-open",
|
||||||
|
"allow-usb-serial-close",
|
||||||
|
"allow-usb-serial-list-camel",
|
||||||
|
"allow-usb-serial-open-camel",
|
||||||
|
"allow-usb-serial-close-camel",
|
||||||
|
"allow-local-commands"
|
||||||
|
]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-usb-serial-list"
|
||||||
|
description = "Allows listing Android USB serial devices."
|
||||||
|
commands.allow = ["plugin:usb-serial|usb_serial_list"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-usb-serial-open"
|
||||||
|
description = "Allows opening Android USB serial devices."
|
||||||
|
commands.allow = ["plugin:usb-serial|usb_serial_open"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-usb-serial-close"
|
||||||
|
description = "Allows closing Android USB serial devices."
|
||||||
|
commands.allow = ["plugin:usb-serial|usb_serial_close"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-usb-serial-list-camel"
|
||||||
|
description = "Allows listing Android USB serial devices via camelCase command."
|
||||||
|
commands.allow = ["plugin:usb-serial|usbSerialList"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-usb-serial-open-camel"
|
||||||
|
description = "Allows opening Android USB serial devices via camelCase command."
|
||||||
|
commands.allow = ["plugin:usb-serial|usbSerialOpen"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-usb-serial-close-camel"
|
||||||
|
description = "Allows closing Android USB serial devices via camelCase command."
|
||||||
|
commands.allow = ["plugin:usb-serial|usbSerialClose"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-local-commands"
|
||||||
|
description = "Allows application commands used by the Android frontend."
|
||||||
|
commands.allow = [
|
||||||
|
"file_explorer_list",
|
||||||
|
"serial_enum",
|
||||||
|
"serial_connect",
|
||||||
|
"serial_connect_fd",
|
||||||
|
"serial_disconnect",
|
||||||
|
"serial_export_csv",
|
||||||
|
"serial_has_record_data",
|
||||||
|
"serial_export_csv_to_path",
|
||||||
|
"serial_import_csv",
|
||||||
|
"serial_import_csv_from_path",
|
||||||
|
"win_minimize",
|
||||||
|
"win_toggle_maximize",
|
||||||
|
"win_close",
|
||||||
|
"devkit_status",
|
||||||
|
"devkit_start",
|
||||||
|
"devkit_stop",
|
||||||
|
"devkit_get_config",
|
||||||
|
"devkit_set_config",
|
||||||
|
"devkit_process_export"
|
||||||
|
]
|
||||||
9
src-tauri/plugins/usb-serial-plugin.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"plugins": {
|
||||||
|
"usb-serial": {
|
||||||
|
"android": {
|
||||||
|
"package": "com.lenn.tauri_serial.UsbSerialPlugin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -141,6 +141,7 @@ fn resolve_start_path(app: &AppHandle, raw_path: Option<String>) -> Result<PathB
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_default_path(app: &AppHandle) -> Result<PathBuf, String> {
|
fn resolve_default_path(app: &AppHandle) -> Result<PathBuf, String> {
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
if let Ok(path) = app.path().desktop_dir() {
|
if let Ok(path) = app.path().desktop_dir() {
|
||||||
return Ok(path);
|
return Ok(path);
|
||||||
}
|
}
|
||||||
@@ -175,6 +176,7 @@ fn collect_roots(app: &AppHandle) -> Vec<FileExplorerRoot> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
if let Ok(path) = app.path().desktop_dir() {
|
if let Ok(path) = app.path().desktop_dir() {
|
||||||
push_root("Desktop", path);
|
push_root("Desktop", path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
||||||
use tauri::{async_runtime::JoinHandle, AppHandle, Manager, State};
|
use tauri::{async_runtime::JoinHandle, AppHandle, Manager, State};
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
use tokio_serial::{available_ports, SerialPortBuilderExt};
|
use tokio_serial::{available_ports, SerialPortBuilderExt};
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
|
|
||||||
@@ -113,22 +114,31 @@ pub async fn shutdown_active_session(
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn serial_enum() -> Result<Vec<String>, SerialError> {
|
pub fn serial_enum() -> Result<Vec<String>, SerialError> {
|
||||||
let ports = available_ports()
|
#[cfg(target_os = "android")]
|
||||||
.map_err(|_| SerialError::ScanError)?
|
{
|
||||||
.into_iter()
|
Ok(Vec::new())
|
||||||
.filter_map(|p| {
|
}
|
||||||
let name = p.port_name;
|
|
||||||
#[cfg(unix)]
|
|
||||||
if !name.contains("USB") {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
Some(name)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
Ok(ports)
|
#[cfg(not(target_os = "android"))]
|
||||||
|
{
|
||||||
|
let ports = available_ports()
|
||||||
|
.map_err(|_| SerialError::ScanError)?
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|p| {
|
||||||
|
let name = p.port_name;
|
||||||
|
#[cfg(unix)]
|
||||||
|
if !name.contains("USB") {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(name)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
Ok(ports)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn serial_connect(
|
pub async fn serial_connect(
|
||||||
app: AppHandle,
|
app: AppHandle,
|
||||||
@@ -246,15 +256,122 @@ pub async fn serial_disconnect(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn serial_connect_fd(
|
||||||
|
app: AppHandle,
|
||||||
|
fd: i32,
|
||||||
|
device_name: String,
|
||||||
|
state: State<'_, SerialConnectionState>,
|
||||||
|
) -> Result<SerialConnectResponse, SerialError> {
|
||||||
|
if fd < 0 {
|
||||||
|
return Err(SerialError::InvalidConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let session = state.session.lock().map_err(|_| SerialError::StateError)?;
|
||||||
|
if session.is_some() {
|
||||||
|
return Err(SerialError::AlreadyConnected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let cancel = CancellationToken::new();
|
||||||
|
let current_record = Arc::new(Mutex::new(TactileARecording::new()));
|
||||||
|
let task_record = current_record.clone();
|
||||||
|
let task_cancel = cancel.clone();
|
||||||
|
let task_app = app.clone();
|
||||||
|
let task_port_name = device_name.clone();
|
||||||
|
|
||||||
|
let port = crate::serial_core::raw_fd_stream::RawFdStream::new(fd)
|
||||||
|
.map_err(|_| SerialError::OpenError)?;
|
||||||
|
let session_started_at = Instant::now();
|
||||||
|
|
||||||
|
let task = tauri::async_runtime::spawn(async move {
|
||||||
|
let codec = TactileACodec::new(DEFAULT_TACTILE_COLS, DEFAULT_TACTILE_ROWS);
|
||||||
|
let handler = TactileAHandler;
|
||||||
|
let poll_mode = PollMode::Enabled(Box::new(TactileAPollRequester::new(
|
||||||
|
Duration::from_millis(DEFAULT_TACTILE_POLL_INTERVAL_MS),
|
||||||
|
DEFAULT_TACTILE_COLS,
|
||||||
|
DEFAULT_TACTILE_ROWS,
|
||||||
|
Duration::from_millis(DEFAULT_TACTILE_REPLY_TIMEOUT_MS),
|
||||||
|
)));
|
||||||
|
|
||||||
|
if let Err(error) = serial::run_serial_with_poll(
|
||||||
|
task_app.clone(),
|
||||||
|
port,
|
||||||
|
codec,
|
||||||
|
handler,
|
||||||
|
session_started_at,
|
||||||
|
task_record.clone(),
|
||||||
|
task_cancel,
|
||||||
|
poll_mode,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
eprintln!("serial task exited with error: {error}");
|
||||||
|
}
|
||||||
|
|
||||||
|
let manager = task_app.state::<SerialConnectionState>();
|
||||||
|
if let Ok(mut last_record) = manager.last_record.lock() {
|
||||||
|
*last_record = Some(task_record);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut session = match manager.session.lock() {
|
||||||
|
Ok(session) => session,
|
||||||
|
Err(_) => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
let should_clear = session
|
||||||
|
.as_ref()
|
||||||
|
.map(|current| current.port.as_str() == task_port_name.as_str())
|
||||||
|
.unwrap_or(false);
|
||||||
|
|
||||||
|
if should_clear {
|
||||||
|
session.take();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let mut session = state.session.lock().map_err(|_| SerialError::StateError)?;
|
||||||
|
if session.is_some() {
|
||||||
|
cancel.cancel();
|
||||||
|
task.abort();
|
||||||
|
return Err(SerialError::AlreadyConnected);
|
||||||
|
}
|
||||||
|
|
||||||
|
*session = Some(SerialSession {
|
||||||
|
port: device_name.clone(),
|
||||||
|
cancel,
|
||||||
|
task,
|
||||||
|
current_record,
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(SerialConnectResponse {
|
||||||
|
port: device_name,
|
||||||
|
connected: true,
|
||||||
|
message: "connected".to_string(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn serial_export_csv(
|
pub fn serial_export_csv(
|
||||||
app: AppHandle,
|
app: AppHandle,
|
||||||
state: State<'_, SerialConnectionState>,
|
state: State<'_, SerialConnectionState>,
|
||||||
) -> Result<SerialExportResponse, SerialError> {
|
) -> Result<SerialExportResponse, SerialError> {
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
let mut output_dir = match app.path().desktop_dir() {
|
let mut output_dir = match app.path().desktop_dir() {
|
||||||
Ok(path) => path,
|
Ok(path) => path,
|
||||||
Err(_) => std::env::current_dir().map_err(|_| SerialError::ExportError)?,
|
Err(_) => std::env::current_dir().map_err(|_| SerialError::ExportError)?,
|
||||||
};
|
};
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
let mut output_dir = match app.path().download_dir() {
|
||||||
|
Ok(path) => path,
|
||||||
|
Err(_) => app.path().document_dir()
|
||||||
|
.or_else(|_| app.path().home_dir())
|
||||||
|
.or_else(|_| std::env::current_dir())
|
||||||
|
.map_err(|_| SerialError::ExportError)?,
|
||||||
|
};
|
||||||
|
|
||||||
let timestamp = SystemTime::now()
|
let timestamp = SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
|
|||||||
@@ -9,20 +9,36 @@ fn main_window(app: &AppHandle) -> Result<WebviewWindow, String> {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn win_minimize(app: AppHandle) -> Result<(), String> {
|
pub fn win_minimize(app: AppHandle) -> Result<(), String> {
|
||||||
main_window(&app)?
|
#[cfg(not(target_os = "android"))]
|
||||||
.minimize()
|
{
|
||||||
.map_err(|error| error.to_string())
|
main_window(&app)?
|
||||||
|
.minimize()
|
||||||
|
.map_err(|error| error.to_string())
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
{
|
||||||
|
let _ = app;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn win_toggle_maximize(app: AppHandle) -> Result<(), String> {
|
pub fn win_toggle_maximize(app: AppHandle) -> Result<(), String> {
|
||||||
let window = main_window(&app)?;
|
#[cfg(not(target_os = "android"))]
|
||||||
let is_maximized = window.is_maximized().map_err(|error| error.to_string())?;
|
{
|
||||||
|
let window = main_window(&app)?;
|
||||||
|
let is_maximized = window.is_maximized().map_err(|error| error.to_string())?;
|
||||||
|
|
||||||
if is_maximized {
|
if is_maximized {
|
||||||
window.unmaximize().map_err(|error| error.to_string())
|
window.unmaximize().map_err(|error| error.to_string())
|
||||||
} else {
|
} else {
|
||||||
window.maximize().map_err(|error| error.to_string())
|
window.maximize().map_err(|error| error.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
{
|
||||||
|
let _ = app;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,16 @@ use commands::serial::SerialConnectionState;
|
|||||||
#[cfg(feature = "devkit")]
|
#[cfg(feature = "devkit")]
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
fn usb_serial_plugin<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||||
|
tauri::plugin::Builder::new("usb-serial")
|
||||||
|
.setup(|_app, api| {
|
||||||
|
api.register_android_plugin("com.lenn.tauri_serial", "UsbSerialPlugin")?;
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "devkit")]
|
#[cfg(feature = "devkit")]
|
||||||
fn start_server_exe(exe_path: &std::path::Path) {
|
fn start_server_exe(exe_path: &std::path::Path) {
|
||||||
let mut command = std::process::Command::new(exe_path);
|
let mut command = std::process::Command::new(exe_path);
|
||||||
@@ -66,6 +76,9 @@ pub fn run() {
|
|||||||
.manage(SerialConnectionState::default())
|
.manage(SerialConnectionState::default())
|
||||||
.plugin(tauri_plugin_opener::init());
|
.plugin(tauri_plugin_opener::init());
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
let builder = builder.plugin(usb_serial_plugin());
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
let builder = builder.plugin(tauri_plugin_updater::Builder::new().build());
|
let builder = builder.plugin(tauri_plugin_updater::Builder::new().build());
|
||||||
|
|
||||||
@@ -135,7 +148,7 @@ pub fn run() {
|
|||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "devkit")]
|
#[cfg(all(feature = "devkit", not(target_os = "android")))]
|
||||||
let builder = builder.invoke_handler(tauri::generate_handler![
|
let builder = builder.invoke_handler(tauri::generate_handler![
|
||||||
commands::file_explorer::file_explorer_list,
|
commands::file_explorer::file_explorer_list,
|
||||||
commands::serial::serial_enum,
|
commands::serial::serial_enum,
|
||||||
@@ -157,7 +170,7 @@ pub fn run() {
|
|||||||
commands::devkit::devkit_process_export
|
commands::devkit::devkit_process_export
|
||||||
]);
|
]);
|
||||||
|
|
||||||
#[cfg(not(feature = "devkit"))]
|
#[cfg(all(not(feature = "devkit"), not(target_os = "android")))]
|
||||||
let builder = builder.invoke_handler(tauri::generate_handler![
|
let builder = builder.invoke_handler(tauri::generate_handler![
|
||||||
commands::file_explorer::file_explorer_list,
|
commands::file_explorer::file_explorer_list,
|
||||||
commands::serial::serial_enum,
|
commands::serial::serial_enum,
|
||||||
@@ -173,6 +186,44 @@ pub fn run() {
|
|||||||
commands::window::win_close
|
commands::window::win_close
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
#[cfg(all(feature = "devkit", target_os = "android"))]
|
||||||
|
let builder = builder.invoke_handler(tauri::generate_handler![
|
||||||
|
commands::file_explorer::file_explorer_list,
|
||||||
|
commands::serial::serial_enum,
|
||||||
|
commands::serial::serial_connect_fd,
|
||||||
|
commands::serial::serial_disconnect,
|
||||||
|
commands::serial::serial_export_csv,
|
||||||
|
commands::serial::serial_has_record_data,
|
||||||
|
commands::serial::serial_export_csv_to_path,
|
||||||
|
commands::serial::serial_import_csv,
|
||||||
|
commands::serial::serial_import_csv_from_path,
|
||||||
|
commands::window::win_minimize,
|
||||||
|
commands::window::win_toggle_maximize,
|
||||||
|
commands::window::win_close,
|
||||||
|
commands::devkit::devkit_status,
|
||||||
|
commands::devkit::devkit_start,
|
||||||
|
commands::devkit::devkit_stop,
|
||||||
|
commands::devkit::devkit_get_config,
|
||||||
|
commands::devkit::devkit_set_config,
|
||||||
|
commands::devkit::devkit_process_export
|
||||||
|
]);
|
||||||
|
|
||||||
|
#[cfg(all(not(feature = "devkit"), target_os = "android"))]
|
||||||
|
let builder = builder.invoke_handler(tauri::generate_handler![
|
||||||
|
commands::file_explorer::file_explorer_list,
|
||||||
|
commands::serial::serial_enum,
|
||||||
|
commands::serial::serial_connect_fd,
|
||||||
|
commands::serial::serial_disconnect,
|
||||||
|
commands::serial::serial_export_csv,
|
||||||
|
commands::serial::serial_has_record_data,
|
||||||
|
commands::serial::serial_export_csv_to_path,
|
||||||
|
commands::serial::serial_import_csv,
|
||||||
|
commands::serial::serial_import_csv_from_path,
|
||||||
|
commands::window::win_minimize,
|
||||||
|
commands::window::win_toggle_maximize,
|
||||||
|
commands::window::win_close
|
||||||
|
]);
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ pub mod model;
|
|||||||
pub mod serial;
|
pub mod serial;
|
||||||
pub mod record;
|
pub mod record;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
pub mod raw_fd_stream;
|
||||||
#[cfg(feature = "multi-dim")]
|
#[cfg(feature = "multi-dim")]
|
||||||
pub mod multi_dim_force;
|
pub mod multi_dim_force;
|
||||||
|
|
||||||
|
|||||||
127
src-tauri/src/serial_core/raw_fd_stream.rs
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
use std::io;
|
||||||
|
use std::os::unix::io::RawFd;
|
||||||
|
use tokio::io::unix::AsyncFd;
|
||||||
|
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
|
|
||||||
|
/// A wrapper around a raw file descriptor that implements AsyncRead + AsyncWrite.
|
||||||
|
/// Uses tokio's AsyncFd to properly integrate with the async reactor.
|
||||||
|
/// Used on Android to wrap USB device file descriptors obtained from the USB Host API.
|
||||||
|
pub struct RawFdStream {
|
||||||
|
inner: AsyncFd<RawFd>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RawFdStream {
|
||||||
|
pub fn new(fd: RawFd) -> io::Result<Self> {
|
||||||
|
if fd < 0 {
|
||||||
|
return Err(io::Error::new(io::ErrorKind::InvalidInput, "invalid fd"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set non-blocking
|
||||||
|
unsafe {
|
||||||
|
let flags = libc::fcntl(fd, libc::F_GETFL);
|
||||||
|
if flags < 0 {
|
||||||
|
return Err(io::Error::last_os_error());
|
||||||
|
}
|
||||||
|
if libc::fcntl(fd, libc::F_SETFL, flags | libc::O_NONBLOCK) < 0 {
|
||||||
|
return Err(io::Error::last_os_error());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let inner = AsyncFd::new(fd)?;
|
||||||
|
Ok(Self { inner })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for RawFdStream {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
unsafe {
|
||||||
|
libc::close(*self.inner.get_ref());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsyncRead for RawFdStream {
|
||||||
|
fn poll_read(
|
||||||
|
self: std::pin::Pin<&mut Self>,
|
||||||
|
cx: &mut std::task::Context<'_>,
|
||||||
|
buf: &mut ReadBuf<'_>,
|
||||||
|
) -> std::task::Poll<io::Result<()>> {
|
||||||
|
loop {
|
||||||
|
let mut guard = match self.inner.poll_read_ready(cx) {
|
||||||
|
std::task::Poll::Ready(Ok(guard)) => guard,
|
||||||
|
std::task::Poll::Ready(Err(e)) => return std::task::Poll::Ready(Err(e)),
|
||||||
|
std::task::Poll::Pending => return std::task::Poll::Pending,
|
||||||
|
};
|
||||||
|
|
||||||
|
let unfilled = buf.initialize_unfilled();
|
||||||
|
let result = unsafe {
|
||||||
|
libc::read(
|
||||||
|
*self.inner.get_ref(),
|
||||||
|
unfilled.as_mut_ptr() as *mut libc::c_void,
|
||||||
|
unfilled.len(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
if result < 0 {
|
||||||
|
let err = io::Error::last_os_error();
|
||||||
|
if err.kind() == io::ErrorKind::WouldBlock {
|
||||||
|
guard.clear_ready();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return std::task::Poll::Ready(Err(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
buf.advance(result as usize);
|
||||||
|
return std::task::Poll::Ready(Ok(()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsyncWrite for RawFdStream {
|
||||||
|
fn poll_write(
|
||||||
|
self: std::pin::Pin<&mut Self>,
|
||||||
|
cx: &mut std::task::Context<'_>,
|
||||||
|
buf: &[u8],
|
||||||
|
) -> std::task::Poll<io::Result<usize>> {
|
||||||
|
loop {
|
||||||
|
let mut guard = match self.inner.poll_write_ready(cx) {
|
||||||
|
std::task::Poll::Ready(Ok(guard)) => guard,
|
||||||
|
std::task::Poll::Ready(Err(e)) => return std::task::Poll::Ready(Err(e)),
|
||||||
|
std::task::Poll::Pending => return std::task::Poll::Pending,
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = unsafe {
|
||||||
|
libc::write(
|
||||||
|
*self.inner.get_ref(),
|
||||||
|
buf.as_ptr() as *const libc::c_void,
|
||||||
|
buf.len(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
if result < 0 {
|
||||||
|
let err = io::Error::last_os_error();
|
||||||
|
if err.kind() == io::ErrorKind::WouldBlock {
|
||||||
|
guard.clear_ready();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return std::task::Poll::Ready(Err(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::task::Poll::Ready(Ok(result as usize));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn poll_flush(
|
||||||
|
self: std::pin::Pin<&mut Self>,
|
||||||
|
_cx: &mut std::task::Context<'_>,
|
||||||
|
) -> std::task::Poll<io::Result<()>> {
|
||||||
|
std::task::Poll::Ready(Ok(()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn poll_shutdown(
|
||||||
|
self: std::pin::Pin<&mut Self>,
|
||||||
|
_cx: &mut std::task::Context<'_>,
|
||||||
|
) -> std::task::Poll<io::Result<()>> {
|
||||||
|
std::task::Poll::Ready(Ok(()))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,8 +18,9 @@ use std::time::Instant;
|
|||||||
use tauri::{AppHandle, Emitter};
|
use tauri::{AppHandle, Emitter};
|
||||||
#[cfg(feature = "devkit")]
|
#[cfg(feature = "devkit")]
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
||||||
use tokio::time::{self, Duration, MissedTickBehavior};
|
use tokio::time::{self, Duration, MissedTickBehavior};
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
use tokio_serial::SerialStream;
|
use tokio_serial::SerialStream;
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
|
|
||||||
@@ -171,6 +172,7 @@ impl PollRequester<TactileAFrame> for TactileAPollRequester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
pub async fn run_serial<C, H, T, F>(
|
pub async fn run_serial<C, H, T, F>(
|
||||||
app: AppHandle,
|
app: AppHandle,
|
||||||
port: SerialStream,
|
port: SerialStream,
|
||||||
@@ -201,7 +203,7 @@ where
|
|||||||
|
|
||||||
pub async fn run_serial_with_poll<C, H, T, F>(
|
pub async fn run_serial_with_poll<C, H, T, F>(
|
||||||
app: AppHandle,
|
app: AppHandle,
|
||||||
mut port: SerialStream,
|
mut port: impl AsyncRead + AsyncWrite + Unpin,
|
||||||
mut codec: C,
|
mut codec: C,
|
||||||
mut handler: H,
|
mut handler: H,
|
||||||
session_started_at: Instant,
|
session_started_at: Instant,
|
||||||
|
|||||||
@@ -45,15 +45,5 @@
|
|||||||
"resources/je-skin-devkit-server.exe"
|
"resources/je-skin-devkit-server.exe"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"plugins": {
|
"plugins": {}
|
||||||
"updater": {
|
|
||||||
"windows": {
|
|
||||||
"installMode": "passive"
|
|
||||||
},
|
|
||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDkwODM1QkFEODI2NkZENgpSV1RXYnliWXVqVUlDUVRxbjlseDNDNjhQTGpDYis4TEZMeUk2WVhiMEhTRWJhN3hGRnQ3TTJtcwo=",
|
|
||||||
"endpoints": [
|
|
||||||
"https://je-skin.cn-nb1.rains3.com/latest.json"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -460,6 +460,12 @@
|
|||||||
color: rgb(var(--hud-orange-rgb) / 0.96);
|
color: rgb(var(--hud-orange-rgb) / 0.96);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.window-controls {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.control-bar {
|
.control-bar {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 0.45rem;
|
gap: 0.45rem;
|
||||||
|
|||||||
@@ -200,7 +200,6 @@
|
|||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateX(var(--offset-x)) scale(0.98) rotate(-0.6deg);
|
transform: translateX(var(--offset-x)) scale(0.98) rotate(-0.6deg);
|
||||||
filter: blur(1.3px);
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
transition-delay: 0ms;
|
transition-delay: 0ms;
|
||||||
}
|
}
|
||||||
@@ -302,6 +301,7 @@
|
|||||||
stroke-linecap: round;
|
stroke-linecap: round;
|
||||||
stroke-linejoin: round;
|
stroke-linejoin: round;
|
||||||
filter: drop-shadow(0 0 2px rgb(0 0 0 / 0.42));
|
filter: drop-shadow(0 0 2px rgb(0 0 0 / 0.42));
|
||||||
|
will-change: d;
|
||||||
}
|
}
|
||||||
|
|
||||||
.series-line.tone-cyan {
|
.series-line.tone-cyan {
|
||||||
@@ -397,6 +397,10 @@
|
|||||||
aspect-ratio: 1.5 / 1;
|
aspect-ratio: 1.5 / 1;
|
||||||
min-block-size: 10.1rem;
|
min-block-size: 10.1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chart-stage {
|
||||||
|
block-size: clamp(5.7rem, 7.6vw, 6.9rem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-height: 900px) {
|
@media (max-height: 900px) {
|
||||||
@@ -452,6 +456,21 @@
|
|||||||
inline-size: 100%;
|
inline-size: 100%;
|
||||||
aspect-ratio: 1.7 / 1;
|
aspect-ratio: 1.7 / 1;
|
||||||
min-block-size: 0;
|
min-block-size: 0;
|
||||||
|
background: linear-gradient(160deg, rgb(var(--hud-surface-alt-rgb) / 0.86) 0%, rgb(var(--hud-surface-deep-rgb) / 0.9) 100%);
|
||||||
|
box-shadow: inset 0 0 0 1px rgb(var(--hud-border-strong-rgb) / 0.08), 0 0 8px rgb(var(--hud-glow-rgb) / 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.series-line {
|
||||||
|
filter: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scan-haze {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-stage {
|
||||||
|
background: linear-gradient(180deg, rgb(var(--hud-surface-alt-rgb) / 0.78), rgb(var(--hud-surface-deep-rgb) / 0.88));
|
||||||
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -637,6 +637,20 @@
|
|||||||
@media (max-width: 900px) {
|
@media (max-width: 900px) {
|
||||||
.signal-panel {
|
.signal-panel {
|
||||||
inline-size: 100%;
|
inline-size: 100%;
|
||||||
|
background: linear-gradient(160deg, rgb(var(--hud-surface-alt-rgb) / 0.86) 0%, rgb(var(--hud-surface-deep-rgb) / 0.9) 100%);
|
||||||
|
box-shadow: inset 0 0 0 1px rgb(var(--hud-border-strong-rgb) / 0.08), 0 0 8px rgb(var(--hud-glow-rgb) / 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-line {
|
||||||
|
filter: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-dot {
|
||||||
|
filter: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-stage {
|
||||||
|
background: linear-gradient(180deg, rgb(var(--hud-surface-alt-rgb) / 0.78), rgb(var(--hud-surface-deep-rgb) / 0.88));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -44,6 +44,29 @@
|
|||||||
dtsMs: number;
|
dtsMs: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface AndroidUsbSerialDevice {
|
||||||
|
name: string;
|
||||||
|
vendorId: number;
|
||||||
|
productId: number;
|
||||||
|
manufacturer: string;
|
||||||
|
product: string;
|
||||||
|
serial: string;
|
||||||
|
hasPermission: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AndroidUsbSerialListResult {
|
||||||
|
devices: AndroidUsbSerialDevice[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AndroidUsbSerialOpenResult {
|
||||||
|
fd: number;
|
||||||
|
name: string;
|
||||||
|
vendorId: number;
|
||||||
|
productId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
type AndroidUsbSerialCommand = "list" | "open" | "close";
|
||||||
|
|
||||||
const copyByLocale: Record<LocaleCode, HudCopy> = {
|
const copyByLocale: Record<LocaleCode, HudCopy> = {
|
||||||
"zh-CN": {
|
"zh-CN": {
|
||||||
appName: "JE-Skin",
|
appName: "JE-Skin",
|
||||||
@@ -203,6 +226,7 @@
|
|||||||
let connectionState: ConnectionState = "offline";
|
let connectionState: ConnectionState = "offline";
|
||||||
let serialPortValue = "COM14";
|
let serialPortValue = "COM14";
|
||||||
let serialPortOptions = ["COM4", "COM9", "COM14", "COM16"];
|
let serialPortOptions = ["COM4", "COM9", "COM14", "COM16"];
|
||||||
|
let androidUsbSerialDevices: AndroidUsbSerialDevice[] = [];
|
||||||
let isRefreshingPorts = false;
|
let isRefreshingPorts = false;
|
||||||
let connectionNotice = "";
|
let connectionNotice = "";
|
||||||
let connectionNoticeTone: HudNoticeTone = "info";
|
let connectionNoticeTone: HudNoticeTone = "info";
|
||||||
@@ -287,6 +311,66 @@
|
|||||||
return typeof window !== "undefined" && "__TAURI_INTERNALS__" in window;
|
return typeof window !== "undefined" && "__TAURI_INTERNALS__" in window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAndroidRuntime(): boolean {
|
||||||
|
if (!isTauriRuntime() || typeof navigator === "undefined") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return /Android/i.test(navigator.userAgent);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatAndroidUsbSerialLabel(device: AndroidUsbSerialDevice): string {
|
||||||
|
const product = device.product || device.manufacturer || "USB Serial";
|
||||||
|
const ids = `${device.vendorId.toString(16).padStart(4, "0")}:${device.productId
|
||||||
|
.toString(16)
|
||||||
|
.padStart(4, "0")}`;
|
||||||
|
return `${product} (${ids})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findAndroidUsbSerialDevice(name: string): AndroidUsbSerialDevice | null {
|
||||||
|
return androidUsbSerialDevices.find((device) => device.name === name) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeAndroidUsbSerialDevices(value: unknown): AndroidUsbSerialDevice[] {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return value.filter((device): device is AndroidUsbSerialDevice => {
|
||||||
|
return typeof device === "object" && device !== null && typeof (device as AndroidUsbSerialDevice).name === "string";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === "object" && value !== null) {
|
||||||
|
return Object.values(value).filter((device): device is AndroidUsbSerialDevice => {
|
||||||
|
return typeof device === "object" && device !== null && typeof (device as AndroidUsbSerialDevice).name === "string";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function invokeAndroidUsbSerial<T>(
|
||||||
|
command: AndroidUsbSerialCommand,
|
||||||
|
args?: Record<string, unknown>
|
||||||
|
): Promise<T> {
|
||||||
|
const commandNames: Record<AndroidUsbSerialCommand, [string, string]> = {
|
||||||
|
list: ["usb_serial_list", "usbSerialList"],
|
||||||
|
open: ["usb_serial_open", "usbSerialOpen"],
|
||||||
|
close: ["usb_serial_close", "usbSerialClose"]
|
||||||
|
};
|
||||||
|
|
||||||
|
const [primary, fallback] = commandNames[command];
|
||||||
|
|
||||||
|
try {
|
||||||
|
return await invoke<T>(`plugin:usb-serial|${primary}`, args);
|
||||||
|
} catch (error) {
|
||||||
|
const message = String(error);
|
||||||
|
if (!message.includes("No command")) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await invoke<T>(`plugin:usb-serial|${fallback}`, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function clamp(value: number, min: number, max: number): number {
|
function clamp(value: number, min: number, max: number): number {
|
||||||
return Math.min(max, Math.max(min, value));
|
return Math.min(max, Math.max(min, value));
|
||||||
}
|
}
|
||||||
@@ -1221,6 +1305,10 @@
|
|||||||
|
|
||||||
function handlePortChange(event: CustomEvent<string>): void {
|
function handlePortChange(event: CustomEvent<string>): void {
|
||||||
serialPortValue = event.detail;
|
serialPortValue = event.detail;
|
||||||
|
if (isAndroidRuntime()) {
|
||||||
|
const selectedDevice = findAndroidUsbSerialDevice(serialPortValue);
|
||||||
|
deviceValue = selectedDevice ? formatAndroidUsbSerialLabel(selectedDevice) : "Android USB Serial";
|
||||||
|
}
|
||||||
connectionState = "offline";
|
connectionState = "offline";
|
||||||
connectionNotice = "";
|
connectionNotice = "";
|
||||||
clearHudPanels();
|
clearHudPanels();
|
||||||
@@ -1256,7 +1344,7 @@
|
|||||||
case "InvalidConfig":
|
case "InvalidConfig":
|
||||||
return "当前串口配置无效,请重新选择端口。";
|
return "当前串口配置无效,请重新选择端口。";
|
||||||
default:
|
default:
|
||||||
return "串口连接失败,请稍后重试。";
|
return `串口连接失败:${errorCode}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1277,7 +1365,7 @@
|
|||||||
case "InvalidConfig":
|
case "InvalidConfig":
|
||||||
return "The selected serial port is invalid. Choose another port.";
|
return "The selected serial port is invalid. Choose another port.";
|
||||||
default:
|
default:
|
||||||
return "Connection failed. Please try again.";
|
return `Connection failed: ${errorCode}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1288,14 +1376,16 @@
|
|||||||
const errorCode = normalizeInvokeError(error);
|
const errorCode = normalizeInvokeError(error);
|
||||||
|
|
||||||
if (locale === "zh-CN") {
|
if (locale === "zh-CN") {
|
||||||
return errorCode === "ScanError"
|
if (errorCode === "ScanError") {
|
||||||
? "串口列表刷新失败,请确认系统串口服务正常。"
|
return "串口列表刷新失败,请确认系统串口服务正常。";
|
||||||
: "刷新串口列表失败,请稍后重试。";
|
}
|
||||||
|
|
||||||
|
return `刷新串口列表失败:${errorCode}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return errorCode === "ScanError"
|
return errorCode === "ScanError"
|
||||||
? "Refreshing serial ports failed. Check whether the OS serial service is available."
|
? "Refreshing serial ports failed. Check whether the OS serial service is available."
|
||||||
: "Refreshing serial ports failed. Please try again.";
|
: `Refreshing serial ports failed: ${errorCode}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveExportNotice(error: unknown): string {
|
function resolveExportNotice(error: unknown): string {
|
||||||
@@ -1350,6 +1440,33 @@
|
|||||||
isRefreshingPorts = true;
|
isRefreshingPorts = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
try {
|
||||||
|
const result = await invokeAndroidUsbSerial<AndroidUsbSerialListResult>("list");
|
||||||
|
androidUsbSerialDevices = normalizeAndroidUsbSerialDevices(result.devices);
|
||||||
|
serialPortOptions = androidUsbSerialDevices.map((device) => device.name);
|
||||||
|
|
||||||
|
if (serialPortOptions.includes(serialPortValue)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
serialPortValue = serialPortOptions[0] ?? "";
|
||||||
|
const selectedDevice = findAndroidUsbSerialDevice(serialPortValue);
|
||||||
|
deviceValue = selectedDevice ? formatAndroidUsbSerialLabel(selectedDevice) : "Android USB Serial";
|
||||||
|
|
||||||
|
if (!serialPortValue) {
|
||||||
|
connectionState = "offline";
|
||||||
|
clearHudPanels();
|
||||||
|
connectionNotice =
|
||||||
|
locale === "zh-CN" ? "未发现 USB 串口设备,请确认已通过 OTG 接入设备。" : "No USB serial device found.";
|
||||||
|
connectionNoticeTone = "warn";
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} catch (androidError) {
|
||||||
|
if (isAndroidRuntime()) {
|
||||||
|
throw androidError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ports = await invoke<string[]>("serial_enum");
|
const ports = await invoke<string[]>("serial_enum");
|
||||||
serialPortOptions = ports;
|
serialPortOptions = ports;
|
||||||
|
|
||||||
@@ -1390,7 +1507,28 @@
|
|||||||
connectionNotice = "";
|
connectionNotice = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await invoke<SerialConnectResult>("serial_connect", { port: event.detail });
|
let result: SerialConnectResult;
|
||||||
|
|
||||||
|
if (isAndroidRuntime()) {
|
||||||
|
const selectedDevice = findAndroidUsbSerialDevice(event.detail);
|
||||||
|
const opened = await invokeAndroidUsbSerial<AndroidUsbSerialOpenResult>("open", {
|
||||||
|
name: event.detail,
|
||||||
|
vendorId: selectedDevice?.vendorId,
|
||||||
|
productId: selectedDevice?.productId
|
||||||
|
});
|
||||||
|
result = await invoke<SerialConnectResult>("serial_connect_fd", {
|
||||||
|
fd: opened.fd,
|
||||||
|
deviceName: opened.name,
|
||||||
|
device_name: opened.name
|
||||||
|
});
|
||||||
|
const openedDevice = findAndroidUsbSerialDevice(opened.name) ?? selectedDevice;
|
||||||
|
deviceValue = openedDevice
|
||||||
|
? formatAndroidUsbSerialLabel(openedDevice)
|
||||||
|
: `USB Serial (${opened.vendorId.toString(16)}:${opened.productId.toString(16)})`;
|
||||||
|
} else {
|
||||||
|
result = await invoke<SerialConnectResult>("serial_connect", { port: event.detail });
|
||||||
|
}
|
||||||
|
|
||||||
connectionState = result.connected ? "online" : "offline";
|
connectionState = result.connected ? "online" : "offline";
|
||||||
serialPortValue = result.port;
|
serialPortValue = result.port;
|
||||||
connectionNotice = "";
|
connectionNotice = "";
|
||||||
@@ -1398,6 +1536,13 @@
|
|||||||
clearHudPanels();
|
clearHudPanels();
|
||||||
console.info("[serial] connect result:", result.message);
|
console.info("[serial] connect result:", result.message);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (isAndroidRuntime()) {
|
||||||
|
try {
|
||||||
|
await invokeAndroidUsbSerial("close");
|
||||||
|
} catch (closeError) {
|
||||||
|
console.warn("USB serial close after failed connect failed:", closeError);
|
||||||
|
}
|
||||||
|
}
|
||||||
connectionState = "offline";
|
connectionState = "offline";
|
||||||
connectionNotice = resolveSerialNotice(error, "connect");
|
connectionNotice = resolveSerialNotice(error, "connect");
|
||||||
connectionNoticeTone = "warn";
|
connectionNoticeTone = "warn";
|
||||||
@@ -1409,6 +1554,9 @@
|
|||||||
async function handleSerialDisconnect(): Promise<void> {
|
async function handleSerialDisconnect(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const result = await invoke<SerialConnectResult>("serial_disconnect");
|
const result = await invoke<SerialConnectResult>("serial_disconnect");
|
||||||
|
if (isAndroidRuntime()) {
|
||||||
|
await invokeAndroidUsbSerial("close");
|
||||||
|
}
|
||||||
connectionState = result.connected ? "online" : "offline";
|
connectionState = result.connected ? "online" : "offline";
|
||||||
connectionNotice = "";
|
connectionNotice = "";
|
||||||
connectionNoticeTone = "info";
|
connectionNoticeTone = "info";
|
||||||
@@ -2014,6 +2162,27 @@
|
|||||||
mix-blend-mode: soft-light;
|
mix-blend-mode: soft-light;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.hud-noise {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hud-vignette {
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hud-gradient {
|
||||||
|
background:
|
||||||
|
linear-gradient(170deg, var(--hud-bg-20) 0%, var(--hud-bg-10) 56%, var(--hud-bg-30) 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hud-layout {
|
||||||
|
gap: clamp(0.3rem, 1vw, 0.6rem);
|
||||||
|
padding: clamp(0.4rem, 1.2vw, 0.8rem);
|
||||||
|
box-shadow: inset 0 -12px 24px rgb(0 0 0 / 0.24);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.hud-layout {
|
.hud-layout {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|||||||