Skip to content

Commit 68bc4d7

Browse files
committed
Merge branch 'main' of https://github.com/bmax121/APatch
2 parents 538fea5 + 9c541f9 commit 68bc4d7

29 files changed

Lines changed: 722 additions & 178 deletions

.github/scripts/telegram_url.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import sys
44
import urllib.parse
55

6-
76
url = f'https://api.telegram.org/bot{os.environ["BOT_TOKEN"]}'
87
url += f'/sendMediaGroup?chat_id={urllib.parse.quote(sys.argv[1])}&media='
98

@@ -17,8 +16,9 @@
1716
caption = f"[{commit_id}]({commit_url})\n{msg}"[:1024]
1817

1918
data = json.dumps([
20-
{"type": "document", "media": "attach://Release","caption": caption,"parse_mode":"MarkdownV2"}
21-
])
19+
{"type": "document", "media": "attach://Release1"},
20+
{"type": "document", "media": "attach://Release2", "caption": caption, "parse_mode": "MarkdownV2"}
21+
])
2222

2323
url += urllib.parse.quote(data)
2424
print(url)

.github/workflows/build.yml

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
contents: write
2929
steps:
3030
- name: Checkout
31-
uses: actions/checkout@v5
31+
uses: actions/checkout@v6
3232
with:
3333
fetch-depth: 0
3434

@@ -74,7 +74,7 @@ jobs:
7474
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
7575
echo 'android.native.buildOutput=verbose' >> gradle.properties
7676
sed -i 's/org.gradle.configuration-cache=true//g' gradle.properties
77-
./gradlew clean assembleRelease
77+
./gradlew clean assembleDebug assembleRelease
7878
echo "BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)" >> $GITHUB_ENV
7979
8080
- name: Sign Release
@@ -93,30 +93,58 @@ jobs:
9393
keyPassword: ${{ secrets.KEY_PASSWORD }}
9494
zipAlign: true
9595

96-
- name: Upload build artifact
96+
- name: Sign Debug APK
9797
env:
9898
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
99+
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
99100
if: ${{ env.SIGNING_KEY != '' }}
101+
continue-on-error: true
102+
uses: kevin-david/zipalign-sign-android-release@v2
103+
id: sign_debug_app
104+
with:
105+
releaseDirectory: app/build/outputs/apk/debug
106+
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
107+
alias: ${{ secrets.ALIAS }}
108+
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
109+
keyPassword: ${{ secrets.KEY_PASSWORD }}
110+
zipAlign: true
111+
112+
- name: Upload mappings
100113
uses: actions/upload-artifact@v5
114+
with:
115+
name: "mappings"
116+
path: "app/build/outputs/mapping/release/"
117+
118+
- name: Upload build artifact
119+
env:
120+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
121+
if: ${{ env.SIGNING_KEY != '' }}
122+
uses: actions/upload-artifact@v6
101123
with:
102124
name: APatch
103-
path: ${{steps.sign_app.outputs.signedReleaseFile}}
125+
path: |
126+
${{ steps.sign_app.outputs.signedReleaseFile }}
127+
${{ steps.sign_debug_app.outputs.signedReleaseFile }}
104128
105129
- name: Post to channel
106-
if: ${{github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag'}}
130+
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag' }}
107131
env:
108132
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
109133
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
110134
COMMIT_URL: ${{ github.event.head_commit.url }}
111135
COMMIT_ID: ${{ github.event.head_commit.id }}
112136
run: |
113-
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
114-
OUTPUT="app/build/outputs/apk/release"
115-
export Release=$(find $OUTPUT -name "*.apk")
116-
URL=$(python3 .github/scripts/telegram_url.py -1002058433411)
117-
curl -v "$URL" -F Release=@${{ steps.sign_app.outputs.signedReleaseFile }}
118-
URL=$(python3 .github/scripts/telegram_url.py -1001910818234)
119-
curl -v "$URL" -F Release=@${{ steps.sign_app.outputs.signedReleaseFile }}
137+
if [ -n "${BOT_TOKEN}" ]; then
138+
CHANNELS=(-1002058433411 -1001910818234)
139+
RELEASE_APK="${{ steps.sign_app.outputs.signedReleaseFile }}"
140+
DEBUG_APK="${{ steps.sign_debug_app.outputs.signedReleaseFile }}"
141+
142+
for CHANNEL in "${CHANNELS[@]}"; do
143+
URL=$(python3 .github/scripts/telegram_url.py $CHANNEL)
144+
if [ -f "$RELEASE_APK" ] && [ -f "$DEBUG_APK" ]; then
145+
curl -v "$URL" -F "Release1=@$RELEASE_APK" -F "Release2=@$DEBUG_APK"
146+
fi
147+
done
120148
fi
121149
122150
- name: Release apk

apd/Cargo.lock

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apd/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2024"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9+
mlua = { version = "0.11.5", features = ["lua54","vendored"] }
910
anyhow = "1"
1011
csv = "1.3.1"
1112
clap = { version = "4", features = ["derive"] }

apd/src/cli.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ enum Module {
8181
// module id
8282
id: String,
8383
},
84-
84+
/// module lua runner
85+
Lua {
86+
// module id
87+
id: String,
88+
// lua function
89+
function: String,
90+
},
8591
/// list all modules
8692
List,
8793
}
@@ -142,6 +148,9 @@ pub fn run() -> Result<()> {
142148
Module::Install { zip } => module::install_module(&zip),
143149
Module::Uninstall { id } => module::uninstall_module(&id),
144150
Module::Action { id } => module::run_action(&id),
151+
Module::Lua { id, function } => {
152+
module::run_lua(&id, &function, false, true).map_err(|e| anyhow::anyhow!("{}", e))
153+
}
145154
Module::Enable { id } => module::enable_module(&id),
146155
Module::Disable { id } => module::disable_module(&id),
147156
Module::List => module::list_modules(),

apd/src/event.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ pub fn on_post_data_fs(superkey: Option<String>) -> Result<()> {
407407
if let Err(e) = module::exec_stage_script("post-fs-data", true) {
408408
warn!("exec post-fs-data scripts failed: {}", e);
409409
}
410-
410+
if let Err(e) = module::exec_stage_lua("post-fs-data",true, superkey.as_deref().unwrap_or("")) {
411+
warn!("Failed to exec post-fs-data lua: {}", e);
412+
}
411413
// load system.prop
412414
if let Err(e) = module::load_system_prop() {
413415
warn!("load system.prop failed: {}", e);
@@ -470,8 +472,6 @@ pub fn on_post_data_fs(superkey: Option<String>) -> Result<()> {
470472
info!("remove update flag");
471473
let _ = fs::remove_file(module_update_flag);
472474

473-
474-
475475
run_stage("post-mount", superkey, true);
476476

477477
env::set_current_dir("/").with_context(|| "failed to chdir to /")?;
@@ -487,7 +487,7 @@ fn run_stage(stage: &str, superkey: Option<String>, block: bool) {
487487
return;
488488
}
489489

490-
if utils::is_safe_mode(superkey) {
490+
if utils::is_safe_mode(superkey.clone()) {
491491
warn!("safe mode, skip {stage} scripts");
492492
if let Err(e) = module::disable_all_modules() {
493493
warn!("disable all modules failed: {}", e);
@@ -501,6 +501,9 @@ fn run_stage(stage: &str, superkey: Option<String>, block: bool) {
501501
if let Err(e) = module::exec_stage_script(stage, block) {
502502
warn!("Failed to exec {stage} scripts: {e}");
503503
}
504+
if let Err(e) = module::exec_stage_lua(stage,block,superkey.as_deref().unwrap_or("")) {
505+
warn!("Failed to exec {stage} lua: {e}");
506+
}
504507
}
505508

506509
pub fn on_services(superkey: Option<String>) -> Result<()> {

0 commit comments

Comments
 (0)