shatyuka / adbex

An adbd extension used for adb root and shell replacement.
GNU General Public License v3.0
39 stars 6 forks source link

Please add support for QtScrcpy #1

Closed nil-ref closed 4 months ago

nil-ref commented 5 months ago

https://github.com/barry-ran/QtScrcpy

shatyuka commented 5 months ago

Works fine here. Is anything not working?

nil-ref commented 5 months ago
C:\Users\Administrator\Desktop\Work\scrcpy-win64-v2.4>scrcpy.exe
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  09161FDD400122                  device  Pixel_5
C:\Users\Administrator\Desktop\Work\scrcpy-win64-v2.4\scrc... file pushed, 0 skipped. 72.5 MB/s (69007 bytes in 0.001s)
[server] INFO: Device: [Google] google Pixel 5 (Android 13)
INFO: Renderer: direct3d
ERROR: Demuxer 'audio': stream disabled due to connection error
ERROR: Demuxer 'video': stream disabled due to connection error
ERROR: Demuxer error
Aborted

When I disable the ADBEx module, it works fine:

C:\Users\Administrator\Desktop\Work\scrcpy-win64-v2.4>scrcpy.exe
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  09161FDD400122                  device  Pixel_5
C:\Users\Administrator\Desktop\Work\scrcpy-win64-v2.4\scrc... file pushed, 0 skipped. 76.2 MB/s (69007 bytes in 0.001s)
[server] INFO: Device: [Google] google Pixel 5 (Android 13)
INFO: Renderer: direct3d
INFO: Texture: 1080x2336

Magisk 27.0 Pixel 5 Android 13

nil-ref commented 5 months ago

When I turn off SELinux, ADBEx works fine.

[ 1286.301815] type=1400 audit(1713837138.314:11104): avc: denied { search } for comm=73796E6320737663203337 name="tmp" dev="dm-37" ino=101 scontext=u:r:su:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=1
[ 1286.307840] type=1400 audit(1713837138.321:11105): avc: denied { dac_override } for comm=73796E6320737663203337 capability=1 scontext=u:r:su:s0 tcontext=u:r:su:s0 tclass=capability permissive=1
[ 1286.307904] audit: audit_lost=8663 audit_rate_limit=5 audit_backlog_limit=64
[ 1286.307912] audit: rate limit exceeded
[ 1286.308137] type=1400 audit(1713837138.321:11106): avc: denied { write } for comm=73796E6320737663203337 name="tmp" dev="dm-37" ino=101 scontext=u:r:su:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=1
[ 1286.308362] type=1400 audit(1713837138.321:11107): avc: denied { add_name } for comm=73796E6320737663203337 name="scrcpy-server.jar" scontext=u:r:su:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=1
[ 1286.308560] type=1400 audit(1713837138.321:11108): avc: denied { create } for comm=73796E6320737663203337 name="scrcpy-server.jar" scontext=u:r:su:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=1
[ 1286.308759] type=1400 audit(1713837138.321:11109): avc: denied { write open } for comm=73796E6320737663203337 path="/data/local/tmp/scrcpy-server.jar" dev="dm-37" ino=36888 scontext=u:r:su:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=1
[ 1286.557207] binder: 11093:11093 ioctl 40046210 7fc72de3d8 returned -22
[ 1286.597684] [drm:__sde_crtc_early_wakeup_work:6336] sde crtc is not enabled
[ 1286.598664] [drm:dsi_display_set_mode [msm_drm]] [msm-dsi-info]: mdp_transfer_time_us=9000 us
[ 1286.598705] [drm:dsi_display_set_mode [msm_drm]] [msm-dsi-info]: hactive= 1080,vactive= 2340,fps=90
[ 1286.598771] [drm:dsi_ctrl_isr_configure [msm_drm]] [msm-dsi-info]: dsi-ctrl-0: IRQ 355 registered
[ 1286.604133] dsi_backlight_early_dpms:1156: power_mode:0 state:0x2
[ 1286.614517] binder: 11093:11120 ioctl 40046210 7ac65fe204 returned -22
[ 1286.621946] dsi_backlight_late_dpms:1211: sysfs_notify state:0x2
[ 1286.678345] sm7250_bms: MSC_PCS chg_state=1c2115403010015 [0x15:3:1:4436:450] chg=u
[ 1286.678465] sm7250_bms: CHGR_ENG_CHARGING_CFG_REG = 0x04
[ 1286.687008] google_charger: usbchg=USB typec=C usbv=4714 usbc=446 usbMv=5000 usbMc=450
[ 1286.687095] sm7250_bms: MSC_PCS chg_state=1c2115403010015 [0x15:3:1:4436:450] chg=u
[ 1286.687115] google_battery: MSC_DIN chg_state=1c2115403010015 f=0x15 chg_s=Charging chg_t=Fast vchg=4436 icl=450
[ 1286.688136] google_battery: MSC_DSG vbatt_idx:5->5 vbatt=4436361 ibatt=141906 fv_uv=4450000 cv_cnt=0 ov_cnt=0
[ 1286.688156] google_battery: MSC_VOTE msc_state=2 cv_cnt=0 ov_cnt=0 temp_idx:2, vbatt_idx:5  fv_uv=4450000 cc_max=120000 update_interval=30000
[ 1286.688183] google_charger: MSC_CHG fv_uv=4450000, cc_max=120000, rerun in 30000 ms (0)
[ 1286.690452] healthd: battery l=100 v=4436 t=26.2 h=2 st=2 c=-141906 fc=4028000 cc=405 chg=u
[ 1286.703297] i2c_geni 984000.i2c: i2c error :-107
[ 1286.703319] st21nfc_dev_write : i2c_master_send returned -107
[ 1286.743163] dsi_backlight_late_dpms:1211: sysfs_notify state:0x0
[ 1286.755675] msm_vidc:   high: 00000001: ....e: Opening video instance: 0000000000000000, 0
[ 1286.755769] msm_vidc:   err : 00000001: ....e: Failed to create debugfs for msm_vidc
[ 1286.759109] dsi_backlight_update_status:694: req:0 bl:0 state:0x0
[ 1286.759249] sec_ts spi0.0: [sec_input] sec_ts_resume_work
[ 1286.759677] msm_vidc:   err : 00000001: h264e: Invalid fmt set : 0
[ 1286.759800] sec_ts spi0.0: kernel requesting bus access from SLPI
[ 1286.761996] sec_ts spi0.0: [sec_input] sec_set_switch_gpio: toggling switch to AP
[ 1286.762022] sec_ts spi0.0: [sec_input] sec_ts_pinctrl_configure: ACTIVE
[ 1286.808277] binder: 11107:11107 ioctl 40046210 7fd73c1e58 returned -22
[ 1286.815738] dsi_backlight_update_status:694: req:17 bl:20 state:0x0
[ 1286.833586] sec_ts spi0.0: [sec_input] sec_ts_wait_for_ready_with_count: 09, 00, 40, 00, 00, 00, 00, 00 [0]
[ 1286.833603] sec_ts spi0.0: [sec_input] sec_ts_system_reset: sw_reset done
[ 1286.833799] sec_ts spi0.0: [sec_input] sec_ts_set_grip_type: re-init grip(0), edh:0, edg:0, lan:0
[ 1286.833881] sec_ts spi0.0: [sec_input] sec_ts_resume_work: set charger mode 0x2
[ 1286.833994] sec_ts spi0.0: [sec_input] applying touch_offload settings.
[ 1286.864258] ion_sgl_sync_range: 6 callbacks suppressed
[ 1286.864262] Partial cmo only supported with 1 segment\x0ais dma_set_max_seg_size being set on dev:kgsl-3d0
[ 1286.864289] msm_vidc:   err : ffffffff: .....: qbuf cache ops failed: OUTPUT: idx  5 fd 29 off 0 daddr dea00000 size 1179648 filled 1179648 flags 0x0 ts 1286860094000 refcnt 2 mflags 0x1
[ 1287.119045] Partial cmo only supported with 1 segment\x0ais dma_set_max_seg_size being set on dev:kgsl-3d0
[ 1287.119073] msm_vidc:   err : ffffffff: .....: qbuf cache ops failed: OUTPUT: idx 28 fd 29 off 0 daddr dea00000 size 1179648 filled 1179648 flags 0x0 ts 1287114699000 refcnt 2 mflags 0x1
[ 1287.283645] Partial cmo only supported with 1 segment\x0ais dma_set_max_seg_size being set on dev:kgsl-3d0
[ 1287.283686] msm_vidc:   err : ffffffff: .....: qbuf cache ops failed: OUTPUT: idx 42 fd 41 off 0 daddr de800000 size 1179648 filled 1179648 flags 0x0 ts 1287273086000 refcnt 2 mflags 0x1
[ 1287.303296] Partial cmo only supported with 1 segment\x0ais dma_set_max_seg_size being set on dev:kgsl-3d0
[ 1287.303326] msm_vidc:   err : ffffffff: .....: qbuf cache ops failed: OUTPUT: idx 43 fd 18 off 0 daddr dea00000 size 1179648 filled 1179648 flags 0x0 ts 1287282472000 refcnt 2 mflags 0x1
[ 1287.303511] Partial cmo only supported with 1 segment\x0ais dma_set_max_seg_size being set on dev:kgsl-3d0
[ 1287.303528] msm_vidc:   err : ffffffff: .....: qbuf cache ops failed: OUTPUT: idx 44 fd 35 off 0 daddr de800000 size 1179648 filled 1179648 flags 0x0 ts 1287295242000 refcnt 2 mflags 0x1
[ 1287.488489] Partial cmo only supported with 1 segment\x0ais dma_set_max_seg_size being set on dev:kgsl-3d0
[ 1287.488537] msm_vidc:   err : ffffffff: .....: qbuf cache ops failed: OUTPUT: idx 61 fd 30 off 0 daddr dea00000 size 1179648 filled 1179648 flags 0x0 ts 1287482363000 refcnt 2 mflags 0x1
[ 1287.612501] Partial cmo only supported with 1 segment\x0ais dma_set_max_seg_size being set on dev:kgsl-3d0
[ 1287.634665] Partial cmo only supported with 1 segment\x0ais dma_set_max_seg_size being set on dev:kgsl-3d0
[ 1287.667256] Partial cmo only supported with 1 segment\x0ais dma_set_max_seg_size being set on dev:kgsl-3d0
[ 1287.679264] Partial cmo only supported with 1 segment\x0ais dma_set_max_seg_size being set on dev:kgsl-3d0
[ 1287.977468] msm_vidc_check_ratelimit: 5 callbacks suppressed
[ 1287.977484] msm_vidc:   err : ffffffff: .....: qbuf cache ops failed: OUTPUT: idx 41 fd 36 off 0 daddr de800000 size 1179648 filled 1179648 flags 0x0 ts 1287971651000 refcnt 2 mflags 0x1
[ 1287.989600] msm_vidc:   err : ffffffff: .....: qbuf cache ops failed: OUTPUT: idx 42 fd 28 off 0 daddr dea00000 size 1179648 filled 1179648 flags 0x0 ts 1287983865000 refcnt 2 mflags 0x1
[ 1288.258784] msm_vidc:   err : ffffffff: .....: qbuf cache ops failed: OUTPUT: idx  2 fd 16 off 0 daddr dea00000 size 1179648 filled 1179648 flags 0x0 ts 1288251545000 refcnt 2 mflags 0x1

Here is the log when I turn SELinux on:

[  796.891416] type=1400 audit(1713836648.904:10899): avc: denied { search } for comm=73796E6320737663203430 name="tmp" dev="dm-37" ino=101 scontext=u:r:su:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=1
[  796.894377] audit: audit_lost=8538 audit_rate_limit=5 audit_backlog_limit=64
[  796.894384] audit: rate limit exceeded
[  796.894566] type=1400 audit(1713836648.907:10900): avc: denied { dac_override } for comm=73796E6320737663203430 capability=1 scontext=u:r:su:s0 tcontext=u:r:su:s0 tclass=capability permissive=1
[  796.894864] type=1400 audit(1713836648.907:10901): avc: denied { write } for comm=73796E6320737663203430 name="tmp" dev="dm-37" ino=101 scontext=u:r:su:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=1
[  796.895095] type=1400 audit(1713836648.907:10902): avc: denied { add_name } for comm=73796E6320737663203430 name="scrcpy-server.jar" scontext=u:r:su:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=1
[  796.895363] type=1400 audit(1713836648.907:10903): avc: denied { create } for comm=73796E6320737663203430 name="scrcpy-server.jar" scontext=u:r:su:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=1
[  796.895597] type=1400 audit(1713836648.907:10904): avc: denied { write } for comm=73796E6320737663203430 path="/data/local/tmp/scrcpy-server.jar" dev="dm-37" ino=36730 scontext=u:r:su:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=1
[  797.236283] binder: 10810:10810 ioctl 40046210 7fc49df148 returned -22
[  797.266425] [drm:dsi_display_set_mode [msm_drm]] [msm-dsi-info]: mdp_transfer_time_us=9000 us
[  797.266467] [drm:dsi_display_set_mode [msm_drm]] [msm-dsi-info]: hactive= 1080,vactive= 2340,fps=90
[  797.266535] [drm:dsi_ctrl_isr_configure [msm_drm]] [msm-dsi-info]: dsi-ctrl-0: IRQ 355 registered
[  797.269078] dsi_backlight_early_dpms:1156: power_mode:0 state:0x2
[  797.280283] binder: 1380:9197 transaction failed 29201/-1, size 28-8 line 3476
[  797.280301] binder: send failed reply for transaction 427610 to 10810:10829
[  797.280844] binder: 10810:10829 ioctl 40046210 75aa6008a4 returned -22
[  797.282845] binder: 591:591 transaction failed 29201/-1, size 28-8 line 3492
[  797.282863] binder: send failed reply for transaction 427621 to 10810:10829
[  797.283826] binder: 591:591 transaction failed 29201/-1, size 28-8 line 3476
[  797.283842] binder: send failed reply for transaction 427625 to 10810:10829
[  797.286960] dsi_backlight_late_dpms:1211: sysfs_notify state:0x2
[  797.355712] i2c_geni 984000.i2c: i2c error :-107
[  797.355735] st21nfc_dev_write : i2c_master_send returned -107
[  797.408117] dsi_backlight_late_dpms:1211: sysfs_notify state:0x0
[  797.424121] dsi_backlight_update_status:694: req:0 bl:0 state:0x0
[  797.426095] sec_ts spi0.0: [sec_input] sec_ts_resume_work
[  797.426158] sec_ts spi0.0: kernel requesting bus access from SLPI
[  797.428690] sec_ts spi0.0: [sec_input] sec_set_switch_gpio: toggling switch to AP
[  797.428739] sec_ts spi0.0: [sec_input] sec_ts_pinctrl_configure: ACTIVE
[  797.431596] dsi_backlight_update_status:694: req:17 bl:20 state:0x0
[  797.464668] binder: 10824:10824 ioctl 40046210 7fc90611e8 returned -22
[  797.506924] sec_ts spi0.0: [sec_input] sec_ts_wait_for_ready_with_count: 09, 00, 40, 00, 00, 00, 00, 00 [0]
[  797.506942] sec_ts spi0.0: [sec_input] sec_ts_system_reset: sw_reset done
[  797.507121] sec_ts spi0.0: [sec_input] sec_ts_set_grip_type: re-init grip(0), edh:0, edg:0, lan:0
[  797.507211] sec_ts spi0.0: [sec_input] sec_ts_resume_work: set charger mode 0x2
[  797.507310] sec_ts spi0.0: [sec_input] applying touch_offload settings.
[  797.649822] init: Untracked pid 10859 exited with status 0
[  797.649905] init: Untracked pid 10859 did not have an associated service entry and will not be reaped
[  797.671422] init: Untracked pid 10876 exited with status 0
[  797.671455] init: Untracked pid 10876 did not have an associated service entry and will not be reaped
[  797.701798] init: Untracked pid 10824 exited with status 0
[  797.701830] init: Untracked pid 10824 did not have an associated service entry and will not be reaped
shatyuka commented 5 months ago

Can you provide the bugreport? Reboot your phone and reproduce it once, then run adb bugreport. Send the zip file here.

nil-ref commented 5 months ago

bugreport-redfin-TQ3A.230901.001.C2-2024-04-23-14-04-36.zip

shatyuka commented 5 months ago

execute in adb shell

magiskpolicy --live 'allow system_server su unix_stream_socket { connectto getattr getopt ioctl read write shutdown }'
magiskpolicy --live 'allow priv_app su unix_stream_socket { connectto getattr getopt ioctl read write shutdown }'
nil-ref commented 5 months ago

Your rules are still the same not working.

After I repeatedly asked GPT4, I got the following rules:

magiskpolicy --live "allow audioserver su { * } { * }"
magiskpolicy --live "allow mediaswcodec su { * } { * }"
magiskpolicy --live "allow mediacodec su binder { * }"
magiskpolicy --live "allow hwservicemanager su { * } { * }"
magiskpolicy --live "allow surfaceflinger su binder { * }"

Finally I summarized this rule:

magiskpolicy --live "allow { surfaceflinger audioserver mediaswcodec mediacodec hwservicemanager } su { * } { * }"

Now, it works fine.