2222import android .media .MediaExtractor ;
2323import android .media .MediaFormat ;
2424import android .media .MediaPlayer ;
25+ import android .net .wifi .WifiManager ;
2526import android .os .Build ;
2627import android .os .Environment ;
2728import android .os .Handler ;
@@ -89,6 +90,7 @@ public class HookMain implements IXposedHookLoadPackage {
8990 public static SurfaceTexture c2_virtual_surfaceTexture ;
9091 public boolean need_recreate ;
9192 public static CameraDevice .StateCallback c2_state_cb ;
93+ public static CaptureRequest .Builder c2_builder ;
9294
9395 public int c2_ori_width = 1280 ;
9496 public int c2_ori_height = 720 ;
@@ -523,9 +525,49 @@ protected void beforeHookedMethod(MethodHookParam param) {
523525 }
524526 });
525527
528+ XposedHelpers .findAndHookMethod ("android.hardware.camera2.CaptureRequest.Builder" , lpparam .classLoader , "removeTarget" , Surface .class , new XC_MethodHook () {
529+ @ Override
530+ protected void beforeHookedMethod (MethodHookParam param ) {
531+
532+ if (param .args [0 ] == null ) {
533+ return ;
534+ }
535+ if (param .thisObject == null ){
536+ return ;
537+ }
538+ File control_file = new File (video_path + "disable.jpg" );
539+ if (control_file .exists ()) {
540+ return ;
541+ }
542+ Surface rm_surf = (Surface ) param .args [0 ];
543+ if (rm_surf .equals (c2_preview_Surfcae )){
544+ c2_preview_Surfcae = null ;
545+ }
546+ if (rm_surf .equals (c2_preview_Surfcae_1 )){
547+ c2_preview_Surfcae_1 = null ;
548+ }
549+ if (rm_surf .equals (c2_reader_Surfcae_1 )){
550+ c2_reader_Surfcae_1 = null ;
551+ }
552+ if (rm_surf .equals (c2_reader_Surfcae )){
553+ c2_reader_Surfcae = null ;
554+ }
555+
556+ XposedBridge .log ("【VCAM】移除目标:" + param .args [0 ].toString ());
557+ }
558+ });
559+
526560 XposedHelpers .findAndHookMethod ("android.hardware.camera2.CaptureRequest.Builder" , lpparam .classLoader , "build" , new XC_MethodHook () {
527561 @ Override
528562 protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
563+ if (param .thisObject == null ){
564+ return ;
565+ }
566+ if (param .thisObject .equals (c2_builder )){
567+ return ;
568+ }
569+ c2_builder = (CaptureRequest .Builder ) param .thisObject ;
570+
529571 File control_file = new File (video_path + "disable.jpg" );
530572 if (control_file .exists ()) {
531573 return ;
@@ -582,6 +624,48 @@ protected void beforeHookedMethod(MethodHookParam param) {
582624 }
583625
584626 public void process_camera2_play () {
627+
628+ if (c2_reader_Surfcae != null ) {
629+ if (c2_hw_decode_obj != null ) {
630+ c2_hw_decode_obj .stopDecode ();
631+ c2_hw_decode_obj = null ;
632+ }
633+
634+ c2_hw_decode_obj = new VideoToFrames ();
635+ try {
636+ if (Imagereader_format == 256 ) {
637+ c2_hw_decode_obj .setSaveFrames ("null" , OutputImageFormat .JPEG );
638+ } else {
639+ c2_hw_decode_obj .setSaveFrames ("null" , OutputImageFormat .NV21 );
640+ }
641+ c2_hw_decode_obj .set_surfcae (c2_reader_Surfcae );
642+ c2_hw_decode_obj .decode (video_path + "virtual.mp4" );
643+ } catch (Throwable throwable ) {
644+ XposedBridge .log ("【VCAM】" +throwable .toString ());
645+ }
646+ }
647+
648+ if (c2_reader_Surfcae_1 != null ) {
649+ if (c2_hw_decode_obj_1 != null ) {
650+ c2_hw_decode_obj_1 .stopDecode ();
651+ c2_hw_decode_obj_1 = null ;
652+ }
653+
654+ c2_hw_decode_obj_1 = new VideoToFrames ();
655+ try {
656+ if (Imagereader_format == 256 ) {
657+ c2_hw_decode_obj_1 .setSaveFrames ("null" , OutputImageFormat .JPEG );
658+ } else {
659+ c2_hw_decode_obj_1 .setSaveFrames ("null" , OutputImageFormat .NV21 );
660+ }
661+ c2_hw_decode_obj_1 .set_surfcae (c2_reader_Surfcae_1 );
662+ c2_hw_decode_obj_1 .decode (video_path + "virtual.mp4" );
663+ } catch (Throwable throwable ) {
664+ XposedBridge .log ("【VCAM】" + throwable .toString ());
665+ }
666+ }
667+
668+
585669 if (c2_preview_Surfcae != null ) {
586670 if (c2_player == null ) {
587671 c2_player = new MediaPlayer ();
@@ -596,16 +680,15 @@ public void process_camera2_play() {
596680 }
597681 c2_player .setLooping (true );
598682
599-
600- c2_player .setOnPreparedListener (new MediaPlayer .OnPreparedListener () {
601- public void onPrepared (MediaPlayer mp ) {
602- c2_player .start ();
603- }
604- });
605683 try {
684+ c2_player .setOnPreparedListener (new MediaPlayer .OnPreparedListener () {
685+ public void onPrepared (MediaPlayer mp ) {
686+ c2_player .start ();
687+ }
688+ });
606689 c2_player .setDataSource (video_path + "virtual.mp4" );
607690 c2_player .prepare ();
608- } catch (IOException e ) {
691+ } catch (Exception e ) {
609692 XposedBridge .log ("【VCAM】[c2player][" + c2_preview_Surfcae .toString () +"]" +e .toString ());
610693 }
611694 }
@@ -624,60 +707,19 @@ public void onPrepared(MediaPlayer mp) {
624707 }
625708 c2_player_1 .setLooping (true );
626709
627-
628- c2_player_1 .setOnPreparedListener (new MediaPlayer .OnPreparedListener () {
629- public void onPrepared (MediaPlayer mp ) {
630- c2_player_1 .start ();
631- }
632- });
633710 try {
711+ c2_player_1 .setOnPreparedListener (new MediaPlayer .OnPreparedListener () {
712+ public void onPrepared (MediaPlayer mp ) {
713+ c2_player_1 .start ();
714+ }
715+ });
634716 c2_player_1 .setDataSource (video_path + "virtual.mp4" );
635717 c2_player_1 .prepare ();
636- } catch (IOException e ) {
718+ } catch (Exception e ) {
637719 XposedBridge .log ("【VCAM】[c2player1]" +"[ " + c2_preview_Surfcae_1 .toString () + "]" +e .toString ());
638720 }
639721 }
640-
641-
642- if (c2_reader_Surfcae != null ) {
643- if (c2_hw_decode_obj != null ) {
644- c2_hw_decode_obj .stopDecode ();
645- c2_hw_decode_obj = null ;
646- }
647-
648- c2_hw_decode_obj = new VideoToFrames ();
649- try {
650- if (Imagereader_format == 256 ) {
651- c2_hw_decode_obj .setSaveFrames ("null" , OutputImageFormat .JPEG );
652- } else {
653- c2_hw_decode_obj .setSaveFrames ("null" , OutputImageFormat .NV21 );
654- }
655- c2_hw_decode_obj .set_surfcae (c2_reader_Surfcae );
656- c2_hw_decode_obj .decode (video_path + "virtual.mp4" );
657- } catch (Throwable throwable ) {
658- XposedBridge .log ("【VCAM】" +throwable .toString ());
659- }
660- }
661-
662- if (c2_reader_Surfcae_1 != null ) {
663- if (c2_hw_decode_obj_1 != null ) {
664- c2_hw_decode_obj_1 .stopDecode ();
665- c2_hw_decode_obj_1 = null ;
666- }
667-
668- c2_hw_decode_obj_1 = new VideoToFrames ();
669- try {
670- if (Imagereader_format == 256 ) {
671- c2_hw_decode_obj_1 .setSaveFrames ("null" , OutputImageFormat .JPEG );
672- } else {
673- c2_hw_decode_obj_1 .setSaveFrames ("null" , OutputImageFormat .NV21 );
674- }
675- c2_hw_decode_obj_1 .set_surfcae (c2_reader_Surfcae_1 );
676- c2_hw_decode_obj_1 .decode (video_path + "virtual.mp4" );
677- } catch (Throwable throwable ) {
678- XposedBridge .log ("【VCAM】" +throwable .toString ());
679- }
680- }
722+ XposedBridge .log ("【VCAM】处理过程完全执行" );
681723 }
682724
683725 public Surface create_virtual_surface () {
0 commit comments