With some hard work restoring the code Xiaomi removed, I managed to get the custom actions back, and to work better than they used to work: custom actions were shown on initial selection and when releasing the left selection modifier, but not when releasing the right selection modifier, now I managed to make them work on both.
The investigation I performed while fixing this issue again taught me a few things:
Xiaomi disables AOSP's text selection popup and replaced it with their own implementation, hence the difference in behavior.
Even when I removed a piece of code that prevented the custom actions from showing, they would still only show up if they were added in onCreateActionMode, which is non-standard, as Google specifically said that the menu should be modified in onPrepareActionMode.
Apps like Kuroba use onCreateActionMode to add custom items, hence the items were showing.
Your test app uses onPrepareActionMode, according to Google documentation, but Xiaomi's implementation never calls onPrepareActionMode for custom menus. This is another issue I sorted out in my new patch, and onPrepareActionMode is properly called directly after onCreateActionMode (only if onCreateActionMode returns true, of course), according to Google's documented lifecycle for this action mode:
developer.android.com