I managed to brake an old Nexus smartphone that I use for some infosec stuff (running Kali Nethunter). Only the touchscreen input broke, I can see the screen pretty good, but can't input anything... so how to unlock the phone?
If you used ADB before on the device (and computer), its pretty simple, just connect your smartphone and fire up your terminal:
$ adb shell input text YOURPIN
$ adb shell input keyevent 66
If you haven't used ADB before you probably can't connect to the device because 1) you need to enable developer settings and 2) you need to allow the computer to connect, both steps need user input.
But there are other ways, like using an OTG cable to connect a USB mouse (duh!). I found this article on Joy of Android mentioning other methods.