问题
I'm having a nightmare day with a broken screen ,
I've 'Droid Screen' with 'Ultimate Touchscreen Control' however the gestures dont seem to work for this Phones unlock it usually requires a swipe that stops however I can get it to 'click' in place , any ideas to unlock with the ADB so I can get to my messages would be a life saver
回答1:
so let me be your life saver (maybe)
I've broke screen in my Nexus 4 few weeks ago and I was also looking for similar answer. it's is important that it was Nexus 4 stock Kitkat 4.4 with no root, only ADB and default pattern lock (dots)
so I've been looking in adb command and found simple sendevent
method. it alows to do swipes like you need, some example:
cd C:\sdk_patch\platform-tools
adb shell sendevent /dev/input/event2 3 57 58
adb shell sendevent /dev/input/event2 3 58 17
adb shell sendevent /dev/input/event2 3 53 470
adb shell sendevent /dev/input/event2 3 54 1200
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 3 53 670
adb shell sendevent /dev/input/event2 3 54 1200
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 3 58 88
adb shell sendevent /dev/input/event2 3 54 1494
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 3 54 1820
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 3 58 96
adb shell sendevent /dev/input/event2 3 53 612
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 3 58 98
adb shell sendevent /dev/input/event2 3 53 617
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 3 57 4294967295
adb shell sendevent /dev/input/event2 0 0 0
this code I'm executing as bat and it is drawing my pattern lock which was
1 2 3
4 5 6
7 8 9
1 -> 2 -> 5 -> 8 (dots connected)
I don't really remember these numbers what they mean, but you can found it in documentation. what I remember that 53
and 54
are position (x/y?) in pixels of touch, point 'to swipe', then 0 0 0
as confirmation (?). so you need to know resolution of your screen (N4 is HD) and also position (approximate, point that allows to dot 'check') of your dots (note that probably screens with physical buttons might have dots a bit lower than N4 with soft buttons shrinking a bit screen). in above code there are also some short delays (58
and miliseconds after?) so you can see how pattern/swipe is drawing (pretty fast as I remember)
important: different devices have different event
number responsible for touch. like above in my N4 its event2
, but I've been testing this adb methods with Nexus 7 2013 (full HD, dots in different coordinates, also only adb without root) and there event7
was working (if I remember properly...). Internet said than most common is event0
, its a guessing, depending on producer... In your device it might me another number (event
numbers starting at 0 and rising continously, adb will throw an error/warn when you call non-existing event, probably smth between 7-9 is last event file number)
tip: after unlock first thing to do is set a long screen-off wait time (1 hr) and also in dev options check option "don't turn off screen when charging' or smth like this. these will allow you to keep screen on for long time without auto-lock. you can also remove pattern lock, but in options you need to write it and positions of dots are a bit different, so your onlock code with coordinates may not work
I know that it's not clear, stright answer, but I was looking for this method a lot and some tests with coordinates and event
number should give you what you want. also: when you unlock your phone you might use Android Control which transmitting your screen straight to computer, it also supports touching this screen (but only single tap and stright swipe without turning). you might install any backup app from Google Play, e.g. for sms backuping. Wish you luck
PS. hopeful method for adb is also adb shell input
(check docs) but it supports (as I know) only straight swipe and single tap (and other ones without turning), I'm guessing that Android Control and similar desktop apps are using these commands and this is a reason for no ability of turing while swiping). also I've heard that newest AirDroid 3 can also stream your screen, maybe this app will help
回答2:
Further to the useful tips from @snachmsm, I've put together a shell script for sending pattern swipes over ADB which should make it nice and easy: android-pattern-unlock
来源:https://stackoverflow.com/questions/27348392/unlock-screen-galaxy-nexus-adb