diff --git a/app/build.gradle b/app/build.gradle index 8d5af72..67ce5fb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "com.example.vcam" minSdk 21 targetSdk 29 - versionCode 20 - versionName "3.7" + versionCode 21 + versionName "3.8" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/app/release/app-release.apk b/app/release/app-release.apk index 46f9389..d17d37b 100644 Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index fbc3483..477a655 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 20, - "versionName": "3.7", + "versionCode": 21, + "versionName": "3.8", "outputFile": "app-release.apk" } ], diff --git a/app/src/main/java/com/example/vcam/HookMain.java b/app/src/main/java/com/example/vcam/HookMain.java index 8bc7ebe..baa7360 100644 --- a/app/src/main/java/com/example/vcam/HookMain.java +++ b/app/src/main/java/com/example/vcam/HookMain.java @@ -22,6 +22,7 @@ import android.media.MediaExtractor; import android.media.MediaFormat; import android.media.MediaPlayer; +import android.net.wifi.WifiManager; import android.os.Build; import android.os.Environment; import android.os.Handler; @@ -89,6 +90,7 @@ public class HookMain implements IXposedHookLoadPackage { public static SurfaceTexture c2_virtual_surfaceTexture; public boolean need_recreate; public static CameraDevice.StateCallback c2_state_cb; + public static CaptureRequest.Builder c2_builder; public int c2_ori_width = 1280; public int c2_ori_height = 720; @@ -523,9 +525,49 @@ protected void beforeHookedMethod(MethodHookParam param) { } }); + XposedHelpers.findAndHookMethod("android.hardware.camera2.CaptureRequest.Builder", lpparam.classLoader, "removeTarget", Surface.class, new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) { + + if (param.args[0] == null) { + return; + } + if (param.thisObject == null){ + return; + } + File control_file = new File(video_path + "disable.jpg"); + if (control_file.exists()) { + return; + } + Surface rm_surf = (Surface) param.args[0]; + if (rm_surf.equals(c2_preview_Surfcae)){ + c2_preview_Surfcae= null; + } + if (rm_surf.equals(c2_preview_Surfcae_1)){ + c2_preview_Surfcae_1 = null; + } + if (rm_surf.equals(c2_reader_Surfcae_1)){ + c2_reader_Surfcae_1 = null; + } + if (rm_surf.equals(c2_reader_Surfcae)){ + c2_reader_Surfcae = null; + } + + XposedBridge.log("【VCAM】移除目标:" + param.args[0].toString()); + } + }); + XposedHelpers.findAndHookMethod("android.hardware.camera2.CaptureRequest.Builder", lpparam.classLoader, "build", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + if (param.thisObject == null){ + return; + } + if (param.thisObject.equals(c2_builder)){ + return; + } + c2_builder = (CaptureRequest.Builder) param.thisObject; + File control_file = new File(video_path + "disable.jpg"); if (control_file.exists()) { return; @@ -582,6 +624,48 @@ protected void beforeHookedMethod(MethodHookParam param) { } public void process_camera2_play() { + + if (c2_reader_Surfcae != null) { + if (c2_hw_decode_obj != null) { + c2_hw_decode_obj.stopDecode(); + c2_hw_decode_obj = null; + } + + c2_hw_decode_obj = new VideoToFrames(); + try { + if (Imagereader_format == 256) { + c2_hw_decode_obj.setSaveFrames("null", OutputImageFormat.JPEG); + } else { + c2_hw_decode_obj.setSaveFrames("null", OutputImageFormat.NV21); + } + c2_hw_decode_obj.set_surfcae(c2_reader_Surfcae); + c2_hw_decode_obj.decode(video_path + "virtual.mp4"); + } catch (Throwable throwable) { + XposedBridge.log("【VCAM】"+throwable.toString()); + } + } + + if (c2_reader_Surfcae_1 != null) { + if (c2_hw_decode_obj_1 != null) { + c2_hw_decode_obj_1.stopDecode(); + c2_hw_decode_obj_1 = null; + } + + c2_hw_decode_obj_1 = new VideoToFrames(); + try { + if (Imagereader_format == 256) { + c2_hw_decode_obj_1.setSaveFrames("null", OutputImageFormat.JPEG); + } else { + c2_hw_decode_obj_1.setSaveFrames("null", OutputImageFormat.NV21); + } + c2_hw_decode_obj_1.set_surfcae(c2_reader_Surfcae_1); + c2_hw_decode_obj_1.decode(video_path + "virtual.mp4"); + } catch (Throwable throwable) { + XposedBridge.log("【VCAM】" + throwable.toString()); + } + } + + if (c2_preview_Surfcae != null) { if (c2_player == null) { c2_player = new MediaPlayer(); @@ -596,16 +680,15 @@ public void process_camera2_play() { } c2_player.setLooping(true); - - c2_player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { - public void onPrepared(MediaPlayer mp) { - c2_player.start(); - } - }); try { + c2_player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { + public void onPrepared(MediaPlayer mp) { + c2_player.start(); + } + }); c2_player.setDataSource(video_path + "virtual.mp4"); c2_player.prepare(); - } catch (IOException e) { + } catch (Exception e) { XposedBridge.log("【VCAM】[c2player][" + c2_preview_Surfcae.toString() +"]"+e.toString()); } } @@ -624,60 +707,19 @@ public void onPrepared(MediaPlayer mp) { } c2_player_1.setLooping(true); - - c2_player_1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { - public void onPrepared(MediaPlayer mp) { - c2_player_1.start(); - } - }); try { + c2_player_1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { + public void onPrepared(MediaPlayer mp) { + c2_player_1.start(); + } + }); c2_player_1.setDataSource(video_path + "virtual.mp4"); c2_player_1.prepare(); - } catch (IOException e) { + } catch (Exception e) { XposedBridge.log("【VCAM】[c2player1]"+"[ " + c2_preview_Surfcae_1.toString() + "]"+e.toString()); } } - - - if (c2_reader_Surfcae != null) { - if (c2_hw_decode_obj != null) { - c2_hw_decode_obj.stopDecode(); - c2_hw_decode_obj = null; - } - - c2_hw_decode_obj = new VideoToFrames(); - try { - if (Imagereader_format == 256) { - c2_hw_decode_obj.setSaveFrames("null", OutputImageFormat.JPEG); - } else { - c2_hw_decode_obj.setSaveFrames("null", OutputImageFormat.NV21); - } - c2_hw_decode_obj.set_surfcae(c2_reader_Surfcae); - c2_hw_decode_obj.decode(video_path + "virtual.mp4"); - } catch (Throwable throwable) { - XposedBridge.log("【VCAM】"+throwable.toString()); - } - } - - if (c2_reader_Surfcae_1 != null) { - if (c2_hw_decode_obj_1 != null) { - c2_hw_decode_obj_1.stopDecode(); - c2_hw_decode_obj_1 = null; - } - - c2_hw_decode_obj_1 = new VideoToFrames(); - try { - if (Imagereader_format == 256) { - c2_hw_decode_obj_1.setSaveFrames("null", OutputImageFormat.JPEG); - } else { - c2_hw_decode_obj_1.setSaveFrames("null", OutputImageFormat.NV21); - } - c2_hw_decode_obj_1.set_surfcae(c2_reader_Surfcae_1); - c2_hw_decode_obj_1.decode(video_path + "virtual.mp4"); - } catch (Throwable throwable) { - XposedBridge.log("【VCAM】"+throwable.toString()); - } - } + XposedBridge.log("【VCAM】处理过程完全执行"); } public Surface create_virtual_surface() {