Recently, I setup an Android device and used the 4×4 pattern. Then I went through the steps to encrypt the device. Later that day, I needed to install another ZIP from recovery. So I rebooted into recovery to find that TWRP only has a 3×3 grid for unlocking. At first, I thought I would have to erase everything and start over. After doing some digging, I found out there is a way to unlock recovery using ADB. Here we go…
Use this Java snippet to get your DECRYPT_CODE. In the end, you’ll be entering Usage: adb shell twrp decrypt DECRYPT_CODE
to get access to your TWRP recovery.
Dots are numbered in order like this:
// 3 x 3
0 1 2
3 4 5
6 7 8
// 4 x 4
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
// 5×5
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24
// same goes for 6×6 or larger patterns
Write down the dots in order you connect them, so the simple 3×3 pattern (U pattern from top left to top right corner) translates into 0,3,6,7,8,5,2
, put these numbers in code where DOT_NUMBERS_HERE
is.
Then use javac Pattern && java Pattern
and use the unlock code in adb shell twrp decrypt DECRYPT_CODE
command.
I must give credit where it is due. This solution came from a comment on GitHub and I just tweaked the Java a little bit. I hope it worked for you. If it did, please leave a comment below.