There’s a better solution for programmatically controlling HCP:
One usecase for this is to prevent HCP completely, e.g. on mobiles.
It also allows you to show a dialog before HCP takes place. But beware not to do this on iOS, since Apple‘s reviewer team doesn’t like these kind of dialogs.
I am using Reload._onMigrate() to defer HCP on mobile devices until the app is restarted by the user. In the web browser, I am showing a dialog instead which allows the user to reload the app or cancel HCP if important work would be lost.