Ban phones from class. For real. Lock down websites that are irrelevant to the subjects being taught. These are all technically possible with the tools schools have. Even Youtube. If something is important enough to show the class, the teacher can show it on their larger screen.
Half these issues can be solved by teaching kids how to use technology meaningfully instead of using it as a babysitter.