Android by default runs fstrim every night at midnight as long as the phone is on. However, if fstrim cannot run at that time (phone is off for example), Android forces an fstrim once every three days. mFSTRIM lets you tune this value to your liking. You can have it run once every reboot, never, etc.
This project is FOSS in the sense that the source code is freely available at https://www.github.com/tytydraco/mFSTRIM. It can be compiled using Android Studio Canary at your convenience. While I offer support for the app, I cannot help you compile the app from source.