[Android Software Development] S-trace:
Try to just set triggers in init.rc, like this:

# Used to disable USB when switching states
on property:sys.usb.config=none
stop adbd
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/bDeviceClass 0
setprop sys.usb.state $sys.usb.config

# adb only USB configuration
# This should only be used during device bringup
# and as a fallback if the USB manager fails to set a standard configuration
on property:sys.usb.config=adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct D002
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.config

on property:sys.usb.config=mass_storage
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 0001
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
setprop sys.usb.state $sys.usb.config

on property:sys.usb.config=mass_storage,adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 0003
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.config

on property:sys.usb.config=mtp
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 0006
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
setprop sys.usb.state $sys.usb.config

on property:sys.usb.config=mtp,adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 0007
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.config

Of course, fix idVendor and idProduct to match Your device. You can just copy it from running firmware init.rc or its includes

And here is mine question:

I'm have datamedia device with physical SDCARD slot.

RECOVERY_SDCARD_ON_DATA := true in BoardConfig, but when I click Internal Storage in Install page - it leads me to empty /emmc directory (WHY?? there's no /emmc in whole device tree!!) instead of /data/media/0 (where is real files placed), but in /tmp/recovery.log I can see next:

~ # grep -E 'emmc|media' /tmp/recovery.log
I:Has /data/media + external storage in '/sdcard'
I:Device has /data/media defined.
I:Created '/emmc' folder.
I:Backup folder set to '/data/media/0/TWRP/BACKUPS/000000000000000c'
I:Settings storage is '/data/media/0'
Symlink_Path: /data/media/0
Symlink_Mount_Point: /emmc
Storage_Path: /data/media/0
I:Loading package: TWRP (/data/media/0/TWRP/theme/ui.zip)
I:Unable to open '/data/media/0/TWRP/BACKUPS/000000000000000c'
I:Loading settings from '/data/media/0/TWRP/.twrps'.
I:Backup folder set to '/data/media/0/TWRP/BACKUPS/000000000000000c'

How can I fix file dialog to lead me into /data/media/0/ when selecting Internal Storage (which holds my files), and not empty /emmc/ ?

Thank You.