How to fix a Galaxy S9 that randomly freezes or crashes [troubleshooting guide]

How to fix a Galaxy S9 that turns off on its own and won’t power back on [troubleshooting guide]