You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Compare commits
2301 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fe03d2795 | ||
|
|
c595a87ccf | ||
|
|
fac07c3913 | ||
|
|
c63fdbbc6b | ||
|
|
2ff5d9606b | ||
|
|
ed43452c1a | ||
|
|
8f28d4028f | ||
|
|
b54543b18c | ||
|
|
966d6593ca | ||
|
|
ad95b1c9d1 | ||
|
|
3bfa38c60a | ||
|
|
0bdbcad8be | ||
|
|
80cd85b061 | ||
|
|
89275270f3 | ||
|
|
e7339ba619 | ||
|
|
d9ad7d522c | ||
|
|
ef0e22cc41 | ||
|
|
62db65bf18 | ||
|
|
d5371f752c | ||
|
|
a5f5e94115 | ||
|
|
67c3f40adb | ||
|
|
ff7a0ba599 | ||
|
|
b152c63102 | ||
|
|
415ff23be5 | ||
|
|
b0d6de783e | ||
|
|
ac28e6e5ca | ||
|
|
a9350f50c9 | ||
|
|
ed7babcbf1 | ||
|
|
61ebc335c4 | ||
|
|
0167bd76f1 | ||
|
|
79d704008b | ||
|
|
0a703585b0 | ||
|
|
b27801a27c | ||
|
|
a0cfce7cbc | ||
|
|
8b7144c986 | ||
|
|
d3f5f5ee59 | ||
|
|
a2a3c7f438 | ||
|
|
4496f82d5b | ||
|
|
09d531557d | ||
|
|
7fee82f731 | ||
|
|
475054c48a | ||
|
|
a743d05751 | ||
|
|
d1ed502e03 | ||
|
|
37744c7ab6 | ||
|
|
b25c49725f | ||
|
|
b245782c7e | ||
|
|
a9f32baae0 | ||
|
|
e7ef71865d | ||
|
|
88c4f72b37 | ||
|
|
abbcdf91a5 | ||
|
|
b876df6e21 | ||
|
|
4bb81f35d7 | ||
|
|
ff20267b3f | ||
|
|
2c9586d811 | ||
|
|
2813d2031a | ||
|
|
4040a0242f | ||
|
|
781ec810d9 | ||
|
|
9e90a71c04 | ||
|
|
5571714b26 | ||
|
|
e0d1f02ef5 | ||
|
|
1b729e5ff2 | ||
|
|
51e587d4e8 | ||
|
|
ac9c55dbc1 | ||
|
|
0893ac3141 | ||
|
|
fb40e96917 | ||
|
|
4ca25f74c6 | ||
|
|
7fda917b86 | ||
|
|
e6bd5f2c40 | ||
|
|
8a904ee384 | ||
|
|
00a9f18a1e | ||
|
|
8d68ebb074 | ||
|
|
5f53cfb4a9 | ||
|
|
a2fa8d8be1 | ||
|
|
70a3c78ebb | ||
|
|
db218407b0 | ||
|
|
d52210dd90 | ||
|
|
f3cd9a096a | ||
|
|
e426090a18 | ||
|
|
cbe64fd559 | ||
|
|
63ea7a70bd | ||
|
|
fb0998f7a2 | ||
|
|
a9b00dd537 | ||
|
|
52eb059515 | ||
|
|
7640246255 | ||
|
|
52c83b2916 | ||
|
|
d9cded0fc9 | ||
|
|
750c42caf1 | ||
|
|
bbf650c6cf | ||
|
|
a25dace7e0 | ||
|
|
14ff22fbcd | ||
|
|
07eb7dda2d | ||
|
|
54d1207f92 | ||
|
|
003e44fb84 | ||
|
|
515f346dcc | ||
|
|
d4058175b4 | ||
|
|
2de984ae24 | ||
|
|
761a8bf2a9 | ||
|
|
6df7006b36 | ||
|
|
aceb3ee863 | ||
|
|
11d716a3c8 | ||
|
|
7cc8c014eb | ||
|
|
f21241d944 | ||
|
|
a181fa0652 | ||
|
|
3f748b4d2a | ||
|
|
683450f9c6 | ||
|
|
6050c4e8ba | ||
|
|
158af8819a | ||
|
|
7787bb31fa | ||
|
|
a1fe3e7ccd | ||
|
|
4316028b23 | ||
|
|
f2b52755d6 | ||
|
|
adbd47a36c | ||
|
|
ce693aa5e9 | ||
|
|
ad80804461 | ||
|
|
2d55632430 | ||
|
|
e81f00ef1a | ||
|
|
93fb0e3d74 | ||
|
|
71ce0de606 | ||
|
|
0407062c1d | ||
|
|
f315c4416b | ||
|
|
cda14af208 | ||
|
|
258f170cd7 | ||
|
|
f76015d714 | ||
|
|
7e5e14163c | ||
|
|
bcd1064e94 | ||
|
|
8a8441c875 | ||
|
|
15aa813416 | ||
|
|
605faccffd | ||
|
|
79f2d08c81 | ||
|
|
0568ae5391 | ||
|
|
5330dda9f8 | ||
|
|
ebab126579 | ||
|
|
0e5417a13e | ||
|
|
9a968e0584 | ||
|
|
ffec64d209 | ||
|
|
f332746188 | ||
|
|
b2fa5b551e | ||
|
|
36e83edddc | ||
|
|
6b045eadef | ||
|
|
147264822c | ||
|
|
36e4ccd800 | ||
|
|
796c16237d | ||
|
|
861ad9881c | ||
|
|
3101c538e9 | ||
|
|
42adc7382f | ||
|
|
9bb4dfad13 | ||
|
|
4e7dafb0e4 | ||
|
|
bd00ae8ede | ||
|
|
f309522268 | ||
|
|
a6395d35db | ||
|
|
a028cd5cec | ||
|
|
540000d26e | ||
|
|
888c656aa8 | ||
|
|
0efaddff23 | ||
|
|
94ba7cb0c5 | ||
|
|
2d58c725e0 | ||
|
|
e035523eb8 | ||
|
|
bea5308ab7 | ||
|
|
f006a85fec | ||
|
|
ea93013ebc | ||
|
|
8d4c407201 | ||
|
|
fdeede23f7 | ||
|
|
53c5ca59b6 | ||
|
|
679db97209 | ||
|
|
fbdd72273e | ||
|
|
0165602515 | ||
|
|
96127f8bd1 | ||
|
|
0dbdf336d6 | ||
|
|
48879df2da | ||
|
|
b067a5bb13 | ||
|
|
4b54cf1288 | ||
|
|
6128c24f96 | ||
|
|
d9c58f307f | ||
|
|
b521fbeeda | ||
|
|
d00a3b89f2 | ||
|
|
3d15518191 | ||
|
|
9b6535fdf5 | ||
|
|
e0424fdba3 | ||
|
|
7481c53451 | ||
|
|
7219947237 | ||
|
|
b72004e9cc | ||
|
|
f187213568 | ||
|
|
fc0df84edd | ||
|
|
f24df4f43d | ||
|
|
dab32e1599 | ||
|
|
bc286fd4d3 | ||
|
|
befe1a83b5 | ||
|
|
82ea9db9fd | ||
|
|
c5758b3f2d | ||
|
|
ace3708c9c | ||
|
|
fc5026d268 | ||
|
|
77fd0e54be | ||
|
|
24490e0ff5 | ||
|
|
da3937ff4e | ||
|
|
ebe1ab982e | ||
|
|
98590cb00d | ||
|
|
ff95f634f0 | ||
|
|
ced9b4a8ee | ||
|
|
7af7910e78 | ||
|
|
a4f5d47e72 | ||
|
|
6953cc2411 | ||
|
|
6a0b2ddee9 | ||
|
|
24f5bc98d8 | ||
|
|
5203886f0b | ||
|
|
c10b376575 | ||
|
|
ceb21ced2b | ||
|
|
86789a8694 | ||
|
|
ca2235aee7 | ||
|
|
a385e5cd92 | ||
|
|
0c7a95bdf6 | ||
|
|
036b5acf42 | ||
|
|
056dafc59f | ||
|
|
a9c90718d6 | ||
|
|
cc77a24502 | ||
|
|
71a91ac7a7 | ||
|
|
08a70f033a | ||
|
|
1b0c36dbd5 | ||
|
|
91da1cf817 | ||
|
|
c577a9525d | ||
|
|
0149b1368d | ||
|
|
cd6bcb97ef | ||
|
|
df4161ffcc | ||
|
|
7a133eaf03 | ||
|
|
1cd45b53b1 | ||
|
|
5b30c77403 | ||
|
|
8248480d56 | ||
|
|
345d992d39 | ||
|
|
a7f6afa4bc | ||
|
|
d22c7de79a | ||
|
|
3eae9494ce | ||
|
|
be7e737253 | ||
|
|
b6eb912dba | ||
|
|
8049b08918 | ||
|
|
d1fa5be210 | ||
|
|
fdbb1af02c | ||
|
|
c85a5cae88 | ||
|
|
649ef53409 | ||
|
|
e784212283 | ||
|
|
66eb1078fe | ||
|
|
1c09b3642f | ||
|
|
d08b1a6639 | ||
|
|
10f50e2401 | ||
|
|
8e9a7b25a1 | ||
|
|
4859ee2da9 | ||
|
|
b45db44ad9 | ||
|
|
e25ce63872 | ||
|
|
162eeaa0a6 | ||
|
|
f36ce905aa | ||
|
|
8ac3aaf36c | ||
|
|
a199b0ace1 | ||
|
|
2f2108e4e8 | ||
|
|
f5f7fd9132 | ||
|
|
f9ae4ab475 | ||
|
|
8de03eef3f | ||
|
|
8df942f96e | ||
|
|
9bb2243b56 | ||
|
|
db06038548 | ||
|
|
ecb33d3176 | ||
|
|
eae1c17738 | ||
|
|
ea55532e33 | ||
|
|
2a40cb60a9 | ||
|
|
d371d017b7 | ||
|
|
1d9359d563 | ||
|
|
945f88105f | ||
|
|
957feca626 | ||
|
|
c0447009db | ||
|
|
8893cbd64a | ||
|
|
f0240b1f06 | ||
|
|
e476c18c99 | ||
|
|
a1b5185ecb | ||
|
|
981e90cc32 | ||
|
|
da0a72e8b0 | ||
|
|
b7e2e972c7 | ||
|
|
650b2ce6b1 | ||
|
|
ecf3d30349 | ||
|
|
15ddd0e284 | ||
|
|
18ac6b270f | ||
|
|
3e35de9b39 | ||
|
|
1e24c72c11 | ||
|
|
217564963d | ||
|
|
f2f4649ab0 | ||
|
|
4395ffec5f | ||
|
|
9a7a26407a | ||
|
|
5072a67807 | ||
|
|
dce0b6c05a | ||
|
|
a4a661bf34 | ||
|
|
771e500468 | ||
|
|
7e3ff03109 | ||
|
|
a1827fd680 | ||
|
|
9ce334feac | ||
|
|
ed11e0bff6 | ||
|
|
5111086637 | ||
|
|
20f204810e | ||
|
|
4581354e7a | ||
|
|
faf4d76388 | ||
|
|
a46e255709 | ||
|
|
63e2bbb4d1 | ||
|
|
c3dabae237 | ||
|
|
f1abcbb7fb | ||
|
|
70efddb90f | ||
|
|
f24a5dfd45 | ||
|
|
081074ad9d | ||
|
|
ab0cc78d2c | ||
|
|
de5c902fdb | ||
|
|
cf65169c99 | ||
|
|
745865ee53 | ||
|
|
c134fb1939 | ||
|
|
0204d05316 | ||
|
|
c345633d80 | ||
|
|
a57a94040e | ||
|
|
1bde78d121 | ||
|
|
bbd014ad1b | ||
|
|
1287372f5a | ||
|
|
d2cb638fcd | ||
|
|
bbe4b69c8d | ||
|
|
7f08c06943 | ||
|
|
8f4a6415cd | ||
|
|
0442d6d509 | ||
|
|
a3fc6d2a27 | ||
|
|
7db05ac927 | ||
|
|
8bed93b3c5 | ||
|
|
915b49014f | ||
|
|
c699f30831 | ||
|
|
3e73e3a906 | ||
|
|
32c65d8a88 | ||
|
|
a49328edd3 | ||
|
|
9a15365a57 | ||
|
|
82c864d57e | ||
|
|
6226f875ff | ||
|
|
370015a853 | ||
|
|
6597b7adc0 | ||
|
|
4e53ebfe44 | ||
|
|
04ef1e6405 | ||
|
|
b278d07b05 | ||
|
|
6c3896079d | ||
|
|
e73fa57d54 | ||
|
|
eaa9c7e2a0 | ||
|
|
14ae29d907 | ||
|
|
e8f35b02ca | ||
|
|
dee3c3e7ba | ||
|
|
d8cd2031c7 | ||
|
|
7203e7df5c | ||
|
|
b51feffe80 | ||
|
|
b1afd554fc | ||
|
|
885e3c574b | ||
|
|
05dd5f3396 | ||
|
|
ec3c43faf1 | ||
|
|
e72c6685ed | ||
|
|
99d6bd8efc | ||
|
|
4c8587a9f2 | ||
|
|
54a8a05dae | ||
|
|
164a99681b | ||
|
|
0eef4eacd6 | ||
|
|
5764f0c839 | ||
|
|
f28e425542 | ||
|
|
d1a4f046e9 | ||
|
|
2ce1dc4afe | ||
|
|
37ac249fd7 | ||
|
|
f152bea8d8 | ||
|
|
7b089b888a | ||
|
|
68f0e1fe39 | ||
|
|
8032bd0bac | ||
|
|
0c227f2917 | ||
|
|
c9fa8118d1 | ||
|
|
63b18246d8 | ||
|
|
16ec37a226 | ||
|
|
bd4e5bfc1a | ||
|
|
621fd0ee29 | ||
|
|
6ca8db2f0c | ||
|
|
ea129fb206 | ||
|
|
3356d7b6ff | ||
|
|
c84023bdc2 | ||
|
|
86f778c0aa | ||
|
|
defbbdfe21 | ||
|
|
0f46493477 | ||
|
|
340bac7e42 | ||
|
|
1d3ce9fef1 | ||
|
|
4a398642b8 | ||
|
|
9c89e56c56 | ||
|
|
267c59b1f1 | ||
|
|
2ab17204c6 | ||
|
|
75939047d1 | ||
|
|
2d7f130d2c | ||
|
|
f7ae72a36c | ||
|
|
391783e268 | ||
|
|
6f12c08204 | ||
|
|
cb8fe70734 | ||
|
|
69d10b747a | ||
|
|
da3394f34e | ||
|
|
b4c2a9f49f | ||
|
|
7cee77f57a | ||
|
|
f28bd1972f | ||
|
|
0f92d1de1b | ||
|
|
e59c5c8780 | ||
|
|
86d8026301 | ||
|
|
d67b827338 | ||
|
|
660e0dc09a | ||
|
|
3ebc886f8a | ||
|
|
5b54ef840a | ||
|
|
c08b0d4974 | ||
|
|
7d652afd87 | ||
|
|
0f61c627b1 | ||
|
|
7126648404 | ||
|
|
4a5e2dc9c7 | ||
|
|
10613686ed | ||
|
|
17ab55115a | ||
|
|
2708c74ebe | ||
|
|
50ff11405f | ||
|
|
31a27838f5 | ||
|
|
2f1b0fe57f | ||
|
|
692f893e1f | ||
|
|
14aa6041ec | ||
|
|
fb55fe184c | ||
|
|
6412bfc7b5 | ||
|
|
3c56f38229 | ||
|
|
f4f2274c60 | ||
|
|
19ee189468 | ||
|
|
a19c7215d2 | ||
|
|
8b84039f1f | ||
|
|
9430dbb96c | ||
|
|
4872df6a46 | ||
|
|
014105f0a0 | ||
|
|
b106d1c501 | ||
|
|
99db0672b4 | ||
|
|
d584360de2 | ||
|
|
4eed6794c7 | ||
|
|
c66cabd80f | ||
|
|
24da3485bd | ||
|
|
7384d2d330 | ||
|
|
e5940168fe | ||
|
|
6855baf0f8 | ||
|
|
dfd16e8fef | ||
|
|
98a36819bc | ||
|
|
de8bc9ca9d | ||
|
|
c137f2de4f | ||
|
|
0f55fcafe8 | ||
|
|
ed027ec3ee | ||
|
|
b3fd79cbb9 | ||
|
|
ed4df87b57 | ||
|
|
1321f097b8 | ||
|
|
cfa28f0c4a | ||
|
|
ab47b717b1 | ||
|
|
65ebb0d2f8 | ||
|
|
49640ce03a | ||
|
|
e05cdc83f3 | ||
|
|
992a9ea2f9 | ||
|
|
228351fc13 | ||
|
|
8a5b6f2b86 | ||
|
|
71ecbb3af3 | ||
|
|
5746614ccf | ||
|
|
3a422c3f15 | ||
|
|
b3242322fd | ||
|
|
9826640ae6 | ||
|
|
1f5267204b | ||
|
|
ed25e1bbd6 | ||
|
|
c8491d008f | ||
|
|
08e3405394 | ||
|
|
4ebfa07186 | ||
|
|
6698c189fc | ||
|
|
f0639390aa | ||
|
|
bbdfed2d5a | ||
|
|
7f4daa2c50 | ||
|
|
baf9b67b35 | ||
|
|
caf73b0b36 | ||
|
|
acf87c2794 | ||
|
|
7f5f6b54fb | ||
|
|
a08eb8a446 | ||
|
|
b31402766e | ||
|
|
9ab3143bf0 | ||
|
|
81a0cddb9e | ||
|
|
f620ac769f | ||
|
|
dc91041edd | ||
|
|
6ee08b6717 | ||
|
|
5a2cd2ac84 | ||
|
|
2bd8448aaa | ||
|
|
2360adb592 | ||
|
|
c7301a5161 | ||
|
|
72270825c1 | ||
|
|
1e94f0a094 | ||
|
|
e39d2567ea | ||
|
|
949136c92a | ||
|
|
9f456a9b19 | ||
|
|
4cf6ba25ca | ||
|
|
093f971896 | ||
|
|
df38a9da71 | ||
|
|
813814c54a | ||
|
|
68cb32f375 | ||
|
|
93c9590b0f | ||
|
|
619d979c39 | ||
|
|
c30faad838 | ||
|
|
bea0de4980 | ||
|
|
ef5a490415 | ||
|
|
fa404285be | ||
|
|
0e526258ff | ||
|
|
56d2fb9a3b | ||
|
|
7c82690852 | ||
|
|
62acc17e42 | ||
|
|
9fbe5895b7 | ||
|
|
6bbe0f07d4 | ||
|
|
bd3e0b9336 | ||
|
|
699debdaca | ||
|
|
70eba568af | ||
|
|
bb7560e441 | ||
|
|
43c0cac52f | ||
|
|
4b4aa148a9 | ||
|
|
c9c90c4e7f | ||
|
|
99093e9a4c | ||
|
|
2cf33d635d | ||
|
|
d6abaf846e | ||
|
|
4b88131977 | ||
|
|
4520f46a57 | ||
|
|
348d47076a | ||
|
|
6e7b90a184 | ||
|
|
28d7a7a6d2 | ||
|
|
da13b5dbf2 | ||
|
|
a60710e3bb | ||
|
|
7d2a2b9983 | ||
|
|
749df5dacd | ||
|
|
af88b7c807 | ||
|
|
4091687733 | ||
|
|
cfb0a3ba2a | ||
|
|
6c4d082f35 | ||
|
|
262185046a | ||
|
|
da9d00be7d | ||
|
|
454abc388b | ||
|
|
3e9174deed | ||
|
|
4df1047b07 | ||
|
|
60f69feaff | ||
|
|
5df426380d | ||
|
|
976c299657 | ||
|
|
18ab6b51fd | ||
|
|
4be8bd4d18 | ||
|
|
075bc4a6d5 | ||
|
|
1c61feb368 | ||
|
|
d32b788988 | ||
|
|
7565ea2787 | ||
|
|
9275975b2c | ||
|
|
b3e0d5ba58 | ||
|
|
841dee94c6 | ||
|
|
71638191ee | ||
|
|
9d6851cbbd | ||
|
|
d633d05803 | ||
|
|
45d7879d7b | ||
|
|
4a8375355c | ||
|
|
d3ebd763a2 | ||
|
|
b7f69238a1 | ||
|
|
118a9f224e | ||
|
|
a44dc8df37 | ||
|
|
abf19aad74 | ||
|
|
d73127b175 | ||
|
|
00f4242fa4 | ||
|
|
f6a4510659 | ||
|
|
33215424d8 | ||
|
|
6094bc9210 | ||
|
|
a8cd9b3aa9 | ||
|
|
a189dec1c8 | ||
|
|
858216796a | ||
|
|
f24342f117 | ||
|
|
50b55a77de | ||
|
|
fdf167db11 | ||
|
|
a4f8bd4ee0 | ||
|
|
3e4c12cf56 | ||
|
|
03c39e692a | ||
|
|
ab63b0e970 | ||
|
|
6ea42a35a9 | ||
|
|
d366dfc72b | ||
|
|
85042fbe25 | ||
|
|
23e5188422 | ||
|
|
93ee0c8798 | ||
|
|
aa88486f59 | ||
|
|
1d9c441038 | ||
|
|
928c56bda2 | ||
|
|
bc6f37eecc | ||
|
|
ffebff8cab | ||
|
|
6d6bd89d6b | ||
|
|
0a64a7e5d4 | ||
|
|
586488af48 | ||
|
|
7b9a45f1a8 | ||
|
|
4ff70aefac | ||
|
|
d63b5d7014 | ||
|
|
ab5f6bf901 | ||
|
|
04088b34a2 | ||
|
|
3edcd2004e | ||
|
|
7bd52d0245 | ||
|
|
1df65940b9 | ||
|
|
d9ace35c3e | ||
|
|
1fe92cee6f | ||
|
|
267868c3b0 | ||
|
|
6d27eb7f64 | ||
|
|
2e10fa494f | ||
|
|
039be65a89 | ||
|
|
570ecd9987 | ||
|
|
a575180475 | ||
|
|
07d1a20f3d | ||
|
|
76491cbb31 | ||
|
|
bf7d6ddcb2 | ||
|
|
44b969e0b6 | ||
|
|
176e470497 | ||
|
|
646a10d9bf | ||
|
|
52137fd64f | ||
|
|
3ccac8c3b8 | ||
|
|
0be158afa1 | ||
|
|
e6942e0122 | ||
|
|
496b22026f | ||
|
|
bb2df02dff | ||
|
|
4c850ecc31 | ||
|
|
da9c6f6e23 | ||
|
|
58ba0b0b4e | ||
|
|
1d0b87246a | ||
|
|
920b60da19 | ||
|
|
523e66294b | ||
|
|
23f8f35098 | ||
|
|
8d210b5e37 | ||
|
|
3c6c0e6700 | ||
|
|
01344c451f | ||
|
|
2c42c79482 | ||
|
|
75c2cfe7bf | ||
|
|
6c6eeb3f28 | ||
|
|
31053e0cd0 | ||
|
|
aad9aced18 | ||
|
|
dd2c9eeafe | ||
|
|
740d76bc42 | ||
|
|
45f4f5afd9 | ||
|
|
e875de3e98 | ||
|
|
fd7786633d | ||
|
|
bce9cfa39a | ||
|
|
ff3d66a661 | ||
|
|
006d28abd5 | ||
|
|
59b1e63bdf | ||
|
|
eab74ef06b | ||
|
|
89837de9b0 | ||
|
|
b245931c79 | ||
|
|
fd5e42698c | ||
|
|
c75512ba6e | ||
|
|
a22e7aa0b1 | ||
|
|
020dd97f99 | ||
|
|
e9882d9702 | ||
|
|
fd4a27dbf2 | ||
|
|
9c63e31da6 | ||
|
|
c91f809eba | ||
|
|
a54eaf5371 | ||
|
|
8032bd4bb9 | ||
|
|
ea1beec2f7 | ||
|
|
05f2f6820e | ||
|
|
0f5f15a5ce | ||
|
|
14ac37e8a5 | ||
|
|
1fae89cbb6 | ||
|
|
8b4008798f | ||
|
|
fd4faf59b8 | ||
|
|
109891d668 | ||
|
|
bdea796121 | ||
|
|
c8813c05c9 | ||
|
|
1cff08ce5d | ||
|
|
a868118f6f | ||
|
|
e5c62f5750 | ||
|
|
4084e8790b | ||
|
|
8d931dd773 | ||
|
|
25d6366297 | ||
|
|
08cd5b81d1 | ||
|
|
5d3a8a5b1a | ||
|
|
79b84da4b8 | ||
|
|
68b07c5913 | ||
|
|
553db9124d | ||
|
|
b495f37299 | ||
|
|
1915547594 | ||
|
|
03de29164a | ||
|
|
86d8b50547 | ||
|
|
7b04386162 | ||
|
|
07bfdf3e4d | ||
|
|
d510224e2a | ||
|
|
e658f9297d | ||
|
|
2b502e9a0f | ||
|
|
59141f9bbe | ||
|
|
3af66b72f2 | ||
|
|
422c24bd68 | ||
|
|
f0f87c8eb9 | ||
|
|
80dad54119 | ||
|
|
56a76df28e | ||
|
|
ee2c801fe0 | ||
|
|
fc314cc248 | ||
|
|
fe231a4c80 | ||
|
|
2e2bbe0a7f | ||
|
|
857e6e8345 | ||
|
|
3402981ada | ||
|
|
f401e577e5 | ||
|
|
0241a50c6f | ||
|
|
2a2e1236fc | ||
|
|
9b170f2b4f | ||
|
|
51e9ff59de | ||
|
|
2977dbcded | ||
|
|
ac60b51035 | ||
|
|
4c2f33a089 | ||
|
|
3b071116ac | ||
|
|
a9f265a591 | ||
|
|
5b62fc8103 | ||
|
|
0598f5f89a | ||
|
|
f723427b8b | ||
|
|
f69a004c1c | ||
|
|
1134b18a8b | ||
|
|
2e4aa507f7 | ||
|
|
5fb96cdcf4 | ||
|
|
e8cba3524e | ||
|
|
7e6b5363f1 | ||
|
|
29457a1d28 | ||
|
|
731455f164 | ||
|
|
b01a8cace6 | ||
|
|
72db5b4fac | ||
|
|
ddfd42994e | ||
|
|
2a9ff9c5ef | ||
|
|
6d49f05356 | ||
|
|
85a5e62e36 | ||
|
|
e67965a381 | ||
|
|
ec4723096f | ||
|
|
762b678d24 | ||
|
|
38fcc57bbf | ||
|
|
c8c57c74cc | ||
|
|
0784448c69 | ||
|
|
de0064af47 | ||
|
|
baae1fc84f | ||
|
|
2ab999f4ca | ||
|
|
c9f390d6e0 | ||
|
|
af05922ecc | ||
|
|
299edbf3ab | ||
|
|
c8abed9d48 | ||
|
|
3622c49ce1 | ||
|
|
0462e9a7d9 | ||
|
|
c3a6091908 | ||
|
|
ab5fedda0b | ||
|
|
ba70269398 | ||
|
|
77fd5fa7de | ||
|
|
ab74290fe3 | ||
|
|
3aad9d8166 | ||
|
|
572e078d87 | ||
|
|
ee4548230b | ||
|
|
96b93bd876 | ||
|
|
927f69fe30 | ||
|
|
7e9ad5927a | ||
|
|
6d6b07865e | ||
|
|
376e7977f0 | ||
|
|
83ae66daea | ||
|
|
89e0be0099 | ||
|
|
ef40c1212e | ||
|
|
3a2a2a4ffa | ||
|
|
9592a69986 | ||
|
|
89be07e1f2 | ||
|
|
c61c3ae0e9 | ||
|
|
817350c8c5 | ||
|
|
3603b7c82b | ||
|
|
5743c72cca | ||
|
|
4cdd66ceff | ||
|
|
d3947d2cfa | ||
|
|
07718b994a | ||
|
|
ef9d463bd7 | ||
|
|
8745c7884e | ||
|
|
b6965105b7 | ||
|
|
3d269fe8be | ||
|
|
be5f00aa1a | ||
|
|
59ba350f34 | ||
|
|
803c5377a6 | ||
|
|
7c12bf7fa1 | ||
|
|
ca35a9681f | ||
|
|
9fe5f37337 | ||
|
|
0742901cd2 | ||
|
|
5e4d2dedbe | ||
|
|
411ea56a3e | ||
|
|
cda57dd4b4 | ||
|
|
4351de503f | ||
|
|
6339ba6bfb | ||
|
|
ef6677f43d | ||
|
|
a7824af5a8 | ||
|
|
1eb7d7b7a8 | ||
|
|
11c33d4447 | ||
|
|
b8a3cc8b60 | ||
|
|
27c688252d | ||
|
|
3e2afd4b1d | ||
|
|
f45b0686d2 | ||
|
|
1f3f881f81 | ||
|
|
ceb51bb14f | ||
|
|
3e22573d8d | ||
|
|
79418a3767 | ||
|
|
40d4683de1 | ||
|
|
79e5b54ec7 | ||
|
|
bd81923f2f | ||
|
|
69560b8ad7 | ||
|
|
dc413e7b73 | ||
|
|
7fc00c446b | ||
|
|
2efc423cf8 | ||
|
|
8ec3086cdd | ||
|
|
5fc7079023 | ||
|
|
bfbd254be7 | ||
|
|
f8ea43466c | ||
|
|
75ab1fa570 | ||
|
|
bf4a46d57c | ||
|
|
1046dd5eda | ||
|
|
f9e32a119a | ||
|
|
dbb8b8a439 | ||
|
|
2a65c3dc8f | ||
|
|
f17ec9e9d7 | ||
|
|
675d6d8328 | ||
|
|
6dc9ccad75 | ||
|
|
6add02702b | ||
|
|
958d6377e3 | ||
|
|
9954154ca2 | ||
|
|
4ecbf8c12c | ||
|
|
fc8a3c5fb4 | ||
|
|
01e7dff1a0 | ||
|
|
018c0064cd | ||
|
|
c2b016370b | ||
|
|
fc791b4371 | ||
|
|
f76bb009f4 | ||
|
|
8a1292b295 | ||
|
|
d7d80d3fc1 | ||
|
|
41b01003fd | ||
|
|
6557070ae1 | ||
|
|
e7e580e177 | ||
|
|
dd9ddd2019 | ||
|
|
74aae523ba | ||
|
|
48c40f9516 | ||
|
|
e0e7674715 | ||
|
|
e1a65276b9 | ||
|
|
469adc85ad | ||
|
|
e1b181ca4e | ||
|
|
a4f0fbf8b7 | ||
|
|
190cdaddf8 | ||
|
|
5c4ba13839 | ||
|
|
e62630cf3e | ||
|
|
36fe7846c0 | ||
|
|
8d150dd67a | ||
|
|
506df00d81 | ||
|
|
a9121fa28f | ||
|
|
d5a56d9e85 | ||
|
|
acf7c0c665 | ||
|
|
619d48c97a | ||
|
|
2cb198c38c | ||
|
|
e8e39e0f3c | ||
|
|
37860181d4 | ||
|
|
d119dd9a0c | ||
|
|
09ef19f7ec | ||
|
|
6a06c92fa6 | ||
|
|
58ae596b0f | ||
|
|
f1ca21678d | ||
|
|
d7eeef2c8a | ||
|
|
4f626897f2 | ||
|
|
b127e01845 | ||
|
|
2118beeb23 | ||
|
|
5020cd1bbf | ||
|
|
cce636224c | ||
|
|
60b3b8ddce | ||
|
|
41446ec9ba | ||
|
|
df8b047bca | ||
|
|
12ced52012 | ||
|
|
1d53335ae5 | ||
|
|
971a50d290 | ||
|
|
36dd9106a8 | ||
|
|
0a4ee3ffc7 | ||
|
|
cfe32f1a70 | ||
|
|
d877f5d5c6 | ||
|
|
0ab6ffefb4 | ||
|
|
a292a1d23a | ||
|
|
3f87f6aee3 | ||
|
|
04bcd145d3 | ||
|
|
244e811291 | ||
|
|
ac7467fb59 | ||
|
|
2c0436216f | ||
|
|
017fbf267b | ||
|
|
e6afbf2ec0 | ||
|
|
906b4aad9e | ||
|
|
4cf8d41f6a | ||
|
|
47c860142e | ||
|
|
2fba3f213b | ||
|
|
af7c6f9fce | ||
|
|
78534deab6 | ||
|
|
6710314832 | ||
|
|
0cd4fa6fa0 | ||
|
|
065949496e | ||
|
|
39c82576ae | ||
|
|
37221a508d | ||
|
|
6b43a32a10 | ||
|
|
d7cd1ff142 | ||
|
|
659d947863 | ||
|
|
39be7a6288 | ||
|
|
8ac976c579 | ||
|
|
70fd432c57 | ||
|
|
00135f2f49 | ||
|
|
9b944bc29c | ||
|
|
d520b3d2a0 | ||
|
|
6f41d9855b | ||
|
|
2d7c1da741 | ||
|
|
c0f45b6b1e | ||
|
|
7a0025673c | ||
|
|
ad7ec79903 | ||
|
|
0543239cca | ||
|
|
ff3dad2457 | ||
|
|
298d5e197b | ||
|
|
d73c0a998d | ||
|
|
1b79a3ddbf | ||
|
|
a8478ace18 | ||
|
|
72cf5f3f9f | ||
|
|
6f9d493a18 | ||
|
|
08f7d5ebff | ||
|
|
1fe3675403 | ||
|
|
a0f956d2c1 | ||
|
|
1560f91b4a | ||
|
|
c20f362594 | ||
|
|
7ae8c26e50 | ||
|
|
adfffe6121 | ||
|
|
64601baa76 | ||
|
|
aa374b51f1 | ||
|
|
5c483745ff | ||
|
|
0c247110a0 | ||
|
|
1643638a78 | ||
|
|
4ace228fc2 | ||
|
|
25aa86a0dc | ||
|
|
70d3b24338 | ||
|
|
8664e9d19b | ||
|
|
50d9877446 | ||
|
|
fe06352089 | ||
|
|
7b599419b5 | ||
|
|
491adf072e | ||
|
|
f6aae2b048 | ||
|
|
d2d5c94633 | ||
|
|
10581f9ef2 | ||
|
|
c7e0e1c038 | ||
|
|
a914d701eb | ||
|
|
0f9dee6e9c | ||
|
|
aa383e2190 | ||
|
|
9bbfcf326c | ||
|
|
3948e67c8f | ||
|
|
d56e1b2cc5 | ||
|
|
bfac1f1bc2 | ||
|
|
d4a956c355 | ||
|
|
6c71fefa58 | ||
|
|
ad3003c00a | ||
|
|
0ad5dcb258 | ||
|
|
d790309b02 | ||
|
|
1072faf309 | ||
|
|
d2c196896d | ||
|
|
e42b608444 | ||
|
|
89a501a3af | ||
|
|
c19b78180c | ||
|
|
c0b750a09a | ||
|
|
c967e618a1 | ||
|
|
59f78d7dfc | ||
|
|
d8405f0d05 | ||
|
|
0f34f0033c | ||
|
|
190646d50c | ||
|
|
a46c6252c6 | ||
|
|
5c1886c8f5 | ||
|
|
afcb3d8f34 | ||
|
|
9fbffafdbf | ||
|
|
075f0458f7 | ||
|
|
d4568aa0a7 | ||
|
|
97588408a2 | ||
|
|
1def9b301b | ||
|
|
5bac442b18 | ||
|
|
6add682705 | ||
|
|
8b50d84a05 | ||
|
|
d3858b81e2 | ||
|
|
bdff9769be | ||
|
|
c61df75e5e | ||
|
|
a74bf2cc27 | ||
|
|
ada0f93686 | ||
|
|
ff36f2ba17 | ||
|
|
5164cfd399 | ||
|
|
5fa021503e | ||
|
|
7b5d79d313 | ||
|
|
3e3f38500d | ||
|
|
5109b9abfd | ||
|
|
7fb4777c1c | ||
|
|
c38533e0f8 | ||
|
|
51ba99d09e | ||
|
|
9159f86a9e | ||
|
|
e139f4fc13 | ||
|
|
2fbfeacb87 | ||
|
|
ebb7a9fcda | ||
|
|
9e72317302 | ||
|
|
d764c20c08 | ||
|
|
9c17b8a098 | ||
|
|
3084873154 | ||
|
|
32809e56d0 | ||
|
|
9f05b182a2 | ||
|
|
525484e834 | ||
|
|
65a4e69cae | ||
|
|
e973f8bab9 | ||
|
|
92466671ff | ||
|
|
6d61106070 | ||
|
|
ac13749fb8 | ||
|
|
7ec1a9a316 | ||
|
|
cf17e21ad3 | ||
|
|
0e0240c4ab | ||
|
|
d1b290b91a | ||
|
|
a63696836c | ||
|
|
46aad00f16 | ||
|
|
252afe8932 | ||
|
|
9dd467a613 | ||
|
|
4c14df67cc | ||
|
|
20e0fe3ba1 | ||
|
|
6a005135f2 | ||
|
|
82e8375957 | ||
|
|
bb25edc09e | ||
|
|
169c0fe4af | ||
|
|
cd6918e6eb | ||
|
|
5be035fd44 | ||
|
|
f1edc8443c | ||
|
|
d9564bd04c | ||
|
|
35f1c396f2 | ||
|
|
6acb950990 | ||
|
|
27e0d1641a | ||
|
|
9ac71ff8af | ||
|
|
075737a4ec | ||
|
|
6d0e4a6a5e | ||
|
|
a2544768a0 | ||
|
|
8574a14ed2 | ||
|
|
e90c555c18 | ||
|
|
863b9a410f | ||
|
|
23c7bbc7d5 | ||
|
|
f900189f90 | ||
|
|
7c74be2790 | ||
|
|
70dd2d4829 | ||
|
|
914b7ee056 | ||
|
|
e39f83edbf | ||
|
|
52fe0c6abb | ||
|
|
5cb3e5937f | ||
|
|
e0cd224831 | ||
|
|
de225ac64a | ||
|
|
5807808a10 | ||
|
|
362877d18f | ||
|
|
88b8dd0149 | ||
|
|
1552f32e09 | ||
|
|
50b73a6720 | ||
|
|
53e51f1735 | ||
|
|
40b63bfebe | ||
|
|
89861eceef | ||
|
|
b8eaff66fa | ||
|
|
a747fdd27d | ||
|
|
27851bdefa | ||
|
|
3fdeb40ddf | ||
|
|
546c7cebd3 | ||
|
|
473902f5f4 | ||
|
|
41c0721159 | ||
|
|
413d4badfd | ||
|
|
c5d67ebf72 | ||
|
|
91818cfa1a | ||
|
|
6263d684d9 | ||
|
|
07140d33a7 | ||
|
|
4ffc388491 | ||
|
|
0ef026c610 | ||
|
|
153c7fdf20 | ||
|
|
90379eeb35 | ||
|
|
3ae959af95 | ||
|
|
c8cc652b71 | ||
|
|
4b6285e5c2 | ||
|
|
013de7b3ef | ||
|
|
e11e88a9c5 | ||
|
|
7cec8baa55 | ||
|
|
e987db9fb5 | ||
|
|
c603b9084f | ||
|
|
492d6dfcf0 | ||
|
|
a3e0f2dcc3 | ||
|
|
cf211e26f4 | ||
|
|
c5aaaa7c55 | ||
|
|
f86d077e27 | ||
|
|
f8076825cb | ||
|
|
201d8a97d4 | ||
|
|
d08f326990 | ||
|
|
8dc9d3bc78 | ||
|
|
adf95ce3a0 | ||
|
|
3c1aca114f | ||
|
|
18d0fd9d2a | ||
|
|
c2e673f978 | ||
|
|
2bde8a1975 | ||
|
|
bf9927c7dd | ||
|
|
f339a087a2 | ||
|
|
6ccc5f3788 | ||
|
|
1affb91f17 | ||
|
|
7779c3e372 | ||
|
|
49ba7ad22e | ||
|
|
6ad33d60f7 | ||
|
|
0117274061 | ||
|
|
e50192a407 | ||
|
|
c6fc0e587e | ||
|
|
68c448bc34 | ||
|
|
ef62272df7 | ||
|
|
b885ccbd63 | ||
|
|
da6f1d0f12 | ||
|
|
4c0d435b6b | ||
|
|
52a6a7bce8 | ||
|
|
0e717a2de4 | ||
|
|
cada862214 | ||
|
|
682c6d4e7b | ||
|
|
d0a253c97e | ||
|
|
c0e2b3027b | ||
|
|
e7dc14b07d | ||
|
|
0da9146e90 | ||
|
|
ad05a33e02 | ||
|
|
8224e038a3 | ||
|
|
03c04c2141 | ||
|
|
2e091b04e5 | ||
|
|
60296493fe | ||
|
|
20c20f8f9b | ||
|
|
f1d642a4e5 | ||
|
|
e0e5ea17a4 | ||
|
|
91a0ba72dc | ||
|
|
c54c5a974a | ||
|
|
532b8c54ab | ||
|
|
5ac87891b5 | ||
|
|
2d905ce3fb | ||
|
|
831112abd2 | ||
|
|
153d0f5505 | ||
|
|
c78896a335 | ||
|
|
316ec98e0f | ||
|
|
cf58545a45 | ||
|
|
513d732934 | ||
|
|
e86015badc | ||
|
|
c8f65fc9a1 | ||
|
|
2c4001387e | ||
|
|
caa39474cb | ||
|
|
7684602ea8 | ||
|
|
4601989d4a | ||
|
|
23f697d62b | ||
|
|
4ff39f8817 | ||
|
|
1df41003ec | ||
|
|
1f39ee41ad | ||
|
|
42d8b1ecb9 | ||
|
|
a4da7b33e6 | ||
|
|
e4ee9e9095 | ||
|
|
77430a282f | ||
|
|
30e459252c | ||
|
|
e6c1dd532d | ||
|
|
d1f301e059 | ||
|
|
79eb5b2ed2 | ||
|
|
f0533fca70 | ||
|
|
08e98eeb15 | ||
|
|
b2f719989d | ||
|
|
1e812c40ce | ||
|
|
a949641342 | ||
|
|
c231e88a5d | ||
|
|
79c71509f6 | ||
|
|
5dab580cfc | ||
|
|
499a157946 | ||
|
|
c5a7ab2415 | ||
|
|
3dd5a6f378 | ||
|
|
7be26a0677 | ||
|
|
c183fdd3ca | ||
|
|
baa439457e | ||
|
|
4dbcd54b72 | ||
|
|
11062f2d4f | ||
|
|
a0466085fe | ||
|
|
f2f7d77847 | ||
|
|
b2105f2d88 | ||
|
|
4126f3bdcb | ||
|
|
74ccfe6088 | ||
|
|
48085b5573 | ||
|
|
7b9ddc9b3b | ||
|
|
15726a759c | ||
|
|
2c7474ea87 | ||
|
|
c726aee643 | ||
|
|
c3e94e1480 | ||
|
|
5f1343e5b4 | ||
|
|
ffb1303d61 | ||
|
|
a0b0d938f0 | ||
|
|
158f5ba7d9 | ||
|
|
b8cf40161c | ||
|
|
fb96e6a56f | ||
|
|
6668ba2511 | ||
|
|
4668ef3020 | ||
|
|
630f2b7d19 | ||
|
|
dde0a4a7c8 | ||
|
|
c69dc0f036 | ||
|
|
b06f69573d | ||
|
|
8fd03f7434 | ||
|
|
90e4ac2d23 | ||
|
|
956bceae75 | ||
|
|
c663be86de | ||
|
|
aca78baecf | ||
|
|
fbcf6b7954 | ||
|
|
84123222aa | ||
|
|
e9dbcf693d | ||
|
|
1cd0a9d48f | ||
|
|
1b48e44914 | ||
|
|
0a398f03fd | ||
|
|
15ed3e52f2 | ||
|
|
8990919dab | ||
|
|
e5638e4b15 | ||
|
|
404c6fac9a | ||
|
|
267395bfa2 | ||
|
|
920fc5ae99 | ||
|
|
92ed0ae51b | ||
|
|
c694776162 | ||
|
|
7e2ba41c64 | ||
|
|
bb2c744ec0 | ||
|
|
873f14bbe0 | ||
|
|
31110b1927 | ||
|
|
6764a98409 | ||
|
|
fd7b5f393a | ||
|
|
2ca528f93f | ||
|
|
ce2e6b7d35 | ||
|
|
684c5d225a | ||
|
|
b75018b03b | ||
|
|
41499d4b3c | ||
|
|
383c97c303 | ||
|
|
74b54ef371 | ||
|
|
bbf7b4db79 | ||
|
|
c61f0acab5 | ||
|
|
398af123b2 | ||
|
|
315fa9d7d3 | ||
|
|
fb5e8ef40c | ||
|
|
e79d764148 | ||
|
|
ebbee0dc43 | ||
|
|
ed0c16e201 | ||
|
|
209fdf349a | ||
|
|
f49f2afacd | ||
|
|
8c6330a3c4 | ||
|
|
337b777125 | ||
|
|
1b756e8d96 | ||
|
|
52d478df1a | ||
|
|
0c782edf21 | ||
|
|
e3948d295e | ||
|
|
5f2c742a5c | ||
|
|
b30c77aab9 | ||
|
|
a5916b9c49 | ||
|
|
453180e30b | ||
|
|
8bd432d391 | ||
|
|
c9d3e20aef | ||
|
|
d5408d1f09 | ||
|
|
f334532aba | ||
|
|
be77c09f3d | ||
|
|
7de6a92753 | ||
|
|
36f76f5a14 | ||
|
|
b84523d557 | ||
|
|
21a557a184 | ||
|
|
2c78c415e9 | ||
|
|
79ccb30dd2 | ||
|
|
3c566becf6 | ||
|
|
151ca593af | ||
|
|
4132eacba0 | ||
|
|
06e6151816 | ||
|
|
70277d4edd | ||
|
|
d21d2f1a9c | ||
|
|
74a7be996f | ||
|
|
3f38579529 | ||
|
|
4d5a9f6e15 | ||
|
|
41f47acd76 | ||
|
|
821dcaa7c7 | ||
|
|
7135d26419 | ||
|
|
f7fd354dce | ||
|
|
0c69a65bc4 | ||
|
|
2f2ca5eab4 | ||
|
|
df9c40c035 | ||
|
|
25b67017e4 | ||
|
|
bc9c3346f3 | ||
|
|
1db7e19fe8 | ||
|
|
102c03ce2b | ||
|
|
ec19eb4455 | ||
|
|
6d9924d50e | ||
|
|
16c4d74274 | ||
|
|
e4af5fd36a | ||
|
|
702775493a | ||
|
|
b2ae826066 | ||
|
|
cc3e9990fa | ||
|
|
271cbddd5e | ||
|
|
26dfbb3028 | ||
|
|
f16cd987e4 | ||
|
|
c1423ca9ad | ||
|
|
74379150a1 | ||
|
|
c840a30c30 | ||
|
|
ae5277a898 | ||
|
|
bffa837825 | ||
|
|
b9e7d0faea | ||
|
|
860b08d9ed | ||
|
|
691dc1d49e | ||
|
|
9d6886d367 | ||
|
|
9589b68f5a | ||
|
|
28d88af1af | ||
|
|
8b5acd1849 | ||
|
|
33dc63a7fd | ||
|
|
d0a86385b7 | ||
|
|
50a49e2c8c | ||
|
|
c60adb113e | ||
|
|
aee015e8f6 | ||
|
|
bf6af29205 | ||
|
|
329905d472 | ||
|
|
00d450d262 | ||
|
|
2365d1bd20 | ||
|
|
5b385c18e5 | ||
|
|
98c0434ec0 | ||
|
|
f318d0a3bc | ||
|
|
27f5b410c0 | ||
|
|
3f55be9676 | ||
|
|
b05d2d3a2d | ||
|
|
19af5f9e0b | ||
|
|
f37f330670 | ||
|
|
40082d4571 | ||
|
|
00d655f346 | ||
|
|
821726e7c0 | ||
|
|
759e905c3c | ||
|
|
8bf7e42913 | ||
|
|
0dcd073554 | ||
|
|
2fe35d578d | ||
|
|
8d139e156e | ||
|
|
7c2849356a | ||
|
|
0025ffd1c0 | ||
|
|
2ef7146642 | ||
|
|
1b27e69e40 | ||
|
|
8e7b757efd | ||
|
|
1ab543cea1 | ||
|
|
a3f86903e4 | ||
|
|
c239c305ab | ||
|
|
2e02af994e | ||
|
|
2f4062a923 | ||
|
|
836d9afe17 | ||
|
|
007a352742 | ||
|
|
e526e5659e | ||
|
|
4a5227c7bf | ||
|
|
c2c151ec4c | ||
|
|
452096e7e4 | ||
|
|
50c2a9859e | ||
|
|
677b667307 | ||
|
|
5c338cd0a7 | ||
|
|
1adf331268 | ||
|
|
349b3e961b | ||
|
|
96650c06f0 | ||
|
|
26038a0a07 | ||
|
|
6a148b5dd9 | ||
|
|
0e109ef979 | ||
|
|
de2285d5e9 | ||
|
|
b2483ba437 | ||
|
|
a82a5e5a49 | ||
|
|
d161a02e71 | ||
|
|
d2b6a700b1 | ||
|
|
af203cef24 | ||
|
|
673e917e76 | ||
|
|
a3bd41db54 | ||
|
|
0d9527921a | ||
|
|
f0e4aec0af | ||
|
|
b0d65b5edd | ||
|
|
75532ef591 | ||
|
|
9a6d1bd700 | ||
|
|
a7ed6c15d3 | ||
|
|
5ee49ba065 | ||
|
|
190d857949 | ||
|
|
d34bd47bea | ||
|
|
f17792380b | ||
|
|
c11920110e | ||
|
|
ec5a993fea | ||
|
|
d250c2cc89 | ||
|
|
767e73f40c | ||
|
|
3f699c9d2f | ||
|
|
50dbd9befd | ||
|
|
760e01bf92 | ||
|
|
543f435b1e | ||
|
|
91337218b3 | ||
|
|
afff3c0a49 | ||
|
|
2b6c271d37 | ||
|
|
b0c1a6f73a | ||
|
|
a1871e4bc3 | ||
|
|
3aa0294cd4 | ||
|
|
310b266251 | ||
|
|
21b1b5098e | ||
|
|
a3a4a5d8a5 | ||
|
|
270536f33c | ||
|
|
66bb433cc6 | ||
|
|
bd4ef1a03a | ||
|
|
aa2d9a3bf1 | ||
|
|
257308d5db | ||
|
|
d4620e1654 | ||
|
|
fd6cbb138c | ||
|
|
aa75c8e5e4 | ||
|
|
c461fc6daa | ||
|
|
96eaa833f5 | ||
|
|
863b13a694 | ||
|
|
e6fea4e6dd | ||
|
|
83bfc13056 | ||
|
|
bc4f09209b | ||
|
|
967ca17238 | ||
|
|
595c72147c | ||
|
|
f3c3b5a649 | ||
|
|
1cd2c5e653 | ||
|
|
b2873dd44b | ||
|
|
bb80ab4026 | ||
|
|
80cabb338b | ||
|
|
2c69e2c151 | ||
|
|
c1dd23f5e0 | ||
|
|
f93624a41c | ||
|
|
9f4559a059 | ||
|
|
fd05cad303 | ||
|
|
d58b06e493 | ||
|
|
d7a6127273 | ||
|
|
8ee9984e4e | ||
|
|
2f0b549027 | ||
|
|
87dbd7e541 | ||
|
|
96e5da36be | ||
|
|
43745edac0 | ||
|
|
18bee21cfc | ||
|
|
e5b6121d17 | ||
|
|
f5ceee547c | ||
|
|
b612bce779 | ||
|
|
2e88e5e9c7 | ||
|
|
9a7aa25c90 | ||
|
|
c4420fe932 | ||
|
|
a5260f3a95 | ||
|
|
47ccf4b1f5 | ||
|
|
a356b21895 | ||
|
|
614a36c888 | ||
|
|
b7e717ee8c | ||
|
|
f520fe36bd | ||
|
|
7273a1c34d | ||
|
|
dc45cbce37 | ||
|
|
708d8f75c0 | ||
|
|
bd37d90228 | ||
|
|
b1ad691464 | ||
|
|
f4e7baf31e | ||
|
|
c0e60c41f2 | ||
|
|
c8dad43e00 | ||
|
|
a8f124704d | ||
|
|
eed2816491 | ||
|
|
a6334b3e35 | ||
|
|
334beebfeb | ||
|
|
13dad848bd | ||
|
|
e518f4cef8 | ||
|
|
c8fd5da2da | ||
|
|
3a74729ecc | ||
|
|
49c672ac4d | ||
|
|
b570cb5b77 | ||
|
|
97bf388471 | ||
|
|
1a32aaea6f | ||
|
|
4635883dec | ||
|
|
3ba6db4a50 | ||
|
|
2f1de25747 | ||
|
|
f60fd42ac0 | ||
|
|
ecc8f9c792 | ||
|
|
e295dfdcf7 | ||
|
|
fc42c25390 | ||
|
|
27d5858e06 | ||
|
|
e1ef732b60 | ||
|
|
9840b95c21 | ||
|
|
a6f8446d81 | ||
|
|
c1c844c830 | ||
|
|
389299afd1 | ||
|
|
826543a291 | ||
|
|
4ac83cfded | ||
|
|
64c363ce53 | ||
|
|
cca4347bf9 | ||
|
|
3ae3d4926a | ||
|
|
36025d6d9f | ||
|
|
e171362e3e | ||
|
|
3e0bf2ae15 | ||
|
|
07aa9f4b8b | ||
|
|
b2d9f3fc64 | ||
|
|
5fb3e9167e | ||
|
|
99c74b31be | ||
|
|
ce5b13824e | ||
|
|
c39170c42e | ||
|
|
9e96824161 | ||
|
|
fd19fbf300 | ||
|
|
166469827f | ||
|
|
a34ed538b6 | ||
|
|
5f22d3e055 | ||
|
|
fdd700f3e5 | ||
|
|
adf930f126 | ||
|
|
05f41928cd | ||
|
|
2ee0829871 | ||
|
|
743560825d | ||
|
|
e3d84ac349 | ||
|
|
266c832b30 | ||
|
|
f5374a024e | ||
|
|
4956d826fb | ||
|
|
f5cc2af5d0 | ||
|
|
84ca8e1f3e | ||
|
|
5880d4a6ec | ||
|
|
ae05dce958 | ||
|
|
9ebe372a9a | ||
|
|
e6e04cc5b3 | ||
|
|
12352510fd | ||
|
|
2b3d927937 | ||
|
|
a8890740f5 | ||
|
|
f60d7ee54b | ||
|
|
896ca2ef6b | ||
|
|
c036f6d529 | ||
|
|
6f457c0c59 | ||
|
|
13bf1b27b4 | ||
|
|
f742bb1c47 | ||
|
|
aa0b9e2db2 | ||
|
|
c10076f7ed | ||
|
|
bcd92499f2 | ||
|
|
b2bb0d4f72 | ||
|
|
e140481f14 | ||
|
|
6b7b71b1f8 | ||
|
|
186bd11463 | ||
|
|
a0490d6687 | ||
|
|
beef740ade | ||
|
|
2ac7786a90 | ||
|
|
a3fb5e910f | ||
|
|
319afe86b5 | ||
|
|
762ab66b86 | ||
|
|
0c239a42de | ||
|
|
e9322fba26 | ||
|
|
39b6df27b3 | ||
|
|
b1ee284e7f | ||
|
|
e986332bf2 | ||
|
|
48f9b27381 | ||
|
|
42a6e0dd10 | ||
|
|
d4798b02ac | ||
|
|
963edfe8ab | ||
|
|
53237f3ae0 | ||
|
|
64da9281a4 | ||
|
|
ab7fd9799d | ||
|
|
f6bcc84251 | ||
|
|
35dc3d9df9 | ||
|
|
566714a75d | ||
|
|
c92f30b122 | ||
|
|
294ad094c4 | ||
|
|
c1a0f520f9 | ||
|
|
773c24b7fc | ||
|
|
8f926c7ca9 | ||
|
|
c562cbc2bb | ||
|
|
3fbbb0865a | ||
|
|
7d5f612a48 | ||
|
|
4a5a36440b | ||
|
|
43dd5cfea1 | ||
|
|
7b5fec1842 | ||
|
|
5762ded601 | ||
|
|
a3abb86daa | ||
|
|
4f5c656b05 | ||
|
|
a31cddbe7b | ||
|
|
b4ecd93f1c | ||
|
|
1a702b08b9 | ||
|
|
8c52dfb804 | ||
|
|
0acc23e058 | ||
|
|
cdd5f9b628 | ||
|
|
4c9f5f4655 | ||
|
|
b80ba13cb4 | ||
|
|
8260bdc09c | ||
|
|
24f856e02b | ||
|
|
3aa619b928 | ||
|
|
4cb5e98d94 | ||
|
|
272910575e | ||
|
|
a15a62f4bc | ||
|
|
53cf11db8c | ||
|
|
01052fbe47 | ||
|
|
a5e1e075c7 | ||
|
|
6be32ac688 | ||
|
|
b362c0ef38 | ||
|
|
bba9969e31 | ||
|
|
007ba24809 | ||
|
|
df21539311 | ||
|
|
2592cb6019 | ||
|
|
f7df17a7ed | ||
|
|
62f42b72f8 | ||
|
|
a1ba4fda6f | ||
|
|
1c06b04c45 | ||
|
|
2ee22fd374 | ||
|
|
4c230d9e61 | ||
|
|
727294fbbe | ||
|
|
478c43969b | ||
|
|
79b5303350 | ||
|
|
ce4b742b25 | ||
|
|
a9dc15bda5 | ||
|
|
ba6387ff5c | ||
|
|
8fa98508b7 | ||
|
|
decdbaecf9 | ||
|
|
6d87cf9be0 | ||
|
|
94f434c4a6 | ||
|
|
7ba867c30b | ||
|
|
3424395e10 | ||
|
|
926c7359a2 | ||
|
|
ec0af99a2e | ||
|
|
b4d948886c | ||
|
|
4d8d79372a | ||
|
|
04a589722c | ||
|
|
d4a10e2873 | ||
|
|
4998ad6c7e | ||
|
|
a07ca5ff50 | ||
|
|
f07e7571ab | ||
|
|
834c16485c | ||
|
|
04a4265ef3 | ||
|
|
0ec473195d | ||
|
|
0bf09256b0 | ||
|
|
db8fd2c913 | ||
|
|
dbe6e5b3d7 | ||
|
|
cc81cd446b | ||
|
|
439c7118f1 | ||
|
|
d8154a5815 | ||
|
|
4e3787bc0d | ||
|
|
02e0955924 | ||
|
|
3c6a170138 | ||
|
|
a78950e822 | ||
|
|
1ce1a94a35 | ||
|
|
977b6d9f67 | ||
|
|
b5e6dbd797 | ||
|
|
833e6688f1 | ||
|
|
bc22c9f84f | ||
|
|
2149a7d116 | ||
|
|
29175d2c17 | ||
|
|
803454d5c8 | ||
|
|
36cf32dc42 | ||
|
|
657f4ab303 | ||
|
|
c0c38022ea | ||
|
|
93b66d26ff | ||
|
|
ea6552615d | ||
|
|
4bf3287fce | ||
|
|
832c2034c2 | ||
|
|
b0aa26e1f1 | ||
|
|
e52baeb967 | ||
|
|
8268eb9a83 | ||
|
|
3cc458abd9 | ||
|
|
337b4c4268 | ||
|
|
001f8657f6 | ||
|
|
ea884e7fa1 | ||
|
|
9be2844c82 | ||
|
|
1b1394cf5d | ||
|
|
1eef930dbb | ||
|
|
875c687e3f | ||
|
|
1e175e74ed | ||
|
|
75a46c365e | ||
|
|
8e7b8825f5 | ||
|
|
2ecbca303b | ||
|
|
8195a4d616 | ||
|
|
7ba40f925f | ||
|
|
345cd1795f | ||
|
|
959aaee045 | ||
|
|
53477f0f59 | ||
|
|
5716218f41 | ||
|
|
9df6b9d5c0 | ||
|
|
a0be47ab8b | ||
|
|
ec46031d36 | ||
|
|
55b84d166a | ||
|
|
34ae8bacec | ||
|
|
cb4e5ca0f7 | ||
|
|
0ba45468c4 | ||
|
|
710502784e | ||
|
|
0275a8558d | ||
|
|
58acc75cf6 | ||
|
|
874ababb9f | ||
|
|
3771e6b0cd | ||
|
|
33eaefa966 | ||
|
|
cd7e236d57 | ||
|
|
54c0b7c7d5 | ||
|
|
a2177daec2 | ||
|
|
628386b453 | ||
|
|
b222bfb3e0 | ||
|
|
ab199d883d | ||
|
|
356065d1ee | ||
|
|
76e7c5623d | ||
|
|
085fba050a | ||
|
|
295334d3ac | ||
|
|
36124ddca4 | ||
|
|
bd6585765e | ||
|
|
c325deb4ed | ||
|
|
73bb0b10ee | ||
|
|
72820b162c | ||
|
|
89e5b8d057 | ||
|
|
da4f53ebbb | ||
|
|
8458553b74 | ||
|
|
55ecc41d06 | ||
|
|
28fcdf2cbb | ||
|
|
24087679a8 | ||
|
|
5ac6a8cb4a | ||
|
|
668d85d14e | ||
|
|
c11a3dc95c | ||
|
|
56f57c20a2 | ||
|
|
240d14779a | ||
|
|
3550d1e61c | ||
|
|
6513ad249c | ||
|
|
50297b1880 | ||
|
|
f189b78b9e | ||
|
|
5c0250f495 | ||
|
|
2093f726e9 | ||
|
|
10efe3859d | ||
|
|
6933bcf7bb | ||
|
|
2ea046cd80 | ||
|
|
f4097a372b | ||
|
|
40b6de599c | ||
|
|
87ea2a2bef | ||
|
|
cc14a1c361 | ||
|
|
bcdface60d | ||
|
|
4dc9419d2e | ||
|
|
d2bcac813e | ||
|
|
080c37a7f6 | ||
|
|
c1c6f55f8f | ||
|
|
f9a3838db6 | ||
|
|
1e61db104b | ||
|
|
30a9c7718d | ||
|
|
34b052b5d3 | ||
|
|
aaa12853ad | ||
|
|
b0ab55b0bf | ||
|
|
d2f8496f4e | ||
|
|
4c7e081e15 | ||
|
|
1a69b16d36 | ||
|
|
b5e8673e62 | ||
|
|
264c6a50b6 | ||
|
|
493642eb38 | ||
|
|
28d42b9164 | ||
|
|
42f29062ca | ||
|
|
09392be069 | ||
|
|
5529dab84e | ||
|
|
60ca704a9e | ||
|
|
c4377ed6c2 | ||
|
|
7c4d5cee95 | ||
|
|
7d283ed65f | ||
|
|
bf1f941e50 | ||
|
|
789fef34ba | ||
|
|
1daf5a611c | ||
|
|
6aed1db67e | ||
|
|
cf68854770 | ||
|
|
711392c73b | ||
|
|
9573c32481 | ||
|
|
a15f80f79d | ||
|
|
23e7475f06 | ||
|
|
1eb571b787 | ||
|
|
dd3b716d85 | ||
|
|
28649c07e3 | ||
|
|
961e02be0d | ||
|
|
a161491bfd | ||
|
|
e0b4d1c1e4 | ||
|
|
fd4aaab137 | ||
|
|
42d14d5ca2 | ||
|
|
d3ff482c9b | ||
|
|
c9286624d4 | ||
|
|
f682368eeb | ||
|
|
4a5d033efb | ||
|
|
343161b195 | ||
|
|
bc576a9659 | ||
|
|
19e407fcc4 | ||
|
|
bc7327d004 | ||
|
|
666fa1c797 | ||
|
|
0eda4a7821 | ||
|
|
862058fd2b | ||
|
|
193d160bed | ||
|
|
69e5bcd57d | ||
|
|
efeddda328 | ||
|
|
1ddd746862 | ||
|
|
ff6938280e | ||
|
|
1e4425b30f | ||
|
|
b5d1d8cdad | ||
|
|
029be5ccca | ||
|
|
29c2d785b5 | ||
|
|
abda8cfa32 | ||
|
|
44e7d79d4c | ||
|
|
9a1dc8ee0e | ||
|
|
27879c3f01 | ||
|
|
29096eb5d7 | ||
|
|
a573baea03 | ||
|
|
48ace3de57 | ||
|
|
5af07c4531 | ||
|
|
44e36feb09 | ||
|
|
3395c84560 | ||
|
|
2a7d996881 | ||
|
|
94c2fc80d2 | ||
|
|
738f943a68 | ||
|
|
47e62a5681 | ||
|
|
1ecbfd7590 | ||
|
|
67c139a04b | ||
|
|
31cc008249 | ||
|
|
9cb026439d | ||
|
|
e6f10176c6 | ||
|
|
0917c79470 | ||
|
|
597baa986d | ||
|
|
75cc4b4843 | ||
|
|
aac088d496 | ||
|
|
a822e5bbc5 | ||
|
|
c527249c21 | ||
|
|
9ef798f534 | ||
|
|
e69b99f089 | ||
|
|
55b8079e86 | ||
|
|
e272dbe9af | ||
|
|
962f8354ac | ||
|
|
20e4a960f7 | ||
|
|
371db886b4 | ||
|
|
3904ca38c0 | ||
|
|
16527ceaf6 | ||
|
|
feec3e8255 | ||
|
|
82249cb50a | ||
|
|
fad417e553 | ||
|
|
5ba692f50c | ||
|
|
f799db67eb | ||
|
|
3e106a9dc5 | ||
|
|
907e01e524 | ||
|
|
b8ed23efa7 | ||
|
|
2b3bbf7e67 | ||
|
|
464fe627a3 | ||
|
|
6a9e39c470 | ||
|
|
7fec9a3cc6 | ||
|
|
008f6ef462 | ||
|
|
2440c108ca | ||
|
|
430baad8a4 | ||
|
|
51132e74b4 | ||
|
|
a4f33e106a | ||
|
|
baba3190e0 | ||
|
|
47b13aa5ea | ||
|
|
a0de3fc643 | ||
|
|
9de3c582c0 | ||
|
|
45cff2b51b | ||
|
|
670397a73e | ||
|
|
272eb37e9a | ||
|
|
ca79e58ab9 | ||
|
|
977c049875 | ||
|
|
aefbc1c9bf | ||
|
|
c37a2e61ed | ||
|
|
7f6cd5e469 | ||
|
|
f6d1f1985c | ||
|
|
222c31b306 | ||
|
|
e99185f011 | ||
|
|
5c662f1230 | ||
|
|
a65c7ee2fc | ||
|
|
743c4f554d | ||
|
|
838b2757eb | ||
|
|
a92c9fc226 | ||
|
|
ed052e0b0b | ||
|
|
ae88d3054d | ||
|
|
7bb8b9039c | ||
|
|
3800b4b45c | ||
|
|
cd498711bc | ||
|
|
411b600e14 | ||
|
|
0a0ad9a184 | ||
|
|
234bead59e | ||
|
|
76de310986 | ||
|
|
817f050bcd | ||
|
|
60ae685d1e | ||
|
|
dc9670c439 | ||
|
|
03c8079858 | ||
|
|
0cfc527328 | ||
|
|
f66a820e14 | ||
|
|
4c7bdbb284 | ||
|
|
435251ca41 | ||
|
|
324a0dd38f | ||
|
|
cc77d93918 | ||
|
|
0ea7d8bd8c | ||
|
|
2e6bea23ac | ||
|
|
ca75dd0728 | ||
|
|
849b217143 | ||
|
|
9af6efba59 | ||
|
|
079d6f06ef | ||
|
|
9cf0757689 | ||
|
|
b54c438948 | ||
|
|
c3ff4bfdad | ||
|
|
e103676b65 | ||
|
|
17e395c2a8 | ||
|
|
d50c1f39ab | ||
|
|
ef6b25b3bb | ||
|
|
9f35fa0fa3 | ||
|
|
ff48996bbe | ||
|
|
2fe4d97061 | ||
|
|
eb38393cad | ||
|
|
5d62e066e2 | ||
|
|
e94219c5a3 | ||
|
|
8ed9634adf | ||
|
|
0aefa9599f | ||
|
|
e279cf0575 | ||
|
|
a3f0ef8e77 | ||
|
|
8eba05ed4a | ||
|
|
2f78155723 | ||
|
|
6785221479 | ||
|
|
9bc410dd3d | ||
|
|
2491ab6bf9 | ||
|
|
f615ed40cd | ||
|
|
430f2cafc1 | ||
|
|
0ad049da88 | ||
|
|
2c7691567b | ||
|
|
1d70d0fe94 | ||
|
|
ac44f05811 | ||
|
|
d99252f394 | ||
|
|
b58c7ba7c5 | ||
|
|
8c5acd1a0a | ||
|
|
b9b1ebf18c | ||
|
|
8ca132cef0 | ||
|
|
a03bb90754 | ||
|
|
d1c939f48a | ||
|
|
21b11f1b48 | ||
|
|
23c84a7803 | ||
|
|
f9ab060403 | ||
|
|
df7a5bf149 | ||
|
|
e205969b11 | ||
|
|
6bf19ecc34 | ||
|
|
c4afa069df | ||
|
|
1bfafdb44f | ||
|
|
1ef5bd7076 | ||
|
|
29176fa4f4 | ||
|
|
958c95732b | ||
|
|
44b0d4127c | ||
|
|
1418ec2416 | ||
|
|
b51978f51c | ||
|
|
b07361580a | ||
|
|
6ff45a754d | ||
|
|
d1b5ebad7d | ||
|
|
32d2df0f08 | ||
|
|
f4ce813de9 | ||
|
|
b44ac994d8 | ||
|
|
333948814c | ||
|
|
1a51ad6e01 | ||
|
|
22a5c11f0d | ||
|
|
51b22d1ad4 | ||
|
|
bef5969580 | ||
|
|
c6bf7bb9cd | ||
|
|
2a84d92cbf | ||
|
|
62de36b0da | ||
|
|
03a9aaeff7 | ||
|
|
45765e292d | ||
|
|
6e28a26015 | ||
|
|
9150bf720d | ||
|
|
845864679c | ||
|
|
b3b2149ebb | ||
|
|
0886dca385 | ||
|
|
53198ba4a7 | ||
|
|
a9652ee1fd | ||
|
|
75caf2f01c | ||
|
|
65bab2666e | ||
|
|
6d93ae399a | ||
|
|
7239c2e31a | ||
|
|
f269695d4a | ||
|
|
443af5f760 | ||
|
|
0e35350160 | ||
|
|
10bf497cda | ||
|
|
76eb629fc2 | ||
|
|
91de738563 | ||
|
|
43b7ef8110 | ||
|
|
99ef0b8cb4 | ||
|
|
0cf13f6393 | ||
|
|
4a8acfd123 | ||
|
|
abaffc1908 | ||
|
|
ea61d5c1a5 | ||
|
|
9a14931175 | ||
|
|
165eee102a | ||
|
|
6900c197cd | ||
|
|
fe3c66a7c8 | ||
|
|
0efb4da0ee | ||
|
|
1d728475e3 | ||
|
|
827057b9f1 | ||
|
|
ed7920d61e | ||
|
|
c0379c8e25 | ||
|
|
00a0e64fdd | ||
|
|
0dc60debea | ||
|
|
c44ae5888c | ||
|
|
b9495cd1bb | ||
|
|
bfec381933 | ||
|
|
2dddb8df69 | ||
|
|
d30397e9c0 | ||
|
|
d9597549fd | ||
|
|
13512b4146 | ||
|
|
49e546919a | ||
|
|
586015c2ed | ||
|
|
4a7e067d1a | ||
|
|
9bc0b7f183 | ||
|
|
cd4dfc9861 | ||
|
|
1716452203 | ||
|
|
09bdbc1224 | ||
|
|
978b3a64c5 | ||
|
|
651547ef20 | ||
|
|
b4d95977d0 | ||
|
|
5d8bb897db | ||
|
|
84c8ecb372 | ||
|
|
61abe5b948 | ||
|
|
a5b573eaaa | ||
|
|
cbb32f82eb | ||
|
|
ca9334b2df | ||
|
|
959ed7f866 | ||
|
|
a5c0411be0 | ||
|
|
32e1303742 | ||
|
|
7263b6fe89 | ||
|
|
46a4070f84 | ||
|
|
c3c155a1ed | ||
|
|
b067105660 | ||
|
|
15ca18848e | ||
|
|
67c9e2ead6 | ||
|
|
3681177be4 | ||
|
|
6eb814ef0b | ||
|
|
bcc695234c | ||
|
|
ad16a6fc1b | ||
|
|
478b7eeb65 | ||
|
|
151a153dc9 | ||
|
|
ad131854ca | ||
|
|
0bd0eb9e59 | ||
|
|
54827cacb9 | ||
|
|
e3a4a16507 | ||
|
|
cf16fd0104 | ||
|
|
21b00ac6ca | ||
|
|
57e6f3080c | ||
|
|
89744100ce | ||
|
|
a718f9bbfd | ||
|
|
e81bc4f044 | ||
|
|
4dbacd79ae | ||
|
|
ae74d54451 | ||
|
|
dc316c5669 | ||
|
|
e9f04256c9 | ||
|
|
e1aabd70e8 | ||
|
|
a9dc1b32e0 | ||
|
|
01d847ae4e | ||
|
|
61e2c3444a | ||
|
|
5363b0f810 | ||
|
|
f0e1a8823e | ||
|
|
7be5937aa0 | ||
|
|
8f43055b0e | ||
|
|
953a81b299 | ||
|
|
1d34ae7934 | ||
|
|
2cabb2666b | ||
|
|
0b59bb1a29 | ||
|
|
c1e7d74b96 | ||
|
|
cc262d6595 | ||
|
|
61d43b118b | ||
|
|
989d8181dd | ||
|
|
cffc157d98 | ||
|
|
2a70619577 | ||
|
|
b91919bffa | ||
|
|
fb7a4bf880 | ||
|
|
4b41799a90 | ||
|
|
123f39a21b | ||
|
|
cadab12737 | ||
|
|
742055c43b | ||
|
|
fa73b41fa7 | ||
|
|
a474eafe84 | ||
|
|
442fcf921c | ||
|
|
fb0923f3ab | ||
|
|
5bb943f845 | ||
|
|
a3109953d0 | ||
|
|
ff266c8c79 | ||
|
|
ef2e02098d | ||
|
|
93598d3a51 | ||
|
|
53aebcfb1e | ||
|
|
bb2467d2ac | ||
|
|
05c063b61d | ||
|
|
ef1d1303f4 | ||
|
|
b84ab656d8 | ||
|
|
edd4b477f8 | ||
|
|
04fcb33d7e | ||
|
|
f31d2486c9 | ||
|
|
7dea682713 | ||
|
|
7955ddceb2 | ||
|
|
8a6b254799 | ||
|
|
94562cb5cf | ||
|
|
b064c124e7 | ||
|
|
c7e64f40f9 | ||
|
|
0f254dca13 | ||
|
|
e0f2ff36af | ||
|
|
3546e7b51e | ||
|
|
5e7c3ed46a | ||
|
|
13ec1aafa0 | ||
|
|
f521bce9e6 | ||
|
|
c78209604c | ||
|
|
8fe4cfecb6 | ||
|
|
a5a2df4956 | ||
|
|
2fa5e4679f | ||
|
|
57af984e68 | ||
|
|
442e840a53 | ||
|
|
3c33f7d294 | ||
|
|
42a66ad49e | ||
|
|
2d1d70b3b6 | ||
|
|
c9217a419a | ||
|
|
a180395832 | ||
|
|
3dfcc6b0be | ||
|
|
cb1df5217e | ||
|
|
24ef80351c | ||
|
|
bb878a1ccf | ||
|
|
4daea7d7e6 | ||
|
|
3b20747192 | ||
|
|
403e30feba | ||
|
|
f58c73b7f1 | ||
|
|
2a8477cbda | ||
|
|
f5bee7b691 | ||
|
|
8c077a7373 | ||
|
|
4e07b51460 | ||
|
|
44294e1a88 | ||
|
|
25a0a68cde | ||
|
|
3e259021d0 | ||
|
|
f760a9d0c2 | ||
|
|
f69facc842 | ||
|
|
e17638bc06 | ||
|
|
399c0d337a | ||
|
|
856eb479e4 | ||
|
|
1c7de1d668 | ||
|
|
8a8f24f93e | ||
|
|
e76dba0f84 | ||
|
|
aababe1a87 | ||
|
|
436b0624e7 | ||
|
|
0a37d1c15c | ||
|
|
793269731d | ||
|
|
b69a4fe8b5 | ||
|
|
665d84f40a | ||
|
|
4734b390a5 | ||
|
|
50d0721c39 | ||
|
|
9079f15f52 | ||
|
|
60b460d594 | ||
|
|
98f42d9b3b | ||
|
|
23adcb544b | ||
|
|
e6b24d2e3c | ||
|
|
ea3e736a14 | ||
|
|
a5c39b829a | ||
|
|
1ec333ee5a | ||
|
|
bbae93aa16 | ||
|
|
be1dcb7264 | ||
|
|
4a1e6dcc32 | ||
|
|
f644a4ea78 | ||
|
|
85b7405963 | ||
|
|
c854f436bf | ||
|
|
e5be8b7f67 | ||
|
|
906ae730e9 | ||
|
|
92df7747b2 | ||
|
|
0ee8f5efe3 | ||
|
|
4b5b0b065d | ||
|
|
15cf8d2a6d | ||
|
|
ef0ba9483f | ||
|
|
70500cf21e | ||
|
|
a7da6cf172 | ||
|
|
ae76ae4025 | ||
|
|
9614ec4c6a | ||
|
|
c4e90b810d | ||
|
|
887ce3377e | ||
|
|
6ef47249ab | ||
|
|
3a0df56605 | ||
|
|
98cdee7f03 | ||
|
|
b3e2a6a860 | ||
|
|
55410f026b | ||
|
|
f2611f64ac | ||
|
|
d788bd8323 | ||
|
|
9eb108f13e | ||
|
|
eebd64bedb | ||
|
|
21504f1329 | ||
|
|
ff6bae936d | ||
|
|
62523c815e | ||
|
|
0f5465c5da | ||
|
|
e4cba70008 | ||
|
|
692b993eee | ||
|
|
35e3a479cd | ||
|
|
bb7ff27d04 | ||
|
|
0acc5e33b3 | ||
|
|
cb5187fd8d | ||
|
|
160c6e6554 | ||
|
|
a173179b03 | ||
|
|
e73497e4b7 | ||
|
|
835ef01a70 | ||
|
|
a1335aecfb | ||
|
|
c553312fd5 | ||
|
|
3adc7ca22a | ||
|
|
441e603bc0 | ||
|
|
7511df61b3 | ||
|
|
91d3d2ad1f | ||
|
|
6692b618ea | ||
|
|
2052149dc1 | ||
|
|
7b8237afae | ||
|
|
859a984ec8 | ||
|
|
89932b325d | ||
|
|
dac85757b3 | ||
|
|
3b0cec9db6 | ||
|
|
17749bb14a | ||
|
|
c56dd4172e | ||
|
|
d2335485f2 | ||
|
|
cf69dd644a | ||
|
|
8df6af62d7 | ||
|
|
3c3bb70b01 | ||
|
|
d8a4eaf026 | ||
|
|
2402010d24 | ||
|
|
16c804106a | ||
|
|
b1ef9361f3 | ||
|
|
766a26128d | ||
|
|
5b2dce6cf6 | ||
|
|
bee9be534c | ||
|
|
4b49331d97 | ||
|
|
f9513ca802 | ||
|
|
3de13a4d9e | ||
|
|
8a7df954e5 | ||
|
|
3706b53e65 | ||
|
|
8a8aaf3297 | ||
|
|
41a5639711 | ||
|
|
5d8f9f1a5a | ||
|
|
5124cd4b77 | ||
|
|
0cbf66996f | ||
|
|
e922fdc5d0 | ||
|
|
0addbaa9a8 | ||
|
|
8176fb7bad | ||
|
|
baae3592d3 | ||
|
|
6a40e18193 | ||
|
|
2cdb6b811f | ||
|
|
8a8aa1337b | ||
|
|
3fe5647a15 | ||
|
|
fec1245811 | ||
|
|
ccab6eb7c4 | ||
|
|
c9f6e2e257 | ||
|
|
f0d3a4e4b7 | ||
|
|
41295e0c4d | ||
|
|
2abd0265c8 | ||
|
|
1e09ccb4d9 | ||
|
|
11e1d04dd1 | ||
|
|
f140f5f14b | ||
|
|
5898534c23 | ||
|
|
7836336689 | ||
|
|
f96865c2cb | ||
|
|
e475893fd7 | ||
|
|
75a37adcd1 | ||
|
|
c3b1070b83 | ||
|
|
339ca7accf | ||
|
|
0b02e8116c | ||
|
|
8f973661f4 | ||
|
|
c5a73a5c19 | ||
|
|
6a90340b14 | ||
|
|
46abbfe224 | ||
|
|
145d4e4bd5 | ||
|
|
b3ba79a3ba | ||
|
|
c69db035ee | ||
|
|
60a7eaf2bb | ||
|
|
3f43567c8f | ||
|
|
e690f6d487 | ||
|
|
3d4b4e04c5 | ||
|
|
62dd8f35c0 | ||
|
|
1468dfd6b6 | ||
|
|
40e92721c1 | ||
|
|
204e940dcb | ||
|
|
98aa9bd3fe | ||
|
|
041531e96d | ||
|
|
c2a188f7fe | ||
|
|
1a1d37a2d0 | ||
|
|
214649ec20 | ||
|
|
e3866eeb29 | ||
|
|
20db216275 | ||
|
|
f404fe0570 | ||
|
|
bef4361736 | ||
|
|
aa991b62f4 | ||
|
|
8dfe0f4373 | ||
|
|
ffedb79670 | ||
|
|
0e23935455 | ||
|
|
4f62320e7b | ||
|
|
aee3bd3a80 | ||
|
|
c992b89b2f | ||
|
|
fc5c9647d8 | ||
|
|
3a238e9d4b | ||
|
|
9d9fea49ca | ||
|
|
e21131d67e | ||
|
|
1f02d0f6d0 | ||
|
|
830fde8007 | ||
|
|
c44ce77e95 | ||
|
|
ab318ef99e | ||
|
|
c86c2661af | ||
|
|
dabb222511 | ||
|
|
ef13b3a36c | ||
|
|
6fb9081394 | ||
|
|
1ba38b3902 | ||
|
|
dc06a132bc | ||
|
|
644b4f88ac | ||
|
|
c97197b61a | ||
|
|
3e97d29bcf | ||
|
|
a5ea214553 | ||
|
|
91c6ae229e | ||
|
|
e18f4c843a | ||
|
|
0f103d5853 | ||
|
|
56f10e238b | ||
|
|
5baa2e9069 | ||
|
|
7bf83371d5 | ||
|
|
36c575023e | ||
|
|
7eadc74f6c | ||
|
|
3ad06c406c | ||
|
|
c68e37a8c4 | ||
|
|
e66496eae7 | ||
|
|
e6b951c62a | ||
|
|
5279226f36 | ||
|
|
31b552ab51 | ||
|
|
f5e53cd60f | ||
|
|
4a48f59d27 | ||
|
|
bc2c63bf1f | ||
|
|
b56a757f2e | ||
|
|
4692ed4b4a | ||
|
|
615bbcae74 | ||
|
|
7737c6aee1 | ||
|
|
f7c0499158 | ||
|
|
9ebcefee00 | ||
|
|
b18b5c4f43 | ||
|
|
4752b0772f | ||
|
|
957e319649 | ||
|
|
a8978a0d4d | ||
|
|
10712c5ec0 | ||
|
|
83c39f57f0 | ||
|
|
173757cfa2 | ||
|
|
c6be73dba2 | ||
|
|
ccf293906a | ||
|
|
0f4c0b95e2 | ||
|
|
82973e7608 | ||
|
|
c011bccc45 | ||
|
|
8473caf5a6 | ||
|
|
85b038525b | ||
|
|
51a5c3c664 | ||
|
|
d6cda9df0a | ||
|
|
ca7d09d1cb | ||
|
|
4ab478c49c | ||
|
|
1a1c1fd0da | ||
|
|
370951ab67 | ||
|
|
a0632a572a | ||
|
|
10601e7760 | ||
|
|
088ce9c2ad | ||
|
|
e1a69b97db | ||
|
|
a2fd45bb95 | ||
|
|
01ddd8eaa8 | ||
|
|
22fa57b82c | ||
|
|
92a51ca546 | ||
|
|
6a9234e634 | ||
|
|
e8d062a95a | ||
|
|
3394d64f6c | ||
|
|
0fd5a277ed | ||
|
|
8eef2818fa | ||
|
|
a15703d5af | ||
|
|
34d8165edd | ||
|
|
1759add2b6 | ||
|
|
dd80f1b997 | ||
|
|
90ff602ecd | ||
|
|
0099ff1321 |
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -16,3 +16,4 @@ chromeos/** binary
|
|||||||
*.exe binary
|
*.exe binary
|
||||||
*.apk binary
|
*.apk binary
|
||||||
*.png binary
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
|||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -3,9 +3,7 @@ out
|
|||||||
*.jks
|
*.jks
|
||||||
*.apk
|
*.apk
|
||||||
config.prop
|
config.prop
|
||||||
|
update.sh
|
||||||
# Manually dumped jars
|
|
||||||
snet/libs
|
|
||||||
|
|
||||||
# Built binaries
|
# Built binaries
|
||||||
native/out
|
native/out
|
||||||
@@ -17,4 +15,3 @@ native/out
|
|||||||
/.idea
|
/.idea
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
.externalNativeBuild
|
|
||||||
|
|||||||
9
.gitmodules
vendored
9
.gitmodules
vendored
@@ -1,15 +1,6 @@
|
|||||||
[submodule "selinux"]
|
[submodule "selinux"]
|
||||||
path = native/jni/external/selinux
|
path = native/jni/external/selinux
|
||||||
url = https://github.com/topjohnwu/selinux.git
|
url = https://github.com/topjohnwu/selinux.git
|
||||||
[submodule "su"]
|
|
||||||
path = native/jni/su
|
|
||||||
url = https://github.com/topjohnwu/MagiskSU.git
|
|
||||||
[submodule "magiskpolicy"]
|
|
||||||
path = native/jni/magiskpolicy
|
|
||||||
url = https://github.com/topjohnwu/magiskpolicy.git
|
|
||||||
[submodule "MagiskManager"]
|
|
||||||
path = app
|
|
||||||
url = https://github.com/topjohnwu/MagiskManager.git
|
|
||||||
[submodule "busybox"]
|
[submodule "busybox"]
|
||||||
path = native/jni/external/busybox
|
path = native/jni/external/busybox
|
||||||
url = https://github.com/topjohnwu/ndk-busybox.git
|
url = https://github.com/topjohnwu/ndk-busybox.git
|
||||||
|
|||||||
127
README.MD
127
README.MD
@@ -1,74 +1,75 @@
|
|||||||
# Magisk
|
# Magisk
|
||||||
|
|
||||||
|
[Downloads](https://github.com/topjohnwu/Magisk/releases) \| [Documentation](https://topjohnwu.github.io/Magisk/) \| [XDA Thread](https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445)
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Magisk is a suite of open source tools for customizing Android, supporting devices higher than Android 4.2 (API 17). It covers the fundamental parts for Android customization: root, boot scripts, SELinux patches, AVB2.0 / dm-verity / forceencrypt removals etc.
|
||||||
|
|
||||||
|
Furthermore, Magisk provides a **Systemless Interface** to alter the system (or vendor) arbitrarily while the actual partitions stay completely intact. With its systemless nature along with several other hacks, Magisk can hide modifications from nearly any system integrity verifications used in banking apps, corporation monitoring apps, game cheat detections, and most importantly [Google's SafetyNet API](https://developer.android.com/training/safetynet/index.html).
|
||||||
|
|
||||||
|
## Bug Reports
|
||||||
|
|
||||||
|
**Make sure to install the latest [Canary Build](https://forum.xda-developers.com/apps/magisk/dev-magisk-canary-channel-bleeding-edge-t3839337) before reporting any bugs!** **DO NOT** report bugs that is already fixed upstream. Follow the instructions in the [Canary Channel XDA Thread](https://forum.xda-developers.com/apps/magisk/dev-magisk-canary-channel-bleeding-edge-t3839337), and report a bug either by opening an issue on GitHub or directly in the thread.
|
||||||
|
|
||||||
## Building Environment Requirements
|
## Building Environment Requirements
|
||||||
|
|
||||||
1. Python 3.5+: run `build.py` script
|
- Python 3: run `build.py` script
|
||||||
2. Java Development Kit (JDK) 8: Compile Magisk Manager and sign zips
|
- Java Development Kit (JDK) 8: Compile Magisk Manager and sign zips
|
||||||
3. Latest Android SDK: set `ANDROID_HOME` environment variable to the path to Android SDK
|
- Latest Android SDK: set `ANDROID_HOME` environment variable to the path to Android SDK
|
||||||
4. Android NDK: Install NDK along with SDK (`$ANDROID_HOME/ndk-bundle`), or optionally specify a custom path `ANDROID_NDK`
|
- Android NDK: Install NDK along with SDK (`$ANDROID_HOME/ndk-bundle`), or optionally specify a custom path `ANDROID_NDK_HOME`
|
||||||
5. (Windows Only) Python package Colorama: Install with `pip install colorama`, used for ANSI color codes
|
- (Windows Only) Python package Colorama: Install with `pip install colorama`, used for ANSI color codes
|
||||||
|
|
||||||
## Building Notes and Instructions
|
## Building Notes and Instructions
|
||||||
1. Building is tested on macOS, Ubuntu, and Windows 10 using the latest stable NDK and NDK r10e. Officially released binaries were built with NDK r10e.
|
|
||||||
2. Set configurations in `config.prop`. A sample file `config.prop.sample` is provided as an example.
|
- Clone sources with submodules: `git clone --recurse-submodules https://github.com/topjohnwu/Magisk.git`
|
||||||
3. Run `build.py` with argument `-h` to see the built-in help message. The `-h` option also works for each supported actions, e.g. `./build.py binary -h`
|
- Building is supported on macOS, Linux, and Windows. Official releases are built and tested with [FrankeNDK](https://github.com/topjohnwu/FrankeNDK); point `ANDROID_NDK_HOME` to FrankeNDK if you want to use it for compiling.
|
||||||
4. By default, `build.py` build binaries and Magisk Manager in debug mode. If you want to build Magisk Manager in release mode (via the `--release` flag), you need a Java Keystore file `release-key.jks` to sign Magisk Manager's APK. For more information, check out [Google's Official Documentation](https://developer.android.com/studio/publish/app-signing.html#signing-manually).
|
- Set configurations in `config.prop`. A sample file `config.prop.sample` is provided as an example.
|
||||||
5. The SafetyNet extension pack requires the full Magisk Manager as a `compileOnly` dependency. Build the **release** APK, convert it back to Java `.class` files (I use [dex2jar](https://github.com/pxb1988/dex2jar)), and place the converted JAR under `snet/libs` before compiling.
|
- Run `build.py` with argument `-h` to see the built-in help message. The `-h` option also works for each supported actions, e.g. `./build.py binary -h`
|
||||||
|
- By default, `build.py` build binaries and Magisk Manager in debug mode. If you want to build Magisk Manager in release mode (via the `-r, --release` flag), you need a Java Keystore file `release-key.jks` (only `JKS` format is supported) to sign APKs and zips. For more information, check out [Google's Official Documentation](https://developer.android.com/studio/publish/app-signing.html#signing-manually).
|
||||||
|
|
||||||
|
## Translations
|
||||||
|
|
||||||
|
Default string resources for Magisk Manager are scattered throughout
|
||||||
|
|
||||||
|
- `app/src/main/res/values/strings.xml`
|
||||||
|
- `stub/src/main/res/values/strings.xml`
|
||||||
|
- `shared/src/main/res/values/strings.xml`
|
||||||
|
|
||||||
|
Translate each and place them in the respective locations (`<module>/src/main/res/values-<lang>/strings.xml`).
|
||||||
|
|
||||||
|
## Signature Verification
|
||||||
|
|
||||||
|
Official release zips and APKs are signed with my personal private key. You can verify the key certificate to make sure the binaries you downloaded are not manipulated in anyway.
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
# Use the keytool command from JDK to print certificates
|
||||||
|
keytool -printcert -jarfile <APK or Magisk zip>
|
||||||
|
|
||||||
|
# The output should contain the following signature
|
||||||
|
Owner: CN=John Wu, L=Taipei, C=TW
|
||||||
|
Issuer: CN=John Wu, L=Taipei, C=TW
|
||||||
|
Serial number: 50514879
|
||||||
|
Valid from: Sun Aug 14 13:23:44 EDT 2016 until: Tue Jul 21 13:23:44 EDT 2116
|
||||||
|
Certificate fingerprints:
|
||||||
|
MD5: CE:DA:68:C1:E1:74:71:0A:EF:58:89:7D:AE:6E:AB:4F
|
||||||
|
SHA1: DC:0F:2B:61:CB:D7:E9:D3:DB:BE:06:0B:2B:87:0D:46:BB:06:02:11
|
||||||
|
SHA256: B4:CB:83:B4:DA:D9:9F:99:7D:BE:87:2F:01:3A:A1:6C:14:EE:C4:1D:16:70:21:F3:71:F7:E1:33:0F:27:3E:E6
|
||||||
|
Signature algorithm name: SHA256withRSA
|
||||||
|
Version: 3
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
```
|
Magisk, including all git submodules are free software:
|
||||||
Magisk, including all git submodules are free software:
|
you can redistribute it and/or modify it under the terms of the
|
||||||
you can redistribute it and/or modify it under the terms of the
|
GNU General Public License as published by the Free Software Foundation,
|
||||||
GNU General Public License as published by the Free Software Foundation,
|
either version 3 of the License, or (at your option) any later version.
|
||||||
either version 3 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
```
|
|
||||||
|
|
||||||
## Credits
|
|
||||||
|
|
||||||
**MagiskManager** (`app`)
|
|
||||||
|
|
||||||
* Copyright 2016-2018, John Wu (@topjohnwu)
|
|
||||||
* All contributors and translators on Github
|
|
||||||
|
|
||||||
**MagiskSU** (`native/jni/su`)
|
|
||||||
|
|
||||||
* Copyright 2016-2018, John Wu (@topjohnwu)
|
|
||||||
* Copyright 2015, Pierre-Hugues Husson (phh@phh.me)
|
|
||||||
* Copyright 2013, Koushik Dutta (@koush)
|
|
||||||
* Copyright 2010, Adam Shanks (@ChainsDD)
|
|
||||||
* Copyright 2008, Zinx Verituse (@zinxv)
|
|
||||||
|
|
||||||
**MagiskPolicy** (`native/jni/magiskpolicy`)
|
|
||||||
|
|
||||||
* Copyright 2016-2018, John Wu (@topjohnwu)
|
|
||||||
* Copyright 2015, Pierre-Hugues Husson (phh@phh.me)
|
|
||||||
* Copyright 2015, Joshua Brindle (@joshua_brindle)
|
|
||||||
|
|
||||||
**MagiskHide** (`native/jni/magiskhide`)
|
|
||||||
|
|
||||||
* Copyright 2016-2018, John Wu (@topjohnwu)
|
|
||||||
* Copyright 2016, Pierre-Hugues Husson (phh@phh.me)
|
|
||||||
|
|
||||||
**resetprop** (`native/jni/resetprop`)
|
|
||||||
|
|
||||||
* Copyright 2016-2018 John Wu (@topjohnwu)
|
|
||||||
* Copyright 2016 nkk71 (nkk71x@gmail.com)
|
|
||||||
|
|
||||||
**External Dependencies** (`native/jni/external`)
|
|
||||||
|
|
||||||
* Makefile for busybox, generated by [ndk-busybox-kitchen](https://github.com/topjohnwu/ndk-busybox-kitchen)
|
|
||||||
* Each dependencies has its own license/copyright information in each subdirectory.
|
|
||||||
All of them are either GPL or GPL compatible.
|
|
||||||
|
|
||||||
**Others Not Mentioned**
|
|
||||||
|
|
||||||
* Copyright 2016-2018, John Wu (@topjohnwu)
|
|
||||||
|
|||||||
1
app
1
app
Submodule app deleted from b885ccbd63
11
app/.gitignore
vendored
Normal file
11
app/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
.idea/
|
||||||
|
/build
|
||||||
|
app/release
|
||||||
|
*.hprof
|
||||||
|
.externalNativeBuild/
|
||||||
|
public.certificate.x509.pem
|
||||||
|
private.key.pk8
|
||||||
|
*.apk
|
||||||
83
app/build.gradle
Normal file
83
app/build.gradle
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
apply plugin: 'kotlin-kapt'
|
||||||
|
|
||||||
|
kapt {
|
||||||
|
correctErrorTypes = true
|
||||||
|
useBuildCache = true
|
||||||
|
mapDiagnosticLocations = true
|
||||||
|
javacOptions {
|
||||||
|
option("-Xmaxerrs", 1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
defaultConfig {
|
||||||
|
applicationId 'com.topjohnwu.magisk'
|
||||||
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
multiDexEnabled true
|
||||||
|
versionName configProps['appVersion']
|
||||||
|
versionCode configProps['appVersionCode'] as Integer
|
||||||
|
javaCompileOptions {
|
||||||
|
annotationProcessorOptions {
|
||||||
|
argument('butterknife.debuggable', 'false')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataBinding {
|
||||||
|
enabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
packagingOptions {
|
||||||
|
exclude '/META-INF/*.version'
|
||||||
|
exclude '/META-INF/*.kotlin_module'
|
||||||
|
exclude '/META-INF/rxkotlin.properties'
|
||||||
|
exclude '/androidsupportmultidexversion.txt'
|
||||||
|
exclude '/org/**'
|
||||||
|
exclude '/kotlin/**'
|
||||||
|
exclude '/kotlinx/**'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
|
implementation project(':net')
|
||||||
|
implementation project(':shared')
|
||||||
|
implementation project(':signing')
|
||||||
|
|
||||||
|
implementation 'com.github.topjohnwu:jtar:1.0.0'
|
||||||
|
implementation 'com.jakewharton.timber:timber:4.7.1'
|
||||||
|
implementation 'com.github.skoumalcz:teanity:0.3.3'
|
||||||
|
implementation 'com.ncapdevi:frag-nav:3.2.0'
|
||||||
|
|
||||||
|
def markwonVersion = '3.0.1'
|
||||||
|
implementation "ru.noties.markwon:core:${markwonVersion}"
|
||||||
|
implementation "ru.noties.markwon:html:${markwonVersion}"
|
||||||
|
implementation "ru.noties.markwon:image-svg:${markwonVersion}"
|
||||||
|
|
||||||
|
def libsuVersion = '2.5.0'
|
||||||
|
implementation "com.github.topjohnwu.libsu:core:${libsuVersion}"
|
||||||
|
implementation "com.github.topjohnwu.libsu:io:${libsuVersion}"
|
||||||
|
|
||||||
|
def koin = "2.0.0-rc-2"
|
||||||
|
implementation "org.koin:koin-core:${koin}"
|
||||||
|
implementation "org.koin:koin-android:${koin}"
|
||||||
|
implementation "org.koin:koin-androidx-viewmodel:${koin}"
|
||||||
|
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
|
implementation 'androidx.preference:preference:1.0.0'
|
||||||
|
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha05'
|
||||||
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
|
implementation 'com.google.android.material:material:1.1.0-alpha06'
|
||||||
|
implementation 'androidx.work:work-runtime:2.0.1'
|
||||||
|
implementation 'androidx.transition:transition:1.2.0-alpha01'
|
||||||
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
|
}
|
||||||
49
app/proguard-rules.pro
vendored
Normal file
49
app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# By default, the flags in this file are appended to flags specified
|
||||||
|
# in /Users/topjohnwu/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||||
|
# You can edit the include path and order by changing the proguardFiles
|
||||||
|
# directive in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# Add any project specific keep options here:
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Snet
|
||||||
|
-keepclassmembers class com.topjohnwu.magisk.utils.ISafetyNetHelper { *; }
|
||||||
|
-keep,allowobfuscation interface com.topjohnwu.magisk.utils.ISafetyNetHelper$Callback
|
||||||
|
-keepclassmembers class * implements com.topjohnwu.magisk.utils.ISafetyNetHelper$Callback {
|
||||||
|
void onResponse(int);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Keep all fragment constructors
|
||||||
|
-keepclassmembers class * extends androidx.fragment.app.Fragment {
|
||||||
|
public <init>(...);
|
||||||
|
}
|
||||||
|
|
||||||
|
# DelegateWorker
|
||||||
|
-keep,allowobfuscation class * extends com.topjohnwu.magisk.model.worker.DelegateWorker
|
||||||
|
|
||||||
|
# BootSigner
|
||||||
|
-keepclassmembers class com.topjohnwu.signing.BootSigner { *; }
|
||||||
|
|
||||||
|
# Strip logging
|
||||||
|
-assumenosideeffects class com.topjohnwu.magisk.utils.Logger {
|
||||||
|
public *** debug(...);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Excessive obfuscation
|
||||||
|
-repackageclasses 'a'
|
||||||
|
-allowaccessmodification
|
||||||
|
|
||||||
|
# QOL
|
||||||
|
-dontnote **
|
||||||
|
-dontwarn com.caverock.androidsvg.**
|
||||||
|
-dontwarn ru.noties.markwon.**
|
||||||
77
app/src/main/AndroidManifest.xml
Normal file
77
app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
package="com.topjohnwu.magisk">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:name="a.e"
|
||||||
|
android:theme="@style/MagiskTheme"
|
||||||
|
android:usesCleartextTraffic="true"
|
||||||
|
tools:ignore="UnusedAttribute,GoogleAppIndexingWarning">
|
||||||
|
|
||||||
|
<!-- Activities -->
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="a.b"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
|
android:exported="true" />
|
||||||
|
<activity
|
||||||
|
android:name="a.c"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
|
android:exported="true"
|
||||||
|
android:theme="@style/SplashTheme">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="a.f"
|
||||||
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
|
android:screenOrientation="nosensor"
|
||||||
|
android:theme="@style/MagiskTheme.Flashing" />
|
||||||
|
|
||||||
|
<!-- Superuser -->
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="a.m"
|
||||||
|
android:exported="false"
|
||||||
|
android:directBootAware="true"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
|
android:theme="@style/MagiskTheme.SU" />
|
||||||
|
|
||||||
|
<!-- Receiver -->
|
||||||
|
|
||||||
|
<receiver
|
||||||
|
android:name="a.h"
|
||||||
|
android:directBootAware="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
<action android:name="android.intent.action.LOCALE_CHANGED" />
|
||||||
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||||
|
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
|
||||||
|
|
||||||
|
<data android:scheme="package" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
|
<!-- Service -->
|
||||||
|
|
||||||
|
<service android:name="a.j" />
|
||||||
|
|
||||||
|
<!-- Hardcode GMS version -->
|
||||||
|
<meta-data
|
||||||
|
android:name="com.google.android.gms.version"
|
||||||
|
android:value="12451000" />
|
||||||
|
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
13
app/src/main/java/a/a.java
Normal file
13
app/src/main/java/a/a.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package a;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.utils.PatchAPK;
|
||||||
|
import com.topjohnwu.signing.BootSigner;
|
||||||
|
|
||||||
|
import androidx.annotation.Keep;
|
||||||
|
|
||||||
|
@Keep
|
||||||
|
public class a extends BootSigner {
|
||||||
|
public static boolean patchAPK(String in, String out, String pkg) {
|
||||||
|
return PatchAPK.patch(in, out, pkg);
|
||||||
|
}
|
||||||
|
}
|
||||||
7
app/src/main/java/a/b.java
Normal file
7
app/src/main/java/a/b.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package a;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.ui.MainActivity;
|
||||||
|
|
||||||
|
public class b extends MainActivity {
|
||||||
|
/* stub */
|
||||||
|
}
|
||||||
7
app/src/main/java/a/c.java
Normal file
7
app/src/main/java/a/c.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package a;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.ui.SplashActivity;
|
||||||
|
|
||||||
|
public class c extends SplashActivity {
|
||||||
|
/* stub */
|
||||||
|
}
|
||||||
7
app/src/main/java/a/e.java
Normal file
7
app/src/main/java/a/e.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package a;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.App;
|
||||||
|
|
||||||
|
public class e extends App {
|
||||||
|
/* stub */
|
||||||
|
}
|
||||||
7
app/src/main/java/a/f.java
Normal file
7
app/src/main/java/a/f.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package a;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.ui.flash.FlashActivity;
|
||||||
|
|
||||||
|
public class f extends FlashActivity {
|
||||||
|
/* stub */
|
||||||
|
}
|
||||||
15
app/src/main/java/a/g.java
Normal file
15
app/src/main/java/a/g.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package a;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.model.update.UpdateCheckService;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.work.WorkerParameters;
|
||||||
|
|
||||||
|
public class g extends w<UpdateCheckService> {
|
||||||
|
/* Stub */
|
||||||
|
public g(@NonNull Context context, @NonNull WorkerParameters workerParams) {
|
||||||
|
super(context, workerParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
7
app/src/main/java/a/h.java
Normal file
7
app/src/main/java/a/h.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package a;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.model.receiver.GeneralReceiver;
|
||||||
|
|
||||||
|
public class h extends GeneralReceiver {
|
||||||
|
/* stub */
|
||||||
|
}
|
||||||
7
app/src/main/java/a/j.java
Normal file
7
app/src/main/java/a/j.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package a;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.model.download.DownloadModuleService;
|
||||||
|
|
||||||
|
public class j extends DownloadModuleService {
|
||||||
|
/* stub */
|
||||||
|
}
|
||||||
7
app/src/main/java/a/m.java
Normal file
7
app/src/main/java/a/m.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package a;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.ui.surequest.SuRequestActivity;
|
||||||
|
|
||||||
|
public class m extends SuRequestActivity {
|
||||||
|
/* stub */
|
||||||
|
}
|
||||||
42
app/src/main/java/a/w.java
Normal file
42
app/src/main/java/a/w.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package a;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.model.worker.DelegateWorker;
|
||||||
|
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.work.Worker;
|
||||||
|
import androidx.work.WorkerParameters;
|
||||||
|
|
||||||
|
public abstract class w<T extends DelegateWorker> extends Worker {
|
||||||
|
|
||||||
|
/* Wrapper class to workaround Proguard -keep class * extends Worker */
|
||||||
|
|
||||||
|
private T base;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
w(@NonNull Context context, @NonNull WorkerParameters workerParams) {
|
||||||
|
super(context, workerParams);
|
||||||
|
try {
|
||||||
|
base = ((Class<T>) ((ParameterizedType) getClass().getGenericSuperclass())
|
||||||
|
.getActualTypeArguments()[0]).newInstance();
|
||||||
|
base.setActualWorker(this);
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Result doWork() {
|
||||||
|
if (base == null)
|
||||||
|
return Result.failure();
|
||||||
|
return base.doWork();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopped() {
|
||||||
|
if (base != null)
|
||||||
|
base.onStopped();
|
||||||
|
}
|
||||||
|
}
|
||||||
130
app/src/main/java/com/topjohnwu/magisk/App.kt
Normal file
130
app/src/main/java/com/topjohnwu/magisk/App.kt
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
package com.topjohnwu.magisk
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.content.res.Configuration
|
||||||
|
import android.os.AsyncTask
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.multidex.MultiDex
|
||||||
|
import com.topjohnwu.magisk.data.database.MagiskDB
|
||||||
|
import com.topjohnwu.magisk.data.database.RepoDatabaseHelper
|
||||||
|
import com.topjohnwu.magisk.di.koinModules
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager
|
||||||
|
import com.topjohnwu.magisk.utils.RootUtils
|
||||||
|
import com.topjohnwu.magisk.utils.inject
|
||||||
|
import com.topjohnwu.net.Networking
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
import org.koin.android.ext.android.inject
|
||||||
|
import org.koin.android.ext.koin.androidContext
|
||||||
|
import org.koin.core.context.startKoin
|
||||||
|
import timber.log.Timber
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor
|
||||||
|
|
||||||
|
open class App : Application(), Application.ActivityLifecycleCallbacks {
|
||||||
|
|
||||||
|
lateinit var protectedContext: Context
|
||||||
|
|
||||||
|
@Deprecated("Use dependency injection")
|
||||||
|
val prefs: SharedPreferences by inject()
|
||||||
|
@Deprecated("Use dependency injection")
|
||||||
|
val DB: MagiskDB by inject()
|
||||||
|
@Deprecated("Use dependency injection")
|
||||||
|
val repoDB: RepoDatabaseHelper by inject()
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
private var foreground: Activity? = null
|
||||||
|
|
||||||
|
override fun attachBaseContext(base: Context) {
|
||||||
|
super.attachBaseContext(base)
|
||||||
|
if (BuildConfig.DEBUG)
|
||||||
|
MultiDex.install(base)
|
||||||
|
Timber.plant(Timber.DebugTree())
|
||||||
|
|
||||||
|
startKoin {
|
||||||
|
androidContext(this@App)
|
||||||
|
modules(koinModules)
|
||||||
|
}
|
||||||
|
|
||||||
|
protectedContext = baseContext
|
||||||
|
self = this
|
||||||
|
deContext = base
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
|
protectedContext = base.createDeviceProtectedStorageContext()
|
||||||
|
deContext = protectedContext
|
||||||
|
deContext.moveSharedPreferencesFrom(base, base.defaultPrefsName)
|
||||||
|
}
|
||||||
|
|
||||||
|
registerActivityLifecycleCallbacks(this)
|
||||||
|
|
||||||
|
Networking.init(base)
|
||||||
|
LocaleManager.setLocale(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
|
super.onConfigurationChanged(newConfig)
|
||||||
|
LocaleManager.setLocale(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
//region ActivityLifecycleCallbacks
|
||||||
|
override fun onActivityCreated(activity: Activity, bundle: Bundle?) {}
|
||||||
|
|
||||||
|
override fun onActivityStarted(activity: Activity) {}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
override fun onActivityResumed(activity: Activity) {
|
||||||
|
foreground = activity
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
override fun onActivityPaused(activity: Activity) {
|
||||||
|
foreground = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityStopped(activity: Activity) {}
|
||||||
|
|
||||||
|
override fun onActivitySaveInstanceState(activity: Activity, bundle: Bundle) {}
|
||||||
|
|
||||||
|
override fun onActivityDestroyed(activity: Activity) {}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
private val Context.defaultPrefsName get() = "${packageName}_preferences"
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
@Deprecated("Use dependency injection")
|
||||||
|
@JvmStatic
|
||||||
|
lateinit var self: App
|
||||||
|
|
||||||
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
@Deprecated("Use dependency injection; replace with protectedContext")
|
||||||
|
@JvmStatic
|
||||||
|
lateinit var deContext: Context
|
||||||
|
|
||||||
|
@Deprecated("Use Rx or similar")
|
||||||
|
@JvmField
|
||||||
|
var THREAD_POOL: ThreadPoolExecutor
|
||||||
|
|
||||||
|
init {
|
||||||
|
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
||||||
|
Shell.Config.setFlags(Shell.FLAG_MOUNT_MASTER or Shell.FLAG_USE_MAGISK_BUSYBOX)
|
||||||
|
Shell.Config.verboseLogging(BuildConfig.DEBUG)
|
||||||
|
Shell.Config.addInitializers(RootUtils::class.java)
|
||||||
|
Shell.Config.setTimeout(2)
|
||||||
|
THREAD_POOL = AsyncTask.THREAD_POOL_EXECUTOR as ThreadPoolExecutor
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated("")
|
||||||
|
@JvmStatic
|
||||||
|
fun foreground(): Activity? {
|
||||||
|
val app: App by inject()
|
||||||
|
return app.foreground
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
31
app/src/main/java/com/topjohnwu/magisk/ClassMap.java
Normal file
31
app/src/main/java/com/topjohnwu/magisk/ClassMap.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.model.download.DownloadModuleService;
|
||||||
|
import com.topjohnwu.magisk.model.receiver.GeneralReceiver;
|
||||||
|
import com.topjohnwu.magisk.model.update.UpdateCheckService;
|
||||||
|
import com.topjohnwu.magisk.ui.MainActivity;
|
||||||
|
import com.topjohnwu.magisk.ui.SplashActivity;
|
||||||
|
import com.topjohnwu.magisk.ui.flash.FlashActivity;
|
||||||
|
import com.topjohnwu.magisk.ui.surequest.SuRequestActivity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ClassMap {
|
||||||
|
private static Map<Class, Class> classMap = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
classMap.put(App.class, a.e.class);
|
||||||
|
classMap.put(MainActivity.class, a.b.class);
|
||||||
|
classMap.put(SplashActivity.class, a.c.class);
|
||||||
|
classMap.put(FlashActivity.class, a.f.class);
|
||||||
|
classMap.put(UpdateCheckService.class, a.g.class);
|
||||||
|
classMap.put(GeneralReceiver.class, a.h.class);
|
||||||
|
classMap.put(DownloadModuleService.class, a.j.class);
|
||||||
|
classMap.put(SuRequestActivity.class, a.m.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Class<T> get(Class c) {
|
||||||
|
return classMap.get(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
396
app/src/main/java/com/topjohnwu/magisk/Config.java
Normal file
396
app/src/main/java/com/topjohnwu/magisk/Config.java
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.util.Xml;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
import com.topjohnwu.superuser.ShellUtils;
|
||||||
|
import com.topjohnwu.superuser.io.SuFile;
|
||||||
|
import com.topjohnwu.superuser.io.SuFileInputStream;
|
||||||
|
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import androidx.collection.ArrayMap;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
|
||||||
|
// Current status
|
||||||
|
public static String magiskVersionString;
|
||||||
|
public static int magiskVersionCode = -1;
|
||||||
|
private static boolean magiskHide;
|
||||||
|
|
||||||
|
// Update Info
|
||||||
|
public static String remoteMagiskVersionString;
|
||||||
|
public static int remoteMagiskVersionCode = -1;
|
||||||
|
public static String magiskLink;
|
||||||
|
public static String magiskNoteLink;
|
||||||
|
public static String magiskMD5;
|
||||||
|
public static String remoteManagerVersionString;
|
||||||
|
public static int remoteManagerVersionCode = -1;
|
||||||
|
public static String managerLink;
|
||||||
|
public static String managerNoteLink;
|
||||||
|
public static String uninstallerLink;
|
||||||
|
|
||||||
|
// Install flags
|
||||||
|
public static boolean keepVerity = false;
|
||||||
|
public static boolean keepEnc = false;
|
||||||
|
public static boolean recovery = false;
|
||||||
|
|
||||||
|
public static int suLogTimeout = 14;
|
||||||
|
|
||||||
|
public static class Key {
|
||||||
|
// su configs
|
||||||
|
public static final String ROOT_ACCESS = "root_access";
|
||||||
|
public static final String SU_MULTIUSER_MODE = "multiuser_mode";
|
||||||
|
public static final String SU_MNT_NS = "mnt_ns";
|
||||||
|
public static final String SU_MANAGER = "requester";
|
||||||
|
public static final String SU_REQUEST_TIMEOUT = "su_request_timeout";
|
||||||
|
public static final String SU_AUTO_RESPONSE = "su_auto_response";
|
||||||
|
public static final String SU_NOTIFICATION = "su_notification";
|
||||||
|
public static final String SU_REAUTH = "su_reauth";
|
||||||
|
public static final String SU_FINGERPRINT = "su_fingerprint";
|
||||||
|
|
||||||
|
// prefs
|
||||||
|
public static final String CHECK_UPDATES = "check_update";
|
||||||
|
public static final String UPDATE_CHANNEL = "update_channel";
|
||||||
|
public static final String CUSTOM_CHANNEL = "custom_channel";
|
||||||
|
public static final String LOCALE = "locale";
|
||||||
|
public static final String DARK_THEME = "dark_theme";
|
||||||
|
public static final String ETAG_KEY = "ETag";
|
||||||
|
public static final String REPO_ORDER = "repo_order";
|
||||||
|
public static final String SHOW_SYSTEM_APP = "show_system";
|
||||||
|
|
||||||
|
// system state
|
||||||
|
public static final String UPDATE_SERVICE_VER = "update_service_version";
|
||||||
|
public static final String MAGISKHIDE = "magiskhide";
|
||||||
|
public static final String COREONLY = "disable";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Value {
|
||||||
|
public static final int DEFAULT_CHANNEL = -1;
|
||||||
|
public static final int STABLE_CHANNEL = 0;
|
||||||
|
public static final int BETA_CHANNEL = 1;
|
||||||
|
public static final int CUSTOM_CHANNEL = 2;
|
||||||
|
public static final int CANARY_CHANNEL = 3;
|
||||||
|
public static final int CANARY_DEBUG_CHANNEL = 4;
|
||||||
|
public static final int ROOT_ACCESS_DISABLED = 0;
|
||||||
|
public static final int ROOT_ACCESS_APPS_ONLY = 1;
|
||||||
|
public static final int ROOT_ACCESS_ADB_ONLY = 2;
|
||||||
|
public static final int ROOT_ACCESS_APPS_AND_ADB = 3;
|
||||||
|
public static final int MULTIUSER_MODE_OWNER_ONLY = 0;
|
||||||
|
public static final int MULTIUSER_MODE_OWNER_MANAGED = 1;
|
||||||
|
public static final int MULTIUSER_MODE_USER = 2;
|
||||||
|
public static final int NAMESPACE_MODE_GLOBAL = 0;
|
||||||
|
public static final int NAMESPACE_MODE_REQUESTER = 1;
|
||||||
|
public static final int NAMESPACE_MODE_ISOLATE = 2;
|
||||||
|
public static final int NO_NOTIFICATION = 0;
|
||||||
|
public static final int NOTIFICATION_TOAST = 1;
|
||||||
|
public static final int SU_PROMPT = 0;
|
||||||
|
public static final int SU_AUTO_DENY = 1;
|
||||||
|
public static final int SU_AUTO_ALLOW = 2;
|
||||||
|
public static final int[] TIMEOUT_LIST = {0, -1, 10, 20, 30, 60};
|
||||||
|
public static final int ORDER_NAME = 0;
|
||||||
|
public static final int ORDER_DATE = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadMagiskInfo() {
|
||||||
|
try {
|
||||||
|
magiskVersionString = ShellUtils.fastCmd("magisk -v").split(":")[0];
|
||||||
|
magiskVersionCode = Integer.parseInt(ShellUtils.fastCmd("magisk -V"));
|
||||||
|
magiskHide = Shell.su("magiskhide --status").exec().isSuccess();
|
||||||
|
} catch (NumberFormatException ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void export() {
|
||||||
|
// Flush prefs to disk
|
||||||
|
App app = App.self;
|
||||||
|
app.getPrefs().edit().commit();
|
||||||
|
File xml = new File(App.deContext.getFilesDir().getParent() + "/shared_prefs",
|
||||||
|
app.getPackageName() + "_preferences.xml");
|
||||||
|
Shell.su(Utils.fmt("cat %s > /data/adb/%s", xml, Const.MANAGER_CONFIGS)).exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initialize() {
|
||||||
|
SharedPreferences pref = App.self.getPrefs();
|
||||||
|
SharedPreferences.Editor editor = pref.edit();
|
||||||
|
File config = SuFile.open("/data/adb", Const.MANAGER_CONFIGS);
|
||||||
|
if (config.exists()) {
|
||||||
|
try {
|
||||||
|
SuFileInputStream is = new SuFileInputStream(config);
|
||||||
|
XmlPullParser parser = Xml.newPullParser();
|
||||||
|
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
|
||||||
|
parser.setInput(is, "UTF-8");
|
||||||
|
parser.nextTag();
|
||||||
|
parser.require(XmlPullParser.START_TAG, null, "map");
|
||||||
|
while (parser.next() != XmlPullParser.END_TAG) {
|
||||||
|
if (parser.getEventType() != XmlPullParser.START_TAG)
|
||||||
|
continue;
|
||||||
|
String key = parser.getAttributeValue(null, "name");
|
||||||
|
String value = parser.getAttributeValue(null, "value");
|
||||||
|
switch (parser.getName()) {
|
||||||
|
case "string":
|
||||||
|
parser.require(XmlPullParser.START_TAG, null, "string");
|
||||||
|
editor.putString(key, parser.nextText());
|
||||||
|
parser.require(XmlPullParser.END_TAG, null, "string");
|
||||||
|
break;
|
||||||
|
case "boolean":
|
||||||
|
parser.require(XmlPullParser.START_TAG, null, "boolean");
|
||||||
|
editor.putBoolean(key, Boolean.parseBoolean(value));
|
||||||
|
parser.nextTag();
|
||||||
|
parser.require(XmlPullParser.END_TAG, null, "boolean");
|
||||||
|
break;
|
||||||
|
case "int":
|
||||||
|
parser.require(XmlPullParser.START_TAG, null, "int");
|
||||||
|
editor.putInt(key, Integer.parseInt(value));
|
||||||
|
parser.nextTag();
|
||||||
|
parser.require(XmlPullParser.END_TAG, null, "int");
|
||||||
|
break;
|
||||||
|
case "long":
|
||||||
|
parser.require(XmlPullParser.START_TAG, null, "long");
|
||||||
|
editor.putLong(key, Long.parseLong(value));
|
||||||
|
parser.nextTag();
|
||||||
|
parser.require(XmlPullParser.END_TAG, null, "long");
|
||||||
|
break;
|
||||||
|
case "float":
|
||||||
|
parser.require(XmlPullParser.START_TAG, null, "int");
|
||||||
|
editor.putFloat(key, Float.parseFloat(value));
|
||||||
|
parser.nextTag();
|
||||||
|
parser.require(XmlPullParser.END_TAG, null, "int");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
parser.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException | XmlPullParserException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
editor.remove(Key.ETAG_KEY);
|
||||||
|
editor.apply();
|
||||||
|
editor = pref.edit();
|
||||||
|
config.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set defaults if not set
|
||||||
|
setDefs(pref, editor);
|
||||||
|
|
||||||
|
// These settings are from actual device state
|
||||||
|
editor.putBoolean(Key.MAGISKHIDE, magiskHide)
|
||||||
|
.putBoolean(Key.COREONLY, Const.MAGISK_DISABLE_FILE.exists())
|
||||||
|
.putInt(Key.UPDATE_SERVICE_VER, Const.UPDATE_SERVICE_VER)
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int PREF_INT = 0;
|
||||||
|
private static final int PREF_STR_INT = 1;
|
||||||
|
private static final int PREF_BOOL = 2;
|
||||||
|
private static final int PREF_STR = 3;
|
||||||
|
private static final int DB_INT = 4;
|
||||||
|
private static final int DB_BOOL = 5;
|
||||||
|
private static final int DB_STR = 6;
|
||||||
|
|
||||||
|
private static int getConfigType(String key) {
|
||||||
|
switch (key) {
|
||||||
|
case Key.REPO_ORDER:
|
||||||
|
return PREF_INT;
|
||||||
|
|
||||||
|
case Key.SU_REQUEST_TIMEOUT:
|
||||||
|
case Key.SU_AUTO_RESPONSE:
|
||||||
|
case Key.SU_NOTIFICATION:
|
||||||
|
case Key.UPDATE_CHANNEL:
|
||||||
|
return PREF_STR_INT;
|
||||||
|
|
||||||
|
case Key.DARK_THEME:
|
||||||
|
case Key.SU_REAUTH:
|
||||||
|
case Key.CHECK_UPDATES:
|
||||||
|
case Key.MAGISKHIDE:
|
||||||
|
case Key.COREONLY:
|
||||||
|
case Key.SHOW_SYSTEM_APP:
|
||||||
|
return PREF_BOOL;
|
||||||
|
|
||||||
|
case Key.CUSTOM_CHANNEL:
|
||||||
|
case Key.LOCALE:
|
||||||
|
case Key.ETAG_KEY:
|
||||||
|
return PREF_STR;
|
||||||
|
|
||||||
|
case Key.ROOT_ACCESS:
|
||||||
|
case Key.SU_MNT_NS:
|
||||||
|
case Key.SU_MULTIUSER_MODE:
|
||||||
|
return DB_INT;
|
||||||
|
|
||||||
|
case Key.SU_FINGERPRINT:
|
||||||
|
return DB_BOOL;
|
||||||
|
|
||||||
|
case Key.SU_MANAGER:
|
||||||
|
return DB_STR;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T> T get(String key) {
|
||||||
|
App app = App.self;
|
||||||
|
switch (getConfigType(key)) {
|
||||||
|
case PREF_INT:
|
||||||
|
return (T) (Integer) app.getPrefs().getInt(key, getDef(key));
|
||||||
|
case PREF_STR_INT:
|
||||||
|
return (T) (Integer) Utils.getPrefsInt(app.getPrefs(), key, getDef(key));
|
||||||
|
case PREF_BOOL:
|
||||||
|
return (T) (Boolean) app.getPrefs().getBoolean(key, getDef(key));
|
||||||
|
case PREF_STR:
|
||||||
|
return (T) app.getPrefs().getString(key, getDef(key));
|
||||||
|
case DB_INT:
|
||||||
|
return (T) (Integer) app.getDB().getSettings(key, getDef(key));
|
||||||
|
case DB_BOOL:
|
||||||
|
return (T) (Boolean) (app.getDB().getSettings(key, getDef(key) ? 1 : 0) != 0);
|
||||||
|
case DB_STR:
|
||||||
|
return (T) app.getDB().getStrings(key, getDef(key));
|
||||||
|
}
|
||||||
|
/* Will never get here (IllegalArgumentException in getConfigType) */
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set(String key, Object val) {
|
||||||
|
App app = App.self;
|
||||||
|
switch (getConfigType(key)) {
|
||||||
|
case PREF_INT:
|
||||||
|
app.getPrefs().edit().putInt(key, (int) val).apply();
|
||||||
|
break;
|
||||||
|
case PREF_STR_INT:
|
||||||
|
app.getPrefs().edit().putString(key, String.valueOf(val)).apply();
|
||||||
|
break;
|
||||||
|
case PREF_BOOL:
|
||||||
|
app.getPrefs().edit().putBoolean(key, (boolean) val).apply();
|
||||||
|
break;
|
||||||
|
case PREF_STR:
|
||||||
|
app.getPrefs().edit().putString(key, (String) val).apply();
|
||||||
|
break;
|
||||||
|
case DB_INT:
|
||||||
|
app.getDB().setSettings(key, (int) val);
|
||||||
|
break;
|
||||||
|
case DB_BOOL:
|
||||||
|
app.getDB().setSettings(key, (boolean) val ? 1 : 0);
|
||||||
|
break;
|
||||||
|
case DB_STR:
|
||||||
|
app.getDB().setStrings(key, (String) val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remove(String key) {
|
||||||
|
App app = App.self;
|
||||||
|
switch (getConfigType(key)) {
|
||||||
|
case PREF_INT:
|
||||||
|
case PREF_STR_INT:
|
||||||
|
case PREF_BOOL:
|
||||||
|
case PREF_STR:
|
||||||
|
app.getPrefs().edit().remove(key).apply();
|
||||||
|
break;
|
||||||
|
case DB_BOOL:
|
||||||
|
case DB_INT:
|
||||||
|
app.getDB().rmSettings(key);
|
||||||
|
break;
|
||||||
|
case DB_STR:
|
||||||
|
app.getDB().setStrings(key, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayMap<String, Object> defs = new ArrayMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
/* Set default configurations */
|
||||||
|
|
||||||
|
// prefs int
|
||||||
|
defs.put(Key.REPO_ORDER, Value.ORDER_DATE);
|
||||||
|
|
||||||
|
// prefs string int
|
||||||
|
defs.put(Key.SU_REQUEST_TIMEOUT, 10);
|
||||||
|
defs.put(Key.SU_AUTO_RESPONSE, Value.SU_PROMPT);
|
||||||
|
defs.put(Key.SU_NOTIFICATION, Value.NOTIFICATION_TOAST);
|
||||||
|
defs.put(Key.UPDATE_CHANNEL, Utils.isCanary() ?
|
||||||
|
Value.CANARY_DEBUG_CHANNEL : Value.DEFAULT_CHANNEL);
|
||||||
|
|
||||||
|
// prefs bool
|
||||||
|
defs.put(Key.CHECK_UPDATES, true);
|
||||||
|
defs.put(Key.DARK_THEME, true);
|
||||||
|
//defs.put(Key.SU_REAUTH, false);
|
||||||
|
//defs.put(Key.SHOW_SYSTEM_APP, false);
|
||||||
|
|
||||||
|
// prefs string
|
||||||
|
defs.put(Key.CUSTOM_CHANNEL, "");
|
||||||
|
defs.put(Key.LOCALE, "");
|
||||||
|
//defs.put(Key.ETAG_KEY, null);
|
||||||
|
|
||||||
|
// db int
|
||||||
|
defs.put(Key.ROOT_ACCESS, Value.ROOT_ACCESS_APPS_AND_ADB);
|
||||||
|
defs.put(Key.SU_MNT_NS, Value.NAMESPACE_MODE_REQUESTER);
|
||||||
|
defs.put(Key.SU_MULTIUSER_MODE, Value.MULTIUSER_MODE_OWNER_ONLY);
|
||||||
|
|
||||||
|
// db bool
|
||||||
|
//defs.put(Key.SU_FINGERPRINT, false);
|
||||||
|
|
||||||
|
// db strings
|
||||||
|
//defs.put(Key.SU_MANAGER, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> T getDef(String key) {
|
||||||
|
Object val = defs.get(key);
|
||||||
|
switch (getConfigType(key)) {
|
||||||
|
case PREF_INT:
|
||||||
|
case DB_INT:
|
||||||
|
case PREF_STR_INT:
|
||||||
|
return val != null ? (T) val : (T) (Integer) 0;
|
||||||
|
case DB_BOOL:
|
||||||
|
case PREF_BOOL:
|
||||||
|
return val != null ? (T) val : (T) (Boolean) false;
|
||||||
|
case DB_STR:
|
||||||
|
case PREF_STR:
|
||||||
|
return (T) val;
|
||||||
|
}
|
||||||
|
/* Will never get here (IllegalArgumentException in getConfigType) */
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setDefs(SharedPreferences pref, SharedPreferences.Editor editor) {
|
||||||
|
App app = App.self;
|
||||||
|
for (String key : defs.keySet()) {
|
||||||
|
int type = getConfigType(key);
|
||||||
|
switch (type) {
|
||||||
|
case DB_INT:
|
||||||
|
editor.putString(key, String.valueOf(
|
||||||
|
app.getDB().getSettings(key, (Integer) defs.get(key))));
|
||||||
|
continue;
|
||||||
|
case DB_STR:
|
||||||
|
editor.putString(key, app.getDB().getStrings(key, (String) defs.get(key)));
|
||||||
|
continue;
|
||||||
|
case DB_BOOL:
|
||||||
|
int bs = app.getDB().getSettings(key, -1);
|
||||||
|
editor.putBoolean(key, bs < 0 ? (Boolean) defs.get(key) : bs != 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (pref.contains(key))
|
||||||
|
continue;
|
||||||
|
switch (type) {
|
||||||
|
case PREF_INT:
|
||||||
|
editor.putInt(key, (Integer) defs.get(key));
|
||||||
|
break;
|
||||||
|
case PREF_STR_INT:
|
||||||
|
editor.putString(key, String.valueOf(defs.get(key)));
|
||||||
|
break;
|
||||||
|
case PREF_STR:
|
||||||
|
editor.putString(key, (String) defs.get(key));
|
||||||
|
break;
|
||||||
|
case PREF_BOOL:
|
||||||
|
editor.putBoolean(key, (Boolean) defs.get(key));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
102
app/src/main/java/com/topjohnwu/magisk/Const.java
Normal file
102
app/src/main/java/com/topjohnwu/magisk/Const.java
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.os.Process;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class Const {
|
||||||
|
|
||||||
|
public static final String DEBUG_TAG = "MagiskManager";
|
||||||
|
|
||||||
|
// APK content
|
||||||
|
public static final String ANDROID_MANIFEST = "AndroidManifest.xml";
|
||||||
|
|
||||||
|
public static final String SU_KEYSTORE_KEY = "su_key";
|
||||||
|
|
||||||
|
// Paths
|
||||||
|
public static final String MAGISK_PATH = "/sbin/.magisk/img";
|
||||||
|
public static final File EXTERNAL_PATH;
|
||||||
|
public static File MAGISK_DISABLE_FILE;
|
||||||
|
|
||||||
|
static {
|
||||||
|
MAGISK_DISABLE_FILE = new File("xxx");
|
||||||
|
EXTERNAL_PATH = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||||
|
EXTERNAL_PATH.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String TMP_FOLDER_PATH = "/dev/tmp";
|
||||||
|
public static final String MAGISK_LOG = "/cache/magisk.log";
|
||||||
|
public static final String MANAGER_CONFIGS = ".tmp.magisk.config";
|
||||||
|
|
||||||
|
// Versions
|
||||||
|
public static final int UPDATE_SERVICE_VER = 1;
|
||||||
|
public static final int SNET_EXT_VER = 12;
|
||||||
|
|
||||||
|
public static final int USER_ID = Process.myUid() / 100000;
|
||||||
|
|
||||||
|
// Generic
|
||||||
|
public static final String MAGISK_INSTALL_LOG_FILENAME = "magisk_install_log_%s.log";
|
||||||
|
|
||||||
|
public static final class MAGISK_VER {
|
||||||
|
public static final int MIN_SUPPORT = 18000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ID {
|
||||||
|
public static final int FETCH_ZIP = 2;
|
||||||
|
public static final int SELECT_BOOT = 3;
|
||||||
|
|
||||||
|
// notifications
|
||||||
|
public static final int MAGISK_UPDATE_NOTIFICATION_ID = 4;
|
||||||
|
public static final int APK_UPDATE_NOTIFICATION_ID = 5;
|
||||||
|
public static final int DTBO_NOTIFICATION_ID = 7;
|
||||||
|
public static final int HIDE_MANAGER_NOTIFICATION_ID = 8;
|
||||||
|
public static final String UPDATE_NOTIFICATION_CHANNEL = "update";
|
||||||
|
public static final String PROGRESS_NOTIFICATION_CHANNEL = "progress";
|
||||||
|
public static final String CHECK_MAGISK_UPDATE_WORKER_ID = "magisk_update";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Url {
|
||||||
|
private static String getRaw(String where, String name) {
|
||||||
|
return String.format("https://raw.githubusercontent.com/topjohnwu/magisk_files/%s/%s", where, name);
|
||||||
|
}
|
||||||
|
public static final String STABLE_URL = getRaw("master", "stable.json");
|
||||||
|
public static final String BETA_URL = getRaw("master", "beta.json");
|
||||||
|
public static final String CANARY_URL = getRaw("master", "canary_builds/release.json");
|
||||||
|
public static final String CANARY_DEBUG_URL = getRaw("master", "canary_builds/canary.json");
|
||||||
|
public static final String REPO_URL = "https://api.github.com/users/Magisk-Modules-Repo/repos?per_page=100&sort=pushed&page=%d";
|
||||||
|
public static final String FILE_URL = "https://raw.githubusercontent.com/Magisk-Modules-Repo/%s/master/%s";
|
||||||
|
public static final String ZIP_URL = "https://github.com/Magisk-Modules-Repo/%s/archive/master.zip";
|
||||||
|
public static final String MODULE_INSTALLER = "https://raw.githubusercontent.com/topjohnwu/Magisk/master/scripts/module_installer.sh";
|
||||||
|
public static final String PAYPAL_URL = "https://www.paypal.me/topjohnwu";
|
||||||
|
public static final String PATREON_URL = "https://www.patreon.com/topjohnwu";
|
||||||
|
public static final String TWITTER_URL = "https://twitter.com/topjohnwu";
|
||||||
|
public static final String XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382";
|
||||||
|
public static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/Magisk";
|
||||||
|
public static final String SNET_URL = getRaw("b66b1a914978e5f4c4bbfd74a59f4ad371bac107", "snet.apk");
|
||||||
|
public static final String BOOTCTL_URL = getRaw("9c5dfc1b8245c0b5b524901ef0ff0f8335757b77", "bootctl");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Key {
|
||||||
|
// others
|
||||||
|
public static final String LINK_KEY = "Link";
|
||||||
|
public static final String IF_NONE_MATCH = "If-None-Match";
|
||||||
|
// intents
|
||||||
|
public static final String OPEN_SECTION = "section";
|
||||||
|
public static final String INTENT_SET_NAME = "filename";
|
||||||
|
public static final String INTENT_SET_LINK = "link";
|
||||||
|
public static final String FLASH_ACTION = "action";
|
||||||
|
public static final String BROADCAST_MANAGER_UPDATE = "manager_update";
|
||||||
|
public static final String BROADCAST_REBOOT = "reboot";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Value {
|
||||||
|
public static final String FLASH_ZIP = "flash";
|
||||||
|
public static final String PATCH_FILE = "patch";
|
||||||
|
public static final String FLASH_MAGISK = "magisk";
|
||||||
|
public static final String FLASH_INACTIVE_SLOT = "slot";
|
||||||
|
public static final String UNINSTALL = "uninstall";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
package com.topjohnwu.magisk.data.database;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.Config;
|
||||||
|
import com.topjohnwu.magisk.Const;
|
||||||
|
import com.topjohnwu.magisk.model.entity.Policy;
|
||||||
|
import com.topjohnwu.magisk.model.entity.SuLogEntry;
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MagiskDB {
|
||||||
|
|
||||||
|
private static final String POLICY_TABLE = "policies";
|
||||||
|
private static final String LOG_TABLE = "logs";
|
||||||
|
private static final String SETTINGS_TABLE = "settings";
|
||||||
|
private static final String STRINGS_TABLE = "strings";
|
||||||
|
|
||||||
|
private PackageManager pm;
|
||||||
|
|
||||||
|
public MagiskDB(Context context) {
|
||||||
|
pm = context.getPackageManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deletePolicy(Policy policy) {
|
||||||
|
deletePolicy(policy.uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> rawSQL(String fmt, Object... args) {
|
||||||
|
return Shell.su("magisk --sqlite '" + Utils.fmt(fmt, args) + "'").exec().getOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ContentValues> SQL(String fmt, Object... args) {
|
||||||
|
List<ContentValues> list = new ArrayList<>();
|
||||||
|
for (String raw : rawSQL(fmt, args)) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
String[] cols = raw.split("\\|");
|
||||||
|
for (String col : cols) {
|
||||||
|
String[] pair = col.split("=", 2);
|
||||||
|
if (pair.length != 2)
|
||||||
|
continue;
|
||||||
|
values.put(pair[0], pair[1]);
|
||||||
|
}
|
||||||
|
list.add(values);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toSQL(ContentValues values) {
|
||||||
|
StringBuilder keys = new StringBuilder(), vals = new StringBuilder();
|
||||||
|
keys.append('(');
|
||||||
|
vals.append("VALUES(");
|
||||||
|
boolean first = true;
|
||||||
|
for (Map.Entry<String, Object> entry : values.valueSet()) {
|
||||||
|
if (!first) {
|
||||||
|
keys.append(',');
|
||||||
|
vals.append(',');
|
||||||
|
} else {
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
keys.append(entry.getKey());
|
||||||
|
vals.append('"');
|
||||||
|
vals.append(entry.getValue());
|
||||||
|
vals.append('"');
|
||||||
|
}
|
||||||
|
keys.append(')');
|
||||||
|
vals.append(')');
|
||||||
|
keys.append(vals);
|
||||||
|
return keys.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearOutdated() {
|
||||||
|
rawSQL(
|
||||||
|
"DELETE FROM %s WHERE until > 0 AND until < %d;" +
|
||||||
|
"DELETE FROM %s WHERE time < %d",
|
||||||
|
POLICY_TABLE, System.currentTimeMillis() / 1000,
|
||||||
|
LOG_TABLE, System.currentTimeMillis() - Config.suLogTimeout * 86400000
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deletePolicy(String pkg) {
|
||||||
|
rawSQL("DELETE FROM %s WHERE package_name=\"%s\"", POLICY_TABLE, pkg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deletePolicy(int uid) {
|
||||||
|
rawSQL("DELETE FROM %s WHERE uid=%d", POLICY_TABLE, uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Policy getPolicy(int uid) {
|
||||||
|
List<ContentValues> res =
|
||||||
|
SQL("SELECT * FROM %s WHERE uid=%d", POLICY_TABLE, uid);
|
||||||
|
if (!res.isEmpty()) {
|
||||||
|
try {
|
||||||
|
return new Policy(res.get(0), pm);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
deletePolicy(uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePolicy(Policy policy) {
|
||||||
|
rawSQL("REPLACE INTO %s %s", POLICY_TABLE, toSQL(policy.getContentValues()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Policy> getPolicyList() {
|
||||||
|
List<Policy> list = new ArrayList<>();
|
||||||
|
for (ContentValues values : SQL("SELECT * FROM %s WHERE uid/100000=%d", POLICY_TABLE, Const.USER_ID)) {
|
||||||
|
try {
|
||||||
|
list.add(new Policy(values, pm));
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
deletePolicy(values.getAsInteger("uid"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<List<SuLogEntry>> getLogs() {
|
||||||
|
List<List<SuLogEntry>> ret = new ArrayList<>();
|
||||||
|
List<SuLogEntry> list = null;
|
||||||
|
String dateString = null, newString;
|
||||||
|
for (ContentValues values : SQL("SELECT * FROM %s ORDER BY time DESC", LOG_TABLE)) {
|
||||||
|
Date date = new Date(values.getAsLong("time"));
|
||||||
|
newString = DateFormat.getDateInstance(DateFormat.MEDIUM, LocaleManager.locale).format(date);
|
||||||
|
if (!TextUtils.equals(dateString, newString)) {
|
||||||
|
dateString = newString;
|
||||||
|
list = new ArrayList<>();
|
||||||
|
ret.add(list);
|
||||||
|
}
|
||||||
|
list.add(new SuLogEntry(values));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLog(SuLogEntry log) {
|
||||||
|
rawSQL("INSERT INTO %s %s", LOG_TABLE, toSQL(log.getContentValues()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearLogs() {
|
||||||
|
rawSQL("DELETE FROM %s", LOG_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rmSettings(String key) {
|
||||||
|
rawSQL("DELETE FROM %s WHERE key=\"%s\"", SETTINGS_TABLE, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSettings(String key, int value) {
|
||||||
|
ContentValues data = new ContentValues();
|
||||||
|
data.put("key", key);
|
||||||
|
data.put("value", value);
|
||||||
|
rawSQL("REPLACE INTO %s %s", SETTINGS_TABLE, toSQL(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSettings(String key, int defaultValue) {
|
||||||
|
List<ContentValues> res = SQL("SELECT value FROM %s WHERE key=\"%s\"", SETTINGS_TABLE, key);
|
||||||
|
if (res.isEmpty())
|
||||||
|
return defaultValue;
|
||||||
|
return res.get(0).getAsInteger("value");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStrings(String key, String value) {
|
||||||
|
if (value == null) {
|
||||||
|
rawSQL("DELETE FROM %s WHERE key=\"%s\"", STRINGS_TABLE, key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ContentValues data = new ContentValues();
|
||||||
|
data.put("key", key);
|
||||||
|
data.put("value", value);
|
||||||
|
rawSQL("REPLACE INTO %s %s", STRINGS_TABLE, toSQL(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStrings(String key, String defaultValue) {
|
||||||
|
List<ContentValues> res = SQL("SELECT value FROM %s WHERE key=\"%s\"", STRINGS_TABLE, key);
|
||||||
|
if (res.isEmpty())
|
||||||
|
return defaultValue;
|
||||||
|
return res.get(0).getAsString("value");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package com.topjohnwu.magisk.data.database;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.Config;
|
||||||
|
import com.topjohnwu.magisk.model.entity.Repo;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class RepoDatabaseHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
private static final int DATABASE_VER = 5;
|
||||||
|
private static final String TABLE_NAME = "repos";
|
||||||
|
|
||||||
|
private SQLiteDatabase mDb;
|
||||||
|
|
||||||
|
public RepoDatabaseHelper(Context context) {
|
||||||
|
super(context, "repo.db", null, DATABASE_VER);
|
||||||
|
mDb = getWritableDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
onUpgrade(db, 0, DATABASE_VER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
if (oldVersion != newVersion) {
|
||||||
|
// Nuke old DB and create new table
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
|
||||||
|
db.execSQL(
|
||||||
|
"CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " " +
|
||||||
|
"(id TEXT, name TEXT, version TEXT, versionCode INT, " +
|
||||||
|
"author TEXT, description TEXT, last_update INT, PRIMARY KEY(id))");
|
||||||
|
Config.remove(Config.Key.ETAG_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
onUpgrade(db, 0, DATABASE_VER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearRepo() {
|
||||||
|
mDb.delete(TABLE_NAME, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void removeRepo(String id) {
|
||||||
|
mDb.delete(TABLE_NAME, "id=?", new String[] { id });
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeRepo(Repo repo) {
|
||||||
|
removeRepo(repo.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeRepo(Iterable<String> list) {
|
||||||
|
for (String id : list) {
|
||||||
|
if (id == null) continue;
|
||||||
|
mDb.delete(TABLE_NAME, "id=?", new String[] { id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addRepo(Repo repo) {
|
||||||
|
mDb.replace(TABLE_NAME, null, repo.getContentValues());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Repo getRepo(String id) {
|
||||||
|
try (Cursor c = mDb.query(TABLE_NAME, null, "id=?", new String[] { id }, null, null, null)) {
|
||||||
|
if (c.moveToNext()) {
|
||||||
|
return new Repo(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cursor getRawCursor() {
|
||||||
|
return mDb.query(TABLE_NAME, null, null, null, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cursor getRepoCursor() {
|
||||||
|
String orderBy = null;
|
||||||
|
switch ((int) Config.get(Config.Key.REPO_ORDER)) {
|
||||||
|
case Config.Value.ORDER_NAME:
|
||||||
|
orderBy = "name COLLATE NOCASE";
|
||||||
|
break;
|
||||||
|
case Config.Value.ORDER_DATE:
|
||||||
|
orderBy = "last_update DESC";
|
||||||
|
}
|
||||||
|
return mDb.query(TABLE_NAME, null, null, null, null, null, orderBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getRepoIDSet() {
|
||||||
|
HashSet<String> set = new HashSet<>(300);
|
||||||
|
try (Cursor c = mDb.query(TABLE_NAME, null, null, null, null, null, null)) {
|
||||||
|
while (c.moveToNext()) {
|
||||||
|
set.add(c.getString(c.getColumnIndex("id")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.topjohnwu.magisk.di
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
|
import com.skoumal.teanity.rxbus.RxBus
|
||||||
|
import com.topjohnwu.magisk.App
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
|
||||||
|
val applicationModule = module {
|
||||||
|
single { RxBus() }
|
||||||
|
factory { get<Context>().resources }
|
||||||
|
factory { get<Context>() as App }
|
||||||
|
factory { get<Context>().packageManager }
|
||||||
|
single(SUTimeout) {
|
||||||
|
get<App>().protectedContext.getSharedPreferences("su_timeout", 0)
|
||||||
|
}
|
||||||
|
single { PreferenceManager.getDefaultSharedPreferences(get<App>().protectedContext) }
|
||||||
|
}
|
||||||
12
app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt
Normal file
12
app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package com.topjohnwu.magisk.di
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.App
|
||||||
|
import com.topjohnwu.magisk.data.database.MagiskDB
|
||||||
|
import com.topjohnwu.magisk.data.database.RepoDatabaseHelper
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
|
||||||
|
val databaseModule = module {
|
||||||
|
single { MagiskDB(get<App>().protectedContext) }
|
||||||
|
single { RepoDatabaseHelper(get()) }
|
||||||
|
}
|
||||||
10
app/src/main/java/com/topjohnwu/magisk/di/MiscModule.kt
Normal file
10
app/src/main/java/com/topjohnwu/magisk/di/MiscModule.kt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package com.topjohnwu.magisk.di
|
||||||
|
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
|
||||||
|
val miscModule = module {
|
||||||
|
|
||||||
|
// define miscs here
|
||||||
|
|
||||||
|
}
|
||||||
10
app/src/main/java/com/topjohnwu/magisk/di/Modules.kt
Normal file
10
app/src/main/java/com/topjohnwu/magisk/di/Modules.kt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package com.topjohnwu.magisk.di
|
||||||
|
|
||||||
|
val koinModules = listOf(
|
||||||
|
applicationModule,
|
||||||
|
networkingModule,
|
||||||
|
databaseModule,
|
||||||
|
repositoryModule,
|
||||||
|
viewModelModules,
|
||||||
|
miscModule
|
||||||
|
)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.topjohnwu.magisk.di
|
||||||
|
|
||||||
|
import org.koin.core.qualifier.named
|
||||||
|
|
||||||
|
val SUTimeout = named("su_timeout")
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.topjohnwu.magisk.di
|
||||||
|
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
|
||||||
|
val networkingModule = module {}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.topjohnwu.magisk.di
|
||||||
|
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
|
||||||
|
val repositoryModule = module {}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.topjohnwu.magisk.di
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import com.topjohnwu.magisk.ui.MainViewModel
|
||||||
|
import com.topjohnwu.magisk.ui.flash.FlashViewModel
|
||||||
|
import com.topjohnwu.magisk.ui.hide.HideViewModel
|
||||||
|
import com.topjohnwu.magisk.ui.home.HomeViewModel
|
||||||
|
import com.topjohnwu.magisk.ui.log.LogViewModel
|
||||||
|
import com.topjohnwu.magisk.ui.module.ModuleViewModel
|
||||||
|
import com.topjohnwu.magisk.ui.superuser.SuperuserViewModel
|
||||||
|
import com.topjohnwu.magisk.ui.surequest.SuRequestViewModel
|
||||||
|
import org.koin.androidx.viewmodel.dsl.viewModel
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
|
||||||
|
val viewModelModules = module {
|
||||||
|
viewModel { MainViewModel() }
|
||||||
|
viewModel { HomeViewModel(get()) }
|
||||||
|
viewModel { SuperuserViewModel(get(), get(), get(), get()) }
|
||||||
|
viewModel { HideViewModel(get(), get()) }
|
||||||
|
viewModel { ModuleViewModel(get(), get()) }
|
||||||
|
viewModel { LogViewModel(get(), get()) }
|
||||||
|
viewModel { (action: String, uri: Uri?) -> FlashViewModel(action, uri, get()) }
|
||||||
|
viewModel { SuRequestViewModel(get(), get(), get(SUTimeout), get()) }
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
package com.topjohnwu.magisk.model.download;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.IBinder;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.App;
|
||||||
|
import com.topjohnwu.magisk.ClassMap;
|
||||||
|
import com.topjohnwu.magisk.Const;
|
||||||
|
import com.topjohnwu.magisk.model.entity.Repo;
|
||||||
|
import com.topjohnwu.magisk.ui.flash.FlashActivity;
|
||||||
|
import com.topjohnwu.magisk.view.Notifications;
|
||||||
|
import com.topjohnwu.magisk.view.ProgressNotification;
|
||||||
|
import com.topjohnwu.net.Networking;
|
||||||
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
import com.topjohnwu.superuser.ShellUtils;
|
||||||
|
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
public class DownloadModuleService extends Service {
|
||||||
|
|
||||||
|
private List<ProgressNotification> notifications;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
notifications = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
Shell.EXECUTOR.execute(() -> {
|
||||||
|
Repo repo = intent.getParcelableExtra("repo");
|
||||||
|
boolean install = intent.getBooleanExtra("install", false);
|
||||||
|
dlProcessInstall(repo, install);
|
||||||
|
});
|
||||||
|
return START_REDELIVER_INTENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void onTaskRemoved(Intent rootIntent) {
|
||||||
|
for (ProgressNotification n : notifications) {
|
||||||
|
Notifications.mgr.cancel(n.hashCode());
|
||||||
|
}
|
||||||
|
notifications.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void addNotification(ProgressNotification n) {
|
||||||
|
if (notifications.isEmpty()) {
|
||||||
|
// Start foreground
|
||||||
|
startForeground(n.hashCode(), n.getNotification());
|
||||||
|
}
|
||||||
|
notifications.add(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void removeNotification(ProgressNotification n) {
|
||||||
|
notifications.remove(n);
|
||||||
|
if (notifications.isEmpty()) {
|
||||||
|
// No more tasks, stop service
|
||||||
|
stopForeground(true);
|
||||||
|
stopSelf();
|
||||||
|
} else {
|
||||||
|
// Pick another notification as our foreground notification
|
||||||
|
n = notifications.get(0);
|
||||||
|
startForeground(n.hashCode(), n.getNotification());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dlProcessInstall(Repo repo, boolean install) {
|
||||||
|
File output = new File(Const.EXTERNAL_PATH, repo.getDownloadFilename());
|
||||||
|
ProgressNotification progress = new ProgressNotification(output.getName());
|
||||||
|
addNotification(progress);
|
||||||
|
try {
|
||||||
|
InputStream in = Networking.get(repo.getZipUrl())
|
||||||
|
.setDownloadProgressListener(progress)
|
||||||
|
.execForInputStream().getResult();
|
||||||
|
OutputStream out = new BufferedOutputStream(new FileOutputStream(output));
|
||||||
|
processZip(in, out);
|
||||||
|
Intent intent = new Intent(this, ClassMap.get(FlashActivity.class));
|
||||||
|
intent.setData(Uri.fromFile(output))
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
.putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_ZIP);
|
||||||
|
synchronized (getApplication()) {
|
||||||
|
if (install && App.foreground() != null &&
|
||||||
|
!(App.foreground() instanceof FlashActivity)) {
|
||||||
|
/* Only start flashing if there is a foreground activity and the
|
||||||
|
* user is not also flashing another module at the same time */
|
||||||
|
App.foreground().startActivity(intent);
|
||||||
|
} else {
|
||||||
|
/* Or else we preset a notification notifying that we are done */
|
||||||
|
PendingIntent pi = PendingIntent.getActivity(this, progress.hashCode(), intent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
progress.dlDone(pi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
progress.dlFail();
|
||||||
|
}
|
||||||
|
removeNotification(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processZip(InputStream in, OutputStream out)
|
||||||
|
throws IOException {
|
||||||
|
try (ZipInputStream zin = new ZipInputStream(in);
|
||||||
|
ZipOutputStream zout = new ZipOutputStream(out)) {
|
||||||
|
|
||||||
|
// Inject latest module-installer.sh as update-binary
|
||||||
|
zout.putNextEntry(new ZipEntry("META-INF/"));
|
||||||
|
zout.putNextEntry(new ZipEntry("META-INF/com/"));
|
||||||
|
zout.putNextEntry(new ZipEntry("META-INF/com/google/"));
|
||||||
|
zout.putNextEntry(new ZipEntry("META-INF/com/google/android/"));
|
||||||
|
zout.putNextEntry(new ZipEntry("META-INF/com/google/android/update-binary"));
|
||||||
|
try (InputStream update_bin = Networking.get(Const.Url.MODULE_INSTALLER)
|
||||||
|
.execForInputStream().getResult()) {
|
||||||
|
ShellUtils.pump(update_bin, zout);
|
||||||
|
}
|
||||||
|
zout.putNextEntry(new ZipEntry("META-INF/com/google/android/updater-script"));
|
||||||
|
zout.write("#MAGISK\n".getBytes("UTF-8"));
|
||||||
|
|
||||||
|
int off = -1;
|
||||||
|
ZipEntry entry;
|
||||||
|
while ((entry = zin.getNextEntry()) != null) {
|
||||||
|
if (off < 0)
|
||||||
|
off = entry.getName().indexOf('/') + 1;
|
||||||
|
String path = entry.getName().substring(off);
|
||||||
|
if (path.isEmpty())
|
||||||
|
continue;
|
||||||
|
if (path.startsWith("META-INF"))
|
||||||
|
continue;
|
||||||
|
zout.putNextEntry(new ZipEntry(path));
|
||||||
|
if (!entry.isDirectory())
|
||||||
|
ShellUtils.pump(zin, zout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
public abstract class BaseModule implements Comparable<BaseModule>, Parcelable {
|
||||||
|
|
||||||
|
private String mId, mName, mVersion, mAuthor, mDescription;
|
||||||
|
private int mVersionCode = -1;
|
||||||
|
|
||||||
|
protected BaseModule() {
|
||||||
|
mId = mName = mVersion = mAuthor = mDescription = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BaseModule(Cursor c) {
|
||||||
|
mId = nonNull(c.getString(c.getColumnIndex("id")));
|
||||||
|
mName = nonNull(c.getString(c.getColumnIndex("name")));
|
||||||
|
mVersion = nonNull(c.getString(c.getColumnIndex("version")));
|
||||||
|
mVersionCode = c.getInt(c.getColumnIndex("versionCode"));
|
||||||
|
mAuthor = nonNull(c.getString(c.getColumnIndex("author")));
|
||||||
|
mDescription = nonNull(c.getString(c.getColumnIndex("description")));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BaseModule(Parcel p) {
|
||||||
|
mId = p.readString();
|
||||||
|
mName = p.readString();
|
||||||
|
mVersion = p.readString();
|
||||||
|
mAuthor = p.readString();
|
||||||
|
mDescription = p.readString();
|
||||||
|
mVersionCode = p.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(@NonNull BaseModule module) {
|
||||||
|
return this.getName().toLowerCase().compareTo(module.getName().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeString(mId);
|
||||||
|
dest.writeString(mName);
|
||||||
|
dest.writeString(mVersion);
|
||||||
|
dest.writeString(mAuthor);
|
||||||
|
dest.writeString(mDescription);
|
||||||
|
dest.writeInt(mVersionCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String nonNull(String s) {
|
||||||
|
return s == null ? "" : s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContentValues getContentValues() {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("id", mId);
|
||||||
|
values.put("name", mName);
|
||||||
|
values.put("version", mVersion);
|
||||||
|
values.put("versionCode", mVersionCode);
|
||||||
|
values.put("author", mAuthor);
|
||||||
|
values.put("description", mDescription);
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void parseProps(List<String> props) { parseProps(props.toArray(new String[0])); }
|
||||||
|
|
||||||
|
protected void parseProps(String[] props) throws NumberFormatException {
|
||||||
|
for (String line : props) {
|
||||||
|
String[] prop = line.split("=", 2);
|
||||||
|
if (prop.length != 2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String key = prop[0].trim();
|
||||||
|
String value = prop[1].trim();
|
||||||
|
if (key.isEmpty() || key.charAt(0) == '#')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case "id":
|
||||||
|
mId = value;
|
||||||
|
break;
|
||||||
|
case "name":
|
||||||
|
mName = value;
|
||||||
|
break;
|
||||||
|
case "version":
|
||||||
|
mVersion = value;
|
||||||
|
break;
|
||||||
|
case "versionCode":
|
||||||
|
mVersionCode = Integer.parseInt(value);
|
||||||
|
break;
|
||||||
|
case "author":
|
||||||
|
mAuthor = value;
|
||||||
|
break;
|
||||||
|
case "description":
|
||||||
|
mDescription = value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return mVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthor() {
|
||||||
|
return mAuthor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
mId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return mDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersionCode() {
|
||||||
|
return mVersionCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity
|
||||||
|
|
||||||
|
import android.content.pm.ApplicationInfo
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import com.topjohnwu.magisk.utils.packageInfo
|
||||||
|
import com.topjohnwu.magisk.utils.processes
|
||||||
|
|
||||||
|
class HideAppInfo(
|
||||||
|
val info: ApplicationInfo,
|
||||||
|
val name: String,
|
||||||
|
val icon: Drawable
|
||||||
|
) {
|
||||||
|
|
||||||
|
val processes = info.packageInfo?.processes?.distinct() ?: listOf(info.packageName)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity
|
||||||
|
|
||||||
|
class HideTarget(line: String) {
|
||||||
|
|
||||||
|
private val split = line.split(Regex("\\|"), 2)
|
||||||
|
|
||||||
|
val packageName = split[0]
|
||||||
|
val process = split.getOrElse(1) { packageName }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
import com.topjohnwu.superuser.io.SuFile;
|
||||||
|
|
||||||
|
public class Module extends BaseModule {
|
||||||
|
|
||||||
|
private SuFile mRemoveFile, mDisableFile, mUpdateFile;
|
||||||
|
private boolean mEnable, mRemove, mUpdated;
|
||||||
|
|
||||||
|
public Module(String path) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
parseProps(Shell.su("dos2unix < " + path + "/module.prop").exec().getOut());
|
||||||
|
} catch (NumberFormatException ignored) {}
|
||||||
|
|
||||||
|
mRemoveFile = new SuFile(path, "remove");
|
||||||
|
mDisableFile = new SuFile(path, "disable");
|
||||||
|
mUpdateFile = new SuFile(path, "update");
|
||||||
|
|
||||||
|
if (getId().isEmpty()) {
|
||||||
|
int sep = path.lastIndexOf('/');
|
||||||
|
setId(path.substring(sep + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getName().isEmpty()) {
|
||||||
|
setName(getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
mEnable = !mDisableFile.exists();
|
||||||
|
mRemove = mRemoveFile.exists();
|
||||||
|
mUpdated = mUpdateFile.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<Module> CREATOR = new Creator<Module>() {
|
||||||
|
/* It won't be used at any place */
|
||||||
|
@Override
|
||||||
|
public Module createFromParcel(Parcel source) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Module[] newArray(int size) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void createDisableFile() {
|
||||||
|
mEnable = !mDisableFile.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeDisableFile() {
|
||||||
|
mEnable = mDisableFile.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return mEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createRemoveFile() {
|
||||||
|
mRemove = mRemoveFile.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteRemoveFile() {
|
||||||
|
mRemove = !mRemoveFile.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean willBeRemoved() {
|
||||||
|
return mRemove;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUpdated() {
|
||||||
|
return mUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
|
||||||
|
public class Policy implements Comparable<Policy>{
|
||||||
|
public static final int INTERACTIVE = 0;
|
||||||
|
public static final int DENY = 1;
|
||||||
|
public static final int ALLOW = 2;
|
||||||
|
|
||||||
|
public int uid, policy = INTERACTIVE;
|
||||||
|
public long until;
|
||||||
|
public boolean logging = true, notification = true;
|
||||||
|
public String packageName, appName;
|
||||||
|
public ApplicationInfo info;
|
||||||
|
|
||||||
|
public Policy(int uid, PackageManager pm) throws PackageManager.NameNotFoundException {
|
||||||
|
String[] pkgs = pm.getPackagesForUid(uid);
|
||||||
|
if (pkgs == null || pkgs.length == 0)
|
||||||
|
throw new PackageManager.NameNotFoundException();
|
||||||
|
this.uid = uid;
|
||||||
|
packageName = pkgs[0];
|
||||||
|
info = pm.getApplicationInfo(packageName, 0);
|
||||||
|
appName = Utils.getAppLabel(info, pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Policy(ContentValues values, PackageManager pm) throws PackageManager.NameNotFoundException {
|
||||||
|
uid = values.getAsInteger("uid");
|
||||||
|
packageName = values.getAsString("package_name");
|
||||||
|
policy = values.getAsInteger("policy");
|
||||||
|
until = values.getAsInteger("until");
|
||||||
|
logging = values.getAsInteger("logging") != 0;
|
||||||
|
notification = values.getAsInteger("notification") != 0;
|
||||||
|
info = pm.getApplicationInfo(packageName, 0);
|
||||||
|
if (info.uid != uid)
|
||||||
|
throw new PackageManager.NameNotFoundException();
|
||||||
|
appName = info.loadLabel(pm).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContentValues getContentValues() {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("uid", uid);
|
||||||
|
values.put("package_name", packageName);
|
||||||
|
values.put("policy", policy);
|
||||||
|
values.put("until", until);
|
||||||
|
values.put("logging", logging ? 1 : 0);
|
||||||
|
values.put("notification", notification ? 1 : 0);
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(@NonNull Policy policy) {
|
||||||
|
return appName.toLowerCase().compareTo(policy.appName.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
109
app/src/main/java/com/topjohnwu/magisk/model/entity/Repo.java
Normal file
109
app/src/main/java/com/topjohnwu/magisk/model/entity/Repo.java
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.Const;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class Repo extends BaseModule {
|
||||||
|
|
||||||
|
private Date mLastUpdate;
|
||||||
|
|
||||||
|
public Repo(String id) {
|
||||||
|
setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Repo(Cursor c) {
|
||||||
|
super(c);
|
||||||
|
mLastUpdate = new Date(c.getLong(c.getColumnIndex("last_update")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Repo(Parcel p) {
|
||||||
|
super(p);
|
||||||
|
mLastUpdate = new Date(p.readLong());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<Repo> CREATOR = new Parcelable.Creator<Repo>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Repo createFromParcel(Parcel source) {
|
||||||
|
return new Repo(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Repo[] newArray(int size) {
|
||||||
|
return new Repo[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
super.writeToParcel(dest, flags);
|
||||||
|
dest.writeLong(mLastUpdate.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() throws IllegalRepoException {
|
||||||
|
String props[] = Utils.dlString(getPropUrl()).split("\\n");
|
||||||
|
try {
|
||||||
|
parseProps(props);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new IllegalRepoException("Repo [" + getId() + "] parse error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getVersionCode() < 0) {
|
||||||
|
throw new IllegalRepoException("Repo [" + getId() + "] does not contain versionCode");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(Date lastUpdate) throws IllegalRepoException {
|
||||||
|
mLastUpdate = lastUpdate;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContentValues getContentValues() {
|
||||||
|
ContentValues values = super.getContentValues();
|
||||||
|
values.put("last_update", mLastUpdate.getTime());
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getZipUrl() {
|
||||||
|
return String.format(Const.Url.ZIP_URL, getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPropUrl() {
|
||||||
|
return getFileUrl("module.prop");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDetailUrl() {
|
||||||
|
return getFileUrl("README.md");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileUrl(String file) {
|
||||||
|
return String.format(Const.Url.FILE_URL, getId(), file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastUpdateString() {
|
||||||
|
return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(mLastUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastUpdate() {
|
||||||
|
return mLastUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDownloadFilename() {
|
||||||
|
return Utils.getLegalFilename(getName() + "-" + getVersion() + ".zip");
|
||||||
|
}
|
||||||
|
|
||||||
|
public class IllegalRepoException extends Exception {
|
||||||
|
IllegalRepoException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class SuLogEntry {
|
||||||
|
|
||||||
|
public int fromUid, toUid, fromPid;
|
||||||
|
public String packageName, appName, command;
|
||||||
|
public boolean action;
|
||||||
|
public Date date;
|
||||||
|
|
||||||
|
public SuLogEntry(Policy policy) {
|
||||||
|
fromUid = policy.uid;
|
||||||
|
packageName = policy.packageName;
|
||||||
|
appName = policy.appName;
|
||||||
|
action = policy.policy == Policy.ALLOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuLogEntry(ContentValues values) {
|
||||||
|
fromUid = values.getAsInteger("from_uid");
|
||||||
|
packageName = values.getAsString("package_name");
|
||||||
|
appName = values.getAsString("app_name");
|
||||||
|
fromPid = values.getAsInteger("from_pid");
|
||||||
|
command = values.getAsString("command");
|
||||||
|
toUid = values.getAsInteger("to_uid");
|
||||||
|
action = values.getAsInteger("action") != 0;
|
||||||
|
date = new Date(values.getAsLong("time"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContentValues getContentValues() {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("from_uid", fromUid);
|
||||||
|
values.put("package_name", packageName);
|
||||||
|
values.put("app_name", appName);
|
||||||
|
values.put("from_pid", fromPid);
|
||||||
|
values.put("command", command);
|
||||||
|
values.put("to_uid", toUid);
|
||||||
|
values.put("action", action ? 1 : 0);
|
||||||
|
values.put("time", date.getTime());
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDateString() {
|
||||||
|
return DateFormat.getDateInstance(DateFormat.MEDIUM, LocaleManager.locale).format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTimeString() {
|
||||||
|
return new SimpleDateFormat("h:mm a", LocaleManager.locale).format(date);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity.recycler
|
||||||
|
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
|
||||||
|
class ConsoleRvItem(val item: String) : ComparableRvItem<ConsoleRvItem>() {
|
||||||
|
override val layoutRes: Int = R.layout.item_console
|
||||||
|
|
||||||
|
override fun contentSameAs(other: ConsoleRvItem) = itemSameAs(other)
|
||||||
|
override fun itemSameAs(other: ConsoleRvItem) = item == other.item
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity.recycler
|
||||||
|
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.skoumal.teanity.extensions.addOnPropertyChangedCallback
|
||||||
|
import com.skoumal.teanity.rxbus.RxBus
|
||||||
|
import com.skoumal.teanity.util.DiffObservableList
|
||||||
|
import com.skoumal.teanity.util.KObservableField
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.model.entity.HideAppInfo
|
||||||
|
import com.topjohnwu.magisk.model.entity.HideTarget
|
||||||
|
import com.topjohnwu.magisk.model.entity.state.IndeterminateState
|
||||||
|
import com.topjohnwu.magisk.model.events.HideProcessEvent
|
||||||
|
import com.topjohnwu.magisk.utils.inject
|
||||||
|
import com.topjohnwu.magisk.utils.toggle
|
||||||
|
|
||||||
|
class HideRvItem(val item: HideAppInfo, targets: List<HideTarget>) :
|
||||||
|
ComparableRvItem<HideRvItem>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.item_hide_app
|
||||||
|
|
||||||
|
val packageName = item.info.packageName.orEmpty()
|
||||||
|
val items = DiffObservableList(callback).also {
|
||||||
|
val items = item.processes.map {
|
||||||
|
val isHidden = targets.any { target ->
|
||||||
|
packageName == target.packageName && it == target.process
|
||||||
|
}
|
||||||
|
HideProcessRvItem(packageName, it, isHidden)
|
||||||
|
}
|
||||||
|
it.update(items)
|
||||||
|
}
|
||||||
|
val isHiddenState = KObservableField(currentState)
|
||||||
|
val isExpanded = KObservableField(false)
|
||||||
|
|
||||||
|
private val itemsProcess get() = items.filterIsInstance<HideProcessRvItem>()
|
||||||
|
|
||||||
|
private val currentState
|
||||||
|
get() = when (itemsProcess.count { it.isHidden.value }) {
|
||||||
|
items.size -> IndeterminateState.CHECKED
|
||||||
|
in 1 until items.size -> IndeterminateState.INDETERMINATE
|
||||||
|
else -> IndeterminateState.UNCHECKED
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
itemsProcess.forEach {
|
||||||
|
it.isHidden.addOnPropertyChangedCallback { isHiddenState.value = currentState }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toggle() {
|
||||||
|
val desiredState = when (isHiddenState.value) {
|
||||||
|
IndeterminateState.INDETERMINATE,
|
||||||
|
IndeterminateState.UNCHECKED -> true
|
||||||
|
IndeterminateState.CHECKED -> false
|
||||||
|
}
|
||||||
|
itemsProcess.forEach { it.isHidden.value = desiredState }
|
||||||
|
isHiddenState.value = currentState
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toggleExpansion() {
|
||||||
|
if (items.size <= 1) return
|
||||||
|
isExpanded.toggle()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun contentSameAs(other: HideRvItem): Boolean = items.all { other.items.contains(it) }
|
||||||
|
override fun itemSameAs(other: HideRvItem): Boolean = item.info == other.item.info
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class HideProcessRvItem(
|
||||||
|
val packageName: String,
|
||||||
|
val process: String,
|
||||||
|
isHidden: Boolean
|
||||||
|
) : ComparableRvItem<HideProcessRvItem>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.item_hide_process
|
||||||
|
|
||||||
|
val isHidden = KObservableField(isHidden)
|
||||||
|
|
||||||
|
private val rxBus: RxBus by inject()
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.isHidden.addOnPropertyChangedCallback {
|
||||||
|
rxBus.post(HideProcessEvent(this@HideProcessRvItem))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toggle() = isHidden.toggle()
|
||||||
|
|
||||||
|
override fun contentSameAs(other: HideProcessRvItem): Boolean = itemSameAs(other)
|
||||||
|
override fun itemSameAs(other: HideProcessRvItem): Boolean =
|
||||||
|
packageName == other.packageName && process == other.process
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity.recycler
|
||||||
|
|
||||||
|
import androidx.databinding.ObservableList
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.skoumal.teanity.util.DiffObservableList
|
||||||
|
import com.skoumal.teanity.util.KObservableField
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.model.entity.SuLogEntry
|
||||||
|
import com.topjohnwu.magisk.utils.toggle
|
||||||
|
|
||||||
|
class LogRvItem : ComparableRvItem<LogRvItem>() {
|
||||||
|
override val layoutRes: Int = R.layout.item_page_log
|
||||||
|
|
||||||
|
val items = DiffObservableList(callback)
|
||||||
|
|
||||||
|
fun update(list: List<LogItemRvItem>) {
|
||||||
|
list.firstOrNull()?.isExpanded?.value = true
|
||||||
|
items.update(list)
|
||||||
|
}
|
||||||
|
|
||||||
|
//two of these will never be present, safe to assume it's unique
|
||||||
|
override fun contentSameAs(other: LogRvItem): Boolean = false
|
||||||
|
|
||||||
|
override fun itemSameAs(other: LogRvItem): Boolean = false
|
||||||
|
}
|
||||||
|
|
||||||
|
class LogItemRvItem(
|
||||||
|
val items: ObservableList<ComparableRvItem<*>>
|
||||||
|
) : ComparableRvItem<LogItemRvItem>() {
|
||||||
|
override val layoutRes: Int = R.layout.item_superuser_log
|
||||||
|
|
||||||
|
val date = items.filterIsInstance<LogItemEntryRvItem>().firstOrNull()
|
||||||
|
?.item?.dateString.orEmpty()
|
||||||
|
val isExpanded = KObservableField(false)
|
||||||
|
|
||||||
|
fun toggle() = isExpanded.toggle()
|
||||||
|
|
||||||
|
override fun contentSameAs(other: LogItemRvItem): Boolean = items
|
||||||
|
.any { !other.items.contains(it) }
|
||||||
|
|
||||||
|
override fun itemSameAs(other: LogItemRvItem): Boolean = date == other.date
|
||||||
|
}
|
||||||
|
|
||||||
|
class LogItemEntryRvItem(val item: SuLogEntry) : ComparableRvItem<LogItemEntryRvItem>() {
|
||||||
|
override val layoutRes: Int = R.layout.item_superuser_log_entry
|
||||||
|
|
||||||
|
val isExpanded = KObservableField(false)
|
||||||
|
|
||||||
|
fun toggle() = isExpanded.toggle()
|
||||||
|
|
||||||
|
override fun contentSameAs(other: LogItemEntryRvItem) = item.fromUid == other.item.fromUid &&
|
||||||
|
item.toUid == other.item.toUid &&
|
||||||
|
item.fromPid == other.item.fromPid &&
|
||||||
|
item.packageName == other.item.packageName &&
|
||||||
|
item.command == other.item.command &&
|
||||||
|
item.action == other.item.action &&
|
||||||
|
item.date == other.item.date
|
||||||
|
|
||||||
|
override fun itemSameAs(other: LogItemEntryRvItem) = item.appName == other.item.appName
|
||||||
|
}
|
||||||
|
|
||||||
|
class MagiskLogRvItem : ComparableRvItem<MagiskLogRvItem>() {
|
||||||
|
override val layoutRes: Int = R.layout.item_page_magisk_log
|
||||||
|
|
||||||
|
val items = DiffObservableList(callback)
|
||||||
|
|
||||||
|
fun update(list: List<ConsoleRvItem>) {
|
||||||
|
items.update(list)
|
||||||
|
}
|
||||||
|
|
||||||
|
//two of these will never be present, safe to assume it's unique
|
||||||
|
override fun contentSameAs(other: MagiskLogRvItem): Boolean = false
|
||||||
|
|
||||||
|
override fun itemSameAs(other: MagiskLogRvItem): Boolean = false
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity.recycler
|
||||||
|
|
||||||
|
import android.content.res.Resources
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.skoumal.teanity.extensions.addOnPropertyChangedCallback
|
||||||
|
import com.skoumal.teanity.util.KObservableField
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.model.entity.Module
|
||||||
|
import com.topjohnwu.magisk.model.entity.Repo
|
||||||
|
import com.topjohnwu.magisk.utils.get
|
||||||
|
import com.topjohnwu.magisk.utils.toggle
|
||||||
|
|
||||||
|
class ModuleRvItem(val item: Module) : ComparableRvItem<ModuleRvItem>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.item_module
|
||||||
|
|
||||||
|
val lastActionNotice = KObservableField("")
|
||||||
|
val isChecked = KObservableField(item.isEnabled)
|
||||||
|
val isDeletable = KObservableField(item.willBeRemoved())
|
||||||
|
|
||||||
|
init {
|
||||||
|
isChecked.addOnPropertyChangedCallback {
|
||||||
|
when (it) {
|
||||||
|
true -> item.removeDisableFile().notice(R.string.disable_file_removed)
|
||||||
|
false -> item.createDisableFile().notice(R.string.disable_file_created)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isDeletable.addOnPropertyChangedCallback {
|
||||||
|
when (it) {
|
||||||
|
true -> item.createRemoveFile().notice(R.string.remove_file_created)
|
||||||
|
false -> item.deleteRemoveFile().notice(R.string.remove_file_deleted)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
when {
|
||||||
|
item.isUpdated -> notice(R.string.update_file_created)
|
||||||
|
item.willBeRemoved() -> notice(R.string.remove_file_created)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toggle() = isChecked.toggle()
|
||||||
|
fun toggleDelete() = isDeletable.toggle()
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
private fun Any.notice(@StringRes info: Int) {
|
||||||
|
lastActionNotice.value = get<Resources>().getString(info)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun contentSameAs(other: ModuleRvItem): Boolean = item.version == other.item.version
|
||||||
|
&& item.versionCode == other.item.versionCode
|
||||||
|
&& item.description == other.item.description
|
||||||
|
|
||||||
|
override fun itemSameAs(other: ModuleRvItem): Boolean = item.name == other.item.name
|
||||||
|
}
|
||||||
|
|
||||||
|
class RepoRvItem(val item: Repo) : ComparableRvItem<RepoRvItem>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.item_repo
|
||||||
|
|
||||||
|
override fun contentSameAs(other: RepoRvItem): Boolean = item.version == other.item.version
|
||||||
|
&& item.lastUpdate == other.item.lastUpdate
|
||||||
|
&& item.versionCode == other.item.versionCode
|
||||||
|
&& item.description == other.item.description
|
||||||
|
|
||||||
|
override fun itemSameAs(other: RepoRvItem): Boolean = item.detailUrl == other.item.detailUrl
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity.recycler
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.skoumal.teanity.extensions.addOnPropertyChangedCallback
|
||||||
|
import com.skoumal.teanity.rxbus.RxBus
|
||||||
|
import com.skoumal.teanity.util.KObservableField
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.model.entity.Policy
|
||||||
|
import com.topjohnwu.magisk.model.events.PolicyEnableEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.PolicyUpdateEvent
|
||||||
|
import com.topjohnwu.magisk.utils.inject
|
||||||
|
import com.topjohnwu.magisk.utils.toggle
|
||||||
|
|
||||||
|
class PolicyRvItem(val item: Policy, val icon: Drawable) : ComparableRvItem<PolicyRvItem>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.item_policy
|
||||||
|
|
||||||
|
val isExpanded = KObservableField(false)
|
||||||
|
val isEnabled = KObservableField(item.policy == Policy.ALLOW)
|
||||||
|
val shouldNotify = KObservableField(item.notification)
|
||||||
|
val shouldLog = KObservableField(item.logging)
|
||||||
|
|
||||||
|
fun toggle() = isExpanded.toggle()
|
||||||
|
|
||||||
|
private val rxBus: RxBus by inject()
|
||||||
|
|
||||||
|
init {
|
||||||
|
isEnabled.addOnPropertyChangedCallback {
|
||||||
|
it ?: return@addOnPropertyChangedCallback
|
||||||
|
rxBus.post(PolicyEnableEvent(this@PolicyRvItem, it))
|
||||||
|
}
|
||||||
|
shouldNotify.addOnPropertyChangedCallback {
|
||||||
|
it ?: return@addOnPropertyChangedCallback
|
||||||
|
item.notification = it
|
||||||
|
rxBus.post(PolicyUpdateEvent.Notification(this@PolicyRvItem))
|
||||||
|
}
|
||||||
|
shouldLog.addOnPropertyChangedCallback {
|
||||||
|
it ?: return@addOnPropertyChangedCallback
|
||||||
|
item.logging = it
|
||||||
|
rxBus.post(PolicyUpdateEvent.Log(this@PolicyRvItem))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun contentSameAs(other: PolicyRvItem): Boolean = itemSameAs(other)
|
||||||
|
override fun itemSameAs(other: PolicyRvItem): Boolean = item.uid == other.item.uid
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity.recycler
|
||||||
|
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
|
||||||
|
class SectionRvItem(val text: String) : ComparableRvItem<SectionRvItem>() {
|
||||||
|
override val layoutRes: Int = R.layout.item_section
|
||||||
|
|
||||||
|
override fun contentSameAs(other: SectionRvItem) = itemSameAs(other)
|
||||||
|
override fun itemSameAs(other: SectionRvItem) = text == other.text
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity.recycler
|
||||||
|
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
|
||||||
|
class SpinnerRvItem(val item: String) : ComparableRvItem<SpinnerRvItem>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.item_spinner
|
||||||
|
|
||||||
|
override fun contentSameAs(other: SpinnerRvItem) = itemSameAs(other)
|
||||||
|
override fun itemSameAs(other: SpinnerRvItem) = item == other.item
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.topjohnwu.magisk.model.entity.state
|
||||||
|
|
||||||
|
enum class IndeterminateState {
|
||||||
|
CHECKED, INDETERMINATE, UNCHECKED
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.topjohnwu.magisk.model.events
|
||||||
|
|
||||||
|
import com.skoumal.teanity.rxbus.RxBus
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.HideProcessRvItem
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.ModuleRvItem
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.PolicyRvItem
|
||||||
|
|
||||||
|
class HideProcessEvent(val item: HideProcessRvItem) : RxBus.Event
|
||||||
|
|
||||||
|
class PolicyEnableEvent(val item: PolicyRvItem, val enable: Boolean) : RxBus.Event
|
||||||
|
sealed class PolicyUpdateEvent(val item: PolicyRvItem) : RxBus.Event {
|
||||||
|
class Notification(item: PolicyRvItem) : PolicyUpdateEvent(item)
|
||||||
|
class Log(item: PolicyRvItem) : PolicyUpdateEvent(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
class ModuleUpdatedEvent(val item: ModuleRvItem) : RxBus.Event
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.topjohnwu.magisk.model.events
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import com.skoumal.teanity.viewevents.ViewEvent
|
||||||
|
import com.topjohnwu.magisk.model.entity.Policy
|
||||||
|
import com.topjohnwu.magisk.model.entity.Repo
|
||||||
|
import io.reactivex.subjects.PublishSubject
|
||||||
|
|
||||||
|
|
||||||
|
data class OpenLinkEvent(val url: String) : ViewEvent()
|
||||||
|
|
||||||
|
class ManagerInstallEvent : ViewEvent()
|
||||||
|
class MagiskInstallEvent : ViewEvent()
|
||||||
|
|
||||||
|
class ManagerChangelogEvent : ViewEvent()
|
||||||
|
class MagiskChangelogEvent : ViewEvent()
|
||||||
|
|
||||||
|
class UninstallEvent : ViewEvent()
|
||||||
|
class EnvFixEvent : ViewEvent()
|
||||||
|
|
||||||
|
class UpdateSafetyNetEvent : ViewEvent()
|
||||||
|
|
||||||
|
class ViewActionEvent(val action: Activity.() -> Unit) : ViewEvent()
|
||||||
|
|
||||||
|
class OpenFilePickerEvent : ViewEvent()
|
||||||
|
|
||||||
|
class OpenChangelogEvent(val item: Repo) : ViewEvent()
|
||||||
|
class InstallModuleEvent(val item: Repo) : ViewEvent()
|
||||||
|
|
||||||
|
class PageChangedEvent : ViewEvent()
|
||||||
|
|
||||||
|
class PermissionEvent(
|
||||||
|
val permissions: List<String>,
|
||||||
|
val callback: PublishSubject<Boolean>
|
||||||
|
) : ViewEvent()
|
||||||
|
|
||||||
|
class BackPressEvent : ViewEvent()
|
||||||
|
|
||||||
|
class SuDialogEvent(val policy: Policy) : ViewEvent()
|
||||||
|
class DieEvent : ViewEvent()
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.topjohnwu.magisk.model.flash
|
||||||
|
|
||||||
|
interface FlashResultListener {
|
||||||
|
|
||||||
|
fun onResult(isSuccess: Boolean)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.topjohnwu.magisk.model.flash
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.Uri
|
||||||
|
import androidx.core.os.postDelayed
|
||||||
|
import com.topjohnwu.magisk.tasks.FlashZip
|
||||||
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
|
import com.topjohnwu.magisk.utils.inject
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
import com.topjohnwu.superuser.internal.UiThreadHandler
|
||||||
|
|
||||||
|
sealed class Flashing(
|
||||||
|
uri: Uri,
|
||||||
|
private val console: MutableList<String>,
|
||||||
|
log: MutableList<String>,
|
||||||
|
private val resultListener: FlashResultListener
|
||||||
|
) : FlashZip(uri, console, log) {
|
||||||
|
|
||||||
|
override fun onResult(success: Boolean) {
|
||||||
|
if (!success) {
|
||||||
|
console.add("! Installation failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
resultListener.onResult(success)
|
||||||
|
}
|
||||||
|
|
||||||
|
class Install(
|
||||||
|
uri: Uri,
|
||||||
|
console: MutableList<String>,
|
||||||
|
log: MutableList<String>,
|
||||||
|
resultListener: FlashResultListener
|
||||||
|
) : Flashing(uri, console, log, resultListener) {
|
||||||
|
|
||||||
|
override fun onResult(success: Boolean) {
|
||||||
|
if (success) {
|
||||||
|
Utils.loadModules()
|
||||||
|
}
|
||||||
|
super.onResult(success)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Uninstall(
|
||||||
|
uri: Uri,
|
||||||
|
console: MutableList<String>,
|
||||||
|
log: MutableList<String>,
|
||||||
|
resultListener: FlashResultListener
|
||||||
|
) : Flashing(uri, console, log, resultListener) {
|
||||||
|
|
||||||
|
private val context: Context by inject()
|
||||||
|
|
||||||
|
override fun onResult(success: Boolean) {
|
||||||
|
if (success) {
|
||||||
|
UiThreadHandler.handler.postDelayed(3000) {
|
||||||
|
Shell.su("pm uninstall " + context.packageName).exec()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.onResult(success)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.topjohnwu.magisk.model.flash
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import com.topjohnwu.magisk.tasks.MagiskInstaller
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
|
||||||
|
sealed class Patching(
|
||||||
|
private val console: MutableList<String>,
|
||||||
|
logs: MutableList<String>,
|
||||||
|
private val resultListener: FlashResultListener
|
||||||
|
) : MagiskInstaller(console, logs) {
|
||||||
|
|
||||||
|
override fun onResult(success: Boolean) {
|
||||||
|
if (success) {
|
||||||
|
console.add("- All done!")
|
||||||
|
} else {
|
||||||
|
Shell.sh("rm -rf $installDir").submit()
|
||||||
|
console.add("! Installation failed")
|
||||||
|
}
|
||||||
|
resultListener.onResult(success)
|
||||||
|
}
|
||||||
|
|
||||||
|
class File(
|
||||||
|
private val uri: Uri,
|
||||||
|
console: MutableList<String>,
|
||||||
|
logs: MutableList<String>,
|
||||||
|
resultListener: FlashResultListener
|
||||||
|
) : Patching(console, logs, resultListener) {
|
||||||
|
override fun operations() =
|
||||||
|
extractZip() && handleFile(uri) && patchBoot() && storeBoot()
|
||||||
|
}
|
||||||
|
|
||||||
|
class SecondSlot(
|
||||||
|
console: MutableList<String>,
|
||||||
|
logs: MutableList<String>,
|
||||||
|
resultListener: FlashResultListener
|
||||||
|
) : Patching(console, logs, resultListener) {
|
||||||
|
override fun operations() =
|
||||||
|
findSecondaryImage() && extractZip() && patchBoot() && flashBoot() && postOTA()
|
||||||
|
}
|
||||||
|
|
||||||
|
class Direct(
|
||||||
|
console: MutableList<String>,
|
||||||
|
logs: MutableList<String>,
|
||||||
|
resultListener: FlashResultListener
|
||||||
|
) : Patching(console, logs, resultListener) {
|
||||||
|
override fun operations() =
|
||||||
|
findImage() && extractZip() && patchBoot() && flashBoot()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.topjohnwu.magisk.model.navigation
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.annotation.AnimRes
|
||||||
|
import androidx.annotation.AnimatorRes
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.skoumal.teanity.viewevents.NavigationDslMarker
|
||||||
|
import com.skoumal.teanity.viewevents.ViewEvent
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
class MagiskNavigationEvent(
|
||||||
|
val navDirections: MagiskNavDirectionsBuilder,
|
||||||
|
val navOptions: MagiskNavOptions,
|
||||||
|
val animOptions: MagiskAnimBuilder
|
||||||
|
) : ViewEvent() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
operator fun invoke(builder: Builder.() -> Unit) = Builder().apply(builder).build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@NavigationDslMarker
|
||||||
|
class Builder {
|
||||||
|
|
||||||
|
private var animOptions: MagiskAnimBuilder = MagiskAnimBuilder()
|
||||||
|
private var navOptions: MagiskNavOptions = MagiskNavOptions()
|
||||||
|
private val directionsBuilder = MagiskNavDirectionsBuilder()
|
||||||
|
|
||||||
|
fun args(builder: Bundle.() -> Unit) = directionsBuilder.args(builder)
|
||||||
|
|
||||||
|
fun navAnim(builder: MagiskAnimBuilder.() -> Unit) {
|
||||||
|
animOptions = MagiskAnimBuilder().apply(builder)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun navOptions(builder: MagiskNavOptions.() -> Unit) {
|
||||||
|
navOptions = MagiskNavOptions().apply(builder)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun navDirections(builder: MagiskNavDirectionsBuilder.() -> Unit) {
|
||||||
|
directionsBuilder.apply(builder)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun build() = MagiskNavigationEvent(directionsBuilder, navOptions, animOptions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NavigationDslMarker
|
||||||
|
class MagiskNavDirectionsBuilder {
|
||||||
|
|
||||||
|
var destination: KClass<out Fragment>? = null
|
||||||
|
var isActivity: Boolean = false
|
||||||
|
val args: Bundle = Bundle()
|
||||||
|
|
||||||
|
fun args(builder: Bundle.() -> Unit) = args.apply(builder)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@NavigationDslMarker
|
||||||
|
class MagiskNavOptions {
|
||||||
|
var popUpTo: KClass<*>? = null
|
||||||
|
var inclusive: Boolean = false
|
||||||
|
var clearTask: Boolean = false
|
||||||
|
var singleTop: Boolean = false
|
||||||
|
}
|
||||||
|
|
||||||
|
@NavigationDslMarker
|
||||||
|
class MagiskAnimBuilder {
|
||||||
|
@AnimRes
|
||||||
|
@AnimatorRes
|
||||||
|
var enter = 0
|
||||||
|
|
||||||
|
@AnimRes
|
||||||
|
@AnimatorRes
|
||||||
|
var exit = 0
|
||||||
|
|
||||||
|
@AnimRes
|
||||||
|
@AnimatorRes
|
||||||
|
var popEnter = 0
|
||||||
|
|
||||||
|
@AnimRes
|
||||||
|
@AnimatorRes
|
||||||
|
var popExit = 0
|
||||||
|
|
||||||
|
val anySet: Boolean get() = enter != 0 || exit != 0 || popEnter != 0 || popExit != 0
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.topjohnwu.magisk.model.navigation
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.ui.hide.MagiskHideFragment
|
||||||
|
import com.topjohnwu.magisk.ui.home.HomeFragment
|
||||||
|
import com.topjohnwu.magisk.ui.log.LogFragment
|
||||||
|
import com.topjohnwu.magisk.ui.module.ModulesFragment
|
||||||
|
import com.topjohnwu.magisk.ui.module.ReposFragment
|
||||||
|
import com.topjohnwu.magisk.ui.settings.SettingsFragment
|
||||||
|
import com.topjohnwu.magisk.ui.superuser.SuperuserFragment
|
||||||
|
|
||||||
|
|
||||||
|
object Navigation {
|
||||||
|
|
||||||
|
fun home() = MagiskNavigationEvent {
|
||||||
|
navDirections { destination = HomeFragment::class }
|
||||||
|
navOptions { popUpTo = HomeFragment::class }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun superuser() = MagiskNavigationEvent {
|
||||||
|
navDirections { destination = SuperuserFragment::class }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun modules() = MagiskNavigationEvent {
|
||||||
|
navDirections { destination = ModulesFragment::class }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun repos() = MagiskNavigationEvent {
|
||||||
|
navDirections { destination = ReposFragment::class }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hide() = MagiskNavigationEvent {
|
||||||
|
navDirections { destination = MagiskHideFragment::class }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun log() = MagiskNavigationEvent {
|
||||||
|
navDirections { destination = LogFragment::class }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun settings() = MagiskNavigationEvent {
|
||||||
|
navDirections { destination = SettingsFragment::class }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fromSection(section: String) = when (section) {
|
||||||
|
"superuser" -> superuser()
|
||||||
|
"modules" -> modules()
|
||||||
|
"downloads" -> repos()
|
||||||
|
"magiskhide" -> hide()
|
||||||
|
"log" -> log()
|
||||||
|
"settings" -> settings()
|
||||||
|
else -> home()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
object Main {
|
||||||
|
const val OPEN_NAV = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.topjohnwu.magisk.model.navigation
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
interface Navigator {
|
||||||
|
|
||||||
|
//TODO Elevate Fragment to MagiskFragment<*,*> once everything is on board with it
|
||||||
|
val baseFragments: List<KClass<out Fragment>>
|
||||||
|
|
||||||
|
fun navigateTo(event: MagiskNavigationEvent)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.topjohnwu.magisk.model.observer
|
||||||
|
|
||||||
|
import androidx.databinding.Observable
|
||||||
|
import androidx.databinding.ObservableField
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
|
||||||
|
class Observer<T>(vararg dependencies: Observable, private val observer: () -> T) :
|
||||||
|
ObservableField<T>(*dependencies), Serializable {
|
||||||
|
|
||||||
|
val value: T get() = observer()
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
message = "Use KObservableField.value syntax from code",
|
||||||
|
replaceWith = ReplaceWith("value")
|
||||||
|
)
|
||||||
|
override fun get(): T {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
message = "Observer cannot be set",
|
||||||
|
level = DeprecationLevel.HIDDEN
|
||||||
|
)
|
||||||
|
override fun set(newValue: T) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return "Observer(value=$value)"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.topjohnwu.magisk.model.permissions
|
||||||
|
|
||||||
|
typealias SimpleCallback = () -> Unit
|
||||||
|
typealias PermissionRationaleCallback = (List<String>) -> Unit
|
||||||
|
|
||||||
|
class PermissionRequestBuilder {
|
||||||
|
|
||||||
|
private var onSuccessCallback: SimpleCallback = {}
|
||||||
|
private var onFailureCallback: SimpleCallback = {}
|
||||||
|
private var onShowRationaleCallback: PermissionRationaleCallback = {}
|
||||||
|
|
||||||
|
fun onSuccess(callback: SimpleCallback) {
|
||||||
|
onSuccessCallback = callback
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onFailure(callback: SimpleCallback) {
|
||||||
|
onFailureCallback = callback
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onShowRationale(callback: PermissionRationaleCallback) {
|
||||||
|
onShowRationaleCallback = callback
|
||||||
|
}
|
||||||
|
|
||||||
|
fun build(): PermissionRequest {
|
||||||
|
return PermissionRequest(onSuccessCallback, onFailureCallback, onShowRationaleCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class PermissionRequest(
|
||||||
|
private val onSuccessCallback: SimpleCallback,
|
||||||
|
private val onFailureCallback: SimpleCallback,
|
||||||
|
private val onShowRationaleCallback: PermissionRationaleCallback
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun onSuccess() = onSuccessCallback()
|
||||||
|
fun onFailure() = onFailureCallback()
|
||||||
|
fun onShowRationale(permissions: List<String>) = onShowRationaleCallback(permissions)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.topjohnwu.magisk.model.receiver
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import com.topjohnwu.magisk.ClassMap
|
||||||
|
import com.topjohnwu.magisk.Config
|
||||||
|
import com.topjohnwu.magisk.Const
|
||||||
|
import com.topjohnwu.magisk.data.database.MagiskDB
|
||||||
|
import com.topjohnwu.magisk.ui.surequest.SuRequestActivity
|
||||||
|
import com.topjohnwu.magisk.utils.DownloadApp
|
||||||
|
import com.topjohnwu.magisk.utils.RootUtils
|
||||||
|
import com.topjohnwu.magisk.utils.SuLogger
|
||||||
|
import com.topjohnwu.magisk.utils.get
|
||||||
|
import com.topjohnwu.magisk.view.Notifications
|
||||||
|
import com.topjohnwu.magisk.view.Shortcuts
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
|
||||||
|
open class GeneralReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val REQUEST = "request"
|
||||||
|
const val LOG = "log"
|
||||||
|
const val NOTIFY = "notify"
|
||||||
|
const val TEST = "test"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getPkg(intent: Intent): String {
|
||||||
|
return intent.data?.encodedSchemeSpecificPart ?: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onReceive(context: Context, intent: Intent?) {
|
||||||
|
if (intent == null)
|
||||||
|
return
|
||||||
|
val mDB: MagiskDB = get()
|
||||||
|
var action: String? = intent.action ?: return
|
||||||
|
when (action) {
|
||||||
|
Intent.ACTION_REBOOT, Intent.ACTION_BOOT_COMPLETED -> {
|
||||||
|
action = intent.getStringExtra("action")
|
||||||
|
if (action == null) {
|
||||||
|
// Actual boot completed event
|
||||||
|
Shell.su("mm_patch_dtbo").submit { result ->
|
||||||
|
if (result.isSuccess)
|
||||||
|
Notifications.dtboPatched()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
when (action) {
|
||||||
|
REQUEST -> {
|
||||||
|
val i = Intent(context, ClassMap.get<Any>(SuRequestActivity::class.java))
|
||||||
|
.setAction(action)
|
||||||
|
.putExtra("socket", intent.getStringExtra("socket"))
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
|
||||||
|
context.startActivity(i)
|
||||||
|
}
|
||||||
|
LOG -> SuLogger.handleLogs(intent)
|
||||||
|
NOTIFY -> SuLogger.handleNotify(intent)
|
||||||
|
TEST -> Shell.su("magisk --use-broadcast").submit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Intent.ACTION_PACKAGE_REPLACED ->
|
||||||
|
// This will only work pre-O
|
||||||
|
if (Config.get<Boolean>(Config.Key.SU_REAUTH)!!) {
|
||||||
|
mDB.deletePolicy(getPkg(intent))
|
||||||
|
}
|
||||||
|
Intent.ACTION_PACKAGE_FULLY_REMOVED -> {
|
||||||
|
val pkg = getPkg(intent)
|
||||||
|
mDB.deletePolicy(pkg)
|
||||||
|
Shell.su("magiskhide --rm $pkg").submit()
|
||||||
|
}
|
||||||
|
Intent.ACTION_LOCALE_CHANGED -> Shortcuts.setup(context)
|
||||||
|
Const.Key.BROADCAST_MANAGER_UPDATE -> {
|
||||||
|
Config.managerLink = intent.getStringExtra(Const.Key.INTENT_SET_LINK)
|
||||||
|
DownloadApp.upgrade(intent.getStringExtra(Const.Key.INTENT_SET_NAME))
|
||||||
|
}
|
||||||
|
Const.Key.BROADCAST_REBOOT -> RootUtils.reboot()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.topjohnwu.magisk.model.update;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.work.ListenableWorker;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.App;
|
||||||
|
import com.topjohnwu.magisk.BuildConfig;
|
||||||
|
import com.topjohnwu.magisk.Config;
|
||||||
|
import com.topjohnwu.magisk.model.worker.DelegateWorker;
|
||||||
|
import com.topjohnwu.magisk.tasks.CheckUpdates;
|
||||||
|
import com.topjohnwu.magisk.view.Notifications;
|
||||||
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
|
public class UpdateCheckService extends DelegateWorker {
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ListenableWorker.Result doWork() {
|
||||||
|
if (App.foreground() == null) {
|
||||||
|
Shell.getShell();
|
||||||
|
CheckUpdates.check(this::onCheckDone);
|
||||||
|
}
|
||||||
|
return ListenableWorker.Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onCheckDone() {
|
||||||
|
if (BuildConfig.VERSION_CODE < Config.remoteManagerVersionCode) {
|
||||||
|
Notifications.managerUpdate();
|
||||||
|
} else if (Config.magiskVersionCode < Config.remoteMagiskVersionCode) {
|
||||||
|
Notifications.magiskUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.topjohnwu.magisk.model.worker;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.Network;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import androidx.annotation.MainThread;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
import androidx.work.Data;
|
||||||
|
import androidx.work.ListenableWorker;
|
||||||
|
|
||||||
|
public abstract class DelegateWorker {
|
||||||
|
|
||||||
|
private ListenableWorker worker;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public abstract ListenableWorker.Result doWork();
|
||||||
|
|
||||||
|
public void onStopped() {}
|
||||||
|
|
||||||
|
public void setActualWorker(ListenableWorker w) {
|
||||||
|
worker = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Context getApplicationContext() {
|
||||||
|
return worker.getApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public UUID getId() {
|
||||||
|
return worker.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Data getInputData() {
|
||||||
|
return worker.getInputData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public Set<String> getTags() {
|
||||||
|
return worker.getTags();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@RequiresApi(24)
|
||||||
|
public List<Uri> getTriggeredContentUris() {
|
||||||
|
return worker.getTriggeredContentUris();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@RequiresApi(24)
|
||||||
|
public List<String> getTriggeredContentAuthorities() {
|
||||||
|
return worker.getTriggeredContentAuthorities();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@RequiresApi(28)
|
||||||
|
public Network getNetwork() {
|
||||||
|
return worker.getNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRunAttemptCount() {
|
||||||
|
return worker.getRunAttemptCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@MainThread
|
||||||
|
public ListenableFuture<ListenableWorker.Result> startWork() {
|
||||||
|
return worker.startWork();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStopped() {
|
||||||
|
return worker.isStopped();
|
||||||
|
}
|
||||||
|
}
|
||||||
132
app/src/main/java/com/topjohnwu/magisk/tasks/CheckUpdates.java
Normal file
132
app/src/main/java/com/topjohnwu/magisk/tasks/CheckUpdates.java
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
package com.topjohnwu.magisk.tasks;
|
||||||
|
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.Config;
|
||||||
|
import com.topjohnwu.magisk.Const;
|
||||||
|
import com.topjohnwu.magisk.utils.Event;
|
||||||
|
import com.topjohnwu.net.Networking;
|
||||||
|
import com.topjohnwu.net.Request;
|
||||||
|
import com.topjohnwu.net.ResponseListener;
|
||||||
|
import com.topjohnwu.superuser.ShellUtils;
|
||||||
|
import com.topjohnwu.superuser.internal.UiThreadHandler;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
public class CheckUpdates {
|
||||||
|
|
||||||
|
private static Request getRequest() {
|
||||||
|
String url;
|
||||||
|
switch ((int) Config.get(Config.Key.UPDATE_CHANNEL)) {
|
||||||
|
case Config.Value.BETA_CHANNEL:
|
||||||
|
url = Const.Url.BETA_URL;
|
||||||
|
break;
|
||||||
|
case Config.Value.CUSTOM_CHANNEL:
|
||||||
|
url = Config.get(Config.Key.CUSTOM_CHANNEL);
|
||||||
|
break;
|
||||||
|
case Config.Value.CANARY_CHANNEL:
|
||||||
|
url = Const.Url.CANARY_URL;
|
||||||
|
break;
|
||||||
|
case Config.Value.CANARY_DEBUG_CHANNEL:
|
||||||
|
url = Const.Url.CANARY_DEBUG_URL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
url = Const.Url.STABLE_URL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return Networking.get(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void check() {
|
||||||
|
check(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void check(Runnable cb) {
|
||||||
|
Request request = getRequest();
|
||||||
|
UpdateListener listener = new UpdateListener(cb);
|
||||||
|
if (ShellUtils.onMainThread()) {
|
||||||
|
request.getAsJSONObject(listener);
|
||||||
|
} else {
|
||||||
|
JSONObject json = request.execForJSONObject().getResult();
|
||||||
|
if (json != null)
|
||||||
|
listener.onResponse(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class UpdateListener implements ResponseListener<JSONObject> {
|
||||||
|
|
||||||
|
private Runnable cb;
|
||||||
|
private long start;
|
||||||
|
|
||||||
|
UpdateListener(Runnable callback) {
|
||||||
|
cb = callback;
|
||||||
|
start = SystemClock.uptimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getInt(JSONObject json, String name, int defValue) {
|
||||||
|
if (json == null)
|
||||||
|
return defValue;
|
||||||
|
try {
|
||||||
|
return json.getInt(name);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getString(JSONObject json, String name, String defValue) {
|
||||||
|
if (json == null)
|
||||||
|
return defValue;
|
||||||
|
try {
|
||||||
|
return json.getString(name);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONObject getJson(JSONObject json, String name) {
|
||||||
|
try {
|
||||||
|
return json.getJSONObject(name);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(JSONObject json) {
|
||||||
|
JSONObject magisk = getJson(json, "magisk");
|
||||||
|
Config.remoteMagiskVersionCode = getInt(magisk, "versionCode", -1);
|
||||||
|
|
||||||
|
if ((int) Config.get(Config.Key.UPDATE_CHANNEL) == Config.Value.DEFAULT_CHANNEL) {
|
||||||
|
if (Config.magiskVersionCode > Config.remoteMagiskVersionCode) {
|
||||||
|
// If we are newer than current stable channel, switch to beta
|
||||||
|
Config.set(Config.Key.UPDATE_CHANNEL, Config.Value.BETA_CHANNEL);
|
||||||
|
check(cb);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Config.set(Config.Key.UPDATE_CHANNEL, Config.Value.STABLE_CHANNEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Config.remoteMagiskVersionString = getString(magisk, "version", null);
|
||||||
|
Config.magiskLink = getString(magisk, "link", null);
|
||||||
|
Config.magiskNoteLink = getString(magisk, "note", null);
|
||||||
|
Config.magiskMD5 = getString(magisk, "md5", null);
|
||||||
|
|
||||||
|
JSONObject manager = getJson(json, "app");
|
||||||
|
Config.remoteManagerVersionString = getString(manager, "version", null);
|
||||||
|
Config.remoteManagerVersionCode = getInt(manager, "versionCode", -1);
|
||||||
|
Config.managerLink = getString(manager, "link", null);
|
||||||
|
Config.managerNoteLink = getString(manager, "note", null);
|
||||||
|
|
||||||
|
JSONObject uninstaller = getJson(json, "uninstaller");
|
||||||
|
Config.uninstallerLink = getString(uninstaller, "link", null);
|
||||||
|
|
||||||
|
UiThreadHandler.handler.postAtTime(() -> Event.trigger(Event.UPDATE_CHECK_DONE),
|
||||||
|
start + 1000 /* Add artificial delay to let UI behave correctly */);
|
||||||
|
|
||||||
|
if (cb != null)
|
||||||
|
cb.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
96
app/src/main/java/com/topjohnwu/magisk/tasks/FlashZip.kt
Normal file
96
app/src/main/java/com/topjohnwu/magisk/tasks/FlashZip.kt
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
package com.topjohnwu.magisk.tasks
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import com.skoumal.teanity.extensions.subscribeK
|
||||||
|
import com.topjohnwu.magisk.App
|
||||||
|
import com.topjohnwu.magisk.Const
|
||||||
|
import com.topjohnwu.magisk.utils.fileName
|
||||||
|
import com.topjohnwu.magisk.utils.inject
|
||||||
|
import com.topjohnwu.magisk.utils.readUri
|
||||||
|
import com.topjohnwu.magisk.utils.unzip
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
import io.reactivex.Single
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileNotFoundException
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
abstract class FlashZip(
|
||||||
|
private val mUri: Uri,
|
||||||
|
private val console: MutableList<String>,
|
||||||
|
private val logs: MutableList<String>
|
||||||
|
) {
|
||||||
|
|
||||||
|
private val app: App by inject()
|
||||||
|
private val tmpFile: File = File(app.cacheDir, "install.zip")
|
||||||
|
|
||||||
|
@Throws(IOException::class)
|
||||||
|
private fun unzipAndCheck(): Boolean {
|
||||||
|
val parentFile = tmpFile.parentFile ?: return false
|
||||||
|
tmpFile.unzip(parentFile, "META-INF/com/google/android", true)
|
||||||
|
|
||||||
|
val updaterScript = File(parentFile, "updater-script")
|
||||||
|
return Shell
|
||||||
|
.su("grep -q '#MAGISK' $updaterScript")
|
||||||
|
.exec()
|
||||||
|
.isSuccess
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(IOException::class)
|
||||||
|
private fun flash(): Boolean {
|
||||||
|
console.add("- Copying zip to temp directory")
|
||||||
|
|
||||||
|
runCatching {
|
||||||
|
app.readUri(mUri).use { input ->
|
||||||
|
tmpFile.outputStream().use { out -> input.copyTo(out) }
|
||||||
|
}
|
||||||
|
}.getOrElse {
|
||||||
|
when (it) {
|
||||||
|
is FileNotFoundException -> console.add("! Invalid Uri")
|
||||||
|
is IOException -> console.add("! Cannot copy to cache")
|
||||||
|
}
|
||||||
|
throw it
|
||||||
|
}
|
||||||
|
|
||||||
|
val isMagiskModule = runCatching {
|
||||||
|
unzipAndCheck()
|
||||||
|
}.getOrElse {
|
||||||
|
console.add("! Unzip error")
|
||||||
|
throw it
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isMagiskModule) {
|
||||||
|
console.add("! This zip is not a Magisk Module!")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
console.add("- Installing ${mUri.fileName}")
|
||||||
|
|
||||||
|
val parentFile = tmpFile.parent ?: return false
|
||||||
|
|
||||||
|
return Shell
|
||||||
|
.su(
|
||||||
|
"cd $parentFile",
|
||||||
|
"BOOTMODE=true sh update-binary dummy 1 $tmpFile"
|
||||||
|
)
|
||||||
|
.to(console, logs)
|
||||||
|
.exec().isSuccess
|
||||||
|
}
|
||||||
|
|
||||||
|
fun exec() = Single
|
||||||
|
.fromCallable {
|
||||||
|
runCatching {
|
||||||
|
flash()
|
||||||
|
}.getOrElse {
|
||||||
|
it.printStackTrace()
|
||||||
|
false
|
||||||
|
}.apply {
|
||||||
|
Shell.su("cd /", "rm -rf ${tmpFile.parent} ${Const.TMP_FOLDER_PATH}")
|
||||||
|
.submit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.subscribeK(onError = { onResult(false) }) { onResult(it) }
|
||||||
|
.let { Unit } // ignores result disposable
|
||||||
|
|
||||||
|
|
||||||
|
protected abstract fun onResult(success: Boolean)
|
||||||
|
}
|
||||||
@@ -0,0 +1,380 @@
|
|||||||
|
package com.topjohnwu.magisk.tasks;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import androidx.annotation.MainThread;
|
||||||
|
import androidx.annotation.WorkerThread;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.App;
|
||||||
|
import com.topjohnwu.magisk.Config;
|
||||||
|
import com.topjohnwu.magisk.Const;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
import com.topjohnwu.net.DownloadProgressListener;
|
||||||
|
import com.topjohnwu.net.Networking;
|
||||||
|
import com.topjohnwu.signing.SignBoot;
|
||||||
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
import com.topjohnwu.superuser.ShellUtils;
|
||||||
|
import com.topjohnwu.superuser.internal.NOPList;
|
||||||
|
import com.topjohnwu.superuser.internal.UiThreadHandler;
|
||||||
|
import com.topjohnwu.superuser.io.SuFile;
|
||||||
|
import com.topjohnwu.superuser.io.SuFileInputStream;
|
||||||
|
import com.topjohnwu.superuser.io.SuFileOutputStream;
|
||||||
|
|
||||||
|
import org.kamranzafar.jtar.TarEntry;
|
||||||
|
import org.kamranzafar.jtar.TarHeader;
|
||||||
|
import org.kamranzafar.jtar.TarInputStream;
|
||||||
|
import org.kamranzafar.jtar.TarOutputStream;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
|
public abstract class MagiskInstaller {
|
||||||
|
|
||||||
|
protected String srcBoot;
|
||||||
|
protected File destFile;
|
||||||
|
protected File installDir;
|
||||||
|
|
||||||
|
private List<String> console, logs;
|
||||||
|
private boolean isTar = false;
|
||||||
|
|
||||||
|
private class ProgressLog implements DownloadProgressListener {
|
||||||
|
|
||||||
|
private int prev = -1;
|
||||||
|
private int location;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProgress(long bytesDownloaded, long totalBytes) {
|
||||||
|
if (prev < 0) {
|
||||||
|
location = console.size();
|
||||||
|
console.add("... 0%");
|
||||||
|
}
|
||||||
|
int curr = (int) (100 * bytesDownloaded / totalBytes);
|
||||||
|
if (prev != curr) {
|
||||||
|
prev = curr;
|
||||||
|
console.set(location, "... " + prev + "%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MagiskInstaller() {
|
||||||
|
console = NOPList.getInstance();
|
||||||
|
logs = NOPList.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MagiskInstaller(List<String> out, List<String> err) {
|
||||||
|
console = out;
|
||||||
|
logs = err;
|
||||||
|
installDir = new File(App.deContext.getFilesDir().getParent(), "install");
|
||||||
|
Shell.sh("rm -rf " + installDir).exec();
|
||||||
|
installDir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean findImage() {
|
||||||
|
srcBoot = ShellUtils.fastCmd("find_boot_image", "echo \"$BOOTIMAGE\"");
|
||||||
|
if (srcBoot.isEmpty()) {
|
||||||
|
console.add("! Unable to detect target image");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
console.add("- Target image: " + srcBoot);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean findSecondaryImage() {
|
||||||
|
String slot = ShellUtils.fastCmd("echo $SLOT");
|
||||||
|
String target = (TextUtils.equals(slot, "_a") ? "_b" : "_a");
|
||||||
|
console.add("- Target slot: " + target);
|
||||||
|
srcBoot = ShellUtils.fastCmd(
|
||||||
|
"SLOT=" + target,
|
||||||
|
"find_boot_image",
|
||||||
|
"SLOT=" + slot,
|
||||||
|
"echo \"$BOOTIMAGE\""
|
||||||
|
);
|
||||||
|
if (srcBoot.isEmpty()) {
|
||||||
|
console.add("! Unable to detect target image");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
console.add("- Target image: " + srcBoot);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean extractZip() {
|
||||||
|
String arch;
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
List<String> abis = Arrays.asList(Build.SUPPORTED_ABIS);
|
||||||
|
arch = abis.contains("x86") ? "x86" : "arm";
|
||||||
|
} else {
|
||||||
|
arch = TextUtils.equals(Build.CPU_ABI, "x86") ? "x86" : "arm";
|
||||||
|
}
|
||||||
|
|
||||||
|
console.add("- Device platform: " + Build.CPU_ABI);
|
||||||
|
|
||||||
|
File zip = new File(App.self.getCacheDir(), "magisk.zip");
|
||||||
|
|
||||||
|
if (!ShellUtils.checkSum("MD5", zip, Config.magiskMD5)) {
|
||||||
|
console.add("- Downloading zip");
|
||||||
|
Networking.get(Config.magiskLink)
|
||||||
|
.setDownloadProgressListener(new ProgressLog())
|
||||||
|
.execForFile(zip);
|
||||||
|
} else {
|
||||||
|
console.add("- Existing zip found");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ZipInputStream zi = new ZipInputStream(new BufferedInputStream(
|
||||||
|
new FileInputStream(zip), (int) zip.length()));
|
||||||
|
ZipEntry ze;
|
||||||
|
while ((ze = zi.getNextEntry()) != null) {
|
||||||
|
if (ze.isDirectory())
|
||||||
|
continue;
|
||||||
|
String name = null;
|
||||||
|
String[] names = { arch + "/", "common/", "META-INF/com/google/android/update-binary" };
|
||||||
|
for (String n : names) {
|
||||||
|
if (ze.getName().startsWith(n)) {
|
||||||
|
name = ze.getName().substring(ze.getName().lastIndexOf('/') + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name == null && ze.getName().startsWith("chromeos/"))
|
||||||
|
name = ze.getName();
|
||||||
|
if (name == null)
|
||||||
|
continue;
|
||||||
|
File dest = (installDir instanceof SuFile) ?
|
||||||
|
new SuFile(installDir, name) :
|
||||||
|
new File(installDir, name);
|
||||||
|
dest.getParentFile().mkdirs();
|
||||||
|
try (OutputStream out = new SuFileOutputStream(dest)) {
|
||||||
|
ShellUtils.pump(zi, out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
console.add("! Cannot unzip zip");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
File init64 = SuFile.open(installDir, "magiskinit64");
|
||||||
|
if (Build.VERSION.SDK_INT >= 21 && Build.SUPPORTED_64_BIT_ABIS.length != 0) {
|
||||||
|
init64.renameTo(SuFile.open(installDir, "magiskinit"));
|
||||||
|
} else {
|
||||||
|
init64.delete();
|
||||||
|
}
|
||||||
|
Shell.sh("cd " + installDir, "chmod 755 *").exec();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TarEntry newEntry(String name, long size) {
|
||||||
|
console.add("-- Writing: " + name);
|
||||||
|
return new TarEntry(TarHeader.createHeader(name, size, 0, false, 0644));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleTar(InputStream in) throws IOException {
|
||||||
|
console.add("- Processing tar file");
|
||||||
|
boolean vbmeta = false;
|
||||||
|
try (TarInputStream tarIn = new TarInputStream(in);
|
||||||
|
TarOutputStream tarOut = new TarOutputStream(destFile)) {
|
||||||
|
TarEntry entry;
|
||||||
|
while ((entry = tarIn.getNextEntry()) != null) {
|
||||||
|
if (entry.getName().contains("boot.img")
|
||||||
|
|| entry.getName().contains("recovery.img")) {
|
||||||
|
String name = entry.getName();
|
||||||
|
console.add("-- Extracting: " + name);
|
||||||
|
File extract = new File(installDir, name);
|
||||||
|
try (FileOutputStream fout = new FileOutputStream(extract)) {
|
||||||
|
ShellUtils.pump(tarIn, fout);
|
||||||
|
}
|
||||||
|
if (name.contains(".lz4")) {
|
||||||
|
console.add("-- Decompressing: " + name);
|
||||||
|
Shell.sh("./magiskboot --decompress " + extract).to(console).exec();
|
||||||
|
}
|
||||||
|
} else if (entry.getName().contains("vbmeta.img")) {
|
||||||
|
vbmeta = true;
|
||||||
|
ByteBuffer buf = ByteBuffer.allocate(256);
|
||||||
|
buf.put("AVB0".getBytes()); // magic
|
||||||
|
buf.putInt(1); // required_libavb_version_major
|
||||||
|
buf.putInt(120, 2); // flags
|
||||||
|
buf.position(128); // release_string
|
||||||
|
buf.put("avbtool 1.1.0".getBytes());
|
||||||
|
tarOut.putNextEntry(newEntry("vbmeta.img", 256));
|
||||||
|
tarOut.write(buf.array());
|
||||||
|
} else {
|
||||||
|
console.add("-- Writing: " + entry.getName());
|
||||||
|
tarOut.putNextEntry(entry);
|
||||||
|
ShellUtils.pump(tarIn, tarOut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File boot = SuFile.open(installDir, "boot.img");
|
||||||
|
File recovery = SuFile.open(installDir, "recovery.img");
|
||||||
|
if (vbmeta && recovery.exists() && boot.exists()) {
|
||||||
|
// Install Magisk to recovery
|
||||||
|
srcBoot = recovery.getPath();
|
||||||
|
// Repack boot image to prevent restore
|
||||||
|
Shell.sh(
|
||||||
|
"./magiskboot --unpack boot.img",
|
||||||
|
"./magiskboot --repack boot.img",
|
||||||
|
"./magiskboot --cleanup",
|
||||||
|
"mv new-boot.img boot.img").exec();
|
||||||
|
try (InputStream sin = new SuFileInputStream(boot)) {
|
||||||
|
tarOut.putNextEntry(newEntry("boot.img", boot.length()));
|
||||||
|
ShellUtils.pump(sin, tarOut);
|
||||||
|
}
|
||||||
|
boot.delete();
|
||||||
|
} else {
|
||||||
|
if (!boot.exists()) {
|
||||||
|
console.add("! No boot image found");
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
|
srcBoot = boot.getPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean handleFile(Uri uri) {
|
||||||
|
try (InputStream in = new BufferedInputStream(App.self.getContentResolver().openInputStream(uri))) {
|
||||||
|
in.mark(500);
|
||||||
|
byte[] magic = new byte[5];
|
||||||
|
if (in.skip(257) != 257 || in.read(magic) != magic.length) {
|
||||||
|
console.add("! Invalid file");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
in.reset();
|
||||||
|
if (Arrays.equals(magic, "ustar".getBytes())) {
|
||||||
|
isTar = true;
|
||||||
|
destFile = new File(Const.EXTERNAL_PATH, "magisk_patched.tar");
|
||||||
|
handleTar(in);
|
||||||
|
} else {
|
||||||
|
// Raw image
|
||||||
|
srcBoot = new File(installDir, "boot.img").getPath();
|
||||||
|
destFile = new File(Const.EXTERNAL_PATH, "magisk_patched.img");
|
||||||
|
console.add("- Copying image to cache");
|
||||||
|
try (OutputStream out = new FileOutputStream(srcBoot)) {
|
||||||
|
ShellUtils.pump(in, out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
console.add("! Process error");
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean patchBoot() {
|
||||||
|
boolean isSigned;
|
||||||
|
try (InputStream in = new SuFileInputStream(srcBoot)) {
|
||||||
|
isSigned = SignBoot.verifySignature(in, null);
|
||||||
|
if (isSigned) {
|
||||||
|
console.add("- Boot image is signed with AVB 1.0");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
console.add("! Unable to check signature");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Shell.sh(Utils.fmt(
|
||||||
|
"KEEPFORCEENCRYPT=%b KEEPVERITY=%b RECOVERYMODE=%b " +
|
||||||
|
"sh update-binary sh boot_patch.sh %s",
|
||||||
|
Config.keepEnc, Config.keepVerity, Config.recovery, srcBoot))
|
||||||
|
.to(console, logs).exec().isSuccess())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Shell.Job job = Shell.sh("./magiskboot --cleanup",
|
||||||
|
"mv bin/busybox busybox",
|
||||||
|
"rm -rf magisk.apk bin boot.img update-binary",
|
||||||
|
"cd /");
|
||||||
|
|
||||||
|
File patched = new File(installDir, "new-boot.img");
|
||||||
|
if (isSigned) {
|
||||||
|
console.add("- Signing boot image with test keys");
|
||||||
|
File signed = new File(installDir, "signed.img");
|
||||||
|
try (InputStream in = new SuFileInputStream(patched);
|
||||||
|
OutputStream out = new BufferedOutputStream(new FileOutputStream(signed))) {
|
||||||
|
SignBoot.doSignature("/boot", in, out, null, null);
|
||||||
|
} catch (IOException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
job.add("mv -f " + signed + " " + patched);
|
||||||
|
}
|
||||||
|
job.exec();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean flashBoot() {
|
||||||
|
if (!Shell.su(Utils.fmt("direct_install %s %s", installDir, srcBoot))
|
||||||
|
.to(console, logs).exec().isSuccess())
|
||||||
|
return false;
|
||||||
|
if (!Config.keepVerity)
|
||||||
|
Shell.su("patch_dtbo_image").to(console, logs).exec();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean storeBoot() {
|
||||||
|
File patched = SuFile.open(installDir, "new-boot.img");
|
||||||
|
try {
|
||||||
|
OutputStream os;
|
||||||
|
if (isTar) {
|
||||||
|
os = new TarOutputStream(destFile, true);
|
||||||
|
((TarOutputStream) os).putNextEntry(newEntry(
|
||||||
|
srcBoot.contains("recovery") ? "recovery.img" : "boot.img",
|
||||||
|
patched.length()));
|
||||||
|
} else {
|
||||||
|
os = new BufferedOutputStream(new FileOutputStream(destFile));
|
||||||
|
}
|
||||||
|
try (InputStream in = new SuFileInputStream(patched);
|
||||||
|
OutputStream out = os) {
|
||||||
|
ShellUtils.pump(in, out);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
console.add("! Failed to output to " + destFile);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
patched.delete();
|
||||||
|
console.add("");
|
||||||
|
console.add("****************************");
|
||||||
|
console.add(" Output file is placed in ");
|
||||||
|
console.add(" " + destFile + " ");
|
||||||
|
console.add("****************************");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean postOTA() {
|
||||||
|
SuFile bootctl = new SuFile("/data/adb/bootctl");
|
||||||
|
try (InputStream in = Networking.get(Const.Url.BOOTCTL_URL).execForInputStream().getResult();
|
||||||
|
OutputStream out = new SuFileOutputStream(bootctl)) {
|
||||||
|
ShellUtils.pump(in, out);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Shell.su("post_ota " + bootctl.getParent()).exec();
|
||||||
|
console.add("***************************************");
|
||||||
|
console.add(" Next reboot will boot to second slot!");
|
||||||
|
console.add("***************************************");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
|
protected abstract boolean operations();
|
||||||
|
|
||||||
|
@MainThread
|
||||||
|
protected abstract void onResult(boolean success);
|
||||||
|
|
||||||
|
public void exec() {
|
||||||
|
App.THREAD_POOL.execute(() -> {
|
||||||
|
boolean b = operations();
|
||||||
|
UiThreadHandler.run(() -> onResult(b));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
176
app/src/main/java/com/topjohnwu/magisk/tasks/UpdateRepos.java
Normal file
176
app/src/main/java/com/topjohnwu/magisk/tasks/UpdateRepos.java
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
package com.topjohnwu.magisk.tasks;
|
||||||
|
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.util.Pair;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.App;
|
||||||
|
import com.topjohnwu.magisk.Config;
|
||||||
|
import com.topjohnwu.magisk.Const;
|
||||||
|
import com.topjohnwu.magisk.model.entity.Repo;
|
||||||
|
import com.topjohnwu.magisk.utils.Event;
|
||||||
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
import com.topjohnwu.net.Networking;
|
||||||
|
import com.topjohnwu.net.Request;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
public class UpdateRepos {
|
||||||
|
private static final DateFormat DATE_FORMAT;
|
||||||
|
|
||||||
|
private final App app = App.self;
|
||||||
|
private Set<String> cached;
|
||||||
|
private Queue<Pair<String, Date>> moduleQueue;
|
||||||
|
|
||||||
|
static {
|
||||||
|
DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
|
||||||
|
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runTasks(Runnable task) {
|
||||||
|
Future[] futures = new Future[App.THREAD_POOL.getMaximumPoolSize() - 1];
|
||||||
|
for (int i = 0; i < futures.length; ++i) {
|
||||||
|
futures[i] = App.THREAD_POOL.submit(task);
|
||||||
|
}
|
||||||
|
for (Future f : futures) {
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
f.get();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
continue;
|
||||||
|
} catch (ExecutionException ignored) {}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We sort repos by last push, which means that we only need to check whether the
|
||||||
|
* first page is updated to determine whether the online repo database is changed
|
||||||
|
*/
|
||||||
|
private boolean parsePage(int page) {
|
||||||
|
Request req = Networking.get(Utils.fmt(Const.Url.REPO_URL, page + 1));
|
||||||
|
if (page == 0) {
|
||||||
|
String etag = Config.get(Config.Key.ETAG_KEY);
|
||||||
|
if (etag != null)
|
||||||
|
req.addHeaders(Const.Key.IF_NONE_MATCH, etag);
|
||||||
|
}
|
||||||
|
Request.Result<JSONArray> res = req.execForJSONArray();
|
||||||
|
// JSON not updated
|
||||||
|
if (res.getCode() == HttpURLConnection.HTTP_NOT_MODIFIED)
|
||||||
|
return false;
|
||||||
|
// Network error
|
||||||
|
if (res.getResult() == null) {
|
||||||
|
cached.clear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Current page is the last page
|
||||||
|
if (res.getResult().length() == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < res.getResult().length(); i++) {
|
||||||
|
JSONObject rawRepo = res.getResult().getJSONObject(i);
|
||||||
|
String id = rawRepo.getString("name");
|
||||||
|
Date date = DATE_FORMAT.parse(rawRepo.getString("pushed_at"));
|
||||||
|
moduleQueue.offer(new Pair<>(id, date));
|
||||||
|
}
|
||||||
|
} catch (JSONException | ParseException e) {
|
||||||
|
// Should not happen, but if exception occurs, page load fails
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update ETAG
|
||||||
|
if (page == 0) {
|
||||||
|
String etag = res.getConnection().getHeaderField(Config.Key.ETAG_KEY);
|
||||||
|
if (etag != null) {
|
||||||
|
etag = etag.substring(etag.indexOf('\"'), etag.lastIndexOf('\"') + 1);
|
||||||
|
Config.set(Config.Key.ETAG_KEY, etag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String links = res.getConnection().getHeaderField(Const.Key.LINK_KEY);
|
||||||
|
return links == null || !links.contains("next") || parsePage(page + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean loadPages() {
|
||||||
|
if (!parsePage(0))
|
||||||
|
return false;
|
||||||
|
runTasks(() -> {
|
||||||
|
while (true) {
|
||||||
|
Pair<String, Date> pair = moduleQueue.poll();
|
||||||
|
if (pair == null)
|
||||||
|
return;
|
||||||
|
Repo repo = app.getRepoDB().getRepo(pair.first);
|
||||||
|
try {
|
||||||
|
if (repo == null)
|
||||||
|
repo = new Repo(pair.first);
|
||||||
|
else
|
||||||
|
cached.remove(pair.first);
|
||||||
|
repo.update(pair.second);
|
||||||
|
app.getRepoDB().addRepo(repo);
|
||||||
|
} catch (Repo.IllegalRepoException e) {
|
||||||
|
Logger.debug(e.getMessage());
|
||||||
|
app.getRepoDB().removeRepo(pair.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fullReload() {
|
||||||
|
Cursor c = app.getRepoDB().getRawCursor();
|
||||||
|
runTasks(() -> {
|
||||||
|
while (true) {
|
||||||
|
Repo repo;
|
||||||
|
synchronized (c) {
|
||||||
|
if (!c.moveToNext())
|
||||||
|
return;
|
||||||
|
repo = new Repo(c);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
repo.update();
|
||||||
|
app.getRepoDB().addRepo(repo);
|
||||||
|
} catch (Repo.IllegalRepoException e) {
|
||||||
|
Logger.debug(e.getMessage());
|
||||||
|
app.getRepoDB().removeRepo(repo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exec(boolean force) {
|
||||||
|
Event.reset(Event.REPO_LOAD_DONE);
|
||||||
|
App.THREAD_POOL.execute(() -> {
|
||||||
|
cached = Collections.synchronizedSet(app.getRepoDB().getRepoIDSet());
|
||||||
|
moduleQueue = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
|
if (loadPages()) {
|
||||||
|
// The leftover cached means they are removed from online repo
|
||||||
|
app.getRepoDB().removeRepo(cached);
|
||||||
|
} else if (force) {
|
||||||
|
fullReload();
|
||||||
|
}
|
||||||
|
Event.trigger(Event.REPO_LOAD_DONE);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exec() {
|
||||||
|
exec(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
118
app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt
Normal file
118
app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
package com.topjohnwu.magisk.ui
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.core.view.GravityCompat
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.topjohnwu.magisk.ClassMap
|
||||||
|
import com.topjohnwu.magisk.Config
|
||||||
|
import com.topjohnwu.magisk.Const.Key.OPEN_SECTION
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.databinding.ActivityMainBinding
|
||||||
|
import com.topjohnwu.magisk.model.navigation.Navigation
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskActivity
|
||||||
|
import com.topjohnwu.magisk.ui.hide.MagiskHideFragment
|
||||||
|
import com.topjohnwu.magisk.ui.home.HomeFragment
|
||||||
|
import com.topjohnwu.magisk.ui.log.LogFragment
|
||||||
|
import com.topjohnwu.magisk.ui.module.ModulesFragment
|
||||||
|
import com.topjohnwu.magisk.ui.module.ReposFragment
|
||||||
|
import com.topjohnwu.magisk.ui.settings.SettingsFragment
|
||||||
|
import com.topjohnwu.magisk.ui.superuser.SuperuserFragment
|
||||||
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
|
import com.topjohnwu.net.Networking
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
|
open class MainActivity : MagiskActivity<MainViewModel, ActivityMainBinding>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.activity_main
|
||||||
|
override val viewModel: MainViewModel by viewModel()
|
||||||
|
override val navHostId: Int = R.id.main_nav_host
|
||||||
|
override val defaultPosition: Int = 0
|
||||||
|
|
||||||
|
override val baseFragments: List<KClass<out Fragment>> = listOf(
|
||||||
|
HomeFragment::class,
|
||||||
|
SuperuserFragment::class,
|
||||||
|
MagiskHideFragment::class,
|
||||||
|
ModulesFragment::class,
|
||||||
|
ReposFragment::class,
|
||||||
|
LogFragment::class,
|
||||||
|
SettingsFragment::class
|
||||||
|
)
|
||||||
|
|
||||||
|
/*override fun getDarkTheme(): Int {
|
||||||
|
return R.style.AppTheme_Dark
|
||||||
|
}*/
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
if (!SplashActivity.DONE) {
|
||||||
|
startActivity(Intent(this, ClassMap.get<Any>(SplashActivity::class.java)))
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
checkHideSection()
|
||||||
|
setSupportActionBar(binding.mainInclude.mainToolbar)
|
||||||
|
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
intent.getStringExtra(OPEN_SECTION)?.let {
|
||||||
|
onEventDispatched(Navigation.fromSection(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTitle(title: CharSequence?) {
|
||||||
|
supportActionBar?.title = title
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTitle(titleId: Int) {
|
||||||
|
supportActionBar?.setTitle(titleId)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTabTransaction(fragment: Fragment?, index: Int) {
|
||||||
|
val fragmentId = when (fragment) {
|
||||||
|
is HomeFragment -> R.id.magiskFragment
|
||||||
|
is SuperuserFragment -> R.id.superuserFragment
|
||||||
|
is MagiskHideFragment -> R.id.magiskHideFragment
|
||||||
|
is ModulesFragment -> R.id.modulesFragment
|
||||||
|
is ReposFragment -> R.id.reposFragment
|
||||||
|
is LogFragment -> R.id.logFragment
|
||||||
|
is SettingsFragment -> R.id.settings
|
||||||
|
else -> return
|
||||||
|
}
|
||||||
|
binding.navView.setCheckedItem(fragmentId)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
if (binding.drawerLayout.isDrawerOpen(binding.navView)) {
|
||||||
|
binding.drawerLayout.closeDrawer(binding.navView)
|
||||||
|
} else {
|
||||||
|
super.onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSimpleEventDispatched(event: Int) {
|
||||||
|
super.onSimpleEventDispatched(event)
|
||||||
|
when (event) {
|
||||||
|
Navigation.Main.OPEN_NAV -> openNav()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun openNav() = binding.drawerLayout.openDrawer(GravityCompat.START)
|
||||||
|
|
||||||
|
private fun checkHideSection() {
|
||||||
|
val menu = binding.navView.menu
|
||||||
|
menu.findItem(R.id.magiskHideFragment).isVisible =
|
||||||
|
Shell.rootAccess() && Config.get<Any>(Config.Key.MAGISKHIDE) as Boolean
|
||||||
|
menu.findItem(R.id.modulesFragment).isVisible =
|
||||||
|
Shell.rootAccess() && Config.magiskVersionCode >= 0
|
||||||
|
menu.findItem(R.id.reposFragment).isVisible =
|
||||||
|
(Networking.checkNetworkStatus(this) && Shell.rootAccess() && Config.magiskVersionCode >= 0)
|
||||||
|
menu.findItem(R.id.logFragment).isVisible =
|
||||||
|
Shell.rootAccess()
|
||||||
|
menu.findItem(R.id.superuserFragment).isVisible =
|
||||||
|
Utils.showSuperUser()
|
||||||
|
}
|
||||||
|
}
|
||||||
27
app/src/main/java/com/topjohnwu/magisk/ui/MainViewModel.kt
Normal file
27
app/src/main/java/com/topjohnwu/magisk/ui/MainViewModel.kt
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package com.topjohnwu.magisk.ui
|
||||||
|
|
||||||
|
import android.view.MenuItem
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.model.navigation.Navigation
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskViewModel
|
||||||
|
|
||||||
|
|
||||||
|
class MainViewModel : MagiskViewModel() {
|
||||||
|
|
||||||
|
fun navPressed() = Navigation.Main.OPEN_NAV.publish()
|
||||||
|
|
||||||
|
fun navigationItemPressed(item: MenuItem): Boolean {
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.magiskFragment -> Navigation.home()
|
||||||
|
R.id.superuserFragment -> Navigation.superuser()
|
||||||
|
R.id.magiskHideFragment -> Navigation.hide()
|
||||||
|
R.id.modulesFragment -> Navigation.modules()
|
||||||
|
R.id.reposFragment -> Navigation.repos()
|
||||||
|
R.id.logFragment -> Navigation.log()
|
||||||
|
R.id.settings -> Navigation.settings()
|
||||||
|
else -> null
|
||||||
|
}?.publish()?.let { return@navigationItemPressed true }
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
87
app/src/main/java/com/topjohnwu/magisk/ui/SplashActivity.kt
Normal file
87
app/src/main/java/com/topjohnwu/magisk/ui/SplashActivity.kt
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
package com.topjohnwu.magisk.ui
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.topjohnwu.magisk.*
|
||||||
|
import com.topjohnwu.magisk.tasks.CheckUpdates
|
||||||
|
import com.topjohnwu.magisk.tasks.UpdateRepos
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager
|
||||||
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
|
import com.topjohnwu.magisk.view.Notifications
|
||||||
|
import com.topjohnwu.magisk.view.Shortcuts
|
||||||
|
import com.topjohnwu.net.Networking
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
|
||||||
|
open class SplashActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
Shell.getShell {
|
||||||
|
if (Config.magiskVersionCode > 0 && Config.magiskVersionCode < Const.MAGISK_VER.MIN_SUPPORT) {
|
||||||
|
AlertDialog.Builder(this)
|
||||||
|
.setTitle(R.string.unsupport_magisk_title)
|
||||||
|
.setMessage(R.string.unsupport_magisk_message)
|
||||||
|
.setNegativeButton(R.string.ok, null)
|
||||||
|
.setOnDismissListener { finish() }
|
||||||
|
.show()
|
||||||
|
} else {
|
||||||
|
initAndStart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initAndStart() {
|
||||||
|
val pkg = Config.get<String>(Config.Key.SU_MANAGER)
|
||||||
|
if (pkg != null && packageName == BuildConfig.APPLICATION_ID) {
|
||||||
|
Config.remove(Config.Key.SU_MANAGER)
|
||||||
|
Shell.su("pm uninstall $pkg").submit()
|
||||||
|
}
|
||||||
|
if (TextUtils.equals(pkg, packageName)) {
|
||||||
|
runCatching {
|
||||||
|
// We are the manager, remove com.topjohnwu.magisk as it could be malware
|
||||||
|
packageManager.getApplicationInfo(BuildConfig.APPLICATION_ID, 0)
|
||||||
|
Shell.su("pm uninstall " + BuildConfig.APPLICATION_ID).submit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dynamic detect all locales
|
||||||
|
LocaleManager.loadAvailableLocales(R.string.app_changelog)
|
||||||
|
|
||||||
|
// Set default configs
|
||||||
|
Config.initialize()
|
||||||
|
|
||||||
|
// Create notification channel on Android O
|
||||||
|
Notifications.setup(this)
|
||||||
|
|
||||||
|
// Schedule periodic update checks
|
||||||
|
Utils.scheduleUpdateCheck()
|
||||||
|
CheckUpdates.check()
|
||||||
|
|
||||||
|
// Setup shortcuts
|
||||||
|
Shortcuts.setup(this)
|
||||||
|
|
||||||
|
// Magisk working as expected
|
||||||
|
if (Shell.rootAccess() && Config.magiskVersionCode > 0) {
|
||||||
|
// Load modules
|
||||||
|
Utils.loadModules(false)
|
||||||
|
// Load repos
|
||||||
|
if (Networking.checkNetworkStatus(this))
|
||||||
|
UpdateRepos().exec()
|
||||||
|
}
|
||||||
|
|
||||||
|
val intent = Intent(this, ClassMap.get<Any>(MainActivity::class.java))
|
||||||
|
intent.putExtra(Const.Key.OPEN_SECTION, getIntent().getStringExtra(Const.Key.OPEN_SECTION))
|
||||||
|
DONE = true
|
||||||
|
startActivity(intent)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
var DONE = false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.base
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
|
||||||
|
interface ActivityResultListener {
|
||||||
|
fun onActivityResult(resultCode: Int, data: Intent?)
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.base;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.App;
|
||||||
|
import com.topjohnwu.magisk.R;
|
||||||
|
import com.topjohnwu.magisk.utils.Event;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
import androidx.preference.PreferenceGroupAdapter;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
public abstract class BasePreferenceFragment extends PreferenceFragmentCompat
|
||||||
|
implements SharedPreferences.OnSharedPreferenceChangeListener, Event.AutoListener {
|
||||||
|
|
||||||
|
public App app = App.self;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View v = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
app.getPrefs().registerOnSharedPreferenceChangeListener(this);
|
||||||
|
Event.register(this);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
app.getPrefs().unregisterOnSharedPreferenceChangeListener(this);
|
||||||
|
Event.unregister(this);
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getListeningEvents() {
|
||||||
|
return new int[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
|
||||||
|
return new PreferenceGroupAdapter(preferenceScreen) {
|
||||||
|
@SuppressLint("RestrictedApi")
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(PreferenceViewHolder holder, int position) {
|
||||||
|
super.onBindViewHolder(holder, position);
|
||||||
|
Preference preference = getItem(position);
|
||||||
|
if (preference instanceof PreferenceCategory)
|
||||||
|
setZeroPaddingToLayoutChildren(holder.itemView);
|
||||||
|
else {
|
||||||
|
View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
|
||||||
|
if (iconFrame != null) {
|
||||||
|
iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setZeroPaddingToLayoutChildren(View view) {
|
||||||
|
if (!(view instanceof ViewGroup))
|
||||||
|
return;
|
||||||
|
ViewGroup viewGroup = (ViewGroup) view;
|
||||||
|
int childCount = viewGroup.getChildCount();
|
||||||
|
for (int i = 0; i < childCount; i++) {
|
||||||
|
setZeroPaddingToLayoutChildren(viewGroup.getChildAt(i));
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||||
|
viewGroup.setPaddingRelative(0, viewGroup.getPaddingTop(), viewGroup.getPaddingEnd(), viewGroup.getPaddingBottom());
|
||||||
|
else
|
||||||
|
viewGroup.setPadding(0, viewGroup.getPaddingTop(), viewGroup.getPaddingRight(), viewGroup.getPaddingBottom());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.base
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
|
||||||
|
interface IBaseLeanback {
|
||||||
|
|
||||||
|
fun runWithExternalRW(callback: Runnable)
|
||||||
|
fun runWithPermissions(vararg permissions: String, callback: Runnable)
|
||||||
|
fun startActivityForResult(intent: Intent, requestCode: Int, listener: ActivityResultListener)
|
||||||
|
|
||||||
|
}
|
||||||
210
app/src/main/java/com/topjohnwu/magisk/ui/base/MagiskActivity.kt
Normal file
210
app/src/main/java/com/topjohnwu/magisk/ui/base/MagiskActivity.kt
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.base
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.res.Configuration
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.annotation.CallSuper
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
import androidx.databinding.ViewDataBinding
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentTransaction
|
||||||
|
import com.karumi.dexter.Dexter
|
||||||
|
import com.karumi.dexter.MultiplePermissionsReport
|
||||||
|
import com.karumi.dexter.PermissionToken
|
||||||
|
import com.karumi.dexter.listener.PermissionRequest
|
||||||
|
import com.karumi.dexter.listener.multi.MultiplePermissionsListener
|
||||||
|
import com.ncapdevi.fragnav.FragNavController
|
||||||
|
import com.ncapdevi.fragnav.FragNavTransactionOptions
|
||||||
|
import com.skoumal.teanity.viewevents.ViewEvent
|
||||||
|
import com.topjohnwu.magisk.Config
|
||||||
|
import com.topjohnwu.magisk.model.events.BackPressEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.PermissionEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.ViewActionEvent
|
||||||
|
import com.topjohnwu.magisk.model.navigation.MagiskAnimBuilder
|
||||||
|
import com.topjohnwu.magisk.model.navigation.MagiskNavigationEvent
|
||||||
|
import com.topjohnwu.magisk.model.navigation.Navigator
|
||||||
|
import com.topjohnwu.magisk.model.permissions.PermissionRequestBuilder
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager
|
||||||
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
|
import timber.log.Timber
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
|
abstract class MagiskActivity<ViewModel : MagiskViewModel, Binding : ViewDataBinding> :
|
||||||
|
MagiskLeanbackActivity<ViewModel, Binding>(), FragNavController.RootFragmentListener,
|
||||||
|
Navigator, FragNavController.TransactionListener {
|
||||||
|
|
||||||
|
override val numberOfRootFragments: Int get() = baseFragments.size
|
||||||
|
override val baseFragments: List<KClass<out Fragment>> = listOf()
|
||||||
|
|
||||||
|
protected open val defaultPosition: Int = 0
|
||||||
|
|
||||||
|
protected val navigationController get() = if (navHostId == 0) null else _navigationController
|
||||||
|
private val _navigationController by lazy {
|
||||||
|
if (navHostId == 0) throw IllegalStateException("Did you forget to override \"navHostId\"?")
|
||||||
|
FragNavController(supportFragmentManager, navHostId)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val isRootFragment
|
||||||
|
get() = navigationController?.let { it.currentStackIndex != defaultPosition } ?: false
|
||||||
|
|
||||||
|
init {
|
||||||
|
val isDarkTheme = Config.get<Boolean>(Config.Key.DARK_THEME)
|
||||||
|
val theme = if (isDarkTheme) {
|
||||||
|
AppCompatDelegate.MODE_NIGHT_YES
|
||||||
|
} else {
|
||||||
|
AppCompatDelegate.MODE_NIGHT_NO
|
||||||
|
}
|
||||||
|
AppCompatDelegate.setDefaultNightMode(theme)
|
||||||
|
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun applyOverrideConfiguration(config: Configuration?) {
|
||||||
|
// Force applying our preferred local
|
||||||
|
config?.setLocale(LocaleManager.locale)
|
||||||
|
super.applyOverrideConfiguration(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
navigationController?.apply {
|
||||||
|
rootFragmentListener = this@MagiskActivity
|
||||||
|
transactionListener = this@MagiskActivity
|
||||||
|
initialize(defaultPosition, savedInstanceState)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
|
super.onSaveInstanceState(outState)
|
||||||
|
navigationController?.onSaveInstanceState(outState)
|
||||||
|
}
|
||||||
|
|
||||||
|
@CallSuper
|
||||||
|
override fun onEventDispatched(event: ViewEvent) {
|
||||||
|
super.onEventDispatched(event)
|
||||||
|
when (event) {
|
||||||
|
is BackPressEvent -> onBackPressed()
|
||||||
|
is MagiskNavigationEvent -> navigateTo(event)
|
||||||
|
is ViewActionEvent -> event.action(this)
|
||||||
|
is PermissionEvent -> withPermissions(*event.permissions.toTypedArray()) {
|
||||||
|
onSuccess { event.callback.onNext(true) }
|
||||||
|
onFailure {
|
||||||
|
event.callback.onNext(false)
|
||||||
|
event.callback.onError(SecurityException("User refused permissions"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getRootFragment(index: Int) = baseFragments[index].java.newInstance()
|
||||||
|
|
||||||
|
override fun navigateTo(event: MagiskNavigationEvent) {
|
||||||
|
val directions = event.navDirections
|
||||||
|
|
||||||
|
navigationController?.defaultTransactionOptions = FragNavTransactionOptions.newBuilder()
|
||||||
|
.customAnimations(event.animOptions)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
navigationController?.currentStack
|
||||||
|
?.indexOfFirst { it.javaClass == event.navOptions.popUpTo }
|
||||||
|
?.let { if (it == -1) null else it } // invalidate if class is not found
|
||||||
|
?.let { if (event.navOptions.inclusive) it + 1 else it }
|
||||||
|
?.let { navigationController?.popFragments(it) }
|
||||||
|
|
||||||
|
when (directions.isActivity) {
|
||||||
|
true -> navigateToActivity(event)
|
||||||
|
else -> navigateToFragment(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun navigateToActivity(event: MagiskNavigationEvent) {
|
||||||
|
val destination = event.navDirections.destination?.java ?: let {
|
||||||
|
Timber.e("Cannot navigate to null destination")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val options = event.navOptions
|
||||||
|
|
||||||
|
Intent(this, destination)
|
||||||
|
.putExtras(event.navDirections.args)
|
||||||
|
.apply {
|
||||||
|
if (options.singleTop) addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||||
|
if (options.clearTask) addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||||
|
}
|
||||||
|
.let { startActivity(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun navigateToFragment(event: MagiskNavigationEvent) {
|
||||||
|
val destination = event.navDirections.destination?.java ?: let {
|
||||||
|
Timber.e("Cannot navigate to null destination")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
when (val index = baseFragments.indexOfFirst { it.java.name == destination.name }) {
|
||||||
|
-1 -> destination.newInstance()
|
||||||
|
.apply { arguments = event.navDirections.args }
|
||||||
|
.let { navigationController?.pushFragment(it) }
|
||||||
|
// When it's desired that fragments of same class are put on top of one another edit this
|
||||||
|
else -> navigationController?.switchTab(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
val fragment = navigationController?.currentFrag as? MagiskFragment<*, *>
|
||||||
|
|
||||||
|
if (fragment?.onBackPressed() == true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
navigationController?.popFragment() ?: throw UnsupportedOperationException()
|
||||||
|
} catch (e: UnsupportedOperationException) {
|
||||||
|
when {
|
||||||
|
isRootFragment -> {
|
||||||
|
val options = FragNavTransactionOptions.newBuilder()
|
||||||
|
.transition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
|
||||||
|
.build()
|
||||||
|
navigationController?.switchTab(defaultPosition, options)
|
||||||
|
}
|
||||||
|
else -> super.onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFragmentTransaction(
|
||||||
|
fragment: Fragment?,
|
||||||
|
transactionType: FragNavController.TransactionType
|
||||||
|
) = Unit
|
||||||
|
|
||||||
|
override fun onTabTransaction(fragment: Fragment?, index: Int) = Unit
|
||||||
|
|
||||||
|
fun openUrl(url: String) = Utils.openLink(this, url.toUri())
|
||||||
|
|
||||||
|
fun withPermissions(vararg permissions: String, builder: PermissionRequestBuilder.() -> Unit) {
|
||||||
|
val request = PermissionRequestBuilder().apply(builder).build()
|
||||||
|
Dexter.withActivity(this)
|
||||||
|
.withPermissions(*permissions)
|
||||||
|
.withListener(object : MultiplePermissionsListener {
|
||||||
|
override fun onPermissionsChecked(report: MultiplePermissionsReport?) =
|
||||||
|
if (report?.areAllPermissionsGranted() == true) {
|
||||||
|
request.onSuccess()
|
||||||
|
} else {
|
||||||
|
request.onFailure()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPermissionRationaleShouldBeShown(
|
||||||
|
permissions: MutableList<PermissionRequest>?,
|
||||||
|
token: PermissionToken?
|
||||||
|
) = request.onShowRationale(permissions.orEmpty().map { it.name })
|
||||||
|
})
|
||||||
|
.check()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun FragNavTransactionOptions.Builder.customAnimations(options: MagiskAnimBuilder) =
|
||||||
|
customAnimations(options.enter, options.exit, options.popEnter, options.popExit).apply {
|
||||||
|
if (!options.anySet) {
|
||||||
|
transition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.base
|
||||||
|
|
||||||
|
import androidx.annotation.CallSuper
|
||||||
|
import androidx.databinding.ViewDataBinding
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.skoumal.teanity.view.TeanityFragment
|
||||||
|
import com.skoumal.teanity.viewevents.ViewEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.BackPressEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.PermissionEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.ViewActionEvent
|
||||||
|
import com.topjohnwu.magisk.model.navigation.MagiskNavigationEvent
|
||||||
|
import com.topjohnwu.magisk.model.navigation.Navigator
|
||||||
|
import com.topjohnwu.magisk.model.permissions.PermissionRequestBuilder
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
|
||||||
|
abstract class MagiskFragment<ViewModel : MagiskViewModel, Binding : ViewDataBinding> :
|
||||||
|
TeanityFragment<ViewModel, Binding>(), Navigator {
|
||||||
|
|
||||||
|
protected val magiskActivity get() = activity as MagiskActivity<*, *>
|
||||||
|
|
||||||
|
// We don't need nested fragments
|
||||||
|
override val baseFragments: List<KClass<Fragment>> = listOf()
|
||||||
|
|
||||||
|
override fun navigateTo(event: MagiskNavigationEvent) = magiskActivity.navigateTo(event)
|
||||||
|
|
||||||
|
@CallSuper
|
||||||
|
override fun onEventDispatched(event: ViewEvent) {
|
||||||
|
super.onEventDispatched(event)
|
||||||
|
when (event) {
|
||||||
|
is BackPressEvent -> magiskActivity.onBackPressed()
|
||||||
|
is MagiskNavigationEvent -> navigateTo(event)
|
||||||
|
is ViewActionEvent -> event.action(requireActivity())
|
||||||
|
is PermissionEvent -> magiskActivity.withPermissions(*event.permissions.toTypedArray()) {
|
||||||
|
onSuccess { event.callback.onNext(true) }
|
||||||
|
onFailure {
|
||||||
|
event.callback.onNext(false)
|
||||||
|
event.callback.onError(SecurityException("User refused permissions"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun withPermissions(vararg permissions: String, builder: PermissionRequestBuilder.() -> Unit) {
|
||||||
|
magiskActivity.withPermissions(*permissions, builder = builder)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openLink(url: String) = magiskActivity.openUrl(url)
|
||||||
|
|
||||||
|
open fun onBackPressed(): Boolean = false
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.base
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import android.content.Intent
|
||||||
|
import androidx.collection.SparseArrayCompat
|
||||||
|
import androidx.databinding.ViewDataBinding
|
||||||
|
import com.karumi.dexter.Dexter
|
||||||
|
import com.karumi.dexter.MultiplePermissionsReport
|
||||||
|
import com.karumi.dexter.PermissionToken
|
||||||
|
import com.karumi.dexter.listener.PermissionRequest
|
||||||
|
import com.karumi.dexter.listener.multi.MultiplePermissionsListener
|
||||||
|
import com.skoumal.teanity.view.TeanityActivity
|
||||||
|
import com.topjohnwu.magisk.Const
|
||||||
|
|
||||||
|
abstract class MagiskLeanbackActivity<ViewModel : MagiskViewModel, Binding : ViewDataBinding> :
|
||||||
|
TeanityActivity<ViewModel, Binding>(), IBaseLeanback {
|
||||||
|
|
||||||
|
private val resultListeners = SparseArrayCompat<ActivityResultListener>()
|
||||||
|
|
||||||
|
@Deprecated("Permissions will be checked in a different streamlined way")
|
||||||
|
fun runWithExternalRW(callback: () -> Unit) = runWithExternalRW(Runnable { callback() })
|
||||||
|
|
||||||
|
@Deprecated("Permissions will be checked in a different streamlined way")
|
||||||
|
override fun runWithExternalRW(callback: Runnable) {
|
||||||
|
runWithPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, callback = callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated("Permissions will be checked in a different streamlined way")
|
||||||
|
override fun runWithPermissions(vararg permissions: String, callback: Runnable) {
|
||||||
|
Dexter.withActivity(this)
|
||||||
|
.withPermissions(*permissions)
|
||||||
|
.withListener(object : MultiplePermissionsListener {
|
||||||
|
override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
|
||||||
|
if (report?.areAllPermissionsGranted() == true) {
|
||||||
|
Const.EXTERNAL_PATH.mkdirs()
|
||||||
|
callback.run()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPermissionRationaleShouldBeShown(
|
||||||
|
permissions: MutableList<PermissionRequest>?,
|
||||||
|
token: PermissionToken?
|
||||||
|
) = Unit
|
||||||
|
})
|
||||||
|
.check()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
resultListeners.get(requestCode)?.apply {
|
||||||
|
resultListeners.remove(requestCode)
|
||||||
|
onActivityResult(resultCode, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun startActivityForResult(
|
||||||
|
intent: Intent,
|
||||||
|
requestCode: Int,
|
||||||
|
listener: ActivityResultListener
|
||||||
|
) {
|
||||||
|
resultListeners.put(requestCode, listener)
|
||||||
|
startActivityForResult(intent, requestCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.base
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import com.skoumal.teanity.extensions.doOnSubscribeUi
|
||||||
|
import com.skoumal.teanity.viewmodel.LoadingViewModel
|
||||||
|
import com.topjohnwu.magisk.model.events.BackPressEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.PermissionEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.ViewActionEvent
|
||||||
|
import com.topjohnwu.magisk.utils.Event
|
||||||
|
import io.reactivex.Observable
|
||||||
|
import io.reactivex.subjects.PublishSubject
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
|
|
||||||
|
abstract class MagiskViewModel : LoadingViewModel(), Event.AutoListener {
|
||||||
|
|
||||||
|
override fun onEvent(event: Int) = Timber.i("Event of $event was not handled")
|
||||||
|
override fun getListeningEvents(): IntArray = intArrayOf()
|
||||||
|
|
||||||
|
fun withView(action: Activity.() -> Unit) {
|
||||||
|
ViewActionEvent(action).publish()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun withPermissions(vararg permissions: String): Observable<Boolean> {
|
||||||
|
val subject = PublishSubject.create<Boolean>()
|
||||||
|
return subject.doOnSubscribeUi { PermissionEvent(permissions.toList(), subject).publish() }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun back() = BackPressEvent().publish()
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.flash
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.Const
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.databinding.ActivityFlashBinding
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskActivity
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
import org.koin.core.parameter.parametersOf
|
||||||
|
|
||||||
|
open class FlashActivity : MagiskActivity<FlashViewModel, ActivityFlashBinding>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.activity_flash
|
||||||
|
override val viewModel: FlashViewModel by viewModel {
|
||||||
|
val uri = intent.data
|
||||||
|
val action = intent.getStringExtra(Const.Key.FLASH_ACTION) ?: let { finish();"" }
|
||||||
|
parametersOf(action, uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
if (viewModel.loading) return
|
||||||
|
super.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.flash
|
||||||
|
|
||||||
|
import android.Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
|
import android.Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
|
import android.content.res.Resources
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Handler
|
||||||
|
import androidx.core.os.postDelayed
|
||||||
|
import androidx.databinding.ObservableArrayList
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.skoumal.teanity.extensions.subscribeK
|
||||||
|
import com.skoumal.teanity.util.DiffObservableList
|
||||||
|
import com.skoumal.teanity.util.KObservableField
|
||||||
|
import com.skoumal.teanity.viewevents.SnackbarEvent
|
||||||
|
import com.topjohnwu.magisk.BR
|
||||||
|
import com.topjohnwu.magisk.Const
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.ConsoleRvItem
|
||||||
|
import com.topjohnwu.magisk.model.flash.FlashResultListener
|
||||||
|
import com.topjohnwu.magisk.model.flash.Flashing
|
||||||
|
import com.topjohnwu.magisk.model.flash.Patching
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskViewModel
|
||||||
|
import com.topjohnwu.magisk.utils.*
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
import me.tatarka.bindingcollectionadapter2.ItemBinding
|
||||||
|
import java.io.File
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class FlashViewModel(
|
||||||
|
action: String,
|
||||||
|
uri: Uri?,
|
||||||
|
private val resources: Resources
|
||||||
|
) : MagiskViewModel(), FlashResultListener {
|
||||||
|
|
||||||
|
val canShowReboot = Shell.rootAccess()
|
||||||
|
val showRestartTitle = KObservableField(false)
|
||||||
|
|
||||||
|
val behaviorText = KObservableField(resources.getString(R.string.flashing))
|
||||||
|
|
||||||
|
val items = DiffObservableList(ComparableRvItem.callback)
|
||||||
|
val itemBinding = ItemBinding.of<ComparableRvItem<*>> { itemBinding, _, item ->
|
||||||
|
item.bind(itemBinding)
|
||||||
|
itemBinding.bindExtra(BR.viewModel, this@FlashViewModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val outItems = ObservableArrayList<String>()
|
||||||
|
private val logItems = Collections.synchronizedList(mutableListOf<String>())
|
||||||
|
|
||||||
|
init {
|
||||||
|
outItems.sendUpdatesTo(items) { it.map { ConsoleRvItem(it) } }
|
||||||
|
outItems.copyNewInputInto(logItems)
|
||||||
|
|
||||||
|
state = State.LOADING
|
||||||
|
|
||||||
|
val uri = uri ?: Uri.EMPTY
|
||||||
|
when (action) {
|
||||||
|
Const.Value.FLASH_ZIP -> Flashing
|
||||||
|
.Install(uri, outItems, logItems, this)
|
||||||
|
.exec()
|
||||||
|
Const.Value.UNINSTALL -> Flashing
|
||||||
|
.Uninstall(uri, outItems, logItems, this)
|
||||||
|
.exec()
|
||||||
|
Const.Value.FLASH_MAGISK -> Patching
|
||||||
|
.Direct(outItems, logItems, this)
|
||||||
|
.exec()
|
||||||
|
Const.Value.FLASH_INACTIVE_SLOT -> Patching
|
||||||
|
.SecondSlot(outItems, logItems, this)
|
||||||
|
.exec()
|
||||||
|
Const.Value.PATCH_FILE -> Patching
|
||||||
|
.File(uri, outItems, logItems, this)
|
||||||
|
.exec()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResult(isSuccess: Boolean) {
|
||||||
|
state = if (isSuccess) State.LOADED else State.LOADING_FAILED
|
||||||
|
behaviorText.value = when {
|
||||||
|
isSuccess -> resources.getString(R.string.done)
|
||||||
|
else -> resources.getString(R.string.failure)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSuccess) {
|
||||||
|
Handler().postDelayed(500) {
|
||||||
|
showRestartTitle.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun savePressed() = withPermissions(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)
|
||||||
|
.map { now }
|
||||||
|
.map { it.toTime(timeFormatStandard) }
|
||||||
|
.map { Const.MAGISK_INSTALL_LOG_FILENAME.format(it) }
|
||||||
|
.map { File(Const.EXTERNAL_PATH, it) }
|
||||||
|
.map { file ->
|
||||||
|
file.bufferedWriter().use { writer ->
|
||||||
|
logItems.forEach {
|
||||||
|
writer.write(it)
|
||||||
|
writer.newLine()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file.path
|
||||||
|
}
|
||||||
|
.subscribeK { SnackbarEvent(it).publish() }
|
||||||
|
.add()
|
||||||
|
|
||||||
|
fun restartPressed() = RootUtils.reboot()
|
||||||
|
|
||||||
|
fun backPressed() = back()
|
||||||
|
|
||||||
|
}
|
||||||
128
app/src/main/java/com/topjohnwu/magisk/ui/hide/HideViewModel.kt
Normal file
128
app/src/main/java/com/topjohnwu/magisk/ui/hide/HideViewModel.kt
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.hide
|
||||||
|
|
||||||
|
import android.content.pm.ApplicationInfo
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.skoumal.teanity.extensions.addOnPropertyChangedCallback
|
||||||
|
import com.skoumal.teanity.extensions.subscribeK
|
||||||
|
import com.skoumal.teanity.rxbus.RxBus
|
||||||
|
import com.skoumal.teanity.util.DiffObservableList
|
||||||
|
import com.skoumal.teanity.util.KObservableField
|
||||||
|
import com.topjohnwu.magisk.App
|
||||||
|
import com.topjohnwu.magisk.BR
|
||||||
|
import com.topjohnwu.magisk.model.entity.HideAppInfo
|
||||||
|
import com.topjohnwu.magisk.model.entity.HideTarget
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.HideProcessRvItem
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.HideRvItem
|
||||||
|
import com.topjohnwu.magisk.model.entity.state.IndeterminateState
|
||||||
|
import com.topjohnwu.magisk.model.events.HideProcessEvent
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskViewModel
|
||||||
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
|
import com.topjohnwu.magisk.utils.toSingle
|
||||||
|
import com.topjohnwu.magisk.utils.update
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
import io.reactivex.Single
|
||||||
|
import me.tatarka.bindingcollectionadapter2.OnItemBind
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
|
class HideViewModel(
|
||||||
|
private val packageManager: PackageManager,
|
||||||
|
rxBus: RxBus
|
||||||
|
) : MagiskViewModel() {
|
||||||
|
|
||||||
|
val query = KObservableField("")
|
||||||
|
val isShowSystem = KObservableField(false)
|
||||||
|
|
||||||
|
private val allItems = mutableListOf<ComparableRvItem<*>>()
|
||||||
|
val items = DiffObservableList(ComparableRvItem.callback)
|
||||||
|
val itemBinding = OnItemBind<ComparableRvItem<*>> { itemBinding, _, item ->
|
||||||
|
item.bind(itemBinding)
|
||||||
|
itemBinding.bindExtra(BR.viewModel, this@HideViewModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
rxBus.register<HideProcessEvent>()
|
||||||
|
.subscribeK { toggleItem(it.item) }
|
||||||
|
.add()
|
||||||
|
|
||||||
|
isShowSystem.addOnPropertyChangedCallback { query() }
|
||||||
|
query.addOnPropertyChangedCallback { query() }
|
||||||
|
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun refresh() {
|
||||||
|
// fetching this for every item is nonsensical, so we add .cache() so the response is all
|
||||||
|
// the same for every single mapped item, it only actually executes the whole thing the
|
||||||
|
// first time around.
|
||||||
|
val hideTargets = Shell.su("magiskhide --ls").toSingle()
|
||||||
|
.map { it.exec().out }
|
||||||
|
.flattenAsFlowable { it }
|
||||||
|
.map { HideTarget(it) }
|
||||||
|
.toList()
|
||||||
|
.cache()
|
||||||
|
|
||||||
|
Single.fromCallable { packageManager.getInstalledApplications(0) }
|
||||||
|
.flattenAsFlowable { it }
|
||||||
|
.filter { it.enabled && !blacklist.contains(it.packageName) }
|
||||||
|
.map {
|
||||||
|
val label = Utils.getAppLabel(it, packageManager)
|
||||||
|
val icon = it.loadIcon(packageManager)
|
||||||
|
HideAppInfo(it, label, icon)
|
||||||
|
}
|
||||||
|
.filter { it.processes.isNotEmpty() }
|
||||||
|
.map { HideRvItem(it, hideTargets.blockingGet()) }
|
||||||
|
.toList()
|
||||||
|
.map { it.sortWith(compareBy(
|
||||||
|
{it.isHiddenState.value}, {it.item.name}, {it.packageName})); it }
|
||||||
|
.doOnSuccess { allItems.update(it) }
|
||||||
|
.flatMap { queryRaw() }
|
||||||
|
.applyViewModel(this)
|
||||||
|
.subscribeK(onError = Timber::e) { items.update(it.first, it.second) }
|
||||||
|
.add()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun query() = queryRaw()
|
||||||
|
.subscribeK { items.update(it.first, it.second) }
|
||||||
|
.add()
|
||||||
|
|
||||||
|
private fun queryRaw(
|
||||||
|
showSystem: Boolean = isShowSystem.value,
|
||||||
|
query: String = this.query.value
|
||||||
|
) = allItems.toSingle()
|
||||||
|
.map { it.filterIsInstance<HideRvItem>() }
|
||||||
|
.flattenAsFlowable { it }
|
||||||
|
.filter {
|
||||||
|
it.item.name.contains(query, ignoreCase = true) ||
|
||||||
|
it.item.processes.any { it.contains(query, ignoreCase = true) }
|
||||||
|
}
|
||||||
|
.filter {
|
||||||
|
showSystem || (it.isHiddenState.value != IndeterminateState.UNCHECKED) ||
|
||||||
|
(it.item.info.flags and ApplicationInfo.FLAG_SYSTEM == 0)
|
||||||
|
}
|
||||||
|
.toList()
|
||||||
|
.map { it to items.calculateDiff(it) }
|
||||||
|
|
||||||
|
private fun toggleItem(item: HideProcessRvItem) {
|
||||||
|
val state = if (item.isHidden.value) "add" else "rm"
|
||||||
|
"magiskhide --%s %s %s".format(state, item.packageName, item.process)
|
||||||
|
.let { Shell.su(it) }
|
||||||
|
.toSingle()
|
||||||
|
.map { it.submit() }
|
||||||
|
.subscribeK()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val blacklist = listOf(
|
||||||
|
App.self.packageName,
|
||||||
|
"android",
|
||||||
|
"com.android.chrome",
|
||||||
|
"com.chrome.beta",
|
||||||
|
"com.chrome.dev",
|
||||||
|
"com.chrome.canary",
|
||||||
|
"com.android.webview",
|
||||||
|
"com.google.android.webview"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.hide
|
||||||
|
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.widget.SearchView
|
||||||
|
import com.topjohnwu.magisk.Config
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.databinding.FragmentMagiskHideBinding
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskFragment
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
|
||||||
|
class MagiskHideFragment : MagiskFragment<HideViewModel, FragmentMagiskHideBinding>(),
|
||||||
|
SearchView.OnQueryTextListener {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.fragment_magisk_hide
|
||||||
|
override val viewModel: HideViewModel by viewModel()
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
requireActivity().setTitle(R.string.magiskhide)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
|
inflater.inflate(R.menu.menu_magiskhide, menu)
|
||||||
|
menu.apply {
|
||||||
|
(findItem(R.id.app_search).actionView as? SearchView)
|
||||||
|
?.setOnQueryTextListener(this@MagiskHideFragment)
|
||||||
|
|
||||||
|
val showSystem = Config.get<Boolean>(Config.Key.SHOW_SYSTEM_APP)
|
||||||
|
|
||||||
|
findItem(R.id.show_system).isChecked = showSystem
|
||||||
|
viewModel.isShowSystem.value = showSystem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
if (item.itemId == R.id.show_system) {
|
||||||
|
val showSystem = !item.isChecked
|
||||||
|
item.isChecked = showSystem
|
||||||
|
Config.set(Config.Key.SHOW_SYSTEM_APP, showSystem)
|
||||||
|
viewModel.isShowSystem.value = showSystem
|
||||||
|
//adapter!!.setShowSystem(showSystem)
|
||||||
|
//adapter!!.filter(search!!.query.toString())
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||||
|
viewModel.query.value = query.orEmpty()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onQueryTextChange(query: String?): Boolean {
|
||||||
|
viewModel.query.value = query.orEmpty()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/*override fun onEvent(event: Int) {
|
||||||
|
//mSwipeRefreshLayout!!.isRefreshing = false
|
||||||
|
adapter!!.filter(search!!.query.toString())
|
||||||
|
}*/
|
||||||
|
}
|
||||||
109
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt
Normal file
109
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeFragment.kt
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.home
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import com.skoumal.teanity.viewevents.ViewEvent
|
||||||
|
import com.topjohnwu.magisk.*
|
||||||
|
import com.topjohnwu.magisk.databinding.FragmentMagiskBinding
|
||||||
|
import com.topjohnwu.magisk.model.events.*
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskActivity
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskFragment
|
||||||
|
import com.topjohnwu.magisk.utils.ISafetyNetHelper
|
||||||
|
import com.topjohnwu.magisk.view.MarkDownWindow
|
||||||
|
import com.topjohnwu.magisk.view.dialogs.*
|
||||||
|
import com.topjohnwu.net.Networking
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
import dalvik.system.DexClassLoader
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class HomeFragment : MagiskFragment<HomeViewModel, FragmentMagiskBinding>(),
|
||||||
|
ISafetyNetHelper.Callback {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.fragment_magisk
|
||||||
|
override val viewModel: HomeViewModel by viewModel()
|
||||||
|
|
||||||
|
override fun onResponse(responseCode: Int) = viewModel.finishSafetyNetCheck(responseCode)
|
||||||
|
|
||||||
|
override fun onEventDispatched(event: ViewEvent) {
|
||||||
|
super.onEventDispatched(event)
|
||||||
|
when (event) {
|
||||||
|
is OpenLinkEvent -> openLink(event.url)
|
||||||
|
is ManagerInstallEvent -> installManager()
|
||||||
|
is MagiskInstallEvent -> installMagisk()
|
||||||
|
is UninstallEvent -> uninstall()
|
||||||
|
is ManagerChangelogEvent -> changelogManager()
|
||||||
|
is EnvFixEvent -> fixEnv()
|
||||||
|
is UpdateSafetyNetEvent -> updateSafetyNet(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
requireActivity().setTitle(R.string.magisk)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun installMagisk() {
|
||||||
|
// Show Manager update first
|
||||||
|
if (Config.remoteManagerVersionCode > BuildConfig.VERSION_CODE) {
|
||||||
|
installManager()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
MagiskInstallDialog(requireActivity() as MagiskActivity<*, *>).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun installManager() = ManagerInstallDialog(requireActivity()).show()
|
||||||
|
private fun uninstall() = UninstallDialog(requireActivity()).show()
|
||||||
|
private fun fixEnv() = EnvFixDialog(requireActivity()).show()
|
||||||
|
|
||||||
|
private fun changelogManager() = MarkDownWindow
|
||||||
|
.show(requireActivity(), null, resources.openRawResource(R.raw.changelog))
|
||||||
|
|
||||||
|
private fun downloadSafetyNet(requiresUserInput: Boolean = true) {
|
||||||
|
fun download() = Networking
|
||||||
|
.get(Const.Url.SNET_URL)
|
||||||
|
.getAsFile(EXT_APK) { updateSafetyNet(true) }
|
||||||
|
|
||||||
|
if (!requiresUserInput) {
|
||||||
|
download()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomAlertDialog(requireActivity())
|
||||||
|
.setTitle(R.string.proprietary_title)
|
||||||
|
.setMessage(R.string.proprietary_notice)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(R.string.yes) { _, _ -> download() }
|
||||||
|
.setNegativeButton(R.string.no_thanks) { _, _ -> viewModel.finishSafetyNetCheck(-2) }
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateSafetyNet(dieOnError: Boolean) {
|
||||||
|
try {
|
||||||
|
val loader = DexClassLoader(EXT_APK.path, EXT_APK.parent, null,
|
||||||
|
ISafetyNetHelper::class.java.classLoader)
|
||||||
|
val clazz = loader.loadClass("com.topjohnwu.snet.Snet")
|
||||||
|
val helper = clazz.getMethod("newHelper",
|
||||||
|
Class::class.java, String::class.java, Activity::class.java, Any::class.java)
|
||||||
|
.invoke(null, ISafetyNetHelper::class.java, EXT_APK.path,
|
||||||
|
requireActivity(), this) as ISafetyNetHelper
|
||||||
|
if (helper.version < Const.SNET_EXT_VER)
|
||||||
|
throw Exception()
|
||||||
|
helper.attest()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
if (dieOnError) {
|
||||||
|
viewModel.finishSafetyNetCheck(-1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Shell.sh("rm -rf " + EXT_APK.parent).exec()
|
||||||
|
EXT_APK.parentFile?.mkdir()
|
||||||
|
downloadSafetyNet(!dieOnError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val EXT_APK = File("${App.self.filesDir.parent}/snet", "snet.apk")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
229
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
Normal file
229
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.home
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.skoumal.teanity.extensions.addOnPropertyChangedCallback
|
||||||
|
import com.skoumal.teanity.util.KObservableField
|
||||||
|
import com.topjohnwu.magisk.BuildConfig
|
||||||
|
import com.topjohnwu.magisk.Config
|
||||||
|
import com.topjohnwu.magisk.Const
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.model.events.*
|
||||||
|
import com.topjohnwu.magisk.model.observer.Observer
|
||||||
|
import com.topjohnwu.magisk.tasks.CheckUpdates
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskViewModel
|
||||||
|
import com.topjohnwu.magisk.utils.*
|
||||||
|
import com.topjohnwu.net.Networking
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
|
||||||
|
|
||||||
|
class HomeViewModel(
|
||||||
|
private val context: Context
|
||||||
|
) : MagiskViewModel() {
|
||||||
|
|
||||||
|
val isAdvancedExpanded = KObservableField(false)
|
||||||
|
|
||||||
|
val isForceEncryption = KObservableField(Config.keepEnc)
|
||||||
|
val isKeepVerity = KObservableField(Config.keepVerity)
|
||||||
|
|
||||||
|
val magiskState = KObservableField(MagiskState.LOADING)
|
||||||
|
val magiskStateText = Observer(magiskState) {
|
||||||
|
when (magiskState.value) {
|
||||||
|
MagiskState.NO_ROOT -> TODO()
|
||||||
|
MagiskState.NOT_INSTALLED -> R.string.magisk_version_error.res()
|
||||||
|
MagiskState.UP_TO_DATE -> R.string.magisk_up_to_date.res()
|
||||||
|
MagiskState.LOADING -> R.string.checking_for_updates.res()
|
||||||
|
MagiskState.OBSOLETE -> R.string.magisk_update_title.res()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val magiskCurrentVersion = KObservableField("")
|
||||||
|
val magiskLatestVersion = KObservableField("")
|
||||||
|
val magiskAdditionalInfo = Observer(magiskState) {
|
||||||
|
if (Config.get<Boolean>(Config.Key.COREONLY))
|
||||||
|
R.string.core_only_enabled.res()
|
||||||
|
else
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
val managerState = KObservableField(MagiskState.LOADING)
|
||||||
|
val managerStateText = Observer(managerState) {
|
||||||
|
when (managerState.value) {
|
||||||
|
MagiskState.NO_ROOT -> "wtf"
|
||||||
|
MagiskState.NOT_INSTALLED -> R.string.invalid_update_channel.res()
|
||||||
|
MagiskState.UP_TO_DATE -> R.string.manager_up_to_date.res()
|
||||||
|
MagiskState.LOADING -> R.string.checking_for_updates.res()
|
||||||
|
MagiskState.OBSOLETE -> R.string.manager_update_title.res()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val managerCurrentVersion = KObservableField("")
|
||||||
|
val managerLatestVersion = KObservableField("")
|
||||||
|
val managerAdditionalInfo = Observer(managerState) {
|
||||||
|
if (packageName != BuildConfig.APPLICATION_ID)
|
||||||
|
"($packageName)"
|
||||||
|
else
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
val safetyNetTitle = KObservableField(R.string.safetyNet_check_text)
|
||||||
|
val ctsState = KObservableField(SafetyNetState.IDLE)
|
||||||
|
val basicIntegrityState = KObservableField(SafetyNetState.IDLE)
|
||||||
|
val safetyNetState = Observer(ctsState, basicIntegrityState) {
|
||||||
|
val cts = ctsState.value
|
||||||
|
val basic = basicIntegrityState.value
|
||||||
|
val states = listOf(cts, basic)
|
||||||
|
|
||||||
|
when {
|
||||||
|
states.any { it == SafetyNetState.LOADING } -> State.LOADING
|
||||||
|
states.any { it == SafetyNetState.IDLE } -> State.LOADING
|
||||||
|
else -> State.LOADED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val hasRoot = KObservableField(false)
|
||||||
|
|
||||||
|
private var shownDialog = false
|
||||||
|
|
||||||
|
init {
|
||||||
|
Event.register(this)
|
||||||
|
|
||||||
|
isForceEncryption.addOnPropertyChangedCallback {
|
||||||
|
Config.keepEnc = it ?: return@addOnPropertyChangedCallback
|
||||||
|
}
|
||||||
|
isKeepVerity.addOnPropertyChangedCallback {
|
||||||
|
Config.keepVerity = it ?: return@addOnPropertyChangedCallback
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEvent(event: Int) {
|
||||||
|
updateSelf()
|
||||||
|
ensureEnv()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getListeningEvents(): IntArray = intArrayOf(Event.UPDATE_CHECK_DONE)
|
||||||
|
|
||||||
|
fun paypalPressed() = OpenLinkEvent(Const.Url.PAYPAL_URL).publish()
|
||||||
|
fun patreonPressed() = OpenLinkEvent(Const.Url.PATREON_URL).publish()
|
||||||
|
fun twitterPressed() = OpenLinkEvent(Const.Url.TWITTER_URL).publish()
|
||||||
|
fun githubPressed() = OpenLinkEvent(Const.Url.SOURCE_CODE_URL).publish()
|
||||||
|
fun xdaPressed() = OpenLinkEvent(Const.Url.XDA_THREAD).publish()
|
||||||
|
fun uninstallPressed() = UninstallEvent().publish()
|
||||||
|
|
||||||
|
fun advancedPressed() = isAdvancedExpanded.toggle()
|
||||||
|
|
||||||
|
fun installPressed(item: MagiskItem) = when (item) {
|
||||||
|
MagiskItem.MANAGER -> ManagerInstallEvent().publish()
|
||||||
|
MagiskItem.MAGISK -> MagiskInstallEvent().publish()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun cardPressed(item: MagiskItem) = when (item) {
|
||||||
|
MagiskItem.MANAGER -> ManagerChangelogEvent().publish()
|
||||||
|
MagiskItem.MAGISK -> MagiskChangelogEvent().publish()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun safetyNetPressed() {
|
||||||
|
ctsState.value = SafetyNetState.LOADING
|
||||||
|
basicIntegrityState.value = SafetyNetState.LOADING
|
||||||
|
safetyNetTitle.value = R.string.checking_safetyNet_status
|
||||||
|
|
||||||
|
UpdateSafetyNetEvent().publish()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun finishSafetyNetCheck(response: Int) = when {
|
||||||
|
response and 0x0F == 0 -> {
|
||||||
|
val hasCtsPassed = response and ISafetyNetHelper.CTS_PASS != 0
|
||||||
|
val hasBasicIntegrityPassed = response and ISafetyNetHelper.BASIC_PASS != 0
|
||||||
|
safetyNetTitle.value = R.string.safetyNet_check_success
|
||||||
|
ctsState.value = if (hasCtsPassed) {
|
||||||
|
SafetyNetState.PASS
|
||||||
|
} else {
|
||||||
|
SafetyNetState.FAILED
|
||||||
|
}
|
||||||
|
basicIntegrityState.value = if (hasBasicIntegrityPassed) {
|
||||||
|
SafetyNetState.PASS
|
||||||
|
} else {
|
||||||
|
SafetyNetState.FAILED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response == -2 -> {
|
||||||
|
ctsState.value = SafetyNetState.IDLE
|
||||||
|
basicIntegrityState.value = SafetyNetState.IDLE
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
ctsState.value = SafetyNetState.IDLE
|
||||||
|
basicIntegrityState.value = SafetyNetState.IDLE
|
||||||
|
safetyNetTitle.value = when (response) {
|
||||||
|
ISafetyNetHelper.RESPONSE_ERR -> R.string.safetyNet_res_invalid
|
||||||
|
else -> R.string.safetyNet_api_error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun refresh() {
|
||||||
|
state = State.LOADING
|
||||||
|
magiskState.value = MagiskState.LOADING
|
||||||
|
managerState.value = MagiskState.LOADING
|
||||||
|
ctsState.value = SafetyNetState.IDLE
|
||||||
|
basicIntegrityState.value = SafetyNetState.IDLE
|
||||||
|
safetyNetTitle.value = R.string.safetyNet_check_text
|
||||||
|
Event.reset(this)
|
||||||
|
Config.remoteMagiskVersionString = null
|
||||||
|
Config.remoteMagiskVersionCode = -1
|
||||||
|
|
||||||
|
hasRoot.value = Shell.rootAccess()
|
||||||
|
|
||||||
|
if (Networking.checkNetworkStatus(context)) {
|
||||||
|
CheckUpdates.check()
|
||||||
|
} else {
|
||||||
|
state = State.LOADING_FAILED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateSelf() {
|
||||||
|
state = State.LOADED
|
||||||
|
magiskState.value = when (Config.magiskVersionCode) {
|
||||||
|
in Int.MIN_VALUE until 0 -> MagiskState.NOT_INSTALLED
|
||||||
|
!in Config.remoteMagiskVersionCode..Int.MAX_VALUE -> MagiskState.OBSOLETE
|
||||||
|
else -> MagiskState.UP_TO_DATE
|
||||||
|
}
|
||||||
|
|
||||||
|
magiskCurrentVersion.value = if (magiskState.value != MagiskState.NOT_INSTALLED) {
|
||||||
|
version.format(Config.magiskVersionString, Config.magiskVersionCode)
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
magiskLatestVersion.value = version
|
||||||
|
.format(Config.remoteMagiskVersionString, Config.remoteMagiskVersionCode)
|
||||||
|
|
||||||
|
managerState.value = when (Config.remoteManagerVersionCode) {
|
||||||
|
in Int.MIN_VALUE until 0 -> MagiskState.NOT_INSTALLED //wrong update channel
|
||||||
|
in (BuildConfig.VERSION_CODE + 1)..Int.MAX_VALUE -> MagiskState.OBSOLETE
|
||||||
|
else -> MagiskState.UP_TO_DATE
|
||||||
|
}
|
||||||
|
|
||||||
|
managerCurrentVersion.value = version
|
||||||
|
.format(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)
|
||||||
|
|
||||||
|
managerLatestVersion.value = version
|
||||||
|
.format(Config.remoteManagerVersionString, Config.remoteManagerVersionCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ensureEnv() {
|
||||||
|
val invalidStates =
|
||||||
|
listOf(MagiskState.NOT_INSTALLED, MagiskState.NO_ROOT, MagiskState.LOADING)
|
||||||
|
|
||||||
|
// Don't bother checking env when magisk is not installed, loading or already has been shown
|
||||||
|
if (invalidStates.any { it == magiskState.value } || shownDialog) return
|
||||||
|
|
||||||
|
if (!Shell.su("env_check").exec().isSuccess) {
|
||||||
|
shownDialog = true
|
||||||
|
EnvFixEvent().publish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val version = "%s (%d)"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.home
|
||||||
|
|
||||||
|
|
||||||
|
enum class MagiskItem {
|
||||||
|
MANAGER, MAGISK
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.home
|
||||||
|
|
||||||
|
|
||||||
|
enum class MagiskState {
|
||||||
|
NO_ROOT, NOT_INSTALLED, UP_TO_DATE, OBSOLETE, LOADING
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.home
|
||||||
|
|
||||||
|
enum class SafetyNetState {
|
||||||
|
LOADING, PASS, FAILED, IDLE
|
||||||
|
}
|
||||||
53
app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt
Normal file
53
app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.kt
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.log
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
|
import com.skoumal.teanity.viewevents.ViewEvent
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.databinding.FragmentLogBinding
|
||||||
|
import com.topjohnwu.magisk.model.events.PageChangedEvent
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskFragment
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
|
||||||
|
class LogFragment : MagiskFragment<LogViewModel, FragmentLogBinding>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.fragment_log
|
||||||
|
override val viewModel: LogViewModel by viewModel()
|
||||||
|
|
||||||
|
override fun onEventDispatched(event: ViewEvent) {
|
||||||
|
super.onEventDispatched(event)
|
||||||
|
when (event) {
|
||||||
|
is PageChangedEvent -> magiskActivity.invalidateOptionsMenu()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
binding.logTabs.setupWithViewPager(binding.logContainer, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
magiskActivity.setTitle(R.string.log)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
|
inflater.inflate(R.menu.menu_log, menu)
|
||||||
|
menu.findItem(R.id.menu_save).isVisible = viewModel.currentPage.value == 1
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.menu_save -> viewModel.saveLog()
|
||||||
|
R.id.menu_clear -> viewModel.clearLog()
|
||||||
|
R.id.menu_refresh -> viewModel.refresh()
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
122
app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt
Normal file
122
app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.log
|
||||||
|
|
||||||
|
import android.content.res.Resources
|
||||||
|
import androidx.databinding.ObservableArrayList
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.skoumal.teanity.extensions.addOnPropertyChangedCallback
|
||||||
|
import com.skoumal.teanity.extensions.doOnSuccessUi
|
||||||
|
import com.skoumal.teanity.extensions.subscribeK
|
||||||
|
import com.skoumal.teanity.util.DiffObservableList
|
||||||
|
import com.skoumal.teanity.util.KObservableField
|
||||||
|
import com.skoumal.teanity.viewevents.SnackbarEvent
|
||||||
|
import com.topjohnwu.magisk.BR
|
||||||
|
import com.topjohnwu.magisk.Const
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.data.database.MagiskDB
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.*
|
||||||
|
import com.topjohnwu.magisk.model.events.PageChangedEvent
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskViewModel
|
||||||
|
import com.topjohnwu.magisk.utils.toSingle
|
||||||
|
import com.topjohnwu.magisk.utils.zip
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
import io.reactivex.Single
|
||||||
|
import me.tatarka.bindingcollectionadapter2.BindingViewPagerAdapter
|
||||||
|
import me.tatarka.bindingcollectionadapter2.OnItemBind
|
||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class LogViewModel(
|
||||||
|
private val resources: Resources,
|
||||||
|
private val database: MagiskDB
|
||||||
|
) : MagiskViewModel(), BindingViewPagerAdapter.PageTitles<ComparableRvItem<*>> {
|
||||||
|
|
||||||
|
val items = DiffObservableList(ComparableRvItem.callback)
|
||||||
|
val itemBinding = OnItemBind<ComparableRvItem<*>> { itemBinding, _, item ->
|
||||||
|
item.bind(itemBinding)
|
||||||
|
itemBinding.bindExtra(BR.viewModel, this@LogViewModel)
|
||||||
|
}
|
||||||
|
val currentPage = KObservableField(0)
|
||||||
|
private val currentItem get() = items[currentPage.value]
|
||||||
|
|
||||||
|
private val logItem get() = items[0] as LogRvItem
|
||||||
|
private val magiskLogItem get() = items[1] as MagiskLogRvItem
|
||||||
|
|
||||||
|
init {
|
||||||
|
currentPage.addOnPropertyChangedCallback {
|
||||||
|
it ?: return@addOnPropertyChangedCallback
|
||||||
|
PageChangedEvent().publish()
|
||||||
|
}
|
||||||
|
|
||||||
|
items.addAll(listOf(LogRvItem(), MagiskLogRvItem()))
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getPageTitle(position: Int, item: ComparableRvItem<*>?) = when (item) {
|
||||||
|
is LogRvItem -> resources.getString(R.string.superuser)
|
||||||
|
is MagiskLogRvItem -> resources.getString(R.string.magisk)
|
||||||
|
else -> ""
|
||||||
|
}
|
||||||
|
|
||||||
|
fun refresh() = zip(updateLogs(), updateMagiskLog()) { _, _ -> true }
|
||||||
|
.subscribeK()
|
||||||
|
.add()
|
||||||
|
|
||||||
|
fun saveLog() {
|
||||||
|
val now = Calendar.getInstance()
|
||||||
|
val filename = "magisk_log_%04d%02d%02d_%02d%02d%02d.log".format(
|
||||||
|
now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,
|
||||||
|
now.get(Calendar.DAY_OF_MONTH), now.get(Calendar.HOUR_OF_DAY),
|
||||||
|
now.get(Calendar.MINUTE), now.get(Calendar.SECOND)
|
||||||
|
)
|
||||||
|
|
||||||
|
val logFile = File(Const.EXTERNAL_PATH, filename)
|
||||||
|
try {
|
||||||
|
logFile.createNewFile()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Shell.su("cat ${Const.MAGISK_LOG} > $logFile").submit {
|
||||||
|
SnackbarEvent(logFile.path).publish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearLog() = when (currentItem) {
|
||||||
|
is LogRvItem -> clearLogs { refresh() }
|
||||||
|
is MagiskLogRvItem -> clearMagiskLogs { refresh() }
|
||||||
|
else -> Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clearLogs(callback: () -> Unit) {
|
||||||
|
Single.fromCallable { database.clearLogs() }
|
||||||
|
.subscribeK {
|
||||||
|
SnackbarEvent(R.string.logs_cleared).publish()
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
.add()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clearMagiskLogs(callback: () -> Unit) {
|
||||||
|
Shell.su("echo -n > " + Const.MAGISK_LOG).submit {
|
||||||
|
SnackbarEvent(R.string.logs_cleared).publish()
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateLogs() = Single.fromCallable { database.logs }
|
||||||
|
.flattenAsFlowable { it }
|
||||||
|
.map { it.map { LogItemEntryRvItem(it) } }
|
||||||
|
.map { LogItemRvItem(ObservableArrayList<ComparableRvItem<*>>().apply { addAll(it) }) }
|
||||||
|
.toList()
|
||||||
|
.doOnSuccessUi { logItem.update(it) }
|
||||||
|
|
||||||
|
private fun updateMagiskLog() = Shell.su("tail -n 5000 ${Const.MAGISK_LOG}").toSingle()
|
||||||
|
.map { it.exec() }
|
||||||
|
.map { it.out }
|
||||||
|
.flattenAsFlowable { it }
|
||||||
|
.map { ConsoleRvItem(it) }
|
||||||
|
.toList()
|
||||||
|
.doOnSuccessUi { magiskLogItem.update(it) }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.module
|
||||||
|
|
||||||
|
import android.content.res.Resources
|
||||||
|
import android.database.Cursor
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.skoumal.teanity.extensions.addOnPropertyChangedCallback
|
||||||
|
import com.skoumal.teanity.extensions.subscribeK
|
||||||
|
import com.skoumal.teanity.util.DiffObservableList
|
||||||
|
import com.skoumal.teanity.util.KObservableField
|
||||||
|
import com.topjohnwu.magisk.BR
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.data.database.RepoDatabaseHelper
|
||||||
|
import com.topjohnwu.magisk.model.entity.Module
|
||||||
|
import com.topjohnwu.magisk.model.entity.Repo
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.ModuleRvItem
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.RepoRvItem
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.SectionRvItem
|
||||||
|
import com.topjohnwu.magisk.model.events.InstallModuleEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.OpenChangelogEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.OpenFilePickerEvent
|
||||||
|
import com.topjohnwu.magisk.tasks.UpdateRepos
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskViewModel
|
||||||
|
import com.topjohnwu.magisk.utils.Event
|
||||||
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
|
import com.topjohnwu.magisk.utils.toSingle
|
||||||
|
import com.topjohnwu.magisk.utils.update
|
||||||
|
import io.reactivex.Single
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
|
import me.tatarka.bindingcollectionadapter2.OnItemBind
|
||||||
|
|
||||||
|
class ModuleViewModel(
|
||||||
|
private val repoDatabase: RepoDatabaseHelper,
|
||||||
|
private val resources: Resources
|
||||||
|
) : MagiskViewModel() {
|
||||||
|
|
||||||
|
val query = KObservableField("")
|
||||||
|
|
||||||
|
private val allItems = mutableListOf<ComparableRvItem<*>>()
|
||||||
|
|
||||||
|
val itemsInstalled = DiffObservableList(ComparableRvItem.callback)
|
||||||
|
val itemsRemote = DiffObservableList(ComparableRvItem.callback)
|
||||||
|
val itemBinding = OnItemBind<ComparableRvItem<*>> { itemBinding, _, item ->
|
||||||
|
item.bind(itemBinding)
|
||||||
|
itemBinding.bindExtra(BR.viewModel, this@ModuleViewModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var queryDisposable: Disposable? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
query.addOnPropertyChangedCallback {
|
||||||
|
queryDisposable?.dispose()
|
||||||
|
queryDisposable = query()
|
||||||
|
}
|
||||||
|
Event.register(this)
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getListeningEvents(): IntArray {
|
||||||
|
return intArrayOf(Event.MODULE_LOAD_DONE, Event.REPO_LOAD_DONE)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEvent(event: Int) = when (event) {
|
||||||
|
Event.MODULE_LOAD_DONE -> updateModules(Event.getResult(event))
|
||||||
|
Event.REPO_LOAD_DONE -> updateRepos()
|
||||||
|
else -> Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fabPressed() = OpenFilePickerEvent().publish()
|
||||||
|
fun repoPressed(item: RepoRvItem) = OpenChangelogEvent(item.item).publish()
|
||||||
|
fun downloadPressed(item: RepoRvItem) = InstallModuleEvent(item.item).publish()
|
||||||
|
|
||||||
|
fun refresh() {
|
||||||
|
state = State.LOADING
|
||||||
|
Utils.loadModules(true)
|
||||||
|
UpdateRepos().exec(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateModules(result: Map<String, Module>) = result.values
|
||||||
|
.map { ModuleRvItem(it) }
|
||||||
|
.let { itemsInstalled.update(it) }
|
||||||
|
|
||||||
|
internal fun updateRepos() {
|
||||||
|
Single.fromCallable { repoDatabase.repoCursor.toList { Repo(it) } }
|
||||||
|
.flattenAsFlowable { it }
|
||||||
|
.map { RepoRvItem(it) }
|
||||||
|
.toList()
|
||||||
|
.doOnSuccess { allItems.update(it) }
|
||||||
|
.flatMap { queryRaw() }
|
||||||
|
.applyViewModel(this)
|
||||||
|
.subscribeK { itemsRemote.update(it.first, it.second) }
|
||||||
|
.add()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun query() = queryRaw()
|
||||||
|
.subscribeK { itemsRemote.update(it.first, it.second) }
|
||||||
|
|
||||||
|
private fun queryRaw(query: String = this.query.value) = allItems.toSingle()
|
||||||
|
.map { it.filterIsInstance<RepoRvItem>() }
|
||||||
|
.flattenAsFlowable { it }
|
||||||
|
.filter {
|
||||||
|
it.item.name.contains(query, ignoreCase = true) ||
|
||||||
|
it.item.author.contains(query, ignoreCase = true) ||
|
||||||
|
it.item.description.contains(query, ignoreCase = true)
|
||||||
|
}
|
||||||
|
.toList()
|
||||||
|
.map { if (query.isEmpty()) it.divide() else it }
|
||||||
|
.map { it to itemsRemote.calculateDiff(it) }
|
||||||
|
|
||||||
|
private fun List<RepoRvItem>.divide(): List<ComparableRvItem<*>> {
|
||||||
|
val installed = itemsInstalled.filterIsInstance<ModuleRvItem>()
|
||||||
|
val installedModules = filter { installed.any { item -> it.item.id == item.item.id } }
|
||||||
|
|
||||||
|
fun installedByID(id: String) = installed.firstOrNull { it.item.id == id }
|
||||||
|
|
||||||
|
fun List<RepoRvItem>.filterObsolete() = filter {
|
||||||
|
val module = installedByID(it.item.id) ?: return@filter false
|
||||||
|
module.item.versionCode != it.item.versionCode
|
||||||
|
}
|
||||||
|
|
||||||
|
val resultObsolete = installedModules.filterObsolete()
|
||||||
|
val resultInstalled = installedModules - resultObsolete
|
||||||
|
val resultRemote = toList() - installedModules
|
||||||
|
|
||||||
|
fun buildList(@StringRes text: Int, list: List<RepoRvItem>): List<ComparableRvItem<*>> {
|
||||||
|
return if (list.isEmpty()) list
|
||||||
|
else listOf(SectionRvItem(resources.getString(text))) + list
|
||||||
|
}
|
||||||
|
|
||||||
|
return buildList(R.string.update_available, resultObsolete) +
|
||||||
|
buildList(R.string.installed, resultInstalled) +
|
||||||
|
buildList(R.string.not_installed, resultRemote)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun <Result> Cursor.toList(transformer: (Cursor) -> Result): List<Result> {
|
||||||
|
val out = mutableListOf<Result>()
|
||||||
|
while (moveToNext()) out.add(transformer(this))
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.module
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.skoumal.teanity.viewevents.ViewEvent
|
||||||
|
import com.topjohnwu.magisk.ClassMap
|
||||||
|
import com.topjohnwu.magisk.Const
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.databinding.FragmentModulesBinding
|
||||||
|
import com.topjohnwu.magisk.model.events.OpenFilePickerEvent
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskFragment
|
||||||
|
import com.topjohnwu.magisk.ui.flash.FlashActivity
|
||||||
|
import com.topjohnwu.magisk.utils.RootUtils
|
||||||
|
import com.topjohnwu.superuser.Shell
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
|
||||||
|
class ModulesFragment : MagiskFragment<ModuleViewModel, FragmentModulesBinding>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.fragment_modules
|
||||||
|
override val viewModel: ModuleViewModel by sharedViewModel()
|
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
if (requestCode == Const.ID.FETCH_ZIP && resultCode == Activity.RESULT_OK && data != null) {
|
||||||
|
// Get the URI of the selected file
|
||||||
|
val intent = Intent(activity, ClassMap.get<Any>(FlashActivity::class.java))
|
||||||
|
intent.setData(data.data).putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_ZIP)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
binding.modulesContent.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||||
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
|
binding.modulesRefreshLayout.isEnabled = recyclerView.getChildAt(0).top >= 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEventDispatched(event: ViewEvent) {
|
||||||
|
super.onEventDispatched(event)
|
||||||
|
when (event) {
|
||||||
|
is OpenFilePickerEvent -> selectFile()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
requireActivity().setTitle(R.string.modules)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
|
inflater.inflate(R.menu.menu_reboot, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.reboot -> {
|
||||||
|
RootUtils.reboot()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
R.id.reboot_recovery -> {
|
||||||
|
Shell.su("/system/bin/reboot recovery").submit()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
R.id.reboot_bootloader -> {
|
||||||
|
Shell.su("/system/bin/reboot bootloader").submit()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
R.id.reboot_download -> {
|
||||||
|
Shell.su("/system/bin/reboot download").submit()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
else -> return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun selectFile() {
|
||||||
|
magiskActivity.runWithExternalRW {
|
||||||
|
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
||||||
|
intent.type = "application/zip"
|
||||||
|
startActivityForResult(intent, Const.ID.FETCH_ZIP)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*override fun getListeningEvents(): IntArray {
|
||||||
|
return intArrayOf(Event.MODULE_LOAD_DONE)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEvent(event: Int) {
|
||||||
|
updateUI(Event.getResult(event))
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*private fun updateUI(moduleMap: Map<String, Module>) {
|
||||||
|
listModules.clear()
|
||||||
|
listModules.addAll(moduleMap.values)
|
||||||
|
if (listModules.size == 0) {
|
||||||
|
emptyRv!!.visibility = View.VISIBLE
|
||||||
|
recyclerView!!.visibility = View.GONE
|
||||||
|
} else {
|
||||||
|
emptyRv!!.visibility = View.GONE
|
||||||
|
recyclerView!!.visibility = View.VISIBLE
|
||||||
|
recyclerView!!.adapter = ModulesAdapter(listModules)
|
||||||
|
}
|
||||||
|
mSwipeRefreshLayout!!.isRefreshing = false
|
||||||
|
}*/
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.module
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.widget.SearchView
|
||||||
|
import com.skoumal.teanity.viewevents.ViewEvent
|
||||||
|
import com.topjohnwu.magisk.ClassMap
|
||||||
|
import com.topjohnwu.magisk.Config
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.databinding.FragmentReposBinding
|
||||||
|
import com.topjohnwu.magisk.model.download.DownloadModuleService
|
||||||
|
import com.topjohnwu.magisk.model.entity.Repo
|
||||||
|
import com.topjohnwu.magisk.model.events.InstallModuleEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.OpenChangelogEvent
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskFragment
|
||||||
|
import com.topjohnwu.magisk.view.MarkDownWindow
|
||||||
|
import com.topjohnwu.magisk.view.dialogs.CustomAlertDialog
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
|
||||||
|
class ReposFragment : MagiskFragment<ModuleViewModel, FragmentReposBinding>(),
|
||||||
|
SearchView.OnQueryTextListener {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.fragment_repos
|
||||||
|
override val viewModel: ModuleViewModel by sharedViewModel()
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
requireActivity().setTitle(R.string.downloads)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEventDispatched(event: ViewEvent) {
|
||||||
|
super.onEventDispatched(event)
|
||||||
|
when (event) {
|
||||||
|
is OpenChangelogEvent -> openChangelog(event.item)
|
||||||
|
is InstallModuleEvent -> installModule(event.item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
|
inflater.inflate(R.menu.menu_repo, menu)
|
||||||
|
(menu.findItem(R.id.repo_search).actionView as? SearchView)
|
||||||
|
?.setOnQueryTextListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
if (item.itemId == R.id.repo_sort) {
|
||||||
|
AlertDialog.Builder(activity)
|
||||||
|
.setTitle(R.string.sorting_order)
|
||||||
|
.setSingleChoiceItems(
|
||||||
|
R.array.sorting_orders,
|
||||||
|
Config.get<Int>(Config.Key.REPO_ORDER)!!
|
||||||
|
) { d, which ->
|
||||||
|
Config.set(Config.Key.REPO_ORDER, which)
|
||||||
|
viewModel.updateRepos()
|
||||||
|
d.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onQueryTextSubmit(p0: String?): Boolean {
|
||||||
|
viewModel.query.value = p0.orEmpty()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onQueryTextChange(p0: String?): Boolean {
|
||||||
|
viewModel.query.value = p0.orEmpty()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun openChangelog(item: Repo) {
|
||||||
|
MarkDownWindow.show(context, null, item.detailUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun installModule(item: Repo) {
|
||||||
|
val context = magiskActivity
|
||||||
|
|
||||||
|
fun download(install: Boolean) {
|
||||||
|
context.runWithExternalRW {
|
||||||
|
val intent = Intent(activity, ClassMap.get<Any>(DownloadModuleService::class.java))
|
||||||
|
.putExtra("repo", item).putExtra("install", install)
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
context.startForegroundService(intent) //hmm, service starts itself in foreground, this seems unnecessary
|
||||||
|
} else {
|
||||||
|
context.startService(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomAlertDialog(context)
|
||||||
|
.setTitle(context.getString(R.string.repo_install_title, item.name))
|
||||||
|
.setMessage(context.getString(R.string.repo_install_msg, item.downloadFilename))
|
||||||
|
.setCancelable(true)
|
||||||
|
.setPositiveButton(R.string.install) { _, _ -> download(true) }
|
||||||
|
.setNeutralButton(R.string.download) { _, _ -> download(false) }
|
||||||
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.settings;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.BuildConfig;
|
||||||
|
import com.topjohnwu.magisk.Config;
|
||||||
|
import com.topjohnwu.magisk.Const;
|
||||||
|
import com.topjohnwu.magisk.R;
|
||||||
|
import com.topjohnwu.magisk.tasks.CheckUpdates;
|
||||||
|
import com.topjohnwu.magisk.ui.base.BasePreferenceFragment;
|
||||||
|
import com.topjohnwu.magisk.utils.DownloadApp;
|
||||||
|
import com.topjohnwu.magisk.utils.Event;
|
||||||
|
import com.topjohnwu.magisk.utils.FingerprintHelper;
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
|
import com.topjohnwu.magisk.utils.PatchAPK;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
import com.topjohnwu.magisk.view.dialogs.FingerprintAuthDialog;
|
||||||
|
import com.topjohnwu.net.Networking;
|
||||||
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.preference.ListPreference;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
import androidx.preference.SwitchPreferenceCompat;
|
||||||
|
|
||||||
|
public class SettingsFragment extends BasePreferenceFragment {
|
||||||
|
|
||||||
|
private ListPreference updateChannel, autoRes, suNotification,
|
||||||
|
requestTimeout, rootConfig, multiuserConfig, nsConfig;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
requireActivity().setTitle(R.string.settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
|
getPreferenceManager().setStorageDeviceProtected();
|
||||||
|
setPreferencesFromResource(R.xml.app_settings, rootKey);
|
||||||
|
|
||||||
|
boolean showSuperuser = Utils.showSuperUser();
|
||||||
|
app.getPrefs().edit()
|
||||||
|
.putBoolean(Config.Key.SU_FINGERPRINT, FingerprintHelper.useFingerprint())
|
||||||
|
.apply();
|
||||||
|
|
||||||
|
PreferenceScreen prefScreen = getPreferenceScreen();
|
||||||
|
|
||||||
|
PreferenceCategory generalCatagory = (PreferenceCategory) findPreference("general");
|
||||||
|
PreferenceCategory magiskCategory = (PreferenceCategory) findPreference("magisk");
|
||||||
|
PreferenceCategory suCategory = (PreferenceCategory) findPreference("superuser");
|
||||||
|
Preference hideManager = findPreference("hide");
|
||||||
|
hideManager.setOnPreferenceClickListener(pref -> {
|
||||||
|
PatchAPK.hideManager();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
Preference restoreManager = findPreference("restore");
|
||||||
|
restoreManager.setOnPreferenceClickListener(pref -> {
|
||||||
|
DownloadApp.restore();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
findPreference("clear").setOnPreferenceClickListener(pref -> {
|
||||||
|
app.getPrefs().edit().remove(Config.Key.ETAG_KEY).apply();
|
||||||
|
app.getRepoDB().clearRepo();
|
||||||
|
Utils.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
findPreference("hosts").setOnPreferenceClickListener(pref -> {
|
||||||
|
Shell.su("add_hosts_module").exec();
|
||||||
|
Utils.loadModules();
|
||||||
|
Utils.toast(R.string.settings_hosts_toast, Toast.LENGTH_SHORT);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
updateChannel = (ListPreference) findPreference(Config.Key.UPDATE_CHANNEL);
|
||||||
|
rootConfig = (ListPreference) findPreference(Config.Key.ROOT_ACCESS);
|
||||||
|
autoRes = (ListPreference) findPreference(Config.Key.SU_AUTO_RESPONSE);
|
||||||
|
requestTimeout = (ListPreference) findPreference(Config.Key.SU_REQUEST_TIMEOUT);
|
||||||
|
suNotification = (ListPreference) findPreference(Config.Key.SU_NOTIFICATION);
|
||||||
|
multiuserConfig = (ListPreference) findPreference(Config.Key.SU_MULTIUSER_MODE);
|
||||||
|
nsConfig = (ListPreference) findPreference(Config.Key.SU_MNT_NS);
|
||||||
|
SwitchPreferenceCompat reauth = (SwitchPreferenceCompat) findPreference(Config.Key.SU_REAUTH);
|
||||||
|
SwitchPreferenceCompat fingerprint = (SwitchPreferenceCompat) findPreference(Config.Key.SU_FINGERPRINT);
|
||||||
|
|
||||||
|
updateChannel.setOnPreferenceChangeListener((p, o) -> {
|
||||||
|
int prev = Config.get(Config.Key.UPDATE_CHANNEL);
|
||||||
|
int channel = Integer.parseInt((String) o);
|
||||||
|
if (channel == Config.Value.CUSTOM_CHANNEL) {
|
||||||
|
View v = LayoutInflater.from(requireActivity()).inflate(R.layout.custom_channel_dialog, null);
|
||||||
|
EditText url = v.findViewById(R.id.custom_url);
|
||||||
|
url.setText(app.getPrefs().getString(Config.Key.CUSTOM_CHANNEL, ""));
|
||||||
|
new AlertDialog.Builder(requireActivity())
|
||||||
|
.setTitle(R.string.settings_update_custom)
|
||||||
|
.setView(v)
|
||||||
|
.setPositiveButton(R.string.ok, (d, i) ->
|
||||||
|
Config.set(Config.Key.CUSTOM_CHANNEL, url.getText().toString()))
|
||||||
|
.setNegativeButton(R.string.close, (d, i) ->
|
||||||
|
Config.set(Config.Key.UPDATE_CHANNEL, prev))
|
||||||
|
.setOnCancelListener(d ->
|
||||||
|
Config.set(Config.Key.UPDATE_CHANNEL, prev))
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
/* We only show canary channels if user is already on canary channel
|
||||||
|
* or the user have already chosen canary channel */
|
||||||
|
if (!Utils.isCanary() &&
|
||||||
|
(int) Config.get(Config.Key.UPDATE_CHANNEL) < Config.Value.CANARY_CHANNEL) {
|
||||||
|
// Remove the last 2 entries
|
||||||
|
CharSequence[] entries = updateChannel.getEntries();
|
||||||
|
updateChannel.setEntries(Arrays.copyOf(entries, entries.length - 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
setSummary();
|
||||||
|
|
||||||
|
// Disable dangerous settings in secondary user
|
||||||
|
if (Const.USER_ID > 0) {
|
||||||
|
suCategory.removePreference(multiuserConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable re-authentication option on Android O, it will not work
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
reauth.setEnabled(false);
|
||||||
|
reauth.setChecked(false);
|
||||||
|
reauth.setSummary(R.string.android_o_not_support);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable fingerprint option if not possible
|
||||||
|
if (!FingerprintHelper.canUseFingerprint()) {
|
||||||
|
fingerprint.setEnabled(false);
|
||||||
|
fingerprint.setChecked(false);
|
||||||
|
fingerprint.setSummary(R.string.disable_fingerprint);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Shell.rootAccess() && Const.USER_ID == 0) {
|
||||||
|
if (app.getPackageName().equals(BuildConfig.APPLICATION_ID)) {
|
||||||
|
generalCatagory.removePreference(restoreManager);
|
||||||
|
} else {
|
||||||
|
if (!Networking.checkNetworkStatus(app))
|
||||||
|
generalCatagory.removePreference(restoreManager);
|
||||||
|
generalCatagory.removePreference(hideManager);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
generalCatagory.removePreference(restoreManager);
|
||||||
|
generalCatagory.removePreference(hideManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!showSuperuser) {
|
||||||
|
prefScreen.removePreference(suCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Shell.rootAccess()) {
|
||||||
|
prefScreen.removePreference(magiskCategory);
|
||||||
|
generalCatagory.removePreference(hideManager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLocalePreference(ListPreference lp) {
|
||||||
|
CharSequence[] entries = new CharSequence[LocaleManager.locales.size() + 1];
|
||||||
|
CharSequence[] entryValues = new CharSequence[LocaleManager.locales.size() + 1];
|
||||||
|
entries[0] = LocaleManager.getString(LocaleManager.defaultLocale, R.string.system_default);
|
||||||
|
entryValues[0] = "";
|
||||||
|
int i = 1;
|
||||||
|
for (Locale locale : LocaleManager.locales) {
|
||||||
|
entries[i] = locale.getDisplayName(locale);
|
||||||
|
entryValues[i++] = LocaleManager.toLanguageTag(locale);
|
||||||
|
}
|
||||||
|
lp.setEntries(entries);
|
||||||
|
lp.setEntryValues(entryValues);
|
||||||
|
lp.setSummary(LocaleManager.locale.getDisplayName(LocaleManager.locale));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||||
|
switch (key) {
|
||||||
|
case Config.Key.ROOT_ACCESS:
|
||||||
|
case Config.Key.SU_MULTIUSER_MODE:
|
||||||
|
case Config.Key.SU_MNT_NS:
|
||||||
|
app.getDB().setSettings(key, Utils.getPrefsInt(prefs, key));
|
||||||
|
break;
|
||||||
|
case Config.Key.DARK_THEME:
|
||||||
|
requireActivity().recreate();
|
||||||
|
break;
|
||||||
|
case Config.Key.COREONLY:
|
||||||
|
if (prefs.getBoolean(key, false)) {
|
||||||
|
try {
|
||||||
|
Const.MAGISK_DISABLE_FILE.createNewFile();
|
||||||
|
} catch (IOException ignored) {}
|
||||||
|
} else {
|
||||||
|
Const.MAGISK_DISABLE_FILE.delete();
|
||||||
|
}
|
||||||
|
Utils.toast(R.string.settings_reboot_toast, Toast.LENGTH_LONG);
|
||||||
|
break;
|
||||||
|
case Config.Key.MAGISKHIDE:
|
||||||
|
if (prefs.getBoolean(key, false)) {
|
||||||
|
Shell.su("magiskhide --enable").submit();
|
||||||
|
} else {
|
||||||
|
Shell.su("magiskhide --disable").submit();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Config.Key.LOCALE:
|
||||||
|
LocaleManager.setLocale(app);
|
||||||
|
requireActivity().recreate();
|
||||||
|
break;
|
||||||
|
case Config.Key.UPDATE_CHANNEL:
|
||||||
|
case Config.Key.CUSTOM_CHANNEL:
|
||||||
|
CheckUpdates.check();
|
||||||
|
break;
|
||||||
|
case Config.Key.CHECK_UPDATES:
|
||||||
|
Utils.scheduleUpdateCheck();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setSummary(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceTreeClick(Preference preference) {
|
||||||
|
String key = preference.getKey();
|
||||||
|
switch (key) {
|
||||||
|
case Config.Key.SU_FINGERPRINT:
|
||||||
|
boolean checked = ((SwitchPreferenceCompat) preference).isChecked();
|
||||||
|
((SwitchPreferenceCompat) preference).setChecked(!checked);
|
||||||
|
new FingerprintAuthDialog(requireActivity(), () -> {
|
||||||
|
((SwitchPreferenceCompat) preference).setChecked(checked);
|
||||||
|
Config.set(key, checked);
|
||||||
|
}).show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSummary(String key) {
|
||||||
|
switch (key) {
|
||||||
|
case Config.Key.UPDATE_CHANNEL:
|
||||||
|
int ch = Config.get(key);
|
||||||
|
ch = ch < 0 ? Config.Value.STABLE_CHANNEL : ch;
|
||||||
|
updateChannel.setSummary(getResources()
|
||||||
|
.getStringArray(R.array.update_channel)[ch]);
|
||||||
|
break;
|
||||||
|
case Config.Key.ROOT_ACCESS:
|
||||||
|
rootConfig.setSummary(getResources()
|
||||||
|
.getStringArray(R.array.su_access)[(int)Config.get(key)]);
|
||||||
|
break;
|
||||||
|
case Config.Key.SU_AUTO_RESPONSE:
|
||||||
|
autoRes.setSummary(getResources()
|
||||||
|
.getStringArray(R.array.auto_response)[(int)Config.get(key)]);
|
||||||
|
break;
|
||||||
|
case Config.Key.SU_NOTIFICATION:
|
||||||
|
suNotification.setSummary(getResources()
|
||||||
|
.getStringArray(R.array.su_notification)[(int)Config.get(key)]);
|
||||||
|
break;
|
||||||
|
case Config.Key.SU_REQUEST_TIMEOUT:
|
||||||
|
requestTimeout.setSummary(
|
||||||
|
getString(R.string.request_timeout_summary, (int)Config.get(key)));
|
||||||
|
break;
|
||||||
|
case Config.Key.SU_MULTIUSER_MODE:
|
||||||
|
multiuserConfig.setSummary(getResources()
|
||||||
|
.getStringArray(R.array.multiuser_summary)[(int)Config.get(key)]);
|
||||||
|
break;
|
||||||
|
case Config.Key.SU_MNT_NS:
|
||||||
|
nsConfig.setSummary(getResources()
|
||||||
|
.getStringArray(R.array.namespace_summary)[(int)Config.get(key)]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSummary() {
|
||||||
|
setSummary(Config.Key.UPDATE_CHANNEL);
|
||||||
|
setSummary(Config.Key.ROOT_ACCESS);
|
||||||
|
setSummary(Config.Key.SU_AUTO_RESPONSE);
|
||||||
|
setSummary(Config.Key.SU_NOTIFICATION);
|
||||||
|
setSummary(Config.Key.SU_REQUEST_TIMEOUT);
|
||||||
|
setSummary(Config.Key.SU_MULTIUSER_MODE);
|
||||||
|
setSummary(Config.Key.SU_MNT_NS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(int event) {
|
||||||
|
setLocalePreference((ListPreference) findPreference(Config.Key.LOCALE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getListeningEvents() {
|
||||||
|
return new int[] {Event.LOCALE_FETCH_DONE};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.superuser
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.databinding.FragmentSuperuserBinding
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskFragment
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
|
||||||
|
class SuperuserFragment :
|
||||||
|
MagiskFragment<SuperuserViewModel, FragmentSuperuserBinding>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.fragment_superuser
|
||||||
|
override val viewModel: SuperuserViewModel by viewModel()
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
requireActivity().setTitle(R.string.superuser)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
viewModel.updatePolicies()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.superuser
|
||||||
|
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.content.res.Resources
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.skoumal.teanity.extensions.applySchedulers
|
||||||
|
import com.skoumal.teanity.extensions.subscribeK
|
||||||
|
import com.skoumal.teanity.rxbus.RxBus
|
||||||
|
import com.skoumal.teanity.util.DiffObservableList
|
||||||
|
import com.skoumal.teanity.viewevents.SnackbarEvent
|
||||||
|
import com.topjohnwu.magisk.BR
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.data.database.MagiskDB
|
||||||
|
import com.topjohnwu.magisk.model.entity.Policy
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.PolicyRvItem
|
||||||
|
import com.topjohnwu.magisk.model.events.PolicyEnableEvent
|
||||||
|
import com.topjohnwu.magisk.model.events.PolicyUpdateEvent
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskViewModel
|
||||||
|
import com.topjohnwu.magisk.utils.FingerprintHelper
|
||||||
|
import com.topjohnwu.magisk.utils.toggle
|
||||||
|
import com.topjohnwu.magisk.view.dialogs.CustomAlertDialog
|
||||||
|
import com.topjohnwu.magisk.view.dialogs.FingerprintAuthDialog
|
||||||
|
import io.reactivex.Single
|
||||||
|
import me.tatarka.bindingcollectionadapter2.ItemBinding
|
||||||
|
|
||||||
|
class SuperuserViewModel(
|
||||||
|
private val database: MagiskDB,
|
||||||
|
private val packageManager: PackageManager,
|
||||||
|
private val resources: Resources,
|
||||||
|
rxBus: RxBus
|
||||||
|
) : MagiskViewModel() {
|
||||||
|
|
||||||
|
val items = DiffObservableList(ComparableRvItem.callback)
|
||||||
|
val itemBinding = ItemBinding.of<ComparableRvItem<*>> { itemBinding, _, item ->
|
||||||
|
item.bind(itemBinding)
|
||||||
|
itemBinding.bindExtra(BR.viewModel, this@SuperuserViewModel)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var ignoreNext: PolicyRvItem? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
rxBus.register<PolicyEnableEvent>()
|
||||||
|
.subscribeK { togglePolicy(it.item, it.enable) }
|
||||||
|
.add()
|
||||||
|
rxBus.register<PolicyUpdateEvent>()
|
||||||
|
.subscribeK { updatePolicy(it) }
|
||||||
|
.add()
|
||||||
|
|
||||||
|
updatePolicies()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updatePolicies() {
|
||||||
|
Single.fromCallable { database.policyList }
|
||||||
|
.flattenAsFlowable { it }
|
||||||
|
.map { PolicyRvItem(it, it.info.loadIcon(packageManager)) }
|
||||||
|
.toList()
|
||||||
|
.applySchedulers()
|
||||||
|
.applyViewModel(this)
|
||||||
|
.subscribeK { items.update(it) }
|
||||||
|
.add()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deletePressed(item: PolicyRvItem) {
|
||||||
|
fun updateState() = deletePolicy(item.item)
|
||||||
|
.map { items.filterIsInstance<PolicyRvItem>().toMutableList() }
|
||||||
|
.map { it.removeAll { it.item.packageName == item.item.packageName }; it }
|
||||||
|
.map { it to items.calculateDiff(it) }
|
||||||
|
.subscribeK { items.update(it.first, it.second) }
|
||||||
|
.add()
|
||||||
|
|
||||||
|
withView {
|
||||||
|
if (FingerprintHelper.useFingerprint()) {
|
||||||
|
FingerprintAuthDialog(this) { updateState() }.show()
|
||||||
|
} else {
|
||||||
|
CustomAlertDialog(this)
|
||||||
|
.setTitle(R.string.su_revoke_title)
|
||||||
|
.setMessage(getString(R.string.su_revoke_msg, item.item.appName))
|
||||||
|
.setPositiveButton(R.string.yes) { _, _ -> updateState() }
|
||||||
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
|
.setCancelable(true)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePolicy(it: PolicyUpdateEvent) = when (it) {
|
||||||
|
is PolicyUpdateEvent.Notification -> updatePolicy(it.item) {
|
||||||
|
val textId = if (it.logging) R.string.su_snack_notif_on else R.string.su_snack_notif_off
|
||||||
|
val text = resources.getString(textId).format(it.appName)
|
||||||
|
SnackbarEvent(text).publish()
|
||||||
|
}
|
||||||
|
is PolicyUpdateEvent.Log -> updatePolicy(it.item) {
|
||||||
|
val textId =
|
||||||
|
if (it.notification) R.string.su_snack_log_on else R.string.su_snack_log_off
|
||||||
|
val text = resources.getString(textId).format(it.appName)
|
||||||
|
SnackbarEvent(text).publish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePolicy(item: PolicyRvItem, onSuccess: (Policy) -> Unit) =
|
||||||
|
updatePolicy(item.item)
|
||||||
|
.subscribeK { onSuccess(it) }
|
||||||
|
.add()
|
||||||
|
|
||||||
|
private fun togglePolicy(item: PolicyRvItem, enable: Boolean) {
|
||||||
|
fun updateState() {
|
||||||
|
item.item.policy = if (enable) Policy.ALLOW else Policy.DENY
|
||||||
|
|
||||||
|
updatePolicy(item.item)
|
||||||
|
.map { it.policy == Policy.ALLOW }
|
||||||
|
.subscribeK {
|
||||||
|
val textId = if (it) R.string.su_snack_grant else R.string.su_snack_deny
|
||||||
|
val text = resources.getString(textId).format(item.item.appName)
|
||||||
|
SnackbarEvent(text).publish()
|
||||||
|
}
|
||||||
|
.add()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FingerprintHelper.useFingerprint()) {
|
||||||
|
withView {
|
||||||
|
FingerprintAuthDialog(this, { updateState() }, {
|
||||||
|
ignoreNext = item
|
||||||
|
item.isEnabled.toggle()
|
||||||
|
}).show()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updateState()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePolicy(policy: Policy) =
|
||||||
|
Single.fromCallable { database.updatePolicy(policy); policy }
|
||||||
|
.applySchedulers()
|
||||||
|
|
||||||
|
private fun deletePolicy(policy: Policy) =
|
||||||
|
Single.fromCallable { database.deletePolicy(policy); policy }
|
||||||
|
.applySchedulers()
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.surequest
|
||||||
|
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
|
import android.view.Window
|
||||||
|
import com.skoumal.teanity.viewevents.ViewEvent
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.databinding.ActivityRequestBinding
|
||||||
|
import com.topjohnwu.magisk.model.entity.Policy
|
||||||
|
import com.topjohnwu.magisk.model.events.DieEvent
|
||||||
|
import com.topjohnwu.magisk.model.receiver.GeneralReceiver
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskActivity
|
||||||
|
import com.topjohnwu.magisk.utils.SuLogger
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
|
||||||
|
open class SuRequestActivity : MagiskActivity<SuRequestViewModel, ActivityRequestBinding>() {
|
||||||
|
|
||||||
|
override val layoutRes: Int = R.layout.activity_request
|
||||||
|
override val viewModel: SuRequestViewModel by viewModel()
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
viewModel.handler?.handleAction(Policy.DENY, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||||
|
lockOrientation()
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
val intent = intent
|
||||||
|
val action = intent.action
|
||||||
|
|
||||||
|
if (TextUtils.equals(action, GeneralReceiver.REQUEST)) {
|
||||||
|
if (!viewModel.handleRequest(intent) {})
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TextUtils.equals(action, GeneralReceiver.LOG))
|
||||||
|
SuLogger.handleLogs(intent)
|
||||||
|
else if (TextUtils.equals(action, GeneralReceiver.NOTIFY))
|
||||||
|
SuLogger.handleNotify(intent)
|
||||||
|
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEventDispatched(event: ViewEvent) {
|
||||||
|
super.onEventDispatched(event)
|
||||||
|
when (event) {
|
||||||
|
is DieEvent -> finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun lockOrientation() {
|
||||||
|
requestedOrientation = if (Build.VERSION.SDK_INT < 18)
|
||||||
|
resources.configuration.orientation
|
||||||
|
else
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_LOCKED
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
package com.topjohnwu.magisk.ui.surequest
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.content.res.Resources
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.hardware.fingerprint.FingerprintManager
|
||||||
|
import android.os.CountDownTimer
|
||||||
|
import android.text.TextUtils
|
||||||
|
import com.skoumal.teanity.databinding.ComparableRvItem
|
||||||
|
import com.skoumal.teanity.util.DiffObservableList
|
||||||
|
import com.skoumal.teanity.util.KObservableField
|
||||||
|
import com.topjohnwu.magisk.BuildConfig
|
||||||
|
import com.topjohnwu.magisk.Config
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.data.database.MagiskDB
|
||||||
|
import com.topjohnwu.magisk.model.entity.Policy
|
||||||
|
import com.topjohnwu.magisk.model.entity.recycler.SpinnerRvItem
|
||||||
|
import com.topjohnwu.magisk.model.events.DieEvent
|
||||||
|
import com.topjohnwu.magisk.ui.base.MagiskViewModel
|
||||||
|
import com.topjohnwu.magisk.utils.FingerprintHelper
|
||||||
|
import com.topjohnwu.magisk.utils.SuConnector
|
||||||
|
import com.topjohnwu.magisk.utils.now
|
||||||
|
import me.tatarka.bindingcollectionadapter2.ItemBinding
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.concurrent.TimeUnit.*
|
||||||
|
|
||||||
|
class SuRequestViewModel(
|
||||||
|
private val packageManager: PackageManager,
|
||||||
|
private val database: MagiskDB,
|
||||||
|
private val timeoutPrefs: SharedPreferences,
|
||||||
|
private val resources: Resources
|
||||||
|
) : MagiskViewModel() {
|
||||||
|
|
||||||
|
val icon = KObservableField<Drawable?>(null)
|
||||||
|
val title = KObservableField("")
|
||||||
|
val packageName = KObservableField("")
|
||||||
|
|
||||||
|
val denyText = KObservableField(resources.getString(R.string.deny))
|
||||||
|
val warningText = KObservableField<CharSequence>(resources.getString(R.string.su_warning))
|
||||||
|
|
||||||
|
val canUseFingerprint = KObservableField(FingerprintHelper.useFingerprint())
|
||||||
|
val selectedItemPosition = KObservableField(0)
|
||||||
|
|
||||||
|
val items = DiffObservableList(ComparableRvItem.callback)
|
||||||
|
val itemBinding = ItemBinding.of<ComparableRvItem<*>> { binding, _, item ->
|
||||||
|
item.bind(binding)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var handler: ActionHandler? = null
|
||||||
|
private var timer: CountDownTimer? = null
|
||||||
|
private var policy: Policy? = null
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
updatePolicy(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
resources.getStringArray(R.array.allow_timeout)
|
||||||
|
.map { SpinnerRvItem(it) }
|
||||||
|
.let { items.update(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updatePolicy(policy: Policy?) {
|
||||||
|
policy ?: return
|
||||||
|
|
||||||
|
icon.value = policy.info.loadIcon(packageManager)
|
||||||
|
title.value = policy.appName
|
||||||
|
packageName.value = policy.packageName
|
||||||
|
|
||||||
|
selectedItemPosition.value = timeoutPrefs.getInt(policy.packageName, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cancelTimer() {
|
||||||
|
timer?.cancel()
|
||||||
|
denyText.value = resources.getString(R.string.deny)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun grantPressed() {
|
||||||
|
handler?.handleAction(Policy.ALLOW)
|
||||||
|
timer?.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun denyPressed() {
|
||||||
|
handler?.handleAction(Policy.DENY)
|
||||||
|
timer?.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun spinnerTouched(): Boolean {
|
||||||
|
cancelTimer()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun handleRequest(intent: Intent, createUICallback: () -> Unit): Boolean {
|
||||||
|
val socketName = intent.getStringExtra("socket") ?: return false
|
||||||
|
|
||||||
|
val connector: SuConnector
|
||||||
|
try {
|
||||||
|
connector = object : SuConnector(socketName) {
|
||||||
|
@Throws(IOException::class)
|
||||||
|
override fun onResponse() {
|
||||||
|
out.writeInt(policy?.policy ?: return)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val bundle = connector.readSocketInput()
|
||||||
|
val uid = bundle.getString("uid")?.toIntOrNull() ?: return false
|
||||||
|
database.clearOutdated()
|
||||||
|
policy = database.getPolicy(uid) ?: Policy(uid, packageManager)
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
return false
|
||||||
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
handler = object : ActionHandler() {
|
||||||
|
override fun handleAction() {
|
||||||
|
connector.response()
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleAction(action: Int) {
|
||||||
|
val pos = selectedItemPosition.value
|
||||||
|
timeoutPrefs.edit().putInt(policy?.packageName, pos).apply()
|
||||||
|
handleAction(action, Config.Value.TIMEOUT_LIST[pos])
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleAction(action: Int, time: Int) {
|
||||||
|
policy?.apply {
|
||||||
|
policy = action
|
||||||
|
if (time >= 0) {
|
||||||
|
until = if (time == 0) {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
MILLISECONDS.toSeconds(now) + MINUTES.toSeconds(time.toLong())
|
||||||
|
}
|
||||||
|
database.updatePolicy(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
policy?.policy = action
|
||||||
|
|
||||||
|
handleAction()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Never allow com.topjohnwu.magisk (could be malware)
|
||||||
|
if (TextUtils.equals(policy?.packageName, BuildConfig.APPLICATION_ID))
|
||||||
|
return false
|
||||||
|
|
||||||
|
// If not interactive, response directly
|
||||||
|
if (policy?.policy != Policy.INTERACTIVE) {
|
||||||
|
handler?.handleAction()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
when (Config.get<Any>(Config.Key.SU_AUTO_RESPONSE) as Int) {
|
||||||
|
Config.Value.SU_AUTO_DENY -> {
|
||||||
|
handler?.handleAction(Policy.DENY, 0)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
Config.Value.SU_AUTO_ALLOW -> {
|
||||||
|
handler?.handleAction(Policy.ALLOW, 0)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createUICallback()
|
||||||
|
showUI()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
|
private fun showUI() {
|
||||||
|
val seconds = Config.get<Int>(Config.Key.SU_REQUEST_TIMEOUT).toLong()
|
||||||
|
val millis = SECONDS.toMillis(seconds)
|
||||||
|
timer = object : CountDownTimer(millis, 1000) {
|
||||||
|
override fun onTick(remains: Long) {
|
||||||
|
denyText.value = "%s (%d)"
|
||||||
|
.format(resources.getString(R.string.deny), remains / 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFinish() {
|
||||||
|
denyText.value = resources.getString(R.string.deny)
|
||||||
|
handler?.handleAction(Policy.DENY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
timer?.start()
|
||||||
|
handler?.addCancel(Runnable { cancelTimer() })
|
||||||
|
|
||||||
|
val useFP = canUseFingerprint.value
|
||||||
|
|
||||||
|
if (useFP)
|
||||||
|
try {
|
||||||
|
val helper = SuFingerprint()
|
||||||
|
helper.authenticate()
|
||||||
|
handler?.addCancel(Runnable { helper.cancel() })
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class SuFingerprint @Throws(Exception::class)
|
||||||
|
internal constructor() : FingerprintHelper() {
|
||||||
|
|
||||||
|
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
||||||
|
warningText.value = errString
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence) {
|
||||||
|
warningText.value = helpString
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAuthenticationSucceeded(result: FingerprintManager.AuthenticationResult) {
|
||||||
|
handler?.handleAction(Policy.ALLOW)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAuthenticationFailed() {
|
||||||
|
warningText.value = resources.getString(R.string.auth_fail)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open inner class ActionHandler {
|
||||||
|
private val cancelTasks = mutableListOf<Runnable>()
|
||||||
|
|
||||||
|
internal open fun handleAction() {
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal open fun handleAction(action: Int) {
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal open fun handleAction(action: Int, time: Int) {
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun addCancel(r: Runnable) {
|
||||||
|
cancelTasks.add(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun done() {
|
||||||
|
cancelTasks.forEach { it.run() }
|
||||||
|
DieEvent().publish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
package com.topjohnwu.magisk.utils
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.AdapterView
|
||||||
|
import android.widget.Spinner
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.annotation.ColorInt
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import androidx.databinding.BindingAdapter
|
||||||
|
import androidx.databinding.InverseBindingAdapter
|
||||||
|
import androidx.databinding.InverseBindingListener
|
||||||
|
import androidx.drawerlayout.widget.DrawerLayout
|
||||||
|
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
import com.google.android.material.navigation.NavigationView
|
||||||
|
import com.skoumal.teanity.extensions.subscribeK
|
||||||
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.model.entity.state.IndeterminateState
|
||||||
|
import io.reactivex.Observable
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
|
||||||
|
@BindingAdapter("onNavigationClick")
|
||||||
|
fun setOnNavigationClickedListener(view: Toolbar, listener: View.OnClickListener) {
|
||||||
|
view.setNavigationOnClickListener(listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("onNavigationClick")
|
||||||
|
fun setOnNavigationClickedListener(
|
||||||
|
view: NavigationView,
|
||||||
|
listener: NavigationView.OnNavigationItemSelectedListener
|
||||||
|
) {
|
||||||
|
view.setNavigationItemSelectedListener {
|
||||||
|
(view.parent as? DrawerLayout)?.closeDrawers()
|
||||||
|
listener.onNavigationItemSelected(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("srcCompat")
|
||||||
|
fun setImageResource(view: AppCompatImageView, @DrawableRes resId: Int) {
|
||||||
|
view.setImageResource(resId)
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("app:tint")
|
||||||
|
fun setTint(view: AppCompatImageView, @ColorInt tint: Int) {
|
||||||
|
view.setColorFilter(tint)
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("isChecked")
|
||||||
|
fun setChecked(view: AppCompatImageView, isChecked: Boolean) {
|
||||||
|
val state = when (isChecked) {
|
||||||
|
true -> IndeterminateState.CHECKED
|
||||||
|
else -> IndeterminateState.UNCHECKED
|
||||||
|
}
|
||||||
|
setChecked(view, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("isChecked")
|
||||||
|
fun setChecked(view: AppCompatImageView, isChecked: IndeterminateState) {
|
||||||
|
view.setImageResource(
|
||||||
|
when (isChecked) {
|
||||||
|
IndeterminateState.INDETERMINATE -> R.drawable.ic_indeterminate
|
||||||
|
IndeterminateState.CHECKED -> R.drawable.ic_checked
|
||||||
|
IndeterminateState.UNCHECKED -> R.drawable.ic_unchecked
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("position")
|
||||||
|
fun setPosition(view: ViewPager, position: Int) {
|
||||||
|
view.currentItem = position
|
||||||
|
}
|
||||||
|
|
||||||
|
@InverseBindingAdapter(attribute = "position", event = "positionChanged")
|
||||||
|
fun getPosition(view: ViewPager) = view.currentItem
|
||||||
|
|
||||||
|
@BindingAdapter("positionChanged")
|
||||||
|
fun setPositionChangedListener(view: ViewPager, listener: InverseBindingListener) {
|
||||||
|
view.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||||
|
override fun onPageSelected(position: Int) = listener.onChange()
|
||||||
|
override fun onPageScrollStateChanged(state: Int) = listener.onChange()
|
||||||
|
override fun onPageScrolled(
|
||||||
|
position: Int,
|
||||||
|
positionOffset: Float,
|
||||||
|
positionOffsetPixels: Int
|
||||||
|
) = listener.onChange()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("invisibleScale")
|
||||||
|
fun setInvisibleWithScale(view: View, isInvisible: Boolean) {
|
||||||
|
view.animate()
|
||||||
|
.scaleX(if (isInvisible) 0f else 1f)
|
||||||
|
.scaleY(if (isInvisible) 0f else 1f)
|
||||||
|
.setInterpolator(FastOutSlowInInterpolator())
|
||||||
|
.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("movieBehavior", "movieBehaviorText")
|
||||||
|
fun setMovieBehavior(view: TextView, isMovieBehavior: Boolean, text: String) {
|
||||||
|
(view.tag as? Disposable)?.dispose()
|
||||||
|
if (isMovieBehavior) {
|
||||||
|
val observer = Observable
|
||||||
|
.interval(150, TimeUnit.MILLISECONDS)
|
||||||
|
.subscribeK {
|
||||||
|
view.text = text.replaceRandomWithSpecial()
|
||||||
|
}
|
||||||
|
view.tag = observer
|
||||||
|
} else {
|
||||||
|
view.text = text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("android:selectedItemPosition")
|
||||||
|
fun setSelectedItemPosition(view: Spinner, position: Int) {
|
||||||
|
view.setSelection(position)
|
||||||
|
}
|
||||||
|
|
||||||
|
@InverseBindingAdapter(
|
||||||
|
attribute = "android:selectedItemPosition",
|
||||||
|
event = "android:selectedItemPositionAttrChanged"
|
||||||
|
)
|
||||||
|
fun getSelectedItemPosition(view: Spinner) = view.selectedItemPosition
|
||||||
|
|
||||||
|
@BindingAdapter("android:selectedItemPositionAttrChanged")
|
||||||
|
fun setSelectedItemPositionListener(view: Spinner, listener: InverseBindingListener) {
|
||||||
|
view.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onNothingSelected(p0: AdapterView<*>?) {
|
||||||
|
listener.onChange()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
|
||||||
|
listener.onChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("onTouch")
|
||||||
|
fun setOnTouchListener(view: View, listener: View.OnTouchListener) {
|
||||||
|
view.setOnTouchListener(listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("scrollToLast")
|
||||||
|
fun setScrollToLast(view: RecyclerView, shouldScrollToLast: Boolean) {
|
||||||
|
|
||||||
|
fun scrollToLast() = view.post {
|
||||||
|
view.scrollToPosition(view.adapter?.itemCount?.minus(1) ?: 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun wait(callback: () -> Unit) {
|
||||||
|
Observable.timer(1, TimeUnit.SECONDS).subscribeK { callback() }
|
||||||
|
}
|
||||||
|
|
||||||
|
val tag = RecyclerView::class.java.name.sumBy { it.toInt() }
|
||||||
|
|
||||||
|
fun RecyclerView.Adapter<*>.setListener() {
|
||||||
|
val observer = object : RecyclerView.AdapterDataObserver() {
|
||||||
|
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
|
||||||
|
scrollToLast()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
registerAdapterDataObserver(observer)
|
||||||
|
view.setTag(tag, observer)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun RecyclerView.Adapter<*>.removeListener() {
|
||||||
|
val observer = view.getTag(tag) as? RecyclerView.AdapterDataObserver ?: return
|
||||||
|
unregisterAdapterDataObserver(observer)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun trySetListener(): Unit = view.adapter?.setListener() ?: wait { trySetListener() }
|
||||||
|
|
||||||
|
if (shouldScrollToLast) {
|
||||||
|
trySetListener()
|
||||||
|
} else {
|
||||||
|
view.adapter?.removeListener()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.App;
|
||||||
|
import com.topjohnwu.magisk.BuildConfig;
|
||||||
|
import com.topjohnwu.magisk.ClassMap;
|
||||||
|
import com.topjohnwu.magisk.Config;
|
||||||
|
import com.topjohnwu.magisk.R;
|
||||||
|
import com.topjohnwu.magisk.ui.SplashActivity;
|
||||||
|
import com.topjohnwu.magisk.view.ProgressNotification;
|
||||||
|
import com.topjohnwu.net.Networking;
|
||||||
|
import com.topjohnwu.net.ResponseListener;
|
||||||
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import dalvik.system.DexClassLoader;
|
||||||
|
|
||||||
|
public class DownloadApp {
|
||||||
|
|
||||||
|
public static void upgrade(String name) {
|
||||||
|
dlInstall(name, new PatchPackageName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void restore() {
|
||||||
|
String name = Utils.fmt("MagiskManager v%s(%d)",
|
||||||
|
Config.remoteManagerVersionString, Config.remoteManagerVersionCode);
|
||||||
|
dlInstall(name, new RestoreManager());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void dlInstall(String name, ManagerDownloadListener listener) {
|
||||||
|
File apk = new File(App.self.getCacheDir(), "manager.apk");
|
||||||
|
ProgressNotification progress = new ProgressNotification(name);
|
||||||
|
listener.progress = progress;
|
||||||
|
Networking.get(Config.managerLink)
|
||||||
|
.setExecutor(App.THREAD_POOL)
|
||||||
|
.setDownloadProgressListener(progress)
|
||||||
|
.setErrorHandler((conn, e) -> progress.dlFail())
|
||||||
|
.getAsFile(apk, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private abstract static class ManagerDownloadListener implements ResponseListener<File> {
|
||||||
|
ProgressNotification progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class PatchPackageName extends ManagerDownloadListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(File apk) {
|
||||||
|
File patched = apk;
|
||||||
|
App app = App.self;
|
||||||
|
if (!app.getPackageName().equals(BuildConfig.APPLICATION_ID)) {
|
||||||
|
progress.getNotificationBuilder()
|
||||||
|
.setProgress(0, 0, true)
|
||||||
|
.setContentTitle(app.getString(R.string.hide_manager_title))
|
||||||
|
.setContentText("");
|
||||||
|
progress.update();
|
||||||
|
patched = new File(apk.getParent(), "patched.apk");
|
||||||
|
try {
|
||||||
|
// Try using the new APK to patch itself
|
||||||
|
ClassLoader loader = new DexClassLoader(apk.getPath(),
|
||||||
|
apk.getParent(), null, ClassLoader.getSystemClassLoader());
|
||||||
|
loader.loadClass("a.a")
|
||||||
|
.getMethod("patchAPK", String.class, String.class, String.class)
|
||||||
|
.invoke(null, apk.getPath(), patched.getPath(), app.getPackageName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// Fallback to use the current implementation
|
||||||
|
PatchAPK.patch(apk.getPath(), patched.getPath(), app.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
APKInstall.install(app, patched);
|
||||||
|
progress.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class RestoreManager extends ManagerDownloadListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(File apk) {
|
||||||
|
App app = App.self;
|
||||||
|
progress.getNotificationBuilder()
|
||||||
|
.setProgress(0, 0, true)
|
||||||
|
.setContentTitle(app.getString(R.string.restore_img_msg))
|
||||||
|
.setContentText("");
|
||||||
|
progress.update();
|
||||||
|
Config.export();
|
||||||
|
// Make it world readable
|
||||||
|
apk.setReadable(true, false);
|
||||||
|
if (Shell.su("pm install " + apk).exec().isSuccess())
|
||||||
|
RootUtils.rmAndLaunch(app.getPackageName(),
|
||||||
|
new ComponentName(BuildConfig.APPLICATION_ID,
|
||||||
|
ClassMap.get(SplashActivity.class).getName()));
|
||||||
|
progress.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
123
app/src/main/java/com/topjohnwu/magisk/utils/Event.java
Normal file
123
app/src/main/java/com/topjohnwu/magisk/utils/Event.java
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
|
import androidx.annotation.IntDef;
|
||||||
|
import androidx.collection.ArraySet;
|
||||||
|
|
||||||
|
import com.topjohnwu.superuser.internal.UiThreadHandler;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Event {
|
||||||
|
|
||||||
|
public static final int MAGISK_HIDE_DONE = 0;
|
||||||
|
public static final int MODULE_LOAD_DONE = 1;
|
||||||
|
public static final int REPO_LOAD_DONE = 2;
|
||||||
|
public static final int UPDATE_CHECK_DONE = 3;
|
||||||
|
public static final int LOCALE_FETCH_DONE = 4;
|
||||||
|
|
||||||
|
@IntDef({MAGISK_HIDE_DONE, MODULE_LOAD_DONE, REPO_LOAD_DONE,
|
||||||
|
UPDATE_CHECK_DONE, LOCALE_FETCH_DONE})
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface EventID {}
|
||||||
|
|
||||||
|
// We will not dynamically add topics, so use arrays instead of hash tables
|
||||||
|
private static Store[] eventList = new Store[5];
|
||||||
|
|
||||||
|
public static void register(Listener listener, @EventID int... events) {
|
||||||
|
for (int event : events) {
|
||||||
|
if (eventList[event] == null)
|
||||||
|
eventList[event] = new Store();
|
||||||
|
eventList[event].listeners.add(listener);
|
||||||
|
if (eventList[event].triggered) {
|
||||||
|
listener.onEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void register(AutoListener listener) {
|
||||||
|
register(listener, listener.getListeningEvents());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unregister(Listener listener, @EventID int... events) {
|
||||||
|
for (int event : events) {
|
||||||
|
if (eventList[event] == null)
|
||||||
|
continue;
|
||||||
|
eventList[event].listeners.remove(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unregister(AutoListener listener) {
|
||||||
|
unregister(listener, listener.getListeningEvents());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void trigger(@EventID int event) {
|
||||||
|
trigger(true, event, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void trigger(@EventID int event, Object result) {
|
||||||
|
trigger(true, event, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void trigger(boolean perm, @EventID int event) {
|
||||||
|
trigger(perm, event, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void trigger(boolean perm, @EventID int event, Object result) {
|
||||||
|
if (eventList[event] == null)
|
||||||
|
eventList[event] = new Store();
|
||||||
|
if (perm) {
|
||||||
|
eventList[event].result = result;
|
||||||
|
eventList[event].triggered = true;
|
||||||
|
}
|
||||||
|
for (Listener sub : eventList[event].listeners) {
|
||||||
|
UiThreadHandler.run(() -> sub.onEvent(event));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reset(@EventID int event) {
|
||||||
|
if (eventList[event] == null)
|
||||||
|
return;
|
||||||
|
eventList[event].triggered = false;
|
||||||
|
eventList[event].result = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reset(AutoListener listener) {
|
||||||
|
for (int event : listener.getListeningEvents())
|
||||||
|
reset(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isTriggered(@EventID int event) {
|
||||||
|
if (eventList[event] == null)
|
||||||
|
return false;
|
||||||
|
return eventList[event].triggered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isTriggered(AutoListener listener) {
|
||||||
|
for (int event : listener.getListeningEvents()) {
|
||||||
|
if (!isTriggered(event))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getResult(@EventID int event) {
|
||||||
|
return (T) eventList[event].result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Store {
|
||||||
|
boolean triggered = false;
|
||||||
|
Set<Listener> listeners = new ArraySet<>();
|
||||||
|
Object result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Listener {
|
||||||
|
void onEvent(int event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface AutoListener extends Listener {
|
||||||
|
@EventID
|
||||||
|
int[] getListeningEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.KeyguardManager;
|
||||||
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.CancellationSignal;
|
||||||
|
import android.security.keystore.KeyGenParameterSpec;
|
||||||
|
import android.security.keystore.KeyPermanentlyInvalidatedException;
|
||||||
|
import android.security.keystore.KeyProperties;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.App;
|
||||||
|
import com.topjohnwu.magisk.Config;
|
||||||
|
import com.topjohnwu.magisk.Const;
|
||||||
|
|
||||||
|
import java.security.KeyStore;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.KeyGenerator;
|
||||||
|
import javax.crypto.SecretKey;
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.M)
|
||||||
|
public abstract class FingerprintHelper {
|
||||||
|
|
||||||
|
private FingerprintManager manager;
|
||||||
|
private Cipher cipher;
|
||||||
|
private CancellationSignal cancel;
|
||||||
|
|
||||||
|
public static boolean useFingerprint() {
|
||||||
|
boolean fp = Config.get(Config.Key.SU_FINGERPRINT);
|
||||||
|
if (fp && !canUseFingerprint()) {
|
||||||
|
Config.set(Config.Key.SU_FINGERPRINT, false);
|
||||||
|
fp = false;
|
||||||
|
}
|
||||||
|
return fp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canUseFingerprint() {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||||
|
return false;
|
||||||
|
KeyguardManager km = App.self.getSystemService(KeyguardManager.class);
|
||||||
|
FingerprintManager fm = App.self.getSystemService(FingerprintManager.class);
|
||||||
|
return km.isKeyguardSecure() && fm != null && fm.isHardwareDetected() && fm.hasEnrolledFingerprints();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected FingerprintHelper() throws Exception {
|
||||||
|
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
|
||||||
|
manager = App.self.getSystemService(FingerprintManager.class);
|
||||||
|
cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/"
|
||||||
|
+ KeyProperties.BLOCK_MODE_CBC + "/"
|
||||||
|
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
|
||||||
|
keyStore.load(null);
|
||||||
|
SecretKey key = (SecretKey) keyStore.getKey(Const.SU_KEYSTORE_KEY, null);
|
||||||
|
if (key == null) {
|
||||||
|
key = generateKey();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||||
|
} catch (KeyPermanentlyInvalidatedException e) {
|
||||||
|
// Only happens on Marshmallow
|
||||||
|
key = generateKey();
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void onAuthenticationError(int errorCode, CharSequence errString);
|
||||||
|
|
||||||
|
public abstract void onAuthenticationHelp(int helpCode, CharSequence helpString);
|
||||||
|
|
||||||
|
public abstract void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result);
|
||||||
|
|
||||||
|
public abstract void onAuthenticationFailed();
|
||||||
|
|
||||||
|
public void authenticate() {
|
||||||
|
cancel = new CancellationSignal();
|
||||||
|
FingerprintManager.CryptoObject cryptoObject = new FingerprintManager.CryptoObject(cipher);
|
||||||
|
manager.authenticate(cryptoObject, cancel, 0, new Callback(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancel() {
|
||||||
|
if (cancel != null)
|
||||||
|
cancel.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private SecretKey generateKey() throws Exception {
|
||||||
|
KeyGenerator keygen = KeyGenerator
|
||||||
|
.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
|
||||||
|
KeyGenParameterSpec.Builder builder = new KeyGenParameterSpec.Builder(
|
||||||
|
Const.SU_KEYSTORE_KEY,
|
||||||
|
KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
|
||||||
|
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
|
||||||
|
.setUserAuthenticationRequired(true)
|
||||||
|
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
builder.setInvalidatedByBiometricEnrollment(false);
|
||||||
|
}
|
||||||
|
keygen.init(builder.build());
|
||||||
|
return keygen.generateKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Callback extends FingerprintManager.AuthenticationCallback {
|
||||||
|
@Override
|
||||||
|
public void onAuthenticationError(int errorCode, CharSequence errString) {
|
||||||
|
FingerprintHelper.this.onAuthenticationError(errorCode, errString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
|
||||||
|
FingerprintHelper.this.onAuthenticationHelp(helpCode, helpString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
|
||||||
|
FingerprintHelper.this.onAuthenticationSucceeded(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAuthenticationFailed() {
|
||||||
|
FingerprintHelper.this.onAuthenticationFailed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
|
public interface ISafetyNetHelper {
|
||||||
|
|
||||||
|
int RESPONSE_ERR = 0x01;
|
||||||
|
int CONNECTION_FAIL = 0x02;
|
||||||
|
|
||||||
|
int BASIC_PASS = 0x10;
|
||||||
|
int CTS_PASS = 0x20;
|
||||||
|
|
||||||
|
void attest();
|
||||||
|
|
||||||
|
int getVersion();
|
||||||
|
|
||||||
|
interface Callback {
|
||||||
|
void onResponse(int responseCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user