I am building a custom device with Android 12 AOSP, which does not need the management of media files. Every time I plug in a USB stick - it gets populated with a bunch of folders like Music, Movies, Podcasts, etc. It is very annoying and not desired functionality. How to modify the AOSP code or parameters to disable this behavior?
I have tried to create .nomedia file in the root - it did not help.
After some research, I found that the default folders' creation is enforced in MediaProvider.java. Use the following patch to disable media folders creation on all external volumes: