You can avoid this problem easily not letting students using phones or computers in the classroom and making doing more tasks at the classroom than at home.
If you're going to say "but in a working environment you use a computer", then teach them how to use text processing and spreadsheets int the computer room, a thing that didn't happen today in most schools btw.