Skip to content

Commit

Permalink
Fix openCamera 感谢 @bad-copy 对此项目的贡献
Browse files Browse the repository at this point in the history
  • Loading branch information
w2016561536 committed Aug 24, 2021
1 parent 76645af commit 7d20a69
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 69 deletions.
Binary file modified app/release/app-release.apk
Binary file not shown.
71 changes: 2 additions & 69 deletions app/src/main/java/com/example/vcam/HookMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public class HookMain implements IXposedHookLoadPackage {
public static MediaPlayer c2_player;
public static CaptureRequest.Builder c2_builder;
public static ImageReader c2_image_reader;
public static CaptureRequest.Builder c2_real_builder;

public static Class c2_state_callback;

Expand Down Expand Up @@ -151,7 +150,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
});
}
/*

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
XposedHelpers.findAndHookMethod("android.hardware.camera2.CaptureRequest.Builder", lpparam.classLoader, "addTarget", Surface.class, new XC_MethodHook() {
@SuppressLint("SdCardPath")
Expand Down Expand Up @@ -180,7 +179,6 @@ protected void beforeHookedMethod(MethodHookParam param) {
}

param.args[0] = HookMain.c2_image_reader.getSurface();
XposedBridge.log("target的:reader"+HookMain.c2_image_reader.toString()+" Surface:"+ HookMain.c2_image_reader.getSurface().toString());

if (HookMain.c2_player == null) {
HookMain.c2_player = new MediaPlayer();
Expand Down Expand Up @@ -209,7 +207,7 @@ public void onPrepared(MediaPlayer mp) {
}
});
}
*/


XposedHelpers.findAndHookMethod("android.hardware.Camera", lpparam.classLoader, "setPreviewCallbackWithBuffer", Camera.PreviewCallback.class, new XC_MethodHook() {
@SuppressLint("SdCardPath")
Expand Down Expand Up @@ -284,74 +282,9 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
HookMain.c2_image_reader = ImageReader.newInstance(1280, 720, ImageFormat.YUV_420_888, 5);
}
param.args[0] = Arrays.asList(HookMain.c2_image_reader.getSurface());
XposedBridge.log("configer的:reader"+HookMain.c2_image_reader.toString()+" Surface:"+ HookMain.c2_image_reader.getSurface().toString());
XposedBridge.log("成功HOOK摄像头启动");
}
});

XposedHelpers.findAndHookMethod(param.args[0].getClass(), "createCaptureRequest", int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
c2_real_builder = (CaptureRequest.Builder)param.getResult();

XposedHelpers.findAndHookMethod(c2_real_builder.getClass(), "addTarget", Surface.class, new XC_MethodHook() {
@SuppressLint("SdCardPath")
@Override
protected void beforeHookedMethod(MethodHookParam param) {
File file = new File("/sdcard/DCIM/Camera/virtual.mp4");
if (!file.exists()) {
return;
}
File control_file = new File("/sdcard/DCIM/disable.jpg");
if (control_file.exists()){
return;
}
if (HookMain.c2_builder != null && HookMain.c2_builder.equals(param.thisObject)) {
param.args[0] = HookMain.c2_image_reader.getSurface();
XposedBridge.log("发现重复" + HookMain.c2_builder.toString());
return;
} else {
XposedBridge.log("创建C2预览" );
}
HookMain.c2_builder = (CaptureRequest.Builder) param.thisObject;
HookMain.c2_ori_Surf = (Surface) param.args[0];

if (HookMain.c2_image_reader == null) {
HookMain.c2_image_reader = ImageReader.newInstance(1280, 720, ImageFormat.YUV_420_888, 5);
}

param.args[0] = HookMain.c2_image_reader.getSurface();
XposedBridge.log("target的:reader"+HookMain.c2_image_reader.toString()+" Surface:"+ HookMain.c2_image_reader.getSurface().toString());

if (HookMain.c2_player == null) {
HookMain.c2_player = new MediaPlayer();
} else {
HookMain.c2_player.release();
HookMain.c2_player = new MediaPlayer();
}

HookMain.c2_player.setSurface(HookMain.c2_ori_Surf);
HookMain.c2_player.setVolume(0, 0);
HookMain.c2_player.setLooping(true);

HookMain.c2_player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
HookMain.c2_player.start();
}
});
try {
HookMain.c2_player.setDataSource("/sdcard/DCIM/Camera/virtual.mp4");
HookMain.c2_player.prepare();
} catch (IOException e) {
e.printStackTrace();
}


}
});

}
});
}

});
Expand Down

0 comments on commit 7d20a69

Please sign in to comment.