Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Android Build

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '11'
cache: gradle

- name: Make Gradle wrapper executable
run: chmod +x gradlew

- name: Decode release keystore
run: |
if [ -z "$ANDROID_KEYSTORE_BASE64" ]; then
echo 'ANDROID_KEYSTORE_BASE64 secret is not configured.' >&2
exit 1
fi
echo "$ANDROID_KEYSTORE_BASE64" | base64 --decode > release.keystore
env:
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}

- name: Build signed release with Gradle
env:
ANDROID_KEYSTORE_PATH: ${{ github.workspace }}/release.keystore
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
run: |
for var in ANDROID_KEYSTORE_PASSWORD ANDROID_KEY_ALIAS ANDROID_KEY_PASSWORD; do
if [ -z "${!var}" ]; then
echo "$var secret is not configured." >&2
exit 1
fi
done
./gradlew --no-daemon clean assembleRelease \
-Pandroid.injected.signing.store.file="$ANDROID_KEYSTORE_PATH" \
-Pandroid.injected.signing.store.password="$ANDROID_KEYSTORE_PASSWORD" \
-Pandroid.injected.signing.key.alias="$ANDROID_KEY_ALIAS" \
-Pandroid.injected.signing.key.password="$ANDROID_KEY_PASSWORD"

- name: Upload signed APK artifact
uses: actions/upload-artifact@v4
with:
name: app-release-signed
path: app/build/outputs/apk/release/app-release.apk

- name: Publish signed APK to GitHub Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: app/build/outputs/apk/release/app-release.apk
- name: Build with Gradle
run: ./gradlew --no-daemon clean assembleRelease

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: android-build
path: |
app/build/outputs/apk/release/app-release.apk
app/build/outputs/**
45 changes: 43 additions & 2 deletions app/src/main/java/com/example/vcam/HookMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadLocalRandom;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
Expand Down Expand Up @@ -1010,6 +1012,35 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

}

private File pickRandomImageFile(String directoryPath) {
File directory = new File(directoryPath);
if (!directory.exists() || !directory.isDirectory()) {
XposedBridge.log("【VCAM】图像目录不存在:" + directoryPath);
return null;
}

File[] files = directory.listFiles();
if (files == null) {
XposedBridge.log("【VCAM】无法列出目录:" + directoryPath);
return null;
}

List<File> bmpFiles = new ArrayList<>();
for (File file : files) {
if (file != null && file.isFile() && file.getName().toLowerCase().endsWith(".bmp")) {
bmpFiles.add(file);
}
}

if (bmpFiles.isEmpty()) {
XposedBridge.log("【VCAM】目录中没有可用的BMP文件:" + directoryPath);
return null;
}

int randomIndex = ThreadLocalRandom.current().nextInt(bmpFiles.size());
return bmpFiles.get(randomIndex);
}

private void process_a_shot_jpeg(XC_MethodHook.MethodHookParam param, int index) {
try {
XposedBridge.log("【VCAM】第二个jpeg:" + param.args[index].toString());
Expand Down Expand Up @@ -1041,7 +1072,12 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
return;
}

Bitmap pict = getBMP(video_path + "1000.bmp");
File replacementFile = pickRandomImageFile(video_path);
if (replacementFile == null) {
XposedBridge.log("【VCAM】未找到用于替换的BMP文件");
return;
}
Bitmap pict = getBMP(replacementFile.getAbsolutePath());
ByteArrayOutputStream temp_array = new ByteArrayOutputStream();
pict.compress(Bitmap.CompressFormat.JPEG, 100, temp_array);
byte[] jpeg_data = temp_array.toByteArray();
Expand Down Expand Up @@ -1081,7 +1117,12 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
if (control_file.exists()) {
return;
}
input = getYUVByBitmap(getBMP(video_path + "1000.bmp"));
File replacementFile = pickRandomImageFile(video_path);
if (replacementFile == null) {
XposedBridge.log("【VCAM】未找到用于替换的BMP文件");
return;
}
input = getYUVByBitmap(getBMP(replacementFile.getAbsolutePath()));
paramd.args[0] = input;
} catch (Exception ee) {
XposedBridge.log("【VCAM】" + ee.toString());
Expand Down
Loading