Skip to content

Commit 1238375

Browse files
author
butlanys
committed
feat(init): 初始化 Open-AutoGLM-Android 项目结构
提交包含了基础的 Android 工程文件和构建配置: - 添加 app 模块及源代码目录 - 配置 Gradle 构建脚本 (Kotlin DSL) - 添加 .gitignore、README.md 和 GitHub 配置 - 设置 Gradle Wrapper 环境
0 parents  commit 1238375

49 files changed

Lines changed: 3626 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Release version (e.g., 1.0.0)'
11+
required: false
12+
default: ''
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up JDK 17
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: '17'
26+
distribution: 'temurin'
27+
cache: gradle
28+
29+
- name: Grant execute permission for gradlew
30+
run: chmod +x gradlew
31+
32+
- name: Build Release APK
33+
run: ./gradlew assembleRelease --no-daemon
34+
35+
- name: Build Debug APK
36+
run: ./gradlew assembleDebug --no-daemon
37+
38+
- name: Get version name
39+
id: version
40+
run: |
41+
if [ -n "${{ github.event.inputs.version }}" ]; then
42+
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
43+
elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then
44+
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
45+
else
46+
echo "VERSION=$(date +'%Y%m%d')-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
47+
fi
48+
49+
- name: Rename APKs
50+
run: |
51+
mv app/build/outputs/apk/release/app-release-unsigned.apk app/build/outputs/apk/release/Open-AutoGLM-Android-${{ steps.version.outputs.VERSION }}-release.apk || true
52+
mv app/build/outputs/apk/release/app-release.apk app/build/outputs/apk/release/Open-AutoGLM-Android-${{ steps.version.outputs.VERSION }}-release.apk || true
53+
mv app/build/outputs/apk/debug/app-debug.apk app/build/outputs/apk/debug/Open-AutoGLM-Android-${{ steps.version.outputs.VERSION }}-debug.apk
54+
55+
- name: Upload Release APK
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: release-apk
59+
path: app/build/outputs/apk/release/*.apk
60+
61+
- name: Upload Debug APK
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: debug-apk
65+
path: app/build/outputs/apk/debug/*.apk
66+
67+
- name: Create Release
68+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
69+
uses: softprops/action-gh-release@v2
70+
with:
71+
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || format('v{0}', steps.version.outputs.VERSION) }}
72+
name: Release ${{ steps.version.outputs.VERSION }}
73+
body: |
74+
## Open-AutoGLM Android v${{ steps.version.outputs.VERSION }}
75+
76+
### 下载
77+
- **release**: 正式版本(需要自行签名或使用 debug 版本)
78+
- **debug**: 调试版本(可直接安装)
79+
80+
### 安装要求
81+
- Android 8.0 (API 26) 或更高版本
82+
- [Shizuku](https://shizuku.rikka.app/) 已安装并运行
83+
84+
### 更新日志
85+
- 请查看 [commits](https://github.com/${{ github.repository }}/commits/${{ github.sha }})
86+
files: |
87+
app/build/outputs/apk/release/*.apk
88+
app/build/outputs/apk/debug/*.apk
89+
draft: false
90+
prerelease: ${{ contains(steps.version.outputs.VERSION, 'alpha') || contains(steps.version.outputs.VERSION, 'beta') }}
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Built application files
2+
*.apk
3+
*.ap_
4+
*.aab
5+
6+
# Files for the ART/Dalvik VM
7+
*.dex
8+
9+
# Java class files
10+
*.class
11+
12+
# Generated files
13+
bin/
14+
gen/
15+
out/
16+
17+
# Gradle files
18+
.gradle/
19+
build/
20+
**/build/
21+
22+
# Local configuration file
23+
local.properties
24+
25+
# Android Studio
26+
*.iml
27+
.idea/
28+
.idea
29+
captures/
30+
.externalNativeBuild/
31+
.cxx/
32+
33+
# Signing files
34+
*.jks
35+
*.keystore
36+
keystore.properties
37+
38+
# Log files
39+
*.log
40+
41+
# OS generated files
42+
.DS_Store
43+
.DS_Store?
44+
._*
45+
.Spotlight-V100
46+
.Trashes
47+
ehthumbs.db
48+
Thumbs.db
49+
50+
# Kotlin
51+
.kotlin/
52+
53+
# Platform tools (bundled)
54+
platform-tools/
55+
56+
# Python/Open-AutoGLM reference
57+
Open-AutoGLM/
58+
59+
# Temporary files
60+
*.tmp
61+
*.temp
62+
*.swp
63+
*~

README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Open-AutoGLM-Android
2+
3+
基于 [Open-AutoGLM](https://github.com/zai-org/Open-AutoGLM) 的 Android 原生客户端,通过 Shizuku 实现完全本地化的 AI 手机操控。
4+
5+
## 特性
6+
7+
- 📱 **纯手机端运行** - 无需电脑连接 ADB,通过 Shizuku 直接获取 shell 权限
8+
- 🎨 **Material Design 3** - 现代化 UI,支持动态取色 (Material You)
9+
- 🤖 **自定义 AI API** - 支持智谱 BigModel、ModelScope 等 OpenAI 兼容接口
10+
-**流式响应** - 实时显示 AI 思考过程
11+
- 🔒 **敏感操作确认** - 支付、删除等操作需用户确认
12+
- 🛠️ **人工接管** - 登录、验证码等场景支持人工介入
13+
14+
## 系统要求
15+
16+
- Android 8.0+ (API 26+)
17+
- [Shizuku](https://shizuku.rikka.app/) 已安装并运行
18+
- (可选) [ADB Keyboard](https://github.com/senzhk/ADBKeyBoard) 用于中文输入
19+
20+
## 安装
21+
22+
1. 下载并安装 [Shizuku](https://shizuku.rikka.app/)
23+
2. 启动 Shizuku 并授权
24+
3. 安装本应用
25+
4. 在设置页配置 API
26+
27+
## 配置 API
28+
29+
### 智谱 BigModel (推荐)
30+
31+
- **API 地址**: `https://open.bigmodel.cn/api/paas/v4`
32+
- **模型名称**: `autoglm-phone`
33+
- **API Key**: 在 [智谱开放平台](https://bigmodel.cn/) 申请
34+
35+
### ModelScope
36+
37+
- **API 地址**: `https://api-inference.modelscope.cn/v1`
38+
- **模型名称**: `ZhipuAI/AutoGLM-Phone-9B`
39+
- **API Key**: 在 [ModelScope](https://modelscope.cn/) 申请
40+
41+
## 使用方法
42+
43+
1. 确保 Shizuku 运行且已授权
44+
2. 在设置页配置 API
45+
3. 在主页输入任务,例如:
46+
- "打开微信搜索附近美食"
47+
- "打开淘宝搜索无线耳机"
48+
- "打开设置调整屏幕亮度"
49+
4. 点击开始执行
50+
51+
## 项目结构
52+
53+
```
54+
app/src/main/java/com/autoglm/android/
55+
├── action/ # Action 解析与处理
56+
│ ├── ActionParser.kt
57+
│ └── ActionHandler.kt
58+
├── agent/ # Agent 核心逻辑
59+
│ └── PhoneAgent.kt
60+
├── config/ # 配置
61+
│ ├── AppPackages.kt
62+
│ ├── SystemPrompts.kt
63+
│ └── TimingConfig.kt
64+
├── data/ # 数据持久化
65+
│ └── SettingsRepository.kt
66+
├── device/ # 设备控制
67+
│ ├── DeviceController.kt
68+
│ ├── ScreenshotService.kt
69+
│ ├── AppLauncher.kt
70+
│ ├── InputService.kt
71+
│ └── CurrentAppDetector.kt
72+
├── model/ # AI 模型客户端
73+
│ ├── ModelConfig.kt
74+
│ ├── ModelClient.kt
75+
│ └── MessageBuilder.kt
76+
├── service/ # 后台服务
77+
│ └── AgentForegroundService.kt
78+
├── shizuku/ # Shizuku 集成
79+
│ ├── ShizukuManager.kt
80+
│ └── ShizukuExecutor.kt
81+
└── ui/ # UI 界面
82+
├── AutoGLMApp.kt
83+
├── theme/Theme.kt
84+
├── home/
85+
└── settings/
86+
```
87+
88+
## 支持的操作
89+
90+
| 操作 | 说明 |
91+
|------|------|
92+
| Launch | 启动应用 |
93+
| Tap | 点击 |
94+
| Type | 输入文本 |
95+
| Swipe | 滑动 |
96+
| Back | 返回 |
97+
| Home | 回到桌面 |
98+
| Long Press | 长按 |
99+
| Double Tap | 双击 |
100+
| Wait | 等待 |
101+
| Take_over | 请求人工接管 |
102+
103+
## 构建
104+
105+
```bash
106+
./gradlew assembleDebug
107+
```
108+
109+
## 许可证
110+
111+
本项目基于 Open-AutoGLM,仅供学习研究使用。
112+
113+
## 致谢
114+
115+
- [Open-AutoGLM](https://github.com/zai-org/Open-AutoGLM)
116+
- [Shizuku](https://github.com/RikkaApps/Shizuku)

app/build.gradle.kts

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.android)
4+
alias(libs.plugins.kotlin.compose)
5+
alias(libs.plugins.kotlin.serialization)
6+
}
7+
8+
android {
9+
namespace = "com.autoglm.android"
10+
compileSdk = 35
11+
12+
defaultConfig {
13+
applicationId = "com.autoglm.android"
14+
minSdk = 26
15+
targetSdk = 35
16+
versionCode = 1
17+
versionName = "1.0.0"
18+
19+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
20+
}
21+
22+
buildTypes {
23+
release {
24+
isMinifyEnabled = true
25+
isShrinkResources = true
26+
proguardFiles(
27+
getDefaultProguardFile("proguard-android-optimize.txt"),
28+
"proguard-rules.pro"
29+
)
30+
}
31+
debug {
32+
isMinifyEnabled = false
33+
}
34+
}
35+
36+
compileOptions {
37+
sourceCompatibility = JavaVersion.VERSION_17
38+
targetCompatibility = JavaVersion.VERSION_17
39+
}
40+
41+
kotlinOptions {
42+
jvmTarget = "17"
43+
}
44+
45+
buildFeatures {
46+
compose = true
47+
buildConfig = true
48+
aidl = true
49+
}
50+
}
51+
52+
dependencies {
53+
// AndroidX Core
54+
implementation(libs.androidx.core.ktx)
55+
implementation(libs.androidx.lifecycle.runtime.ktx)
56+
implementation(libs.androidx.lifecycle.viewmodel.compose)
57+
implementation(libs.androidx.activity.compose)
58+
59+
// Compose
60+
implementation(platform(libs.androidx.compose.bom))
61+
implementation(libs.androidx.ui)
62+
implementation(libs.androidx.ui.graphics)
63+
implementation(libs.androidx.ui.tooling.preview)
64+
implementation(libs.androidx.material3)
65+
implementation(libs.androidx.material.icons.extended)
66+
implementation(libs.androidx.navigation.compose)
67+
68+
// Shizuku
69+
implementation(libs.shizuku.api)
70+
implementation(libs.shizuku.provider)
71+
72+
// Network
73+
implementation(libs.okhttp)
74+
implementation(libs.okhttp.sse)
75+
implementation(libs.kotlinx.serialization.json)
76+
77+
// DataStore
78+
implementation(libs.androidx.datastore.preferences)
79+
80+
// Coroutines
81+
implementation(libs.kotlinx.coroutines.android)
82+
83+
// Image loading
84+
implementation(libs.coil.compose)
85+
86+
// Testing
87+
testImplementation(libs.junit)
88+
androidTestImplementation(libs.androidx.junit)
89+
androidTestImplementation(libs.androidx.espresso.core)
90+
androidTestImplementation(platform(libs.androidx.compose.bom))
91+
androidTestImplementation(libs.androidx.ui.test.junit4)
92+
debugImplementation(libs.androidx.ui.tooling)
93+
debugImplementation(libs.androidx.ui.test.manifest)
94+
}

app/proguard-rules.pro

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Add project specific ProGuard rules here.
2+
3+
# Keep Shizuku
4+
-keep class rikka.shizuku.** { *; }
5+
-keep class moe.shizuku.** { *; }
6+
7+
# Keep kotlinx.serialization
8+
-keepattributes *Annotation*, InnerClasses
9+
-dontnote kotlinx.serialization.AnnotationsKt
10+
11+
-keepclassmembers class kotlinx.serialization.json.** {
12+
*** Companion;
13+
}
14+
-keepclasseswithmembers class kotlinx.serialization.json.** {
15+
kotlinx.serialization.KSerializer serializer(...);
16+
}
17+
18+
-keep,includedescriptorclasses class com.autoglm.android.**$$serializer { *; }
19+
-keepclassmembers class com.autoglm.android.** {
20+
*** Companion;
21+
}
22+
-keepclasseswithmembers class com.autoglm.android.** {
23+
kotlinx.serialization.KSerializer serializer(...);
24+
}
25+
26+
# OkHttp
27+
-dontwarn okhttp3.**
28+
-dontwarn okio.**
29+
-keep class okhttp3.** { *; }
30+
-keep interface okhttp3.** { *; }

0 commit comments

Comments
 (0)