このページは
AndroidでカスタムリカバリTWRPを起動した時に/dataパーティションが暗号化されていてマウントできないケースで、パターンロックのパターンをdecryptのためのコードに変換するjavaプログラムと、それを入力してdecryptするためのコマンドを示しています。
参照ページ
Javaプログラム(スニペット)
// file named Pattern.java
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
public class Pattern {
public static void main(String... args) {
int[] pattern = {DOT_NUMBERS_HERE};
byte[] res = new byte[pattern.length];
for( int i = 0; i < pattern.length; i++ ) {
res[i] = (byte) (pattern[i]);
}
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < res.length; i++) {
if ((0xff & res[i]) < 0x10) {
hexString.append("0"
+ Integer.toHexString((0xFF & res[i])));
} else {
hexString.append(Integer.toHexString(0xFF & res[i]));
}
}
System.out.print("unlock code: ");
System.out.println(hexString);
}
}
これをjavac Pattern && java Pattern
でコンパイルしておく。
パターンと数字の対応
// 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
// 5x5
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
// 6x6以上のパターンも同様
この配置に従ってパターンを数字列に変換し、スニペットに入力する。
解除方法(adbコマンド)
adb shell twrp decrypt DECRYPT_CODE
これのDECRYPT_CODE
部分にスニペットから得られたコードを入れる。
(2017-04-17)