Skip to content

Commit

Permalink
catch missing exception
Browse files Browse the repository at this point in the history
  • Loading branch information
w2016561536 committed Nov 28, 2021
1 parent 2ae6ee8 commit 9820115
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 59 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 20,
"versionName": "3.7",
"versionCode": 21,
"versionName": "3.8",
"outputFile": "app-release.apk"
}
],
Expand Down
152 changes: 97 additions & 55 deletions app/src/main/java/com/example/vcam/HookMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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());
}
}
Expand All @@ -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() {
Expand Down

0 comments on commit 9820115

Please sign in to comment.