[Samsung Galaxy S7 Guides, News, & Discussion] AntiKippi:
Recently the screen (incl. digitizer) of my S7 died and I needed to access the data on it. This wasn't trivial since I had encryption enabled and TWRP was unable to decrypt my data. In the hope that it might be helpful for other users in the same situation I am going to share how I managed to accomplish this. Note that this guide might also work for you if you have a different ROM or a different phone, but no guarantees given here.

Device:

Model: Samsung Galaxy S7 (SM-G930F)

ROM: /e/OS (Android Q)

Recovery: SHRP (password protected)

Root: Yes (Magisk)

Encryption: Yes (FDE)

TL;DR:

Use Odin to flash TWRP following this guide.

Boot into the recovery.

Connect your phone to your PC and via adb and append the following lines to /system/build.prop

# Enable ADB
persist.service.adb.enable=1
persist.service.debuggable=1
persist.sys.usb.config=mtp,adb

# Disable authorization
ro.adb.secure=0
ro.secure=0
ro.debuggable=1

Reboot to system

Use scrcpy to enter the decryption PIN/Password/Pattern

Wait until the persistent storage is mounted (e.g. by checking if the directory /data/adb/service.d/ exists) and then IMMEDIATELY push the attached enable_adb.sh script into the /data/adb/service.d/ directory and make it executeable (via adb push /path/to/enable_adb.sh /data/adb/service.d; adb shell chmod 777 /data/adb/service.d/enable_adb.sh.

Reboot and enjoy full control over your device via scrcpy!

In-depth explanation:

My first instinct was to try enabling ADB via a USB keyboard/mouse because with ADB you basicly have full control over your device. I turned out to be able to enter the decryption and lock screen secrets, but I was stuck after that. Since I had almost no feedback except for some occational vibration or sound I wasn't able to control the device reliable enought to navigate to the settings app and change stuff there. Using an MHL (MicroUSB to HDMI) adapter also would not have worked since Samsung dropped MHL support for the S7 and even with MHL support since you only have one port you would need a USB splitter or hub and I don't think MHL would work well over a splitter/hub (but that's just a guess tho).

My second thought was going via the recovery. The only problem was that I had password-protected my SHRP recovery and I was unable to enter the password with a USB keyboard. But since my bootloader is unlocked I found I could just use Odin to flash TWRP. So I rebooted into download mode and followed this XDA guide (until like step 7) to flash the latest version of TWRP. I was a bit worried that this might trigger a factory reset but turns out it doesn't. After Odin had sucessfully flashed the image I rebooted into the recovery, connected my phone to my PC and was able to get a ADB shell. Note that you usually don't need to go anywhere further since with TWRP you can decrypt and access your data partition. In my case however when trying to decrypt my data with the command twrp decrypt <password> TWRP responded with E:No crypto support was compiled into this build..

So I had to take a different path and I found this thread here on XDA explaining how to enable ADB by editing the /system/build.prop file which is perfectly doable with the recovery. In the ADB shell I then mounted the system partition in RW mode with the commands twrp mount system and twrp remountrw and added the following lines to the /system/build.prop file:

# Enable ADB
persist.service.adb.enable=1
persist.service.debuggable=1
persist.sys.usb.config=mtp,adb

Then I rebooted and voilà, ADB was enabled (Note that I still was at the enter decryption secret screen). There was a little problem however, I could not authorize my device since the screen and digitizer were broken. Usually you can fix this by putting your adbkey.pub into the /data/misc/adb/adb_keys/ directory (see here) but since I could not access my data partition this was not possible. After a bit of research I found this XDA post with some build.prop options to disable the authorization. So I rebooted into recovery and added the following lines to /system/build.prop

# Disable authorization
ro.adb.secure=0
ro.secure=0
ro.debuggable=1

Then I rebooted again and voilà, ADB was enabled and the device showed up as authorized. Now I could use scrcpy to enter the decryption secret. However, there was a second problem. After the device was fully booted ADB got suddenly disabled. After some investigation I found this was either magisk fiddling around with build.prop or some properties getting applied from the now decrypted persistent storage. I also found that I have a few seconds before the ADB connection is killed where the data partition is mounted, which means I finally have access to it.

My plan was now to have script executed by Magisk in late_start service mode which uses resetprop to again set the options already incorporated into the build.prop file and additionally store the properties that begin with persist. on the persistent storage. You find the script I ended up using attached to this post. After I had the script I rebooted, opened an ADB shell, entered my secret and waited for the data partition to be mounted. I checked this by testing about every second if the directory /data/adb/service.d/ exists. Immediately after I noticed it exists I pushed the script into Magisk's late_start service mode script directory and marked it as executable by running adb push /path/to/enable_adb.sh /data/adb/service.d; adb shell chmod 777 /data/adb/service.d/enable_adb.sh on my PC.

Then I rebooted again and voilà, ADB was enabled at the decryption screen and when the device was booted up. Then again using scrcpy I had full access to my phone!

I hope this guide is of any help for anyone out there.

Cheers ✌🏻