mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Compare commits
185 Commits
beta-1.2.1
...
beta-1.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fb27dbb12 | ||
|
|
831c65b647 | ||
|
|
afcd38b84c | ||
|
|
5c1bcdeb9d | ||
|
|
6c1f5450cb | ||
|
|
0d070cf422 | ||
|
|
d34d66c691 | ||
|
|
6005d156eb | ||
|
|
94dd75f24b | ||
|
|
c93e5441b0 | ||
|
|
8ec8cc927b | ||
|
|
4663e727eb | ||
|
|
e2acd19ffd | ||
|
|
0befa6a823 | ||
|
|
01083f47ea | ||
|
|
a349bd146c | ||
|
|
4ffa9e191c | ||
|
|
e616fc3da7 | ||
|
|
aed5ac5bb4 | ||
|
|
cae53a9fcc | ||
|
|
6660625ba6 | ||
|
|
bf9ba13b68 | ||
|
|
a52c97ecf7 | ||
|
|
a2174e7677 | ||
|
|
d3cf3d680e | ||
|
|
cbb87aa00c | ||
|
|
53d985161f | ||
|
|
86002b0402 | ||
|
|
f75e789493 | ||
|
|
b22f302fdd | ||
|
|
c4a42760c8 | ||
|
|
8d92f36522 | ||
|
|
6c86873ea7 | ||
|
|
4fa9d654b5 | ||
|
|
3d303ccad5 | ||
|
|
b0d99a9f33 | ||
|
|
1a5e789bec | ||
|
|
97040c6299 | ||
|
|
301085c685 | ||
|
|
946c79d918 | ||
|
|
20418cfc7f | ||
|
|
7b09f0f98d | ||
|
|
97a7c8824b | ||
|
|
423684a14f | ||
|
|
09d91b522f | ||
|
|
64c0e9e9e4 | ||
|
|
15021bffef | ||
|
|
43c6ae4258 | ||
|
|
f819930570 | ||
|
|
aa00ba7220 | ||
|
|
19db58ee19 | ||
|
|
05f4d63356 | ||
|
|
6e5af2d3d3 | ||
|
|
00bf1eac0a | ||
|
|
8a10f16861 | ||
|
|
9bd7214d1d | ||
|
|
fce1247aa6 | ||
|
|
990f983ea9 | ||
|
|
6e57d7bb42 | ||
|
|
1b0cb532de | ||
|
|
fe7121b4ec | ||
|
|
5aa041f9e1 | ||
|
|
6939d8d230 | ||
|
|
c3cea37641 | ||
|
|
d0d2e0ed82 | ||
|
|
cf8f5c989f | ||
|
|
8b45e01c42 | ||
|
|
ec972e8a1d | ||
|
|
100791c3f3 | ||
|
|
83ac866cc1 | ||
|
|
ef9b22670d | ||
|
|
186ac30f37 | ||
|
|
5aa24414c6 | ||
|
|
dd6d72ed30 | ||
|
|
4344be2ca0 | ||
|
|
1e94af3ef3 | ||
|
|
cb69340749 | ||
|
|
f3d068414b | ||
|
|
5fdc7e7cc4 | ||
|
|
7569d5ffb3 | ||
|
|
deca5d56cc | ||
|
|
3d6b48bb34 | ||
|
|
0dc631b7a8 | ||
|
|
921e952b05 | ||
|
|
3b02797639 | ||
|
|
e2e67edbbe | ||
|
|
a9cd40faeb | ||
|
|
dd3c19aba2 | ||
|
|
e8ede55422 | ||
|
|
04517e942e | ||
|
|
9a25ad892d | ||
|
|
3457d8f9ab | ||
|
|
5fb2624ffa | ||
|
|
ed9a7bec2c | ||
|
|
ff70315d5c | ||
|
|
f197243273 | ||
|
|
6409a3b179 | ||
|
|
f882e46b33 | ||
|
|
efa63c306a | ||
|
|
205b4f77b2 | ||
|
|
015ecb1d99 | ||
|
|
fd86b73626 | ||
|
|
9048392d4e | ||
|
|
480aaaa35e | ||
|
|
002feb8e29 | ||
|
|
c6ba2b037a | ||
|
|
98788c7c80 | ||
|
|
e6f66ebc95 | ||
|
|
04485e58da | ||
|
|
97118fd92b | ||
|
|
ac4fbf202f | ||
|
|
b81495eac1 | ||
|
|
db90f75d2e | ||
|
|
bed3abfd40 | ||
|
|
0967f6c48e | ||
|
|
f9a8fcb207 | ||
|
|
eb3c2a3566 | ||
|
|
8d735b3023 | ||
|
|
b24a0e4bc3 | ||
|
|
07da91a6f5 | ||
|
|
e4e0e712dc | ||
|
|
9294794448 | ||
|
|
5a9958793d | ||
|
|
651d2ca377 | ||
|
|
ecd64f08cd | ||
|
|
f3bffb6aa6 | ||
|
|
33331dee3e | ||
|
|
641525fa74 | ||
|
|
4b82079e33 | ||
|
|
caa55ffa14 | ||
|
|
47ae594921 | ||
|
|
a17b154024 | ||
|
|
02ee678bab | ||
|
|
f6bdbb1b80 | ||
|
|
64e1975cf1 | ||
|
|
993502add0 | ||
|
|
54893d2716 | ||
|
|
84657127b8 | ||
|
|
01a146ba71 | ||
|
|
a30e5b672e | ||
|
|
edb584dc3b | ||
|
|
12a8907c8b | ||
|
|
e0f381a973 | ||
|
|
61d3d133e8 | ||
|
|
0caa522f07 | ||
|
|
948212103c | ||
|
|
ce1a57c2b4 | ||
|
|
922a52bf83 | ||
|
|
8cbb38ee68 | ||
|
|
1c4cf7d771 | ||
|
|
090a1bd84e | ||
|
|
44f6f5d416 | ||
|
|
b88f012880 | ||
|
|
93f434e54b | ||
|
|
92f4a3a404 | ||
|
|
c017a813b0 | ||
|
|
6c6dbfd357 | ||
|
|
1f246637e2 | ||
|
|
1ac17cf859 | ||
|
|
0a3ff41feb | ||
|
|
9738dd2838 | ||
|
|
be0e21d39b | ||
|
|
6a2c2bed0f | ||
|
|
de9c6d4447 | ||
|
|
37a2d9f990 | ||
|
|
0e1fb406b5 | ||
|
|
b72e8fa490 | ||
|
|
f3157e5276 | ||
|
|
e2124ff3c9 | ||
|
|
66cc9d25e7 | ||
|
|
e9cdec95e0 | ||
|
|
63d3a78dda | ||
|
|
ccbe6d4bb8 | ||
|
|
cf8241e79c | ||
|
|
61d3fe9055 | ||
|
|
bded1edb2b | ||
|
|
4d27828712 | ||
|
|
0f6f52c37a | ||
|
|
c1cf6f61b9 | ||
|
|
7c22016b81 | ||
|
|
31f42d44af | ||
|
|
a1cf485ecc | ||
|
|
b7d3cd7990 | ||
|
|
4122e0852a | ||
|
|
41411b0e2e |
14
.idea/codeStyles/Project.xml
generated
14
.idea/codeStyles/Project.xml
generated
@@ -28,6 +28,20 @@
|
|||||||
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
|
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
|
||||||
</JavaCodeStyleSettings>
|
</JavaCodeStyleSettings>
|
||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
|
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||||
|
<value />
|
||||||
|
</option>
|
||||||
|
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||||
|
<value>
|
||||||
|
<package name="" alias="false" withSubpackages="true" />
|
||||||
|
<package name="java" alias="false" withSubpackages="true" />
|
||||||
|
<package name="javax" alias="false" withSubpackages="true" />
|
||||||
|
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||||
|
<package name="" alias="true" withSubpackages="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
|
||||||
|
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
|
||||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
</JetCodeStyleSettings>
|
</JetCodeStyleSettings>
|
||||||
<XML>
|
<XML>
|
||||||
|
|||||||
3
.idea/runConfigurations/All_tests.xml
generated
3
.idea/runConfigurations/All_tests.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="All tests" type="AndroidJUnit" factoryName="Android JUnit">
|
<configuration default="false" name="All tests" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
<module name="briar-android" />
|
<module name="briar.briar-android" />
|
||||||
<option name="PACKAGE_NAME" value="" />
|
<option name="PACKAGE_NAME" value="" />
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in bramble-core" run_configuration_type="AndroidJUnit" />
|
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in bramble-core" run_configuration_type="AndroidJUnit" />
|
||||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in bramble-android" run_configuration_type="AndroidJUnit" />
|
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in bramble-android" run_configuration_type="AndroidJUnit" />
|
||||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in bramble-java" run_configuration_type="AndroidJUnit" />
|
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in bramble-java" run_configuration_type="AndroidJUnit" />
|
||||||
|
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in briar-api" run_configuration_type="AndroidJUnit" />
|
||||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in briar-core" run_configuration_type="AndroidJUnit" />
|
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in briar-core" run_configuration_type="AndroidJUnit" />
|
||||||
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in briar-headless" run_configuration_type="AndroidJUnit" />
|
<option name="RunConfigurationTask" enabled="true" run_configuration_name="All tests in briar-headless" run_configuration_type="AndroidJUnit" />
|
||||||
</method>
|
</method>
|
||||||
|
|||||||
@@ -1,20 +1,14 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="All tests in bramble-android" type="AndroidJUnit" factoryName="Android JUnit">
|
<configuration default="false" name="All tests in bramble-android" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
<module name="bramble-android" />
|
<module name="briar.bramble-android" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
<option name="PACKAGE_NAME" value="" />
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
<option name="PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-android" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-android" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<method v="2">
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
<value defaultName="singleModule" />
|
</method>
|
||||||
</option>
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
14
.idea/runConfigurations/All_tests_in_bramble_api.xml
generated
14
.idea/runConfigurations/All_tests_in_bramble_api.xml
generated
@@ -1,20 +1,14 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="All tests in bramble-api" type="AndroidJUnit" factoryName="Android JUnit">
|
<configuration default="false" name="All tests in bramble-api" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
<module name="bramble-api" />
|
<module name="briar.bramble-api" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
<option name="PACKAGE_NAME" value="" />
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
<option name="PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-api" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-api" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<method v="2">
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
<value defaultName="singleModule" />
|
</method>
|
||||||
</option>
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
@@ -1,20 +1,14 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="All tests in bramble-core" type="AndroidJUnit" factoryName="Android JUnit">
|
<configuration default="false" name="All tests in bramble-core" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
<module name="bramble-core" />
|
<module name="briar.bramble-core" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
<option name="PACKAGE_NAME" value="" />
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
<option name="PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-core" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-core" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<method v="2">
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
<value defaultName="singleModule" />
|
</method>
|
||||||
</option>
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="All tests in bramble-java" type="AndroidJUnit" factoryName="Android JUnit">
|
<configuration default="false" name="All tests in bramble-java" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
<module name="bramble-java" />
|
<module name="briar.bramble-java" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
<option name="PACKAGE_NAME" value="" />
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
@@ -10,11 +8,8 @@
|
|||||||
<option name="VM_PARAMETERS" value="-ea -Djava.library.path=libs" />
|
<option name="VM_PARAMETERS" value="-ea -Djava.library.path=libs" />
|
||||||
<option name="PARAMETERS" value="" />
|
<option name="PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-java" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bramble-java" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<method v="2">
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
<value defaultName="singleModule" />
|
</method>
|
||||||
</option>
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
@@ -1,20 +1,14 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="All tests in briar-android" type="AndroidJUnit" factoryName="Android JUnit">
|
<configuration default="false" name="All tests in briar-android" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
<module name="briar-android" />
|
<module name="briar.briar-android" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
<option name="PACKAGE_NAME" value="" />
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
<option name="PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/briar-android" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/briar-android" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<method v="2">
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
<value defaultName="singleModule" />
|
</method>
|
||||||
</option>
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
14
.idea/runConfigurations/All_tests_in_briar_api.xml
generated
Normal file
14
.idea/runConfigurations/All_tests_in_briar_api.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="All tests in briar-api" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
|
<module name="briar.briar-api" />
|
||||||
|
<option name="PACKAGE_NAME" value="" />
|
||||||
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
|
<option name="METHOD_NAME" value="" />
|
||||||
|
<option name="TEST_OBJECT" value="package" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/briar-api" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
14
.idea/runConfigurations/All_tests_in_briar_core.xml
generated
14
.idea/runConfigurations/All_tests_in_briar_core.xml
generated
@@ -1,20 +1,14 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="All tests in briar-core" type="AndroidJUnit" factoryName="Android JUnit">
|
<configuration default="false" name="All tests in briar-core" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
<module name="briar-core" />
|
<module name="briar.briar-core" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="" />
|
<option name="PACKAGE_NAME" value="" />
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
<option name="PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/briar-core" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/briar-core" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<method v="2">
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
<value defaultName="singleModule" />
|
</method>
|
||||||
</option>
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="All tests in briar-headless" type="AndroidJUnit" factoryName="Android JUnit">
|
<configuration default="false" name="All tests in briar-headless" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
<module name="briar-headless" />
|
<module name="briar.briar-headless" />
|
||||||
<option name="PACKAGE_NAME" value="org.briarproject.briar.headless" />
|
<option name="PACKAGE_NAME" value="org.briarproject.briar.headless" />
|
||||||
<option name="MAIN_CLASS_NAME" value="" />
|
<option name="MAIN_CLASS_NAME" value="" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
|
|||||||
24
.idea/runConfigurations/BridgeTest.xml
generated
Normal file
24
.idea/runConfigurations/BridgeTest.xml
generated
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="BridgeTest" type="AndroidJUnit" factoryName="Android JUnit" nameIsGenerated="true">
|
||||||
|
<module name="briar.bramble-java" />
|
||||||
|
<useClassPathOnly />
|
||||||
|
<extension name="coverage">
|
||||||
|
<pattern>
|
||||||
|
<option name="PATTERN" value="org.briarproject.bramble.plugin.tor.*" />
|
||||||
|
<option name="ENABLED" value="true" />
|
||||||
|
</pattern>
|
||||||
|
</extension>
|
||||||
|
<option name="PACKAGE_NAME" value="org.briarproject.bramble.plugin.tor" />
|
||||||
|
<option name="MAIN_CLASS_NAME" value="org.briarproject.bramble.plugin.tor.BridgeTest" />
|
||||||
|
<option name="METHOD_NAME" value="" />
|
||||||
|
<option name="TEST_OBJECT" value="class" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
|
||||||
|
<envs>
|
||||||
|
<env name="OPTIONAL_TESTS" value="org.briarproject.bramble.plugin.tor.BridgeTest" />
|
||||||
|
</envs>
|
||||||
|
<method v="2">
|
||||||
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
14
.idea/runConfigurations/H2_Performance_Test.xml
generated
14
.idea/runConfigurations/H2_Performance_Test.xml
generated
@@ -1,20 +1,14 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="H2 Performance Test" type="AndroidJUnit" factoryName="Android JUnit">
|
<configuration default="false" name="H2 Performance Test" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
<module name="bramble-core" />
|
<module name="briar.bramble-core" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="org.briarproject.bramble.db" />
|
<option name="PACKAGE_NAME" value="org.briarproject.bramble.db" />
|
||||||
<option name="MAIN_CLASS_NAME" value="org.briarproject.bramble.db.H2DatabasePerformanceTest" />
|
<option name="MAIN_CLASS_NAME" value="org.briarproject.bramble.db.H2DatabasePerformanceTest" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
<option name="TEST_OBJECT" value="class" />
|
<option name="TEST_OBJECT" value="class" />
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
<option name="PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="" />
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<method v="2">
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
<value defaultName="singleModule" />
|
</method>
|
||||||
</option>
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
@@ -1,20 +1,14 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="HyperSQL Performance Test" type="AndroidJUnit" factoryName="Android JUnit">
|
<configuration default="false" name="HyperSQL Performance Test" type="AndroidJUnit" factoryName="Android JUnit">
|
||||||
<module name="bramble-core" />
|
<module name="briar.bramble-core" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH" />
|
|
||||||
<option name="PACKAGE_NAME" value="org.briarproject.bramble.db" />
|
<option name="PACKAGE_NAME" value="org.briarproject.bramble.db" />
|
||||||
<option name="MAIN_CLASS_NAME" value="org.briarproject.bramble.db.HyperSqlDatabasePerformanceTest" />
|
<option name="MAIN_CLASS_NAME" value="org.briarproject.bramble.db.HyperSqlDatabasePerformanceTest" />
|
||||||
<option name="METHOD_NAME" value="" />
|
<option name="METHOD_NAME" value="" />
|
||||||
<option name="TEST_OBJECT" value="class" />
|
<option name="TEST_OBJECT" value="class" />
|
||||||
<option name="VM_PARAMETERS" value="-ea" />
|
|
||||||
<option name="PARAMETERS" value="" />
|
<option name="PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="" />
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<method v="2">
|
||||||
<option name="TEST_SEARCH_SCOPE">
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
<value defaultName="singleModule" />
|
</method>
|
||||||
</option>
|
|
||||||
<patterns />
|
|
||||||
<method />
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
9
.idea/runConfigurations/briar_headless.xml
generated
9
.idea/runConfigurations/briar_headless.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="briar-headless" type="JetRunConfigurationType" factoryName="Kotlin" singleton="true">
|
<configuration default="false" name="briar-headless" type="JetRunConfigurationType" singleton="true">
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
<module name="briar.briar-headless" />
|
||||||
<option name="VM_PARAMETERS" value="" />
|
<option name="VM_PARAMETERS" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="-v" />
|
<option name="PROGRAM_PARAMETERS" value="-v" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||||
@@ -8,9 +8,8 @@
|
|||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<option name="PASS_PARENT_ENVS" value="true" />
|
||||||
<option name="MAIN_CLASS_NAME" value="org.briarproject.briar.headless.MainKt" />
|
<option name="MAIN_CLASS_NAME" value="org.briarproject.briar.headless.MainKt" />
|
||||||
<option name="WORKING_DIRECTORY" value="" />
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
<module name="briar-headless" />
|
<method v="2">
|
||||||
<envs />
|
<option name="Make" enabled="true" />
|
||||||
<method>
|
|
||||||
<option name="Gradle.BeforeRunTask" enabled="true" tasks="jar" externalProjectPath="$PROJECT_DIR$/briar-headless" vmOptions="" scriptParameters="" />
|
<option name="Gradle.BeforeRunTask" enabled="true" tasks="jar" externalProjectPath="$PROJECT_DIR$/briar-headless" vmOptions="" scriptParameters="" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
1
bramble-android/.gitignore
vendored
1
bramble-android/.gitignore
vendored
@@ -3,3 +3,4 @@ gen
|
|||||||
build
|
build
|
||||||
.settings
|
.settings
|
||||||
src/main/res/raw/*.zip
|
src/main/res/raw/*.zip
|
||||||
|
src/main/jniLibs
|
||||||
@@ -5,14 +5,14 @@ apply plugin: 'witness'
|
|||||||
apply from: 'witness.gradle'
|
apply from: 'witness.gradle'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion 30
|
||||||
buildToolsVersion '29.0.2'
|
buildToolsVersion '30.0.2'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 28
|
targetSdkVersion 29
|
||||||
versionCode 10210
|
versionCode 10214
|
||||||
versionName "1.2.10"
|
versionName "1.2.14"
|
||||||
consumerProguardFiles 'proguard-rules.txt'
|
consumerProguardFiles 'proguard-rules.txt'
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
@@ -38,7 +38,7 @@ configurations {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(path: ':bramble-core', configuration: 'default')
|
implementation project(path: ':bramble-core', configuration: 'default')
|
||||||
tor 'org.briarproject:tor-android:0.3.5.10@zip'
|
tor 'org.briarproject:tor-android:0.3.5.12@zip'
|
||||||
tor 'org.briarproject:obfs4proxy-android:0.0.11-2@zip'
|
tor 'org.briarproject:obfs4proxy-android:0.0.11-2@zip'
|
||||||
|
|
||||||
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
|
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
|
||||||
@@ -53,10 +53,12 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def torBinariesDir = 'src/main/res/raw'
|
def torBinariesDir = 'src/main/res/raw'
|
||||||
|
def torLibsDir = 'src/main/jniLibs'
|
||||||
|
|
||||||
task cleanTorBinaries {
|
task cleanTorBinaries {
|
||||||
doLast {
|
doLast {
|
||||||
delete fileTree(torBinariesDir) { include '*.zip' }
|
delete fileTree(torBinariesDir) { include '*.zip' }
|
||||||
|
delete fileTree(torLibsDir) { include '**/*.so' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +69,36 @@ task unpackTorBinaries {
|
|||||||
copy {
|
copy {
|
||||||
from configurations.tor.collect { zipTree(it) }
|
from configurations.tor.collect { zipTree(it) }
|
||||||
into torBinariesDir
|
into torBinariesDir
|
||||||
// TODO: Remove after next Tor upgrade, which won't include non-PIE binaries
|
include 'geoip.zip'
|
||||||
include 'geoip.zip', '*_pie.zip'
|
}
|
||||||
|
configurations.tor.each { outer ->
|
||||||
|
zipTree(outer).each { inner ->
|
||||||
|
if (inner.name.endsWith('_arm_pie.zip')) {
|
||||||
|
copy {
|
||||||
|
from zipTree(inner)
|
||||||
|
into torLibsDir
|
||||||
|
rename '(.*)', 'armeabi-v7a/lib$1.so'
|
||||||
|
}
|
||||||
|
} else if (inner.name.endsWith('_arm64_pie.zip')) {
|
||||||
|
copy {
|
||||||
|
from zipTree(inner)
|
||||||
|
into torLibsDir
|
||||||
|
rename '(.*)', 'arm64-v8a/lib$1.so'
|
||||||
|
}
|
||||||
|
} else if (inner.name.endsWith('_x86_pie.zip')) {
|
||||||
|
copy {
|
||||||
|
from zipTree(inner)
|
||||||
|
into torLibsDir
|
||||||
|
rename '(.*)', 'x86/lib$1.so'
|
||||||
|
}
|
||||||
|
} else if (inner.name.endsWith('_x86_64_pie.zip')) {
|
||||||
|
copy {
|
||||||
|
from zipTree(inner)
|
||||||
|
into torLibsDir
|
||||||
|
rename '(.*)', 'x86_64/lib$1.so'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependsOn cleanTorBinaries
|
dependsOn cleanTorBinaries
|
||||||
@@ -76,5 +106,6 @@ task unpackTorBinaries {
|
|||||||
|
|
||||||
tasks.withType(MergeResources) {
|
tasks.withType(MergeResources) {
|
||||||
inputs.dir torBinariesDir
|
inputs.dir torBinariesDir
|
||||||
|
inputs.dir torLibsDir
|
||||||
dependsOn unpackTorBinaries
|
dependsOn unpackTorBinaries
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package org.briarproject.bramble.network;
|
package org.briarproject.bramble.network;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.LinkAddress;
|
||||||
|
import android.net.LinkProperties;
|
||||||
|
import android.net.Network;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.event.EventBus;
|
import org.briarproject.bramble.api.event.EventBus;
|
||||||
@@ -19,6 +23,11 @@ import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
|||||||
import org.briarproject.bramble.api.system.TaskScheduler;
|
import org.briarproject.bramble.api.system.TaskScheduler;
|
||||||
import org.briarproject.bramble.api.system.TaskScheduler.Cancellable;
|
import org.briarproject.bramble.api.system.TaskScheduler.Cancellable;
|
||||||
|
|
||||||
|
import java.net.Inet4Address;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
|
import java.net.SocketException;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
@@ -36,16 +45,22 @@ import static android.net.ConnectivityManager.TYPE_WIFI;
|
|||||||
import static android.net.wifi.p2p.WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION;
|
import static android.net.wifi.p2p.WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION;
|
||||||
import static android.os.Build.VERSION.SDK_INT;
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
import static android.os.PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED;
|
import static android.os.PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED;
|
||||||
|
import static java.net.NetworkInterface.getNetworkInterfaces;
|
||||||
|
import static java.util.Collections.list;
|
||||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static java.util.logging.Level.WARNING;
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
|
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
|
||||||
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@ParametersNotNullByDefault
|
@ParametersNotNullByDefault
|
||||||
class AndroidNetworkManager implements NetworkManager, Service {
|
class AndroidNetworkManager implements NetworkManager, Service {
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(AndroidNetworkManager.class.getName());
|
getLogger(AndroidNetworkManager.class.getName());
|
||||||
|
|
||||||
// See android.net.wifi.WifiManager
|
// See android.net.wifi.WifiManager
|
||||||
private static final String WIFI_AP_STATE_CHANGED_ACTION =
|
private static final String WIFI_AP_STATE_CHANGED_ACTION =
|
||||||
@@ -54,7 +69,8 @@ class AndroidNetworkManager implements NetworkManager, Service {
|
|||||||
private final TaskScheduler scheduler;
|
private final TaskScheduler scheduler;
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final Executor eventExecutor;
|
private final Executor eventExecutor;
|
||||||
private final Context appContext;
|
private final Application app;
|
||||||
|
private final ConnectivityManager connectivityManager;
|
||||||
private final AtomicReference<Cancellable> connectivityCheck =
|
private final AtomicReference<Cancellable> connectivityCheck =
|
||||||
new AtomicReference<>();
|
new AtomicReference<>();
|
||||||
private final AtomicBoolean used = new AtomicBoolean(false);
|
private final AtomicBoolean used = new AtomicBoolean(false);
|
||||||
@@ -67,7 +83,9 @@ class AndroidNetworkManager implements NetworkManager, Service {
|
|||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.eventExecutor = eventExecutor;
|
this.eventExecutor = eventExecutor;
|
||||||
this.appContext = app.getApplicationContext();
|
this.app = app;
|
||||||
|
connectivityManager = (ConnectivityManager)
|
||||||
|
requireNonNull(app.getSystemService(CONNECTIVITY_SERVICE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,24 +100,82 @@ class AndroidNetworkManager implements NetworkManager, Service {
|
|||||||
filter.addAction(WIFI_AP_STATE_CHANGED_ACTION);
|
filter.addAction(WIFI_AP_STATE_CHANGED_ACTION);
|
||||||
filter.addAction(WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
|
filter.addAction(WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
|
||||||
if (SDK_INT >= 23) filter.addAction(ACTION_DEVICE_IDLE_MODE_CHANGED);
|
if (SDK_INT >= 23) filter.addAction(ACTION_DEVICE_IDLE_MODE_CHANGED);
|
||||||
appContext.registerReceiver(networkStateReceiver, filter);
|
app.registerReceiver(networkStateReceiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopService() {
|
public void stopService() {
|
||||||
if (networkStateReceiver != null)
|
if (networkStateReceiver != null)
|
||||||
appContext.unregisterReceiver(networkStateReceiver);
|
app.unregisterReceiver(networkStateReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkStatus getNetworkStatus() {
|
public NetworkStatus getNetworkStatus() {
|
||||||
ConnectivityManager cm = (ConnectivityManager)
|
NetworkInfo net = connectivityManager.getActiveNetworkInfo();
|
||||||
appContext.getSystemService(CONNECTIVITY_SERVICE);
|
|
||||||
if (cm == null) throw new AssertionError();
|
|
||||||
NetworkInfo net = cm.getActiveNetworkInfo();
|
|
||||||
boolean connected = net != null && net.isConnected();
|
boolean connected = net != null && net.isConnected();
|
||||||
boolean wifi = connected && net.getType() == TYPE_WIFI;
|
boolean wifi = false, ipv6Only = false;
|
||||||
return new NetworkStatus(connected, wifi);
|
if (connected) {
|
||||||
|
wifi = net.getType() == TYPE_WIFI;
|
||||||
|
if (SDK_INT >= 23) ipv6Only = isActiveNetworkIpv6Only();
|
||||||
|
else ipv6Only = areAllAvailableNetworksIpv6Only();
|
||||||
|
}
|
||||||
|
return new NetworkStatus(connected, wifi, ipv6Only);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the
|
||||||
|
* {@link ConnectivityManager#getActiveNetwork() active network} has an
|
||||||
|
* IPv6 unicast address and no IPv4 addresses. The active network is
|
||||||
|
* assumed not to be a loopback interface.
|
||||||
|
*/
|
||||||
|
@TargetApi(23)
|
||||||
|
private boolean isActiveNetworkIpv6Only() {
|
||||||
|
Network net = connectivityManager.getActiveNetwork();
|
||||||
|
if (net == null) {
|
||||||
|
LOG.info("No active network");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LinkProperties props = connectivityManager.getLinkProperties(net);
|
||||||
|
if (props == null) {
|
||||||
|
LOG.info("No link properties for active network");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean hasIpv6Unicast = false;
|
||||||
|
for (LinkAddress linkAddress : props.getLinkAddresses()) {
|
||||||
|
InetAddress addr = linkAddress.getAddress();
|
||||||
|
if (addr instanceof Inet4Address) return false;
|
||||||
|
if (!addr.isMulticastAddress()) hasIpv6Unicast = true;
|
||||||
|
}
|
||||||
|
return hasIpv6Unicast;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the device has at least one network interface with an
|
||||||
|
* IPv6 unicast address and no interfaces with IPv4 addresses, excluding
|
||||||
|
* loopback interfaces and interfaces that are
|
||||||
|
* {@link NetworkInterface#isUp() down}. If this method returns true and
|
||||||
|
* the device has internet access then it's via IPv6 only.
|
||||||
|
*/
|
||||||
|
private boolean areAllAvailableNetworksIpv6Only() {
|
||||||
|
try {
|
||||||
|
Enumeration<NetworkInterface> interfaces = getNetworkInterfaces();
|
||||||
|
if (interfaces == null) {
|
||||||
|
LOG.info("No network interfaces");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean hasIpv6Unicast = false;
|
||||||
|
for (NetworkInterface i : list(interfaces)) {
|
||||||
|
if (i.isLoopback() || !i.isUp()) continue;
|
||||||
|
for (InetAddress addr : list(i.getInetAddresses())) {
|
||||||
|
if (addr instanceof Inet4Address) return false;
|
||||||
|
if (!addr.isMulticastAddress()) hasIpv6Unicast = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hasIpv6Unicast;
|
||||||
|
} catch (SocketException e) {
|
||||||
|
logException(LOG, WARNING, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateConnectionStatus() {
|
private void updateConnectionStatus() {
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ class AndroidBluetoothPlugin
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
String getBluetoothAddress() {
|
String getBluetoothAddress() {
|
||||||
|
if (adapter == null) return null;
|
||||||
String address = AndroidUtils.getBluetoothAddress(app, adapter);
|
String address = AndroidUtils.getBluetoothAddress(app, adapter);
|
||||||
return address.isEmpty() ? null : address;
|
return address.isEmpty() ? null : address;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,19 +16,42 @@ import org.briarproject.bramble.api.system.AndroidWakeLockManager;
|
|||||||
import org.briarproject.bramble.api.system.Clock;
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.api.system.LocationUtils;
|
import org.briarproject.bramble.api.system.LocationUtils;
|
||||||
import org.briarproject.bramble.api.system.ResourceProvider;
|
import org.briarproject.bramble.api.system.ResourceProvider;
|
||||||
|
import org.briarproject.bramble.util.AndroidUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import javax.net.SocketFactory;
|
import javax.net.SocketFactory;
|
||||||
|
|
||||||
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@ParametersNotNullByDefault
|
@ParametersNotNullByDefault
|
||||||
class AndroidTorPlugin extends TorPlugin {
|
class AndroidTorPlugin extends TorPlugin {
|
||||||
|
|
||||||
|
private static final List<String> LIBRARY_ARCHITECTURES =
|
||||||
|
asList("armeabi-v7a", "arm64-v8a", "x86", "x86_64");
|
||||||
|
|
||||||
|
private static final String TOR_LIB_NAME = "libtor.so";
|
||||||
|
private static final String OBFS4_LIB_NAME = "libobfs4proxy.so";
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
getLogger(AndroidTorPlugin.class.getName());
|
||||||
|
|
||||||
private final Application app;
|
private final Application app;
|
||||||
private final AndroidWakeLock wakeLock;
|
private final AndroidWakeLock wakeLock;
|
||||||
|
private final File torLib, obfs4Lib;
|
||||||
|
|
||||||
AndroidTorPlugin(Executor ioExecutor,
|
AndroidTorPlugin(Executor ioExecutor,
|
||||||
Executor wakefulIoExecutor,
|
Executor wakefulIoExecutor,
|
||||||
@@ -55,6 +78,9 @@ class AndroidTorPlugin extends TorPlugin {
|
|||||||
maxIdleTime, torDirectory);
|
maxIdleTime, torDirectory);
|
||||||
this.app = app;
|
this.app = app;
|
||||||
wakeLock = wakeLockManager.createWakeLock("TorPlugin");
|
wakeLock = wakeLockManager.createWakeLock("TorPlugin");
|
||||||
|
String nativeLibDir = app.getApplicationInfo().nativeLibraryDir;
|
||||||
|
torLib = new File(nativeLibDir, TOR_LIB_NAME);
|
||||||
|
obfs4Lib = new File(nativeLibDir, OBFS4_LIB_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,4 +111,112 @@ class AndroidTorPlugin extends TorPlugin {
|
|||||||
super.stop();
|
super.stop();
|
||||||
wakeLock.release();
|
wakeLock.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected File getTorExecutableFile() {
|
||||||
|
return torLib.exists() ? torLib : super.getTorExecutableFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected File getObfs4ExecutableFile() {
|
||||||
|
return obfs4Lib.exists() ? obfs4Lib : super.getObfs4ExecutableFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installTorExecutable() throws IOException {
|
||||||
|
File extracted = super.getTorExecutableFile();
|
||||||
|
if (torLib.exists()) {
|
||||||
|
// If an older version left behind a Tor binary, delete it
|
||||||
|
if (extracted.exists()) {
|
||||||
|
if (extracted.delete()) LOG.info("Deleted Tor binary");
|
||||||
|
else LOG.info("Failed to delete Tor binary");
|
||||||
|
}
|
||||||
|
} else if (SDK_INT < 29) {
|
||||||
|
// The binary wasn't extracted at install time. Try to extract it
|
||||||
|
extractLibraryFromApk(TOR_LIB_NAME, extracted);
|
||||||
|
} else {
|
||||||
|
// No point extracting the binary, we won't be allowed to execute it
|
||||||
|
throw new FileNotFoundException(torLib.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installObfs4Executable() throws IOException {
|
||||||
|
File extracted = super.getObfs4ExecutableFile();
|
||||||
|
if (obfs4Lib.exists()) {
|
||||||
|
// If an older version left behind an obfs4 binary, delete it
|
||||||
|
if (extracted.exists()) {
|
||||||
|
if (extracted.delete()) LOG.info("Deleted obfs4 binary");
|
||||||
|
else LOG.info("Failed to delete obfs4 binary");
|
||||||
|
}
|
||||||
|
} else if (SDK_INT < 29) {
|
||||||
|
// The binary wasn't extracted at install time. Try to extract it
|
||||||
|
extractLibraryFromApk(OBFS4_LIB_NAME, extracted);
|
||||||
|
} else {
|
||||||
|
// No point extracting the binary, we won't be allowed to execute it
|
||||||
|
throw new FileNotFoundException(obfs4Lib.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void extractLibraryFromApk(String libName, File dest)
|
||||||
|
throws IOException {
|
||||||
|
File sourceDir = new File(app.getApplicationInfo().sourceDir);
|
||||||
|
if (sourceDir.isFile()) {
|
||||||
|
// Look for other APK files in the same directory, if we're allowed
|
||||||
|
File parent = sourceDir.getParentFile();
|
||||||
|
if (parent != null) sourceDir = parent;
|
||||||
|
}
|
||||||
|
List<String> libPaths = getSupportedLibraryPaths(libName);
|
||||||
|
for (File apk : findApkFiles(sourceDir)) {
|
||||||
|
ZipInputStream zin = new ZipInputStream(new FileInputStream(apk));
|
||||||
|
for (ZipEntry e = zin.getNextEntry(); e != null;
|
||||||
|
e = zin.getNextEntry()) {
|
||||||
|
if (libPaths.contains(e.getName())) {
|
||||||
|
if (LOG.isLoggable(INFO)) {
|
||||||
|
LOG.info("Extracting " + e.getName()
|
||||||
|
+ " from " + apk.getAbsolutePath());
|
||||||
|
}
|
||||||
|
extract(zin, dest); // Zip input stream will be closed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zin.close();
|
||||||
|
}
|
||||||
|
throw new FileNotFoundException(libName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all files with the extension .apk or .APK under the given root.
|
||||||
|
*/
|
||||||
|
private List<File> findApkFiles(File root) {
|
||||||
|
List<File> files = new ArrayList<>();
|
||||||
|
findApkFiles(root, files);
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findApkFiles(File f, List<File> files) {
|
||||||
|
if (f.isFile() && f.getName().toLowerCase().endsWith(".apk")) {
|
||||||
|
files.add(f);
|
||||||
|
} else if (f.isDirectory()) {
|
||||||
|
File[] children = f.listFiles();
|
||||||
|
if (children != null) {
|
||||||
|
for (File child : children) findApkFiles(child, files);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the paths at which libraries with the given name would be found
|
||||||
|
* inside an APK file, for all architectures supported by the device, in
|
||||||
|
* order of preference.
|
||||||
|
*/
|
||||||
|
private List<String> getSupportedLibraryPaths(String libName) {
|
||||||
|
List<String> architectures = new ArrayList<>();
|
||||||
|
for (String abi : AndroidUtils.getSupportedArchitectures()) {
|
||||||
|
if (LIBRARY_ARCHITECTURES.contains(abi)) {
|
||||||
|
architectures.add("lib/" + abi + "/" + libName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return architectures;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import android.bluetooth.BluetoothAdapter;
|
|||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.wifi.WifiConfiguration;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.StrictMode;
|
import android.os.StrictMode;
|
||||||
@@ -17,12 +15,10 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|||||||
|
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static android.content.Context.WIFI_SERVICE;
|
|
||||||
import static android.os.Build.VERSION.SDK_INT;
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
import static android.provider.Settings.Secure.ANDROID_ID;
|
import static android.provider.Settings.Secure.ANDROID_ID;
|
||||||
|
|
||||||
@@ -52,15 +48,6 @@ class AndroidSecureRandomProvider extends UnixSecureRandomProvider {
|
|||||||
String id = Settings.Secure.getString(contentResolver, ANDROID_ID);
|
String id = Settings.Secure.getString(contentResolver, ANDROID_ID);
|
||||||
if (id != null) out.writeUTF(id);
|
if (id != null) out.writeUTF(id);
|
||||||
Parcel parcel = Parcel.obtain();
|
Parcel parcel = Parcel.obtain();
|
||||||
WifiManager wm = (WifiManager) appContext.getApplicationContext()
|
|
||||||
.getSystemService(WIFI_SERVICE);
|
|
||||||
if (wm != null) {
|
|
||||||
List<WifiConfiguration> configs = wm.getConfiguredNetworks();
|
|
||||||
if (configs != null) {
|
|
||||||
for (WifiConfiguration config : configs)
|
|
||||||
parcel.writeParcelable(config, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter();
|
||||||
if (bt != null) {
|
if (bt != null) {
|
||||||
for (BluetoothDevice device : bt.getBondedDevices())
|
for (BluetoothDevice device : bt.getBondedDevices())
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.briarproject.bramble.system;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
|
||||||
@@ -106,14 +105,21 @@ class AndroidWakeLockManagerImpl implements AndroidWakeLockManager {
|
|||||||
|
|
||||||
private String getWakeLockTag(Context ctx) {
|
private String getWakeLockTag(Context ctx) {
|
||||||
PackageManager pm = ctx.getPackageManager();
|
PackageManager pm = ctx.getPackageManager();
|
||||||
for (PackageInfo info : pm.getInstalledPackages(0)) {
|
if (isInstalled(pm, "com.huawei.powergenie")) {
|
||||||
String name = info.packageName.toLowerCase();
|
return "LocationManagerService";
|
||||||
if (name.startsWith("com.huawei.powergenie")) {
|
} else if (isInstalled(pm, "com.evenwell.PowerMonitor")) {
|
||||||
return "LocationManagerService";
|
return "AudioIn";
|
||||||
} else if (name.startsWith("com.evenwell.powermonitor")) {
|
|
||||||
return "AudioIn";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ctx.getPackageName();
|
return ctx.getPackageName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isInstalled(PackageManager pm, String packageName) {
|
||||||
|
try {
|
||||||
|
pm.getPackageInfo(packageName, 0);
|
||||||
|
return true;
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,36 @@
|
|||||||
dependencyVerification {
|
dependencyVerification {
|
||||||
verify = [
|
verify = [
|
||||||
'cglib:cglib:3.2.0:cglib-3.2.0.jar:adb13bab79712ad6bdf1bd59f2a3918018a8016e722e8a357065afb9e6690861',
|
'cglib:cglib:3.2.0:cglib-3.2.0.jar:adb13bab79712ad6bdf1bd59f2a3918018a8016e722e8a357065afb9e6690861',
|
||||||
'com.android.tools.analytics-library:protos:26.5.1:protos-26.5.1.jar:8dde1130725461fe827f2a343d353f2b51e8870661fc860d7d5ebddb097ead4e',
|
'com.android.tools.analytics-library:protos:27.1.1:protos-27.1.1.jar:13f77e73762e58ab372d140b3a6be6903aea9775b62dd14fbc62d4cc7069c9a4',
|
||||||
'com.android.tools.analytics-library:shared:26.5.1:shared-26.5.1.jar:ccc2f3b00ec17b11401610ba68553544fc8fc517120e84439ac6eb86b875e18d',
|
'com.android.tools.analytics-library:shared:27.1.1:shared-27.1.1.jar:82930a52001410e97d809930b670f4de3002286975f046b9de5f6b777b06d366',
|
||||||
'com.android.tools.analytics-library:tracker:26.5.1:tracker-26.5.1.jar:3a76984c0fe2e847ca7a8b35b4780ef0447a9d1666946cb8e60466318e0ab5ae',
|
'com.android.tools.analytics-library:tracker:27.1.1:tracker-27.1.1.jar:31bc5a00be0055bac89c9b2f34751883e987cd89e3ac1783720645c164f591d9',
|
||||||
'com.android.tools.build:aapt2-proto:0.4.0:aapt2-proto-0.4.0.jar:fac0435e08898f89eeeb9ca236bea707155ff816c12205ced285ad53604133ca',
|
'com.android.tools.build:aapt2-proto:4.1.0-alpha01-6193524:aapt2-proto-4.1.0-alpha01-6193524.jar:17e75523e1e92dd4f222c7368ee41df9e964a508232f591e265d0c499baf9dca',
|
||||||
'com.android.tools.build:apksig:3.5.1:apksig-3.5.1.jar:1fd33e7f009a2a0da766cfeec4211a09f548034b015c289a66d75dd8a9302f4a',
|
'com.android.tools.build:apksig:4.1.1:apksig-4.1.1.jar:e0a69da9e5a03986d608b45bbf954ef0e6a0b3f58c1b8315bd169ec08b279e72',
|
||||||
'com.android.tools.build:apkzlib:3.5.1:apkzlib-3.5.1.jar:9f330167cbe973b7db407692f74f4f6453b7ffa5f2048934b06280c2ceee60fa',
|
'com.android.tools.build:apkzlib:4.1.1:apkzlib-4.1.1.jar:ba4b5e419b6be0130eae7f8301c3a551ad3976f487d2e0c6852ebb175ac41127',
|
||||||
'com.android.tools.build:builder-model:3.5.1:builder-model-3.5.1.jar:39ea3c82b76b6e0c9f9fa88d93e0edc1dd4a0f1dfae0ef6fbf2d451da47e5450',
|
'com.android.tools.build:builder-model:4.1.1:builder-model-4.1.1.jar:e95c99cc298ad67b8deb6ced99c51abc8f59afebedad044b1a10dde14646a4dd',
|
||||||
'com.android.tools.build:builder-test-api:3.5.1:builder-test-api-3.5.1.jar:a1b59305584cbcaa078fdc9cfb80871012755b822dd32e8da19add6f7bbcb762',
|
'com.android.tools.build:builder-test-api:4.1.1:builder-test-api-4.1.1.jar:464f596ab261c051c3847406748e843770dea123f6fa5fee8a9390644e709b7a',
|
||||||
'com.android.tools.build:builder:3.5.1:builder-3.5.1.jar:e3a8d382434c5f60990730c4719fc814e85a898a33a1e96c1df8d627d3c6eea6',
|
'com.android.tools.build:builder:4.1.1:builder-4.1.1.jar:0f78d4759d2f7b57b95865522ec34596ba419b9982f3b25e3449213f9c98b80d',
|
||||||
'com.android.tools.build:gradle-api:3.5.1:gradle-api-3.5.1.jar:be9b41859bace11998f66b04ed944f87e413f3ad6da3c4665587699da125addc',
|
'com.android.tools.build:gradle-api:4.1.1:gradle-api-4.1.1.jar:d42e6b539e4c1353ad3546e75ec8ce11a017b97481023e8ea18577eefe374358',
|
||||||
'com.android.tools.build:manifest-merger:26.5.1:manifest-merger-26.5.1.jar:dcad9ecb967251f4d750f55a4204a2b400e8fbfe5cb930a1d0d5dbe10ae8bdfc',
|
'com.android.tools.build:manifest-merger:27.1.1:manifest-merger-27.1.1.jar:7a45fa143687859bb2e5a961dcf6ee88094d3853de0cb543dc03dbcb0f4b554b',
|
||||||
'com.android.tools.ddms:ddmlib:26.5.1:ddmlib-26.5.1.jar:b081aef2a4ed3f4d47cae4cdb128469735f25a114e026d37123bf9ffdec742a8',
|
'com.android.tools.ddms:ddmlib:27.1.1:ddmlib-27.1.1.jar:da6e4bd834b6a85dae8019039849d8bd96933347dfbf460df74913ddade6e40a',
|
||||||
'com.android.tools.external.com-intellij:intellij-core:26.5.1:intellij-core-26.5.1.jar:20eced30adc124805bd93488d9cd9d3e33e6bf7b48e9fe5a703d4983f894d450',
|
'com.android.tools.external.com-intellij:intellij-core:27.1.1:intellij-core-27.1.1.jar:2591a7363c4443c59bf9f793730acafce9d6ec3076e2f46716edaf53a41b6fb6',
|
||||||
'com.android.tools.external.com-intellij:kotlin-compiler:26.5.1:kotlin-compiler-26.5.1.jar:5aed762dd54875b77ae7018d97c05756ff0c5b9fd02ec595dd396ccd14cc22cb',
|
'com.android.tools.external.com-intellij:kotlin-compiler:27.1.1:kotlin-compiler-27.1.1.jar:5054ae770ba788f110303c65abd6b1fa28eccf52dee1274510e201b2b81885c8',
|
||||||
'com.android.tools.external.org-jetbrains:uast:26.5.1:uast-26.5.1.jar:4bc8653d6c0943f40fee963a149e36c6baa45683d2530968a13f5007e3c40740',
|
'com.android.tools.external.org-jetbrains:uast:27.1.1:uast-27.1.1.jar:54cd8f6886a9d2f5641659dd5c91f626629672cd48301f7f0bd6aad9bd448714',
|
||||||
'com.android.tools.layoutlib:layoutlib-api:26.5.1:layoutlib-api-26.5.1.jar:88732f11396c427273e515d23042e35633f4fe4295528a99b866aa2adf0efd9c',
|
'com.android.tools.layoutlib:layoutlib-api:27.1.1:layoutlib-api-27.1.1.jar:8a9a22e3b309521ea83b724e5a89cfdac6076f52d675c0e17d77b05527bc0f8c',
|
||||||
'com.android.tools.lint:lint-api:26.5.1:lint-api-26.5.1.jar:ec33fcd72bfaf70dd841e03fbfd93f109c2e575aec146067c606689c3972f0de',
|
'com.android.tools.lint:lint-api:27.1.1:lint-api-27.1.1.jar:c1d8176094cb0478786070d40533efb578ebc53529a82f6ef5bee879bdca418b',
|
||||||
'com.android.tools.lint:lint-checks:26.5.1:lint-checks-26.5.1.jar:a1b9607d484aaae7a71dcecdc76f8003d8239af226c776894a2cf63f9e6c60d7',
|
'com.android.tools.lint:lint-checks:27.1.1:lint-checks-27.1.1.jar:3899c91e00bd059b40c31a9ca00cd0f8303191947608735ae1b657323693fb61',
|
||||||
'com.android.tools.lint:lint-gradle-api:26.5.1:lint-gradle-api-26.5.1.jar:82453fd98a8394cc84ed995c04d2cd744abd1d6589403427ba7eef53115406f3',
|
'com.android.tools.lint:lint-gradle-api:27.1.1:lint-gradle-api-27.1.1.jar:26aa89d38b9825cc73229daa82a68875801c8b8491f30497ce62aff1f206eb0d',
|
||||||
'com.android.tools.lint:lint-gradle:26.5.1:lint-gradle-26.5.1.jar:59465b56cf7db77c656d5f8195d721c3d48b6bdd0502d774de335bfe4baff00b',
|
'com.android.tools.lint:lint-gradle:27.1.1:lint-gradle-27.1.1.jar:f7355823ead869f4d28184ba28b7a0c693b507519a2d3705bb9848a0f35b3756',
|
||||||
'com.android.tools.lint:lint:26.5.1:lint-26.5.1.jar:336e4b04ec6f8b0f25879131b7a7862d77df83a1879ee5b71be26128755f8e2e',
|
'com.android.tools.lint:lint-model:27.1.1:lint-model-27.1.1.jar:bc23c0c413bdfca59dac2cd56b870d8360d009e9ec0d365e71f774bcf127971d',
|
||||||
'com.android.tools:annotations:26.5.1:annotations-26.5.1.jar:2c43c82f8c59d8f7a61e3239e1a2dc9f69dc342ec09af9b7c9f69b25337c0b6e',
|
'com.android.tools.lint:lint:27.1.1:lint-27.1.1.jar:2f6038a5398a42bd591883c3f5e5894f4ec52ca1c3683bf94fa8553c1700af81',
|
||||||
'com.android.tools:common:26.5.1:common-26.5.1.jar:eccfa54486ed54c4e3123cc42195d023bd0dd21bcd2f0e4868e8c6fc70f8ef6b',
|
'com.android.tools:annotations:27.1.1:annotations-27.1.1.jar:ff28c504d2acb9fd1a5ffbd97ae85cf59ee18c76927525aad250509bccf2cab1',
|
||||||
'com.android.tools:dvlib:26.5.1:dvlib-26.5.1.jar:46f93ad498b4756e7d867d2fe38c38890a80e7407a4ae459e4a8c8d5c5aeacfe',
|
'com.android.tools:common:27.1.1:common-27.1.1.jar:63d9a2a9ad6d278db319f3749b9f50bdf5457ef7020074a1bebe124e714b535c',
|
||||||
'com.android.tools:repository:26.5.1:repository-26.5.1.jar:2b3ee791aa4c3e8ce60498c161a27ca7228816fc630eed4d9f25f2f36a106dce',
|
'com.android.tools:dvlib:27.1.1:dvlib-27.1.1.jar:998a54201fc1cefee5f2399215e95c42b1f64f9e1d8f4452eb8255c68ba5440f',
|
||||||
'com.android.tools:sdk-common:26.5.1:sdk-common-26.5.1.jar:365f749676c3574676fd465177c8a492f340816db2b520d6ed114d3b6e77bea7',
|
'com.android.tools:repository:27.1.1:repository-27.1.1.jar:d25b74ccabf4d876903efb375e9af6fb380d8ae0445bb74bbdcc225c1e37fa1d',
|
||||||
'com.android.tools:sdklib:26.5.1:sdklib-26.5.1.jar:007da104afb27c8c682a1628023fe9ec438249c8d15ef0fd6624c5bb8e23b696',
|
'com.android.tools:sdk-common:27.1.1:sdk-common-27.1.1.jar:4473ae97d0ef7061ee1de61041d5aa97405ae08e44c09cf7bb278b42e4b97c7c',
|
||||||
|
'com.android.tools:sdklib:27.1.1:sdklib-27.1.1.jar:08e6b83961ac9724b3c1e3d0eff971f13be6701292c77914b8794480f3391250',
|
||||||
|
'com.android:signflinger:4.1.1:signflinger-4.1.1.jar:0c66825988873ec2d51057fa463f54a8f18fc7326ff4530b9da363b71e97ce60',
|
||||||
|
'com.android:zipflinger:4.1.1:zipflinger-4.1.1.jar:0a8c3e52ac13dd031236f9fb5ba4408b1d5dcd12325a05440b36da09d8881446',
|
||||||
'com.google.code.findbugs:jsr305:3.0.2:jsr305-3.0.2.jar:766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7',
|
'com.google.code.findbugs:jsr305:3.0.2:jsr305-3.0.2.jar:766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7',
|
||||||
'com.google.code.gson:gson:2.8.5:gson-2.8.5.jar:233a0149fc365c9f6edbd683cfe266b19bdc773be98eabdaf6b3c924b48e7d81',
|
'com.google.code.gson:gson:2.8.5:gson-2.8.5.jar:233a0149fc365c9f6edbd683cfe266b19bdc773be98eabdaf6b3c924b48e7d81',
|
||||||
'com.google.dagger:dagger-compiler:2.24:dagger-compiler-2.24.jar:3c5afb955fb188da485cb2c048eff37dce0e1530b9780a0f2f7187d16d1ccc1f',
|
'com.google.dagger:dagger-compiler:2.24:dagger-compiler-2.24.jar:3c5afb955fb188da485cb2c048eff37dce0e1530b9780a0f2f7187d16d1ccc1f',
|
||||||
@@ -35,27 +38,30 @@ dependencyVerification {
|
|||||||
'com.google.dagger:dagger-spi:2.24:dagger-spi-2.24.jar:c038445d14dbcb4054e61bf49e05009edf26fce4fdc7ec1a9db544784f68e718',
|
'com.google.dagger:dagger-spi:2.24:dagger-spi-2.24.jar:c038445d14dbcb4054e61bf49e05009edf26fce4fdc7ec1a9db544784f68e718',
|
||||||
'com.google.dagger:dagger:2.24:dagger-2.24.jar:550a6e46a6dfcdf1d764887b6090cea94f783327e50e5c73754f18facfc70b64',
|
'com.google.dagger:dagger:2.24:dagger-2.24.jar:550a6e46a6dfcdf1d764887b6090cea94f783327e50e5c73754f18facfc70b64',
|
||||||
'com.google.errorprone:error_prone_annotations:2.2.0:error_prone_annotations-2.2.0.jar:6ebd22ca1b9d8ec06d41de8d64e0596981d9607b42035f9ed374f9de271a481a',
|
'com.google.errorprone:error_prone_annotations:2.2.0:error_prone_annotations-2.2.0.jar:6ebd22ca1b9d8ec06d41de8d64e0596981d9607b42035f9ed374f9de271a481a',
|
||||||
|
'com.google.errorprone:error_prone_annotations:2.3.2:error_prone_annotations-2.3.2.jar:357cd6cfb067c969226c442451502aee13800a24e950fdfde77bcdb4565a668d',
|
||||||
'com.google.errorprone:javac-shaded:9-dev-r4023-3:javac-shaded-9-dev-r4023-3.jar:65bfccf60986c47fbc17c9ebab0be626afc41741e0a6ec7109e0768817a36f30',
|
'com.google.errorprone:javac-shaded:9-dev-r4023-3:javac-shaded-9-dev-r4023-3.jar:65bfccf60986c47fbc17c9ebab0be626afc41741e0a6ec7109e0768817a36f30',
|
||||||
'com.google.googlejavaformat:google-java-format:1.5:google-java-format-1.5.jar:aa19ad7850fb85178aa22f2fddb163b84d6ce4d0035872f30d4408195ca1144e',
|
'com.google.googlejavaformat:google-java-format:1.5:google-java-format-1.5.jar:aa19ad7850fb85178aa22f2fddb163b84d6ce4d0035872f30d4408195ca1144e',
|
||||||
'com.google.guava:failureaccess:1.0.1:failureaccess-1.0.1.jar:a171ee4c734dd2da837e4b16be9df4661afab72a41adaf31eb84dfdaf936ca26',
|
'com.google.guava:failureaccess:1.0.1:failureaccess-1.0.1.jar:a171ee4c734dd2da837e4b16be9df4661afab72a41adaf31eb84dfdaf936ca26',
|
||||||
'com.google.guava:guava:27.0.1-jre:guava-27.0.1-jre.jar:e1c814fd04492a27c38e0317eabeaa1b3e950ec8010239e400fe90ad6c9107b4',
|
|
||||||
'com.google.guava:guava:27.1-jre:guava-27.1-jre.jar:4a5aa70cc968a4d137e599ad37553e5cfeed2265e8c193476d7119036c536fe7',
|
'com.google.guava:guava:27.1-jre:guava-27.1-jre.jar:4a5aa70cc968a4d137e599ad37553e5cfeed2265e8c193476d7119036c536fe7',
|
||||||
|
'com.google.guava:guava:28.1-jre:guava-28.1-jre.jar:30beb8b8527bd07c6e747e77f1a92122c2f29d57ce347461a4a55eb26e382da4',
|
||||||
'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava:listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:b372a037d4230aa57fbeffdef30fd6123f9c0c2db85d0aced00c91b974f33f99',
|
'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava:listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:b372a037d4230aa57fbeffdef30fd6123f9c0c2db85d0aced00c91b974f33f99',
|
||||||
'com.google.j2objc:j2objc-annotations:1.1:j2objc-annotations-1.1.jar:2994a7eb78f2710bd3d3bfb639b2c94e219cedac0d4d084d516e78c16dddecf6',
|
'com.google.j2objc:j2objc-annotations:1.1:j2objc-annotations-1.1.jar:2994a7eb78f2710bd3d3bfb639b2c94e219cedac0d4d084d516e78c16dddecf6',
|
||||||
|
'com.google.j2objc:j2objc-annotations:1.3:j2objc-annotations-1.3.jar:21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b',
|
||||||
'com.google.jimfs:jimfs:1.1:jimfs-1.1.jar:c4828e28d7c0a930af9387510b3bada7daa5c04d7c25a75c7b8b081f1c257ddd',
|
'com.google.jimfs:jimfs:1.1:jimfs-1.1.jar:c4828e28d7c0a930af9387510b3bada7daa5c04d7c25a75c7b8b081f1c257ddd',
|
||||||
'com.google.protobuf:protobuf-java:3.4.0:protobuf-java-3.4.0.jar:dce7e66b32456a1b1198da0caff3a8acb71548658391e798c79369241e6490a4',
|
'com.google.protobuf:protobuf-java:3.10.0:protobuf-java-3.10.0.jar:161d7d61a8cb3970891c299578702fd079646e032329d6c2cabf998d191437c9',
|
||||||
'com.googlecode.json-simple:json-simple:1.1:json-simple-1.1.jar:2d9484f4c649f708f47f9a479465fc729770ee65617dca3011836602264f6439',
|
'com.googlecode.json-simple:json-simple:1.1:json-simple-1.1.jar:2d9484f4c649f708f47f9a479465fc729770ee65617dca3011836602264f6439',
|
||||||
'com.squareup:javapoet:1.11.1:javapoet-1.11.1.jar:9cbf2107be499ec6e95afd36b58e3ca122a24166cdd375732e51267d64058e90',
|
'com.squareup:javapoet:1.11.1:javapoet-1.11.1.jar:9cbf2107be499ec6e95afd36b58e3ca122a24166cdd375732e51267d64058e90',
|
||||||
'com.squareup:javawriter:2.5.0:javawriter-2.5.0.jar:fcfb09fb0ea0aa97d3cfe7ea792398081348e468f126b3603cb3803f240197f0',
|
'com.squareup:javawriter:2.5.0:javawriter-2.5.0.jar:fcfb09fb0ea0aa97d3cfe7ea792398081348e468f126b3603cb3803f240197f0',
|
||||||
'com.sun.activation:javax.activation:1.2.0:javax.activation-1.2.0.jar:993302b16cd7056f21e779cc577d175a810bb4900ef73cd8fbf2b50f928ba9ce',
|
'com.sun.activation:javax.activation:1.2.0:javax.activation-1.2.0.jar:993302b16cd7056f21e779cc577d175a810bb4900ef73cd8fbf2b50f928ba9ce',
|
||||||
'com.sun.istack:istack-commons-runtime:2.21:istack-commons-runtime-2.21.jar:c33e67a0807095f02a0e2da139412dd7c4f9cc1a4c054b3e434f96831ba950f4',
|
'com.sun.istack:istack-commons-runtime:3.0.7:istack-commons-runtime-3.0.7.jar:6443e10ba2e259fb821d9b6becf10db5316285fc30c53cec9d7b19a3877e7fdf',
|
||||||
'com.sun.xml.fastinfoset:FastInfoset:1.2.13:FastInfoset-1.2.13.jar:27a77db909f3c2833c0b1a37c55af1db06045118ad2eed96ce567b6632bce038',
|
'com.sun.xml.fastinfoset:FastInfoset:1.2.15:FastInfoset-1.2.15.jar:785861db11ca1bd0d1956682b974ad73eb19cd3e01a4b3fa82d62eca97210aec',
|
||||||
'commons-codec:commons-codec:1.10:commons-codec-1.10.jar:4241dfa94e711d435f29a4604a3e2de5c4aa3c165e23bd066be6fc1fc4309569',
|
'commons-codec:commons-codec:1.10:commons-codec-1.10.jar:4241dfa94e711d435f29a4604a3e2de5c4aa3c165e23bd066be6fc1fc4309569',
|
||||||
'commons-logging:commons-logging:1.2:commons-logging-1.2.jar:daddea1ea0be0f56978ab3006b8ac92834afeefbd9b7e4e6316fca57df0fa636',
|
'commons-logging:commons-logging:1.2:commons-logging-1.2.jar:daddea1ea0be0f56978ab3006b8ac92834afeefbd9b7e4e6316fca57df0fa636',
|
||||||
'it.unimi.dsi:fastutil:7.2.0:fastutil-7.2.0.jar:74fa208043740642f7e6eb09faba15965218ad2f50ce3020efb100136e4b591c',
|
'it.unimi.dsi:fastutil:7.2.0:fastutil-7.2.0.jar:74fa208043740642f7e6eb09faba15965218ad2f50ce3020efb100136e4b591c',
|
||||||
|
'javax.activation:javax.activation-api:1.2.0:javax.activation-api-1.2.0.jar:43fdef0b5b6ceb31b0424b208b930c74ab58fac2ceeb7b3f6fd3aeb8b5ca4393',
|
||||||
'javax.annotation:jsr250-api:1.0:jsr250-api-1.0.jar:a1a922d0d9b6d183ed3800dfac01d1e1eb159f0e8c6f94736931c1def54a941f',
|
'javax.annotation:jsr250-api:1.0:jsr250-api-1.0.jar:a1a922d0d9b6d183ed3800dfac01d1e1eb159f0e8c6f94736931c1def54a941f',
|
||||||
'javax.inject:javax.inject:1:javax.inject-1.jar:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
|
'javax.inject:javax.inject:1:javax.inject-1.jar:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
|
||||||
'javax.xml.bind:jaxb-api:2.2.12-b140109.1041:jaxb-api-2.2.12-b140109.1041.jar:b5e60cd8b7b5ff01ce4a74c5dd008f4fbd14ced3495d0b47b85cfedc182211f2',
|
'javax.xml.bind:jaxb-api:2.3.1:jaxb-api-2.3.1.jar:88b955a0df57880a26a74708bc34f74dcaf8ebf4e78843a28b50eae945732b06',
|
||||||
'junit:junit:4.12:junit-4.12.jar:59721f0805e223d84b90677887d9ff567dc534d7c502ca903c0c2b17f05c116a',
|
'junit:junit:4.12:junit-4.12.jar:59721f0805e223d84b90677887d9ff567dc534d7c502ca903c0c2b17f05c116a',
|
||||||
'net.ltgt.gradle.incap:incap:0.2:incap-0.2.jar:b625b9806b0f1e4bc7a2e3457119488de3cd57ea20feedd513db070a573a4ffd',
|
'net.ltgt.gradle.incap:incap:0.2:incap-0.2.jar:b625b9806b0f1e4bc7a2e3457119488de3cd57ea20feedd513db070a573a4ffd',
|
||||||
'net.sf.jopt-simple:jopt-simple:4.9:jopt-simple-4.9.jar:26c5856e954b5f864db76f13b86919b59c6eecf9fd930b96baa8884626baf2f5',
|
'net.sf.jopt-simple:jopt-simple:4.9:jopt-simple-4.9.jar:26c5856e954b5f864db76f13b86919b59c6eecf9fd930b96baa8884626baf2f5',
|
||||||
@@ -70,34 +76,35 @@ dependencyVerification {
|
|||||||
'org.bouncycastle:bcpkix-jdk15on:1.56:bcpkix-jdk15on-1.56.jar:7043dee4e9e7175e93e0b36f45b1ec1ecb893c5f755667e8b916eb8dd201c6ca',
|
'org.bouncycastle:bcpkix-jdk15on:1.56:bcpkix-jdk15on-1.56.jar:7043dee4e9e7175e93e0b36f45b1ec1ecb893c5f755667e8b916eb8dd201c6ca',
|
||||||
'org.bouncycastle:bcprov-jdk15on:1.56:bcprov-jdk15on-1.56.jar:963e1ee14f808ffb99897d848ddcdb28fa91ddda867eb18d303e82728f878349',
|
'org.bouncycastle:bcprov-jdk15on:1.56:bcprov-jdk15on-1.56.jar:963e1ee14f808ffb99897d848ddcdb28fa91ddda867eb18d303e82728f878349',
|
||||||
'org.briarproject:obfs4proxy-android:0.0.11-2:obfs4proxy-android-0.0.11-2.zip:57e55cbe87aa2aac210fdbb6cd8cdeafe15f825406a08ebf77a8b787aa2c6a8a',
|
'org.briarproject:obfs4proxy-android:0.0.11-2:obfs4proxy-android-0.0.11-2.zip:57e55cbe87aa2aac210fdbb6cd8cdeafe15f825406a08ebf77a8b787aa2c6a8a',
|
||||||
'org.briarproject:tor-android:0.3.5.10:tor-android-0.3.5.10.zip:edd83bf557fcff2105eaa0bdb3f607a6852ebe7360920929ae3039dd5f4774c5',
|
'org.briarproject:tor-android:0.3.5.12:tor-android-0.3.5.12.zip:db71fb3290acff79d572af0752570eaf6aad7c4d88c9b9aa0b4d5afe2b9ead9c',
|
||||||
'org.checkerframework:checker-compat-qual:2.5.3:checker-compat-qual-2.5.3.jar:d76b9afea61c7c082908023f0cbc1427fab9abd2df915c8b8a3e7a509bccbc6d',
|
'org.checkerframework:checker-compat-qual:2.5.3:checker-compat-qual-2.5.3.jar:d76b9afea61c7c082908023f0cbc1427fab9abd2df915c8b8a3e7a509bccbc6d',
|
||||||
'org.checkerframework:checker-qual:2.5.2:checker-qual-2.5.2.jar:64b02691c8b9d4e7700f8ee2e742dce7ea2c6e81e662b7522c9ee3bf568c040a',
|
'org.checkerframework:checker-qual:2.5.2:checker-qual-2.5.2.jar:64b02691c8b9d4e7700f8ee2e742dce7ea2c6e81e662b7522c9ee3bf568c040a',
|
||||||
|
'org.checkerframework:checker-qual:2.8.1:checker-qual-2.8.1.jar:9103499008bcecd4e948da29b17864abb64304e15706444ae209d17ebe0575df',
|
||||||
'org.codehaus.groovy:groovy-all:2.4.15:groovy-all-2.4.15.jar:51d6c4e71782e85674239189499854359d380fb75e1a703756e3aaa5b98a5af0',
|
'org.codehaus.groovy:groovy-all:2.4.15:groovy-all-2.4.15.jar:51d6c4e71782e85674239189499854359d380fb75e1a703756e3aaa5b98a5af0',
|
||||||
'org.codehaus.mojo:animal-sniffer-annotations:1.17:animal-sniffer-annotations-1.17.jar:92654f493ecfec52082e76354f0ebf87648dc3d5cec2e3c3cdb947c016747a53',
|
'org.codehaus.mojo:animal-sniffer-annotations:1.17:animal-sniffer-annotations-1.17.jar:92654f493ecfec52082e76354f0ebf87648dc3d5cec2e3c3cdb947c016747a53',
|
||||||
'org.glassfish.jaxb:jaxb-core:2.2.11:jaxb-core-2.2.11.jar:37bcaee8ebb04362c8352a5bf6221b86967ecdab5164c696b10b9a2bb587b2aa',
|
'org.codehaus.mojo:animal-sniffer-annotations:1.18:animal-sniffer-annotations-1.18.jar:47f05852b48ee9baefef80fa3d8cea60efa4753c0013121dd7fe5eef2e5c729d',
|
||||||
'org.glassfish.jaxb:jaxb-runtime:2.2.11:jaxb-runtime-2.2.11.jar:a874f2351cfba8e2946be3002d10c18a6da8f21b52ba2acf52f2b85d5520ed70',
|
'org.glassfish.jaxb:jaxb-runtime:2.3.1:jaxb-runtime-2.3.1.jar:45fecfa5c8217ce1f3652ab95179790ec8cc0dec0384bca51cbeb94a293d9f2f',
|
||||||
'org.glassfish.jaxb:txw2:2.2.11:txw2-2.2.11.jar:272a3ccad45a4511351920cd2a8633c53cab8d5220c7a92954da5526bb5eafea',
|
'org.glassfish.jaxb:txw2:2.3.1:txw2-2.3.1.jar:34975dde1c6920f1a39791142235689bc3cd357e24d05edd8ff93b885bd68d60',
|
||||||
'org.hamcrest:hamcrest-core:1.3:hamcrest-core-1.3.jar:66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9',
|
'org.hamcrest:hamcrest-core:1.3:hamcrest-core-1.3.jar:66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9',
|
||||||
'org.hamcrest:hamcrest-library:1.3:hamcrest-library-1.3.jar:711d64522f9ec410983bd310934296da134be4254a125080a0416ec178dfad1c',
|
'org.hamcrest:hamcrest-library:1.3:hamcrest-library-1.3.jar:711d64522f9ec410983bd310934296da134be4254a125080a0416ec178dfad1c',
|
||||||
'org.jetbrains.kotlin:kotlin-reflect:1.3.50:kotlin-reflect-1.3.50.jar:64583199ea5a54aefd1bd1595288925f784226ee562d1dd279011c6075b3d7a4',
|
'org.jetbrains.kotlin:kotlin-reflect:1.3.72:kotlin-reflect-1.3.72.jar:a188d9367de1c4ee9479db630985c0597b20709c83161b1430d24edb27e38c40',
|
||||||
'org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50:kotlin-stdlib-common-1.3.50.jar:8ce678e88e4ba018b66dacecf952471e4d7dfee156a8a819760a5a5ff29d323c',
|
'org.jetbrains.kotlin:kotlin-stdlib-common:1.3.72:kotlin-stdlib-common-1.3.72.jar:5e7d1552863e480c1628b1cc39ce230ef829f5b7230106215a05acda5172203a',
|
||||||
'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50:kotlin-stdlib-jdk7-1.3.50.jar:9a026639e76212f8d57b86d55b075394c2e009f1979110751d34c05c5f75d57b',
|
'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72:kotlin-stdlib-jdk7-1.3.72.jar:40566c0c08d414b9413ba556ff7f8a0b04b98b9f0f424d122dd2088510efccc4',
|
||||||
'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50:kotlin-stdlib-jdk8-1.3.50.jar:1b351fb6e09c14b55525c74c1f4cf48942eae43c348b7bc764a5e6e423d4da0c',
|
'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72:kotlin-stdlib-jdk8-1.3.72.jar:133da70cfc07b56094282eac5c59bccd59f167ee2ead22e5282876d8bc10bf95',
|
||||||
'org.jetbrains.kotlin:kotlin-stdlib:1.3.50:kotlin-stdlib-1.3.50.jar:e6f05746ee0366d0b52825a090fac474dcf44082c9083bbb205bd16976488d6c',
|
'org.jetbrains.kotlin:kotlin-stdlib:1.3.72:kotlin-stdlib-1.3.72.jar:3856a7349ebacd6d1be6802b2fed9c4dc2c5a564ea92b6b945ac988243d4b16b',
|
||||||
'org.jetbrains.trove4j:trove4j:20160824:trove4j-20160824.jar:1917871c8deb468307a584680c87a44572f5a8b0b98c6d397fc0f5f86596dbe7',
|
'org.jetbrains.trove4j:trove4j:20160824:trove4j-20160824.jar:1917871c8deb468307a584680c87a44572f5a8b0b98c6d397fc0f5f86596dbe7',
|
||||||
'org.jetbrains:annotations:13.0:annotations-13.0.jar:ace2a10dc8e2d5fd34925ecac03e4988b2c0f851650c94b8cef49ba1bd111478',
|
'org.jetbrains:annotations:13.0:annotations-13.0.jar:ace2a10dc8e2d5fd34925ecac03e4988b2c0f851650c94b8cef49ba1bd111478',
|
||||||
'org.jmock:jmock-junit4:2.8.2:jmock-junit4-2.8.2.jar:f7ee4df4f7bd7b7f1cafad3b99eb74d579f109d5992ff625347352edb55e674c',
|
'org.jmock:jmock-junit4:2.8.2:jmock-junit4-2.8.2.jar:f7ee4df4f7bd7b7f1cafad3b99eb74d579f109d5992ff625347352edb55e674c',
|
||||||
'org.jmock:jmock-legacy:2.8.2:jmock-legacy-2.8.2.jar:f2b985a5c08a9edb7f37612330c058809da3f6a6d63ce792426ebf8ff0d6d31b',
|
'org.jmock:jmock-legacy:2.8.2:jmock-legacy-2.8.2.jar:f2b985a5c08a9edb7f37612330c058809da3f6a6d63ce792426ebf8ff0d6d31b',
|
||||||
'org.jmock:jmock-testjar:2.8.2:jmock-testjar-2.8.2.jar:8900860f72c474e027cf97fe78dcbf154a1aa7fc62b6845c5fb4e4f3c7bc8760',
|
'org.jmock:jmock-testjar:2.8.2:jmock-testjar-2.8.2.jar:8900860f72c474e027cf97fe78dcbf154a1aa7fc62b6845c5fb4e4f3c7bc8760',
|
||||||
'org.jmock:jmock:2.8.2:jmock-2.8.2.jar:6c73cb4a2e6dbfb61fd99c9a768539c170ab6568e57846bd60dbf19596b65b16',
|
'org.jmock:jmock:2.8.2:jmock-2.8.2.jar:6c73cb4a2e6dbfb61fd99c9a768539c170ab6568e57846bd60dbf19596b65b16',
|
||||||
'org.jvnet.staxex:stax-ex:1.7.7:stax-ex-1.7.7.jar:a31ff7d77163c0deb09e7fee59ad35ae44c2cee2cc8552a116ccd1583d813fb4',
|
'org.jvnet.staxex:stax-ex:1.8:stax-ex-1.8.jar:95b05d9590af4154c6513b9c5dc1fb2e55b539972ba0a9ef28e9a0c01d83ad77',
|
||||||
'org.objenesis:objenesis:2.1:objenesis-2.1.jar:c74330cc6b806c804fd37e74487b4fe5d7c2750c5e15fbc6efa13bdee1bdef80',
|
'org.objenesis:objenesis:2.1:objenesis-2.1.jar:c74330cc6b806c804fd37e74487b4fe5d7c2750c5e15fbc6efa13bdee1bdef80',
|
||||||
'org.ow2.asm:asm-analysis:6.0:asm-analysis-6.0.jar:2f1a6387219c3a6cc4856481f221b03bd9f2408a326d416af09af5d6f608c1f4',
|
'org.ow2.asm:asm-analysis:7.0:asm-analysis-7.0.jar:e981f8f650c4d900bb033650b18e122fa6b161eadd5f88978d08751f72ee8474',
|
||||||
'org.ow2.asm:asm-commons:6.0:asm-commons-6.0.jar:f1bce5c648a96a017bdcd01fe5d59af9845297fd7b79b81c015a6fbbd9719abf',
|
'org.ow2.asm:asm-commons:7.0:asm-commons-7.0.jar:fed348ef05958e3e846a3ac074a12af5f7936ef3d21ce44a62c4fa08a771927d',
|
||||||
'org.ow2.asm:asm-tree:6.0:asm-tree-6.0.jar:887998fb69727c8759e4d253f856822801e33f9fd4caa566b3ac58ee92106215',
|
'org.ow2.asm:asm-tree:7.0:asm-tree-7.0.jar:cfd7a0874f9de36a999c127feeadfbfe6e04d4a71ee954d7af3d853f0be48a6c',
|
||||||
'org.ow2.asm:asm-util:6.0:asm-util-6.0.jar:356afebdb0f870175262e5188f8709a3b17aa2a5a6a4b0340b04d4b449bca5f6',
|
'org.ow2.asm:asm-util:7.0:asm-util-7.0.jar:75fbbca440ef463f41c2b0ab1a80abe67e910ac486da60a7863cbcb5bae7e145',
|
||||||
'org.ow2.asm:asm:5.0.4:asm-5.0.4.jar:896618ed8ae62702521a78bc7be42b7c491a08e6920a15f89a3ecdec31e9a220',
|
'org.ow2.asm:asm:5.0.4:asm-5.0.4.jar:896618ed8ae62702521a78bc7be42b7c491a08e6920a15f89a3ecdec31e9a220',
|
||||||
'org.ow2.asm:asm:6.0:asm-6.0.jar:dd8971c74a4e697899a8e95caae4ea8760ea6c486dc6b97b1795e75760420461',
|
'org.ow2.asm:asm:7.0:asm-7.0.jar:b88ef66468b3c978ad0c97fd6e90979e56155b4ac69089ba7a44e9aa7ffe9acf',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,4 +6,7 @@ package org.briarproject.bramble.api;
|
|||||||
public interface FeatureFlags {
|
public interface FeatureFlags {
|
||||||
|
|
||||||
boolean shouldEnableImageAttachments();
|
boolean shouldEnableImageAttachments();
|
||||||
|
|
||||||
|
boolean shouldEnableProfilePictures();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import org.briarproject.bramble.api.db.PendingContactExistsException;
|
|||||||
import org.briarproject.bramble.api.db.Transaction;
|
import org.briarproject.bramble.api.db.Transaction;
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
import org.briarproject.bramble.api.identity.AuthorId;
|
||||||
import org.briarproject.bramble.api.identity.AuthorInfo;
|
|
||||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
@@ -179,6 +178,11 @@ public interface ContactManager {
|
|||||||
*/
|
*/
|
||||||
Collection<Contact> getContacts() throws DbException;
|
Collection<Contact> getContacts() throws DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all contacts.
|
||||||
|
*/
|
||||||
|
Collection<Contact> getContacts(Transaction txn) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a contact and all associated state.
|
* Removes a contact and all associated state.
|
||||||
*/
|
*/
|
||||||
@@ -215,16 +219,6 @@ public interface ContactManager {
|
|||||||
boolean contactExists(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
boolean contactExists(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link AuthorInfo} for the given author.
|
|
||||||
*/
|
|
||||||
AuthorInfo getAuthorInfo(AuthorId a) throws DbException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link AuthorInfo} for the given author.
|
|
||||||
*/
|
|
||||||
AuthorInfo getAuthorInfo(Transaction txn, AuthorId a) throws DbException;
|
|
||||||
|
|
||||||
interface ContactHook {
|
interface ContactHook {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class NetworkStatus {
|
public class NetworkStatus {
|
||||||
|
|
||||||
private final boolean connected, wifi;
|
private final boolean connected, wifi, ipv6Only;
|
||||||
|
|
||||||
public NetworkStatus(boolean connected, boolean wifi) {
|
public NetworkStatus(boolean connected, boolean wifi, boolean ipv6Only) {
|
||||||
this.connected = connected;
|
this.connected = connected;
|
||||||
this.wifi = wifi;
|
this.wifi = wifi;
|
||||||
|
this.ipv6Only = ipv6Only;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
@@ -22,4 +23,8 @@ public class NetworkStatus {
|
|||||||
public boolean isWifi() {
|
public boolean isWifi() {
|
||||||
return wifi;
|
return wifi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isIpv6Only() {
|
||||||
|
return ipv6Only;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,4 +29,12 @@ public class NullSafety {
|
|||||||
public static void requireNull(@Nullable Object o) {
|
public static void requireNull(@Nullable Object o) {
|
||||||
if (o != null) throw new AssertionError();
|
if (o != null) throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stand-in for {@code Objects.equals()}.
|
||||||
|
*/
|
||||||
|
public static boolean equals(@Nullable Object a, @Nullable Object b) {
|
||||||
|
return (a == b) || (a != null && a.equals(b));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public interface DevReporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends any reports previously stored on disk.
|
* Sends any reports previously stored on disk.
|
||||||
|
*
|
||||||
|
* @return The number of reports that were sent.
|
||||||
*/
|
*/
|
||||||
void sendReports();
|
int sendReports();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
package org.briarproject.bramble.api.identity;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.test.BrambleTestCase;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.NONE;
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.VERIFIED;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotEquals;
|
|
||||||
|
|
||||||
public class AuthorInfoTest extends BrambleTestCase {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testEquals() {
|
|
||||||
assertEquals(
|
|
||||||
new AuthorInfo(NONE),
|
|
||||||
new AuthorInfo(NONE, null)
|
|
||||||
);
|
|
||||||
assertEquals(
|
|
||||||
new AuthorInfo(NONE, "test"),
|
|
||||||
new AuthorInfo(NONE, "test")
|
|
||||||
);
|
|
||||||
|
|
||||||
assertNotEquals(
|
|
||||||
new AuthorInfo(NONE),
|
|
||||||
new AuthorInfo(VERIFIED)
|
|
||||||
);
|
|
||||||
assertNotEquals(
|
|
||||||
new AuthorInfo(NONE, "test"),
|
|
||||||
new AuthorInfo(NONE)
|
|
||||||
);
|
|
||||||
assertNotEquals(
|
|
||||||
new AuthorInfo(NONE),
|
|
||||||
new AuthorInfo(NONE, "test")
|
|
||||||
);
|
|
||||||
assertNotEquals(
|
|
||||||
new AuthorInfo(NONE, "a"),
|
|
||||||
new AuthorInfo(NONE, "b")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -20,9 +20,7 @@ import org.briarproject.bramble.api.event.Event;
|
|||||||
import org.briarproject.bramble.api.event.EventListener;
|
import org.briarproject.bramble.api.event.EventListener;
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
import org.briarproject.bramble.api.identity.AuthorId;
|
||||||
import org.briarproject.bramble.api.identity.AuthorInfo;
|
|
||||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.transport.KeyManager;
|
import org.briarproject.bramble.api.transport.KeyManager;
|
||||||
|
|
||||||
@@ -40,10 +38,6 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import static org.briarproject.bramble.api.contact.PendingContactState.WAITING_FOR_CONNECTION;
|
import static org.briarproject.bramble.api.contact.PendingContactState.WAITING_FOR_CONNECTION;
|
||||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.UNKNOWN;
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.UNVERIFIED;
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.VERIFIED;
|
|
||||||
import static org.briarproject.bramble.util.StringUtils.toUtf8;
|
import static org.briarproject.bramble.util.StringUtils.toUtf8;
|
||||||
|
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
@@ -213,6 +207,11 @@ class ContactManagerImpl implements ContactManager, EventListener {
|
|||||||
return db.transactionWithResult(true, db::getContacts);
|
return db.transactionWithResult(true, db::getContacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Contact> getContacts(Transaction txn) throws DbException {
|
||||||
|
return db.getContacts(txn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeContact(ContactId c) throws DbException {
|
public void removeContact(ContactId c) throws DbException {
|
||||||
db.transaction(false, txn -> removeContact(txn, c));
|
db.transaction(false, txn -> removeContact(txn, c));
|
||||||
@@ -256,25 +255,6 @@ class ContactManagerImpl implements ContactManager, EventListener {
|
|||||||
db.removeContact(txn, c);
|
db.removeContact(txn, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AuthorInfo getAuthorInfo(AuthorId a) throws DbException {
|
|
||||||
return db.transactionWithResult(true, txn -> getAuthorInfo(txn, a));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AuthorInfo getAuthorInfo(Transaction txn, AuthorId authorId)
|
|
||||||
throws DbException {
|
|
||||||
LocalAuthor localAuthor = identityManager.getLocalAuthor(txn);
|
|
||||||
if (localAuthor.getId().equals(authorId))
|
|
||||||
return new AuthorInfo(OURSELVES);
|
|
||||||
Collection<Contact> contacts = db.getContactsByAuthorId(txn, authorId);
|
|
||||||
if (contacts.isEmpty()) return new AuthorInfo(UNKNOWN);
|
|
||||||
if (contacts.size() > 1) throw new AssertionError();
|
|
||||||
Contact c = contacts.iterator().next();
|
|
||||||
if (c.isVerified()) return new AuthorInfo(VERIFIED, c.getAlias());
|
|
||||||
else return new AuthorInfo(UNVERIFIED, c.getAlias());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void eventOccurred(Event e) {
|
public void eventOccurred(Event e) {
|
||||||
if (e instanceof PendingContactStateChangedEvent) {
|
if (e instanceof PendingContactStateChangedEvent) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.briarproject.bramble.api.system.Clock;
|
|||||||
import org.briarproject.bramble.util.Base32;
|
import org.briarproject.bramble.util.Base32;
|
||||||
|
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -52,7 +53,7 @@ class PendingContactFactoryImpl implements PendingContactFactory {
|
|||||||
byte[] raw = new byte[RAW_LINK_BYTES];
|
byte[] raw = new byte[RAW_LINK_BYTES];
|
||||||
raw[0] = FORMAT_VERSION;
|
raw[0] = FORMAT_VERSION;
|
||||||
arraycopy(encoded, 0, raw, 1, encoded.length);
|
arraycopy(encoded, 0, raw, 1, encoded.length);
|
||||||
return "briar://" + Base32.encode(raw).toLowerCase();
|
return "briar://" + Base32.encode(raw).toLowerCase(Locale.US);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PublicKey parseHandshakeLink(String link) throws FormatException {
|
private PublicKey parseHandshakeLink(String link) throws FormatException {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.briarproject.bramble.keyagreement;
|
package org.briarproject.bramble.keyagreement;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.Pair;
|
||||||
import org.briarproject.bramble.api.crypto.KeyAgreementCrypto;
|
import org.briarproject.bramble.api.crypto.KeyAgreementCrypto;
|
||||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||||
import org.briarproject.bramble.api.data.BdfList;
|
import org.briarproject.bramble.api.data.BdfList;
|
||||||
@@ -8,6 +9,8 @@ import org.briarproject.bramble.api.keyagreement.KeyAgreementListener;
|
|||||||
import org.briarproject.bramble.api.keyagreement.Payload;
|
import org.briarproject.bramble.api.keyagreement.Payload;
|
||||||
import org.briarproject.bramble.api.keyagreement.TransportDescriptor;
|
import org.briarproject.bramble.api.keyagreement.TransportDescriptor;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
import org.briarproject.bramble.api.plugin.BluetoothConstants;
|
||||||
|
import org.briarproject.bramble.api.plugin.LanTcpConstants;
|
||||||
import org.briarproject.bramble.api.plugin.Plugin;
|
import org.briarproject.bramble.api.plugin.Plugin;
|
||||||
import org.briarproject.bramble.api.plugin.PluginManager;
|
import org.briarproject.bramble.api.plugin.PluginManager;
|
||||||
import org.briarproject.bramble.api.plugin.TransportId;
|
import org.briarproject.bramble.api.plugin.TransportId;
|
||||||
@@ -19,7 +22,9 @@ import org.briarproject.bramble.api.record.RecordWriterFactory;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
@@ -28,8 +33,10 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.api.keyagreement.KeyAgreementConstants.CONNECTION_TIMEOUT;
|
import static org.briarproject.bramble.api.keyagreement.KeyAgreementConstants.CONNECTION_TIMEOUT;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
|
|
||||||
@@ -41,7 +48,10 @@ class KeyAgreementConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(KeyAgreementConnector.class.getName());
|
getLogger(KeyAgreementConnector.class.getName());
|
||||||
|
|
||||||
|
private static final List<TransportId> PREFERRED_TRANSPORTS =
|
||||||
|
asList(BluetoothConstants.ID, LanTcpConstants.ID);
|
||||||
|
|
||||||
private final Callbacks callbacks;
|
private final Callbacks callbacks;
|
||||||
private final KeyAgreementCrypto keyAgreementCrypto;
|
private final KeyAgreementCrypto keyAgreementCrypto;
|
||||||
@@ -105,24 +115,35 @@ class KeyAgreementConnector {
|
|||||||
this.alice = alice;
|
this.alice = alice;
|
||||||
aliceLatch.countDown();
|
aliceLatch.countDown();
|
||||||
|
|
||||||
// Start connecting over supported transports
|
// Start connecting over supported transports in order of preference
|
||||||
if (LOG.isLoggable(INFO)) {
|
if (LOG.isLoggable(INFO)) {
|
||||||
LOG.info("Starting outgoing BQP connections as "
|
LOG.info("Starting outgoing BQP connections as "
|
||||||
+ (alice ? "Alice" : "Bob"));
|
+ (alice ? "Alice" : "Bob"));
|
||||||
}
|
}
|
||||||
|
Map<TransportId, TransportDescriptor> descriptors = new HashMap<>();
|
||||||
for (TransportDescriptor d : remotePayload.getTransportDescriptors()) {
|
for (TransportDescriptor d : remotePayload.getTransportDescriptors()) {
|
||||||
Plugin p = pluginManager.getPlugin(d.getId());
|
descriptors.put(d.getId(), d);
|
||||||
if (p instanceof DuplexPlugin) {
|
}
|
||||||
|
List<Pair<DuplexPlugin, BdfList>> transports = new ArrayList<>();
|
||||||
|
for (TransportId id : PREFERRED_TRANSPORTS) {
|
||||||
|
TransportDescriptor d = descriptors.get(id);
|
||||||
|
Plugin p = pluginManager.getPlugin(id);
|
||||||
|
if (d != null && p instanceof DuplexPlugin) {
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Connecting via " + d.getId());
|
LOG.info("Connecting via " + id);
|
||||||
DuplexPlugin plugin = (DuplexPlugin) p;
|
transports.add(new Pair<>((DuplexPlugin) p, d.getDescriptor()));
|
||||||
byte[] commitment = remotePayload.getCommitment();
|
|
||||||
BdfList descriptor = d.getDescriptor();
|
|
||||||
connectionChooser.submit(new ReadableTask(
|
|
||||||
new ConnectorTask(plugin, commitment, descriptor)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: If we don't have any transports in common with the peer,
|
||||||
|
// warn the user and give up (#1224)
|
||||||
|
|
||||||
|
if (!transports.isEmpty()) {
|
||||||
|
byte[] commitment = remotePayload.getCommitment();
|
||||||
|
connectionChooser.submit(new ReadableTask(new ConnectorTask(
|
||||||
|
transports, commitment)));
|
||||||
|
}
|
||||||
|
|
||||||
// Get chosen connection
|
// Get chosen connection
|
||||||
try {
|
try {
|
||||||
KeyAgreementConnection chosen =
|
KeyAgreementConnection chosen =
|
||||||
@@ -148,15 +169,13 @@ class KeyAgreementConnector {
|
|||||||
|
|
||||||
private class ConnectorTask implements Callable<KeyAgreementConnection> {
|
private class ConnectorTask implements Callable<KeyAgreementConnection> {
|
||||||
|
|
||||||
|
private final List<Pair<DuplexPlugin, BdfList>> transports;
|
||||||
private final byte[] commitment;
|
private final byte[] commitment;
|
||||||
private final BdfList descriptor;
|
|
||||||
private final DuplexPlugin plugin;
|
|
||||||
|
|
||||||
private ConnectorTask(DuplexPlugin plugin, byte[] commitment,
|
private ConnectorTask(List<Pair<DuplexPlugin, BdfList>> transports,
|
||||||
BdfList descriptor) {
|
byte[] commitment) {
|
||||||
this.plugin = plugin;
|
this.transports = transports;
|
||||||
this.commitment = commitment;
|
this.commitment = commitment;
|
||||||
this.descriptor = descriptor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -164,13 +183,18 @@ class KeyAgreementConnector {
|
|||||||
public KeyAgreementConnection call() throws Exception {
|
public KeyAgreementConnection call() throws Exception {
|
||||||
// Repeat attempts until we connect, get stopped, or get interrupted
|
// Repeat attempts until we connect, get stopped, or get interrupted
|
||||||
while (!stopped) {
|
while (!stopped) {
|
||||||
DuplexTransportConnection conn =
|
for (Pair<DuplexPlugin, BdfList> pair : transports) {
|
||||||
plugin.createKeyAgreementConnection(commitment,
|
if (stopped) return null;
|
||||||
descriptor);
|
DuplexPlugin plugin = pair.getFirst();
|
||||||
if (conn != null) {
|
BdfList descriptor = pair.getSecond();
|
||||||
if (LOG.isLoggable(INFO))
|
DuplexTransportConnection conn =
|
||||||
LOG.info(plugin.getId() + ": Outgoing connection");
|
plugin.createKeyAgreementConnection(commitment,
|
||||||
return new KeyAgreementConnection(conn, plugin.getId());
|
descriptor);
|
||||||
|
if (conn != null) {
|
||||||
|
if (LOG.isLoggable(INFO))
|
||||||
|
LOG.info(plugin.getId() + ": Outgoing connection");
|
||||||
|
return new KeyAgreementConnection(conn, plugin.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Wait 2s before retry (to circumvent transient failures)
|
// Wait 2s before retry (to circumvent transient failures)
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
|
|||||||
@@ -436,8 +436,10 @@ abstract class BluetoothPlugin<S, SS> implements DuplexPlugin, EventListener {
|
|||||||
String uuid = UUID.nameUUIDFromBytes(commitment).toString();
|
String uuid = UUID.nameUUIDFromBytes(commitment).toString();
|
||||||
DuplexTransportConnection conn;
|
DuplexTransportConnection conn;
|
||||||
if (descriptor.size() == 1) {
|
if (descriptor.size() == 1) {
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO)) {
|
||||||
LOG.info("Discovering address for key agreement UUID " + uuid);
|
LOG.info("Discovering address for key agreement UUID " +
|
||||||
|
uuid);
|
||||||
|
}
|
||||||
conn = discoverAndConnect(uuid);
|
conn = discoverAndConnect(uuid);
|
||||||
} else {
|
} else {
|
||||||
String address;
|
String address;
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
private final CircumventionProvider circumventionProvider;
|
private final CircumventionProvider circumventionProvider;
|
||||||
private final ResourceProvider resourceProvider;
|
private final ResourceProvider resourceProvider;
|
||||||
private final int maxLatency, maxIdleTime, socketTimeout;
|
private final int maxLatency, maxIdleTime, socketTimeout;
|
||||||
private final File torDirectory, torFile, geoIpFile, obfs4File, configFile;
|
private final File torDirectory, geoIpFile, configFile;
|
||||||
private final File doneFile, cookieFile;
|
private final File doneFile, cookieFile;
|
||||||
private final AtomicBoolean used = new AtomicBoolean(false);
|
private final AtomicBoolean used = new AtomicBoolean(false);
|
||||||
|
|
||||||
@@ -181,9 +181,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
socketTimeout = Integer.MAX_VALUE;
|
socketTimeout = Integer.MAX_VALUE;
|
||||||
else socketTimeout = maxIdleTime * 2;
|
else socketTimeout = maxIdleTime * 2;
|
||||||
this.torDirectory = torDirectory;
|
this.torDirectory = torDirectory;
|
||||||
torFile = new File(torDirectory, "tor");
|
|
||||||
geoIpFile = new File(torDirectory, "geoip");
|
geoIpFile = new File(torDirectory, "geoip");
|
||||||
obfs4File = new File(torDirectory, "obfs4proxy");
|
|
||||||
configFile = new File(torDirectory, "torrc");
|
configFile = new File(torDirectory, "torrc");
|
||||||
doneFile = new File(torDirectory, "done");
|
doneFile = new File(torDirectory, "done");
|
||||||
cookieFile = new File(torDirectory, ".tor/control_auth_cookie");
|
cookieFile = new File(torDirectory, ".tor/control_auth_cookie");
|
||||||
@@ -192,6 +190,14 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
new PoliteExecutor("TorPlugin", ioExecutor, 1);
|
new PoliteExecutor("TorPlugin", ioExecutor, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected File getTorExecutableFile() {
|
||||||
|
return new File(torDirectory, "tor");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected File getObfs4ExecutableFile() {
|
||||||
|
return new File(torDirectory, "obfs4proxy");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransportId getId() {
|
public TransportId getId() {
|
||||||
return TorConstants.ID;
|
return TorConstants.ID;
|
||||||
@@ -224,6 +230,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
LOG.warning("Old auth cookie not deleted");
|
LOG.warning("Old auth cookie not deleted");
|
||||||
// Start a new Tor process
|
// Start a new Tor process
|
||||||
LOG.info("Starting Tor");
|
LOG.info("Starting Tor");
|
||||||
|
File torFile = getTorExecutableFile();
|
||||||
String torPath = torFile.getAbsolutePath();
|
String torPath = torFile.getAbsolutePath();
|
||||||
String configPath = configFile.getAbsolutePath();
|
String configPath = configFile.getAbsolutePath();
|
||||||
String pid = String.valueOf(getProcessId());
|
String pid = String.valueOf(getProcessId());
|
||||||
@@ -322,44 +329,43 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void installAssets() throws PluginException {
|
private void installAssets() throws PluginException {
|
||||||
InputStream in = null;
|
|
||||||
OutputStream out = null;
|
|
||||||
try {
|
try {
|
||||||
// The done file may already exist from a previous installation
|
// The done file may already exist from a previous installation
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
doneFile.delete();
|
doneFile.delete();
|
||||||
// Unzip the Tor binary to the filesystem
|
installTorExecutable();
|
||||||
in = getTorInputStream();
|
installObfs4Executable();
|
||||||
out = new FileOutputStream(torFile);
|
extract(getGeoIpInputStream(), geoIpFile);
|
||||||
copyAndClose(in, out);
|
extract(getConfigInputStream(), configFile);
|
||||||
// Make the Tor binary executable
|
|
||||||
if (!torFile.setExecutable(true, true)) throw new IOException();
|
|
||||||
// Unzip the GeoIP database to the filesystem
|
|
||||||
in = getGeoIpInputStream();
|
|
||||||
out = new FileOutputStream(geoIpFile);
|
|
||||||
copyAndClose(in, out);
|
|
||||||
// Unzip the Obfs4 proxy to the filesystem
|
|
||||||
in = getObfs4InputStream();
|
|
||||||
out = new FileOutputStream(obfs4File);
|
|
||||||
copyAndClose(in, out);
|
|
||||||
// Make the Obfs4 proxy executable
|
|
||||||
if (!obfs4File.setExecutable(true, true)) throw new IOException();
|
|
||||||
// Copy the config file to the filesystem
|
|
||||||
in = getConfigInputStream();
|
|
||||||
out = new FileOutputStream(configFile);
|
|
||||||
copyAndClose(in, out);
|
|
||||||
if (!doneFile.createNewFile())
|
if (!doneFile.createNewFile())
|
||||||
LOG.warning("Failed to create done file");
|
LOG.warning("Failed to create done file");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
tryToClose(in, LOG, WARNING);
|
|
||||||
tryToClose(out, LOG, WARNING);
|
|
||||||
throw new PluginException(e);
|
throw new PluginException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputStream getTorInputStream() throws IOException {
|
protected void extract(InputStream in, File dest) throws IOException {
|
||||||
|
OutputStream out = new FileOutputStream(dest);
|
||||||
|
copyAndClose(in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void installTorExecutable() throws IOException {
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Installing Tor binary for " + architecture);
|
LOG.info("Installing Tor binary for " + architecture);
|
||||||
|
File torFile = getTorExecutableFile();
|
||||||
|
extract(getTorInputStream(), torFile);
|
||||||
|
if (!torFile.setExecutable(true, true)) throw new IOException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void installObfs4Executable() throws IOException {
|
||||||
|
if (LOG.isLoggable(INFO))
|
||||||
|
LOG.info("Installing obfs4proxy binary for " + architecture);
|
||||||
|
File obfs4File = getObfs4ExecutableFile();
|
||||||
|
extract(getObfs4InputStream(), obfs4File);
|
||||||
|
if (!obfs4File.setExecutable(true, true)) throw new IOException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private InputStream getTorInputStream() throws IOException {
|
||||||
InputStream in = resourceProvider
|
InputStream in = resourceProvider
|
||||||
.getResourceInputStream("tor_" + architecture, ".zip");
|
.getResourceInputStream("tor_" + architecture, ".zip");
|
||||||
ZipInputStream zin = new ZipInputStream(in);
|
ZipInputStream zin = new ZipInputStream(in);
|
||||||
@@ -376,8 +382,6 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private InputStream getObfs4InputStream() throws IOException {
|
private InputStream getObfs4InputStream() throws IOException {
|
||||||
if (LOG.isLoggable(INFO))
|
|
||||||
LOG.info("Installing obfs4proxy binary for " + architecture);
|
|
||||||
InputStream in = resourceProvider
|
InputStream in = resourceProvider
|
||||||
.getResourceInputStream("obfs4proxy_" + architecture, ".zip");
|
.getResourceInputStream("obfs4proxy_" + architecture, ".zip");
|
||||||
ZipInputStream zin = new ZipInputStream(in);
|
ZipInputStream zin = new ZipInputStream(in);
|
||||||
@@ -569,6 +573,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
if (enable) {
|
if (enable) {
|
||||||
Collection<String> conf = new ArrayList<>();
|
Collection<String> conf = new ArrayList<>();
|
||||||
conf.add("UseBridges 1");
|
conf.add("UseBridges 1");
|
||||||
|
File obfs4File = getObfs4ExecutableFile();
|
||||||
if (needsMeek) {
|
if (needsMeek) {
|
||||||
conf.add("ClientTransportPlugin meek_lite exec " +
|
conf.add("ClientTransportPlugin meek_lite exec " +
|
||||||
obfs4File.getAbsolutePath());
|
obfs4File.getAbsolutePath());
|
||||||
@@ -858,6 +863,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
if (!state.isTorRunning()) return;
|
if (!state.isTorRunning()) return;
|
||||||
boolean online = status.isConnected();
|
boolean online = status.isConnected();
|
||||||
boolean wifi = status.isWifi();
|
boolean wifi = status.isWifi();
|
||||||
|
boolean ipv6Only = status.isIpv6Only();
|
||||||
String country = locationUtils.getCurrentCountry();
|
String country = locationUtils.getCurrentCountry();
|
||||||
boolean blocked =
|
boolean blocked =
|
||||||
circumventionProvider.isTorProbablyBlocked(country);
|
circumventionProvider.isTorProbablyBlocked(country);
|
||||||
@@ -874,7 +880,8 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
boolean automatic = network == PREF_TOR_NETWORK_AUTOMATIC;
|
boolean automatic = network == PREF_TOR_NETWORK_AUTOMATIC;
|
||||||
|
|
||||||
if (LOG.isLoggable(INFO)) {
|
if (LOG.isLoggable(INFO)) {
|
||||||
LOG.info("Online: " + online + ", wifi: " + wifi);
|
LOG.info("Online: " + online + ", wifi: " + wifi
|
||||||
|
+ ", IPv6 only: " + ipv6Only);
|
||||||
if (country.isEmpty()) LOG.info("Country code unknown");
|
if (country.isEmpty()) LOG.info("Country code unknown");
|
||||||
else LOG.info("Country code: " + country);
|
else LOG.info("Country code: " + country);
|
||||||
LOG.info("Charging: " + charging);
|
LOG.info("Charging: " + charging);
|
||||||
@@ -911,7 +918,8 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
enableNetwork = true;
|
enableNetwork = true;
|
||||||
if (network == PREF_TOR_NETWORK_WITH_BRIDGES ||
|
if (network == PREF_TOR_NETWORK_WITH_BRIDGES ||
|
||||||
(automatic && bridgesWork)) {
|
(automatic && bridgesWork)) {
|
||||||
if (circumventionProvider.needsMeek(country)) {
|
if (ipv6Only ||
|
||||||
|
circumventionProvider.needsMeek(country)) {
|
||||||
LOG.info("Using meek bridges");
|
LOG.info("Using meek bridges");
|
||||||
enableBridges = true;
|
enableBridges = true;
|
||||||
useMeek = true;
|
useMeek = true;
|
||||||
@@ -937,6 +945,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
if (enableNetwork) {
|
if (enableNetwork) {
|
||||||
enableBridges(enableBridges, useMeek);
|
enableBridges(enableBridges, useMeek);
|
||||||
enableConnectionPadding(enableConnectionPadding);
|
enableConnectionPadding(enableConnectionPadding);
|
||||||
|
useIpv6(ipv6Only);
|
||||||
}
|
}
|
||||||
enableNetwork(enableNetwork);
|
enableNetwork(enableNetwork);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -949,6 +958,11 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
|
|||||||
controlConnection.setConf("ConnectionPadding", enable ? "1" : "0");
|
controlConnection.setConf("ConnectionPadding", enable ? "1" : "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void useIpv6(boolean ipv6Only) throws IOException {
|
||||||
|
controlConnection.setConf("ClientUseIPv4", ipv6Only ? "0" : "1");
|
||||||
|
controlConnection.setConf("ClientUseIPv6", ipv6Only ? "1" : "0");
|
||||||
|
}
|
||||||
|
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
protected class PluginState {
|
protected class PluginState {
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import org.briarproject.bramble.api.system.Clock;
|
|||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
import static org.briarproject.bramble.api.plugin.TransportId.MAX_TRANSPORT_ID_LENGTH;
|
import static org.briarproject.bramble.api.plugin.TransportId.MAX_TRANSPORT_ID_LENGTH;
|
||||||
|
import static org.briarproject.bramble.api.properties.TransportPropertyConstants.MSG_KEY_LOCAL;
|
||||||
|
import static org.briarproject.bramble.api.properties.TransportPropertyConstants.MSG_KEY_TRANSPORT_ID;
|
||||||
|
import static org.briarproject.bramble.api.properties.TransportPropertyConstants.MSG_KEY_VERSION;
|
||||||
import static org.briarproject.bramble.util.ValidationUtils.checkLength;
|
import static org.briarproject.bramble.util.ValidationUtils.checkLength;
|
||||||
import static org.briarproject.bramble.util.ValidationUtils.checkSize;
|
import static org.briarproject.bramble.util.ValidationUtils.checkSize;
|
||||||
|
|
||||||
@@ -43,9 +46,9 @@ class TransportPropertyValidator extends BdfMessageValidator {
|
|||||||
clientHelper.parseAndValidateTransportProperties(dictionary);
|
clientHelper.parseAndValidateTransportProperties(dictionary);
|
||||||
// Return the metadata
|
// Return the metadata
|
||||||
BdfDictionary meta = new BdfDictionary();
|
BdfDictionary meta = new BdfDictionary();
|
||||||
meta.put("transportId", transportId);
|
meta.put(MSG_KEY_TRANSPORT_ID, transportId);
|
||||||
meta.put("version", version);
|
meta.put(MSG_KEY_VERSION, version);
|
||||||
meta.put("local", false);
|
meta.put(MSG_KEY_LOCAL, false);
|
||||||
return new BdfMessageContext(meta);
|
return new BdfMessageContext(meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.net.SocketFactory;
|
import javax.net.SocketFactory;
|
||||||
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static org.briarproject.bramble.util.IoUtils.tryToClose;
|
import static org.briarproject.bramble.util.IoUtils.tryToClose;
|
||||||
|
|
||||||
@@ -100,11 +101,12 @@ class DevReporterImpl implements DevReporter, EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendReports() {
|
public int sendReports() {
|
||||||
File reportDir = devConfig.getReportDir();
|
File reportDir = devConfig.getReportDir();
|
||||||
File[] reports = reportDir.listFiles();
|
File[] reports = reportDir.listFiles();
|
||||||
|
int reportsSent = 0;
|
||||||
if (reports == null || reports.length == 0)
|
if (reports == null || reports.length == 0)
|
||||||
return; // No reports to send
|
return reportsSent; // No reports to send
|
||||||
|
|
||||||
LOG.info("Sending reports to developers");
|
LOG.info("Sending reports to developers");
|
||||||
for (File f : reports) {
|
for (File f : reports) {
|
||||||
@@ -116,13 +118,15 @@ class DevReporterImpl implements DevReporter, EventListener {
|
|||||||
in = new FileInputStream(f);
|
in = new FileInputStream(f);
|
||||||
IoUtils.copyAndClose(in, out);
|
IoUtils.copyAndClose(in, out);
|
||||||
f.delete();
|
f.delete();
|
||||||
|
reportsSent++;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.log(WARNING, "Failed to send reports", e);
|
LOG.log(WARNING, "Failed to send reports", e);
|
||||||
tryToClose(out, LOG, WARNING);
|
tryToClose(out, LOG, WARNING);
|
||||||
tryToClose(in, LOG, WARNING);
|
tryToClose(in, LOG, WARNING);
|
||||||
return;
|
return reportsSent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG.info("Reports sent");
|
if (LOG.isLoggable(INFO)) LOG.info(reportsSent + " report(s) sent");
|
||||||
|
return reportsSent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
|
Bridge obfs4 192.95.36.142:443 CDF2E852BF539B82BD10E27E9115A31734E378C2 cert=qUVQ0srL1JI/vO6V6m/24anYXiJD3QP2HgzUKQtQ7GRqqUvs7P+tG43RtAqdhLOALP7DJQ iat-mode=1
|
||||||
|
Bridge obfs4 38.229.1.78:80 C8CBDB2464FC9804A69531437BCF2BE31FDD2EE4 cert=Hmyfd2ev46gGY7NoVxA9ngrPF2zCZtzskRTzoWXbxNkzeVnGFPWmrTtILRyqCTjHR+s9dg iat-mode=1
|
||||||
|
Bridge obfs4 37.218.245.14:38224 D9A82D2F9C2F65A18407B1D2B764F130847F8B5D cert=bjRaMrr1BRiAW8IE9U5z27fQaYgOhX1UCmOpg2pFpoMvo6ZgQMzLsaTzzQNTlm7hNcb+Sg iat-mode=0
|
||||||
|
Bridge obfs4 85.31.186.98:443 011F2599C0E9B27EE74B353155E244813763C3E5 cert=ayq0XzCwhpdysn5o0EyDUbmSOx3X/oTEbzDMvczHOdBJKlvIdHHLJGkZARtT4dcBFArPPg iat-mode=0
|
||||||
|
Bridge obfs4 85.31.186.26:443 91A6354697E6B02A386312F68D82CF86824D3606 cert=PBwr+S8JTVZo6MPdHnkTwXJPILWADLqfMGoVvhZClMq/Urndyd42BwX9YFJHZnBB3H0XCw iat-mode=0
|
||||||
|
Bridge obfs4 193.11.166.194:27015 2D82C2E354D531A68469ADF7F878FA6060C6BACA cert=4TLQPJrTSaDffMK7Nbao6LC7G9OW/NHkUwIdjLSS3KYf0Nv4/nQiiI8dY2TcsQx01NniOg iat-mode=0
|
||||||
|
Bridge obfs4 193.11.166.194:27020 86AC7B8D430DAC4117E9F42C9EAED18133863AAF cert=0LDeJH4JzMDtkJJrFphJCiPqKx7loozKN7VNfuukMGfHO0Z8OGdzHVkhVAOfo1mUdv9cMg iat-mode=0
|
||||||
|
Bridge obfs4 193.11.166.194:27025 1AE2C08904527FEA90C4C4F8C1083EA59FBC6FAF cert=ItvYZzW5tn6v3G4UnQa6Qz04Npro6e81AP70YujmK/KXwDFPTs3aHXcHp4n8Vt6w/bv8cA iat-mode=0
|
||||||
|
Bridge obfs4 209.148.46.65:443 74FAD13168806246602538555B5521A0383A1875 cert=ssH+9rP8dG2NLDN2XuFw63hIO/9MNNinLmxQDpVa+7kTOa9/m+tGWT1SmSYpQ9uTBGa6Hw iat-mode=0
|
||||||
|
Bridge obfs4 146.57.248.225:22 10A6CD36A537FCE513A322361547444B393989F0 cert=K1gDtDAIcUfeLqbstggjIw2rtgIKqdIhUlHp82XRqNSq/mtAjp1BIC9vHKJ2FAEpGssTPw iat-mode=0
|
||||||
|
Bridge obfs4 45.145.95.6:27015 C5B7CD6946FF10C5B3E89691A7D3F2C122D2117C cert=TD7PbUO0/0k6xYHMPW3vJxICfkMZNdkRrb63Zhl5j9dW3iRGiCx0A7mPhe5T2EDzQ35+Zw iat-mode=0
|
||||||
|
Bridge obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0
|
||||||
Bridge obfs4 78.46.188.239:37356 5A2D2F4158D0453E00C7C176978D3F41D69C45DB cert=3c0SwxpOisbohNxEc4tb875RVW8eOu1opRTVXJhafaKA/PNNtI7ElQIVOVZg1AdL5bxGCw iat-mode=0
|
Bridge obfs4 78.46.188.239:37356 5A2D2F4158D0453E00C7C176978D3F41D69C45DB cert=3c0SwxpOisbohNxEc4tb875RVW8eOu1opRTVXJhafaKA/PNNtI7ElQIVOVZg1AdL5bxGCw iat-mode=0
|
||||||
Bridge obfs4 52.15.78.72:9443 02069A3C5362476936B62BA6F5ACC41ABD573A9B cert=ijYG/OKc7kqu2YzKNFfeXN7/BG2BOgfEP2KyYEiGDQthnHbsOiTWHeIG0WJVW+BckzDgKw iat-mode=0
|
Bridge meek_lite 192.0.2.2:2 97700DFE9F483596DDA6264C4D7DF7641E1E39CE url=https://meek.azureedge.net/ front=ajax.aspnetcdn.com
|
||||||
Bridge obfs4 13.58.29.242:9443 0C58939A77DA6B6B29D4B5236A75865659607AE0 cert=OylWIEHb/ezpq1zWxW0sgKRn+9ARH2eOcQOZ8/Gew+4l+oKOhQ2jUX/Y+FSl61JorXZUWA iat-mode=0
|
|
||||||
Bridge obfs4 45.33.37.112:9443 60A609BB4ABE8D46E634AE81ED29ADAB7776B399 cert=t5v19WmNv5Sc2YPNr8RQids365W7MY8zJwQVkOxBjUMFomMWARDzsbYpcWLLcw0J9Gm+BQ iat-mode=0
|
|
||||||
Bridge meek_lite 0.0.2.0:2 97700DFE9F483596DDA6264C4D7DF7641E1E39CE url=https://meek.azureedge.net/ front=ajax.aspnetcdn.com
|
|
||||||
@@ -8,18 +8,15 @@ import org.briarproject.bramble.api.contact.PendingContactState;
|
|||||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
|
||||||
import org.briarproject.bramble.api.db.NoSuchContactException;
|
import org.briarproject.bramble.api.db.NoSuchContactException;
|
||||||
import org.briarproject.bramble.api.db.Transaction;
|
import org.briarproject.bramble.api.db.Transaction;
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
import org.briarproject.bramble.api.identity.AuthorId;
|
||||||
import org.briarproject.bramble.api.identity.AuthorInfo;
|
|
||||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||||
import org.briarproject.bramble.api.transport.KeyManager;
|
import org.briarproject.bramble.api.transport.KeyManager;
|
||||||
import org.briarproject.bramble.test.BrambleMockTestCase;
|
import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||||
import org.briarproject.bramble.test.DbExpectations;
|
import org.briarproject.bramble.test.DbExpectations;
|
||||||
import org.jmock.Expectations;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -31,10 +28,6 @@ import static java.util.Collections.singletonList;
|
|||||||
import static org.briarproject.bramble.api.contact.HandshakeLinkConstants.BASE32_LINK_BYTES;
|
import static org.briarproject.bramble.api.contact.HandshakeLinkConstants.BASE32_LINK_BYTES;
|
||||||
import static org.briarproject.bramble.api.contact.PendingContactState.WAITING_FOR_CONNECTION;
|
import static org.briarproject.bramble.api.contact.PendingContactState.WAITING_FOR_CONNECTION;
|
||||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.UNKNOWN;
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.UNVERIFIED;
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.VERIFIED;
|
|
||||||
import static org.briarproject.bramble.test.TestUtils.getAgreementPrivateKey;
|
import static org.briarproject.bramble.test.TestUtils.getAgreementPrivateKey;
|
||||||
import static org.briarproject.bramble.test.TestUtils.getAgreementPublicKey;
|
import static org.briarproject.bramble.test.TestUtils.getAgreementPublicKey;
|
||||||
import static org.briarproject.bramble.test.TestUtils.getAuthor;
|
import static org.briarproject.bramble.test.TestUtils.getAuthor;
|
||||||
@@ -46,7 +39,6 @@ import static org.briarproject.bramble.test.TestUtils.getSecretKey;
|
|||||||
import static org.briarproject.bramble.util.StringUtils.getRandomBase32String;
|
import static org.briarproject.bramble.util.StringUtils.getRandomBase32String;
|
||||||
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class ContactManagerImplTest extends BrambleMockTestCase {
|
public class ContactManagerImplTest extends BrambleMockTestCase {
|
||||||
@@ -212,75 +204,6 @@ public class ContactManagerImplTest extends BrambleMockTestCase {
|
|||||||
assertTrue(contactManager.contactExists(remote.getId(), local));
|
assertTrue(contactManager.contactExists(remote.getId(), local));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetAuthorInfo() throws Exception {
|
|
||||||
Transaction txn = new Transaction(null, true);
|
|
||||||
|
|
||||||
context.checking(new DbExpectations() {{
|
|
||||||
oneOf(identityManager).getLocalAuthor(txn);
|
|
||||||
will(returnValue(localAuthor));
|
|
||||||
oneOf(db).getContactsByAuthorId(txn, remote.getId());
|
|
||||||
will(returnValue(singletonList(contact)));
|
|
||||||
}});
|
|
||||||
|
|
||||||
AuthorInfo authorInfo =
|
|
||||||
contactManager.getAuthorInfo(txn, remote.getId());
|
|
||||||
assertEquals(UNVERIFIED, authorInfo.getStatus());
|
|
||||||
assertEquals(contact.getAlias(), authorInfo.getAlias());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetAuthorInfoTransaction() throws DbException {
|
|
||||||
Transaction txn = new Transaction(null, true);
|
|
||||||
|
|
||||||
// check unknown author
|
|
||||||
context.checking(new Expectations() {{
|
|
||||||
oneOf(identityManager).getLocalAuthor(txn);
|
|
||||||
will(returnValue(localAuthor));
|
|
||||||
oneOf(db).getContactsByAuthorId(txn, remote.getId());
|
|
||||||
will(returnValue(emptyList()));
|
|
||||||
}});
|
|
||||||
|
|
||||||
AuthorInfo authorInfo =
|
|
||||||
contactManager.getAuthorInfo(txn, remote.getId());
|
|
||||||
assertEquals(UNKNOWN, authorInfo.getStatus());
|
|
||||||
assertNull(authorInfo.getAlias());
|
|
||||||
|
|
||||||
// check unverified contact
|
|
||||||
checkAuthorInfoContext(txn, remote.getId(), singletonList(contact));
|
|
||||||
authorInfo = contactManager.getAuthorInfo(txn, remote.getId());
|
|
||||||
assertEquals(UNVERIFIED, authorInfo.getStatus());
|
|
||||||
assertEquals(contact.getAlias(), authorInfo.getAlias());
|
|
||||||
|
|
||||||
// check verified contact
|
|
||||||
Contact verified = getContact(remote, local, true);
|
|
||||||
checkAuthorInfoContext(txn, remote.getId(), singletonList(verified));
|
|
||||||
authorInfo = contactManager.getAuthorInfo(txn, remote.getId());
|
|
||||||
assertEquals(VERIFIED, authorInfo.getStatus());
|
|
||||||
assertEquals(verified.getAlias(), authorInfo.getAlias());
|
|
||||||
|
|
||||||
// check ourselves
|
|
||||||
context.checking(new Expectations() {{
|
|
||||||
oneOf(identityManager).getLocalAuthor(txn);
|
|
||||||
will(returnValue(localAuthor));
|
|
||||||
never(db).getContactsByAuthorId(txn, remote.getId());
|
|
||||||
}});
|
|
||||||
|
|
||||||
authorInfo = contactManager.getAuthorInfo(txn, localAuthor.getId());
|
|
||||||
assertEquals(OURSELVES, authorInfo.getStatus());
|
|
||||||
assertNull(authorInfo.getAlias());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkAuthorInfoContext(Transaction txn, AuthorId authorId,
|
|
||||||
Collection<Contact> contacts) throws DbException {
|
|
||||||
context.checking(new Expectations() {{
|
|
||||||
oneOf(identityManager).getLocalAuthor(txn);
|
|
||||||
will(returnValue(localAuthor));
|
|
||||||
oneOf(db).getContactsByAuthorId(txn, authorId);
|
|
||||||
will(returnValue(contacts));
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetHandshakeLink() throws Exception {
|
public void testGetHandshakeLink() throws Exception {
|
||||||
Transaction txn = new Transaction(null, true);
|
Transaction txn = new Transaction(null, true);
|
||||||
|
|||||||
@@ -22,6 +22,17 @@ public class BrambleCoreIntegrationTestModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
FeatureFlags provideFeatureFlags() {
|
FeatureFlags provideFeatureFlags() {
|
||||||
return () -> true;
|
return new FeatureFlags() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldEnableImageAttachments() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldEnableProfilePictures() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ dependencies {
|
|||||||
implementation fileTree(dir: 'libs', include: '*.jar')
|
implementation fileTree(dir: 'libs', include: '*.jar')
|
||||||
implementation 'net.java.dev.jna:jna:4.5.2'
|
implementation 'net.java.dev.jna:jna:4.5.2'
|
||||||
implementation 'net.java.dev.jna:jna-platform:4.5.2'
|
implementation 'net.java.dev.jna:jna-platform:4.5.2'
|
||||||
tor 'org.briarproject:tor:0.3.5.10@zip'
|
tor 'org.briarproject:tor:0.3.5.12@zip'
|
||||||
tor 'org.briarproject:obfs4proxy:0.0.7@zip'
|
tor 'org.briarproject:obfs4proxy:0.0.7@zip'
|
||||||
|
|
||||||
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
|
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import org.briarproject.bramble.api.network.NetworkStatus;
|
|||||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
|
|
||||||
|
import java.net.Inet4Address;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@@ -14,8 +16,8 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import static java.net.NetworkInterface.getNetworkInterfaces;
|
import static java.net.NetworkInterface.getNetworkInterfaces;
|
||||||
import static java.util.Collections.list;
|
import static java.util.Collections.list;
|
||||||
import static java.util.logging.Level.INFO;
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@@ -23,7 +25,7 @@ import static org.briarproject.bramble.util.LogUtils.logException;
|
|||||||
class JavaNetworkManager implements NetworkManager {
|
class JavaNetworkManager implements NetworkManager {
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(JavaNetworkManager.class.getName());
|
getLogger(JavaNetworkManager.class.getName());
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
JavaNetworkManager() {
|
JavaNetworkManager() {
|
||||||
@@ -31,26 +33,28 @@ class JavaNetworkManager implements NetworkManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkStatus getNetworkStatus() {
|
public NetworkStatus getNetworkStatus() {
|
||||||
boolean connected = false;
|
boolean connected = false, hasIpv4 = false, hasIpv6Unicast = false;
|
||||||
try {
|
try {
|
||||||
Enumeration<NetworkInterface> interfaces = getNetworkInterfaces();
|
Enumeration<NetworkInterface> interfaces = getNetworkInterfaces();
|
||||||
if (interfaces != null) {
|
if (interfaces == null) {
|
||||||
|
LOG.info("No network interfaces");
|
||||||
|
} else {
|
||||||
for (NetworkInterface i : list(interfaces)) {
|
for (NetworkInterface i : list(interfaces)) {
|
||||||
if (i.isLoopback()) continue;
|
if (i.isLoopback() || !i.isUp()) continue;
|
||||||
if (i.isUp() && i.getInetAddresses().hasMoreElements()) {
|
for (InetAddress addr : list(i.getInetAddresses())) {
|
||||||
if (LOG.isLoggable(INFO)) {
|
|
||||||
LOG.info("Interface " + i.getDisplayName() +
|
|
||||||
" is up with at least one address.");
|
|
||||||
}
|
|
||||||
connected = true;
|
connected = true;
|
||||||
break;
|
if (addr instanceof Inet4Address) {
|
||||||
|
hasIpv4 = true;
|
||||||
|
} else if (!addr.isMulticastAddress()) {
|
||||||
|
hasIpv6Unicast = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
logException(LOG, WARNING, e);
|
logException(LOG, WARNING, e);
|
||||||
}
|
}
|
||||||
return new NetworkStatus(connected, false);
|
return new NetworkStatus(connected, false, !hasIpv4 && hasIpv6Unicast);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ dependencyVerification {
|
|||||||
'org.apache.ant:ant:1.9.4:ant-1.9.4.jar:649ae0730251de07b8913f49286d46bba7b92d47c5f332610aa426c4f02161d8',
|
'org.apache.ant:ant:1.9.4:ant-1.9.4.jar:649ae0730251de07b8913f49286d46bba7b92d47c5f332610aa426c4f02161d8',
|
||||||
'org.beanshell:bsh:1.3.0:bsh-1.3.0.jar:9b04edc75d19db54f1b4e8b5355e9364384c6cf71eb0a1b9724c159d779879f8',
|
'org.beanshell:bsh:1.3.0:bsh-1.3.0.jar:9b04edc75d19db54f1b4e8b5355e9364384c6cf71eb0a1b9724c159d779879f8',
|
||||||
'org.briarproject:obfs4proxy:0.0.7:obfs4proxy-0.0.7.zip:5b2f693262ce43a7e130f7cc7d5d1617925330640a2eb6d71085e95df8ee0642',
|
'org.briarproject:obfs4proxy:0.0.7:obfs4proxy-0.0.7.zip:5b2f693262ce43a7e130f7cc7d5d1617925330640a2eb6d71085e95df8ee0642',
|
||||||
'org.briarproject:tor:0.3.5.10:tor-0.3.5.10.zip:7b387d3523ae8af289c23be59dc4c64ec5d3721385d7825a09705095e3318d5c',
|
'org.briarproject:tor:0.3.5.12:tor-0.3.5.12.zip:2f542c4befd216f2226bf7c76e3b8b2d99af6f146a8cb28bf727f42014587006',
|
||||||
'org.checkerframework:checker-compat-qual:2.5.3:checker-compat-qual-2.5.3.jar:d76b9afea61c7c082908023f0cbc1427fab9abd2df915c8b8a3e7a509bccbc6d',
|
'org.checkerframework:checker-compat-qual:2.5.3:checker-compat-qual-2.5.3.jar:d76b9afea61c7c082908023f0cbc1427fab9abd2df915c8b8a3e7a509bccbc6d',
|
||||||
'org.checkerframework:checker-qual:2.5.2:checker-qual-2.5.2.jar:64b02691c8b9d4e7700f8ee2e742dce7ea2c6e81e662b7522c9ee3bf568c040a',
|
'org.checkerframework:checker-qual:2.5.2:checker-qual-2.5.2.jar:64b02691c8b9d4e7700f8ee2e742dce7ea2c6e81e662b7522c9ee3bf568c040a',
|
||||||
'org.codehaus.mojo:animal-sniffer-annotations:1.17:animal-sniffer-annotations-1.17.jar:92654f493ecfec52082e76354f0ebf87648dc3d5cec2e3c3cdb947c016747a53',
|
'org.codehaus.mojo:animal-sniffer-annotations:1.17:animal-sniffer-annotations-1.17.jar:92654f493ecfec52082e76354f0ebf87648dc3d5cec2e3c3cdb947c016747a53',
|
||||||
|
|||||||
1
briar-android/artwork/notification_signout.svg
Normal file
1
briar-android/artwork/notification_signout.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M16,17V14H9V10H16V7L21,12L16,17M14,2A2,2 0 0,1 16,4V6H14V4H5V20H14V18H16V20A2,2 0 0,1 14,22H5A2,2 0 0,1 3,20V4A2,2 0 0,1 5,2H14Z" /></svg>
|
||||||
|
After Width: | Height: | Size: 423 B |
@@ -16,15 +16,17 @@ def getStdout = { command, defaultValue ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion 30
|
||||||
buildToolsVersion '29.0.2'
|
buildToolsVersion '30.0.2'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 28
|
targetSdkVersion 29
|
||||||
versionCode 10210
|
versionCode 10214
|
||||||
versionName "1.2.10"
|
versionName "1.2.14"
|
||||||
applicationId "org.briarproject.briar.android"
|
applicationId "org.briarproject.briar.android"
|
||||||
|
|
||||||
|
vectorDrawables.useSupportLibrary = true
|
||||||
buildConfigField "String", "GitHash",
|
buildConfigField "String", "GitHash",
|
||||||
"\"${getStdout(['git', 'rev-parse', '--short=7', 'HEAD'], 'No commit hash')}\""
|
"\"${getStdout(['git', 'rev-parse', '--short=7', 'HEAD'], 'No commit hash')}\""
|
||||||
def now = (long) (System.currentTimeMillis() / 1000)
|
def now = (long) (System.currentTimeMillis() / 1000)
|
||||||
@@ -93,23 +95,22 @@ dependencies {
|
|||||||
implementation project(path: ':bramble-core', configuration: 'default')
|
implementation project(path: ':bramble-core', configuration: 'default')
|
||||||
implementation project(':bramble-android')
|
implementation project(':bramble-android')
|
||||||
|
|
||||||
implementation 'androidx.preference:preference:1.1.0'
|
implementation 'androidx.preference:preference:1.1.1'
|
||||||
implementation 'androidx.exifinterface:exifinterface:1.0.0'
|
implementation 'androidx.exifinterface:exifinterface:1.3.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||||
implementation 'com.google.android.material:material:1.1.0-beta01'
|
implementation 'com.google.android.material:material:1.2.1'
|
||||||
implementation 'androidx.recyclerview:recyclerview-selection:1.1.0-rc01'
|
implementation 'androidx.recyclerview:recyclerview-selection:1.1.0-rc03'
|
||||||
|
|
||||||
implementation 'ch.acra:acra:4.11'
|
|
||||||
implementation 'info.guardianproject.panic:panic:1.0'
|
implementation 'info.guardianproject.panic:panic:1.0'
|
||||||
implementation 'info.guardianproject.trustedintents:trustedintents:0.2'
|
implementation 'info.guardianproject.trustedintents:trustedintents:0.2'
|
||||||
implementation 'de.hdodenhof:circleimageview:3.0.1'
|
implementation 'de.hdodenhof:circleimageview:3.0.1'
|
||||||
implementation 'com.google.zxing:core:3.3.3' // newer version need minSdk 24
|
implementation 'com.google.zxing:core:3.3.3' // newer version need minSdk 24
|
||||||
implementation 'uk.co.samuelwall:material-tap-target-prompt:3.0.0'
|
implementation 'uk.co.samuelwall:material-tap-target-prompt:3.0.0'
|
||||||
implementation 'com.vanniktech:emoji-google:0.6.0'
|
implementation 'com.vanniktech:emoji-google:0.6.0' // newer versions need minSdk 21
|
||||||
implementation 'com.github.kobakei:MaterialFabSpeedDial:1.2.1'
|
implementation 'com.github.kobakei:MaterialFabSpeedDial:1.2.1'
|
||||||
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
||||||
def glideVersion = '4.10.0'
|
def glideVersion = '4.11.0'
|
||||||
implementation("com.github.bumptech.glide:glide:$glideVersion") {
|
implementation("com.github.bumptech.glide:glide:$glideVersion") {
|
||||||
exclude group: 'com.android.support'
|
exclude group: 'com.android.support'
|
||||||
exclude module: 'disklrucache' // when there's no disk cache, we can't accidentally use it
|
exclude module: 'disklrucache' // when there's no disk cache, we can't accidentally use it
|
||||||
@@ -120,33 +121,32 @@ dependencies {
|
|||||||
|
|
||||||
compileOnly 'javax.annotation:jsr250-api:1.0'
|
compileOnly 'javax.annotation:jsr250-api:1.0'
|
||||||
|
|
||||||
def espressoVersion = '3.2.0'
|
def espressoVersion = '3.3.0'
|
||||||
def jmockVersion = '2.8.2'
|
def jmockVersion = '2.8.2'
|
||||||
testImplementation project(path: ':bramble-api', configuration: 'testOutput')
|
testImplementation project(path: ':bramble-api', configuration: 'testOutput')
|
||||||
testImplementation project(path: ':bramble-core', configuration: 'testOutput')
|
testImplementation project(path: ':bramble-core', configuration: 'testOutput')
|
||||||
testImplementation 'androidx.test:runner:1.2.0'
|
testImplementation 'androidx.test:runner:1.3.0'
|
||||||
testImplementation 'androidx.test.ext:junit:1.1.1'
|
testImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
testImplementation 'androidx.fragment:fragment-testing:1.1.0'
|
testImplementation 'androidx.fragment:fragment-testing:1.2.5'
|
||||||
|
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
||||||
testImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
|
testImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
|
||||||
testImplementation 'org.robolectric:robolectric:4.3.1'
|
testImplementation 'org.robolectric:robolectric:4.3.1'
|
||||||
testImplementation 'org.mockito:mockito-core:3.1.0'
|
testImplementation 'org.mockito:mockito-core:3.1.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.13.1'
|
||||||
testImplementation "org.jmock:jmock:$jmockVersion"
|
testImplementation "org.jmock:jmock:$jmockVersion"
|
||||||
testImplementation "org.jmock:jmock-junit4:$jmockVersion"
|
testImplementation "org.jmock:jmock-junit4:$jmockVersion"
|
||||||
testImplementation "org.jmock:jmock-legacy:$jmockVersion"
|
testImplementation "org.jmock:jmock-legacy:$jmockVersion"
|
||||||
|
|
||||||
androidTestImplementation project(path: ':bramble-api', configuration: 'testOutput')
|
androidTestImplementation project(path: ':bramble-api', configuration: 'testOutput')
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
|
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
|
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
|
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
|
||||||
androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.24"
|
androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.24"
|
||||||
androidTestCompileOnly 'javax.annotation:jsr250-api:1.0'
|
androidTestCompileOnly 'javax.annotation:jsr250-api:1.0'
|
||||||
androidTestImplementation 'junit:junit:4.12'
|
androidTestImplementation 'junit:junit:4.13.1'
|
||||||
androidTestScreenshotImplementation('tools.fastlane:screengrab:1.2.0') {
|
androidTestScreenshotImplementation 'tools.fastlane:screengrab:2.0.0'
|
||||||
// workaround for jetifier issue https://issuetracker.google.com/issues/123060356
|
androidTestScreenshotImplementation 'com.jraska:falcon:2.1.1'
|
||||||
exclude group: 'com.android.support.test.uiautomator'
|
|
||||||
}
|
|
||||||
androidTestScreenshotImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
androidTestScreenshotImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,3 +37,6 @@
|
|||||||
|
|
||||||
# Glide
|
# Glide
|
||||||
-dontwarn com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper
|
-dontwarn com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper
|
||||||
|
|
||||||
|
# Dependency injection annotations, needed for UI tests on older API levels
|
||||||
|
-keep class javax.inject.**
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
@@ -5,6 +5,7 @@ import org.briarproject.bramble.BrambleCoreModule;
|
|||||||
import org.briarproject.bramble.account.BriarAccountModule;
|
import org.briarproject.bramble.account.BriarAccountModule;
|
||||||
import org.briarproject.briar.BriarCoreModule;
|
import org.briarproject.briar.BriarCoreModule;
|
||||||
import org.briarproject.briar.android.attachment.AttachmentModule;
|
import org.briarproject.briar.android.attachment.AttachmentModule;
|
||||||
|
import org.briarproject.briar.android.attachment.media.MediaModule;
|
||||||
import org.briarproject.briar.android.navdrawer.NavDrawerActivityTest;
|
import org.briarproject.briar.android.navdrawer.NavDrawerActivityTest;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@@ -15,6 +16,7 @@ import dagger.Component;
|
|||||||
@Component(modules = {
|
@Component(modules = {
|
||||||
AppModule.class,
|
AppModule.class,
|
||||||
AttachmentModule.class,
|
AttachmentModule.class,
|
||||||
|
MediaModule.class,
|
||||||
BriarCoreModule.class,
|
BriarCoreModule.class,
|
||||||
BrambleAndroidModule.class,
|
BrambleAndroidModule.class,
|
||||||
BriarAccountModule.class,
|
BriarAccountModule.class,
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
package org.briarproject.briar.android.attachment;
|
|
||||||
|
|
||||||
import android.content.res.AssetManager;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import static androidx.test.InstrumentationRegistry.getContext;
|
|
||||||
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
|
||||||
|
|
||||||
abstract class AbstractAttachmentCreationTaskTest {
|
|
||||||
|
|
||||||
private final ImageHelper imageHelper = new ImageHelperImpl();
|
|
||||||
private final ImageSizeCalculator imageSizeCalculator =
|
|
||||||
new ImageSizeCalculator(imageHelper);
|
|
||||||
|
|
||||||
private AttachmentCreationTask task;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
@SuppressWarnings("ConstantConditions") // add real objects when needed
|
|
||||||
public void setUp() {
|
|
||||||
task = new AttachmentCreationTask(null,
|
|
||||||
getApplicationContext().getContentResolver(), null,
|
|
||||||
imageSizeCalculator, null, null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testCompress(String filename, String contentType)
|
|
||||||
throws IOException {
|
|
||||||
InputStream is = getAssetManager().open(filename);
|
|
||||||
task.compressImage(is, contentType);
|
|
||||||
}
|
|
||||||
|
|
||||||
static AssetManager getAssetManager() {
|
|
||||||
// pm.getResourcesForApplication(packageName).getAssets() did not work
|
|
||||||
//noinspection deprecation
|
|
||||||
return getContext().getAssets();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.briarproject.briar.android.attachment;
|
||||||
|
|
||||||
|
import org.briarproject.briar.android.attachment.media.MediaModule;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.Component;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Component(modules = {
|
||||||
|
MediaModule.class
|
||||||
|
})
|
||||||
|
interface AbstractAttachmentRetrieverComponent {
|
||||||
|
|
||||||
|
void inject(AttachmentRetrieverIntegrationTest test);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,20 +1,26 @@
|
|||||||
package org.briarproject.briar.android.attachment;
|
package org.briarproject.briar.android.attachment;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.UniqueId;
|
import org.briarproject.bramble.api.UniqueId;
|
||||||
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.api.messaging.Attachment;
|
import org.briarproject.briar.android.attachment.media.ImageHelper;
|
||||||
import org.briarproject.briar.api.messaging.AttachmentHeader;
|
import org.briarproject.briar.android.attachment.media.ImageSizeCalculator;
|
||||||
|
import org.briarproject.briar.api.attachment.Attachment;
|
||||||
|
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import static androidx.test.InstrumentationRegistry.getContext;
|
import static androidx.test.InstrumentationRegistry.getContext;
|
||||||
|
import static org.briarproject.briar.android.attachment.AttachmentItem.State.AVAILABLE;
|
||||||
|
import static org.briarproject.briar.android.attachment.AttachmentItem.State.ERROR;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@@ -23,19 +29,31 @@ public class AttachmentRetrieverIntegrationTest {
|
|||||||
private final AttachmentDimensions dimensions = new AttachmentDimensions(
|
private final AttachmentDimensions dimensions = new AttachmentDimensions(
|
||||||
100, 50, 200, 75, 300
|
100, 50, 200, 75, 300
|
||||||
);
|
);
|
||||||
|
private final GroupId groupId = new GroupId(getRandomId());
|
||||||
private final MessageId msgId = new MessageId(getRandomId());
|
private final MessageId msgId = new MessageId(getRandomId());
|
||||||
|
|
||||||
private final ImageHelper imageHelper = new ImageHelperImpl();
|
@Inject
|
||||||
private final AttachmentRetriever retriever =
|
ImageHelper imageHelper;
|
||||||
new AttachmentRetrieverImpl(null, dimensions, imageHelper,
|
@Inject
|
||||||
new ImageSizeCalculator(imageHelper));
|
ImageSizeCalculator imageSizeCalculator;
|
||||||
|
|
||||||
|
private final AttachmentRetriever retriever;
|
||||||
|
|
||||||
|
public AttachmentRetrieverIntegrationTest() {
|
||||||
|
AbstractAttachmentRetrieverComponent component =
|
||||||
|
DaggerAbstractAttachmentRetrieverComponent.builder().build();
|
||||||
|
component.inject(this);
|
||||||
|
|
||||||
|
retriever = new AttachmentRetrieverImpl(null, null, dimensions,
|
||||||
|
imageHelper, imageSizeCalculator);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSmallJpegImage() throws Exception {
|
public void testSmallJpegImage() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/jpeg");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/jpeg");
|
||||||
InputStream is = getAssetInputStream("kitten_small.jpg");
|
InputStream is = getAssetInputStream("kitten_small.jpg");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(msgId, item.getMessageId());
|
assertEquals(msgId, item.getMessageId());
|
||||||
assertEquals(160, item.getWidth());
|
assertEquals(160, item.getWidth());
|
||||||
assertEquals(240, item.getHeight());
|
assertEquals(240, item.getHeight());
|
||||||
@@ -43,15 +61,15 @@ public class AttachmentRetrieverIntegrationTest {
|
|||||||
assertEquals(240, item.getThumbnailHeight());
|
assertEquals(240, item.getThumbnailHeight());
|
||||||
assertEquals("image/jpeg", item.getMimeType());
|
assertEquals("image/jpeg", item.getMimeType());
|
||||||
assertJpgOrJpeg(item.getExtension());
|
assertJpgOrJpeg(item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBigJpegImage() throws Exception {
|
public void testBigJpegImage() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/jpeg");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/jpeg");
|
||||||
InputStream is = getAssetInputStream("kitten_original.jpg");
|
InputStream is = getAssetInputStream("kitten_original.jpg");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(msgId, item.getMessageId());
|
assertEquals(msgId, item.getMessageId());
|
||||||
assertEquals(1728, item.getWidth());
|
assertEquals(1728, item.getWidth());
|
||||||
assertEquals(2592, item.getHeight());
|
assertEquals(2592, item.getHeight());
|
||||||
@@ -59,15 +77,15 @@ public class AttachmentRetrieverIntegrationTest {
|
|||||||
assertEquals(dimensions.maxHeight, item.getThumbnailHeight());
|
assertEquals(dimensions.maxHeight, item.getThumbnailHeight());
|
||||||
assertEquals("image/jpeg", item.getMimeType());
|
assertEquals("image/jpeg", item.getMimeType());
|
||||||
assertJpgOrJpeg(item.getExtension());
|
assertJpgOrJpeg(item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSmallPngImage() throws Exception {
|
public void testSmallPngImage() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/png");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/png");
|
||||||
InputStream is = getAssetInputStream("kitten.png");
|
InputStream is = getAssetInputStream("kitten.png");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(msgId, item.getMessageId());
|
assertEquals(msgId, item.getMessageId());
|
||||||
assertEquals(737, item.getWidth());
|
assertEquals(737, item.getWidth());
|
||||||
assertEquals(510, item.getHeight());
|
assertEquals(510, item.getHeight());
|
||||||
@@ -75,166 +93,166 @@ public class AttachmentRetrieverIntegrationTest {
|
|||||||
assertEquals(138, item.getThumbnailHeight());
|
assertEquals(138, item.getThumbnailHeight());
|
||||||
assertEquals("image/png", item.getMimeType());
|
assertEquals("image/png", item.getMimeType());
|
||||||
assertEquals("png", item.getExtension());
|
assertEquals("png", item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUberGif() throws Exception {
|
public void testUberGif() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/gif");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/gif");
|
||||||
InputStream is = getAssetInputStream("uber.gif");
|
InputStream is = getAssetInputStream("uber.gif");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(1, item.getWidth());
|
assertEquals(1, item.getWidth());
|
||||||
assertEquals(1, item.getHeight());
|
assertEquals(1, item.getHeight());
|
||||||
assertEquals(dimensions.minHeight, item.getThumbnailWidth());
|
assertEquals(dimensions.minHeight, item.getThumbnailWidth());
|
||||||
assertEquals(dimensions.minHeight, item.getThumbnailHeight());
|
assertEquals(dimensions.minHeight, item.getThumbnailHeight());
|
||||||
assertEquals("image/gif", item.getMimeType());
|
assertEquals("image/gif", item.getMimeType());
|
||||||
assertEquals("gif", item.getExtension());
|
assertEquals("gif", item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLottaPixels() throws Exception {
|
public void testLottaPixels() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/jpeg");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/jpeg");
|
||||||
InputStream is = getAssetInputStream("lottapixel.jpg");
|
InputStream is = getAssetInputStream("lottapixel.jpg");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(64250, item.getWidth());
|
assertEquals(64250, item.getWidth());
|
||||||
assertEquals(64250, item.getHeight());
|
assertEquals(64250, item.getHeight());
|
||||||
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
||||||
assertEquals(dimensions.maxWidth, item.getThumbnailHeight());
|
assertEquals(dimensions.maxWidth, item.getThumbnailHeight());
|
||||||
assertEquals("image/jpeg", item.getMimeType());
|
assertEquals("image/jpeg", item.getMimeType());
|
||||||
assertJpgOrJpeg(item.getExtension());
|
assertJpgOrJpeg(item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testImageIoCrash() throws Exception {
|
public void testImageIoCrash() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/png");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/png");
|
||||||
InputStream is = getAssetInputStream("image_io_crash.png");
|
InputStream is = getAssetInputStream("image_io_crash.png");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(1184, item.getWidth());
|
assertEquals(1184, item.getWidth());
|
||||||
assertEquals(448, item.getHeight());
|
assertEquals(448, item.getHeight());
|
||||||
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
||||||
assertEquals(dimensions.minHeight, item.getThumbnailHeight());
|
assertEquals(dimensions.minHeight, item.getThumbnailHeight());
|
||||||
assertEquals("image/png", item.getMimeType());
|
assertEquals("image/png", item.getMimeType());
|
||||||
assertEquals("png", item.getExtension());
|
assertEquals("png", item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGimpCrash() throws Exception {
|
public void testGimpCrash() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/gif");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/gif");
|
||||||
InputStream is = getAssetInputStream("gimp_crash.gif");
|
InputStream is = getAssetInputStream("gimp_crash.gif");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(1, item.getWidth());
|
assertEquals(1, item.getWidth());
|
||||||
assertEquals(1, item.getHeight());
|
assertEquals(1, item.getHeight());
|
||||||
assertEquals(dimensions.minHeight, item.getThumbnailWidth());
|
assertEquals(dimensions.minHeight, item.getThumbnailWidth());
|
||||||
assertEquals(dimensions.minHeight, item.getThumbnailHeight());
|
assertEquals(dimensions.minHeight, item.getThumbnailHeight());
|
||||||
assertEquals("image/gif", item.getMimeType());
|
assertEquals("image/gif", item.getMimeType());
|
||||||
assertEquals("gif", item.getExtension());
|
assertEquals("gif", item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOptiPngAfl() throws Exception {
|
public void testOptiPngAfl() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/gif");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/gif");
|
||||||
InputStream is = getAssetInputStream("opti_png_afl.gif");
|
InputStream is = getAssetInputStream("opti_png_afl.gif");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(32, item.getWidth());
|
assertEquals(32, item.getWidth());
|
||||||
assertEquals(32, item.getHeight());
|
assertEquals(32, item.getHeight());
|
||||||
assertEquals(dimensions.minHeight, item.getThumbnailWidth());
|
assertEquals(dimensions.minHeight, item.getThumbnailWidth());
|
||||||
assertEquals(dimensions.minHeight, item.getThumbnailHeight());
|
assertEquals(dimensions.minHeight, item.getThumbnailHeight());
|
||||||
assertEquals("image/gif", item.getMimeType());
|
assertEquals("image/gif", item.getMimeType());
|
||||||
assertEquals("gif", item.getExtension());
|
assertEquals("gif", item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLibrawError() throws Exception {
|
public void testLibrawError() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/jpeg");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/jpeg");
|
||||||
InputStream is = getAssetInputStream("libraw_error.jpg");
|
InputStream is = getAssetInputStream("libraw_error.jpg");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertTrue(item.hasError());
|
assertEquals(ERROR, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSmallAnimatedGifMaxDimensions() throws Exception {
|
public void testSmallAnimatedGifMaxDimensions() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/gif");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/gif");
|
||||||
InputStream is = getAssetInputStream("animated.gif");
|
InputStream is = getAssetInputStream("animated.gif");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(65535, item.getWidth());
|
assertEquals(65535, item.getWidth());
|
||||||
assertEquals(65535, item.getHeight());
|
assertEquals(65535, item.getHeight());
|
||||||
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
||||||
assertEquals(dimensions.maxWidth, item.getThumbnailHeight());
|
assertEquals(dimensions.maxWidth, item.getThumbnailHeight());
|
||||||
assertEquals("image/gif", item.getMimeType());
|
assertEquals("image/gif", item.getMimeType());
|
||||||
assertEquals("gif", item.getExtension());
|
assertEquals("gif", item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSmallAnimatedGifHugeDimensions() throws Exception {
|
public void testSmallAnimatedGifHugeDimensions() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/gif");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/gif");
|
||||||
InputStream is = getAssetInputStream("animated2.gif");
|
InputStream is = getAssetInputStream("animated2.gif");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(10000, item.getWidth());
|
assertEquals(10000, item.getWidth());
|
||||||
assertEquals(10000, item.getHeight());
|
assertEquals(10000, item.getHeight());
|
||||||
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
||||||
assertEquals(dimensions.maxWidth, item.getThumbnailHeight());
|
assertEquals(dimensions.maxWidth, item.getThumbnailHeight());
|
||||||
assertEquals("image/gif", item.getMimeType());
|
assertEquals("image/gif", item.getMimeType());
|
||||||
assertEquals("gif", item.getExtension());
|
assertEquals("gif", item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSmallGifLargeDimensions() throws Exception {
|
public void testSmallGifLargeDimensions() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/gif");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/gif");
|
||||||
InputStream is = getAssetInputStream("error_large.gif");
|
InputStream is = getAssetInputStream("error_large.gif");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(16384, item.getWidth());
|
assertEquals(16384, item.getWidth());
|
||||||
assertEquals(16384, item.getHeight());
|
assertEquals(16384, item.getHeight());
|
||||||
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
||||||
assertEquals(dimensions.maxWidth, item.getThumbnailHeight());
|
assertEquals(dimensions.maxWidth, item.getThumbnailHeight());
|
||||||
assertEquals("image/gif", item.getMimeType());
|
assertEquals("image/gif", item.getMimeType());
|
||||||
assertEquals("gif", item.getExtension());
|
assertEquals("gif", item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHighError() throws Exception {
|
public void testHighError() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/jpeg");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/jpeg");
|
||||||
InputStream is = getAssetInputStream("error_high.jpg");
|
InputStream is = getAssetInputStream("error_high.jpg");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(1, item.getWidth());
|
assertEquals(1, item.getWidth());
|
||||||
assertEquals(10000, item.getHeight());
|
assertEquals(10000, item.getHeight());
|
||||||
assertEquals(dimensions.minWidth, item.getThumbnailWidth());
|
assertEquals(dimensions.minWidth, item.getThumbnailWidth());
|
||||||
assertEquals(dimensions.maxHeight, item.getThumbnailHeight());
|
assertEquals(dimensions.maxHeight, item.getThumbnailHeight());
|
||||||
assertEquals("image/jpeg", item.getMimeType());
|
assertEquals("image/jpeg", item.getMimeType());
|
||||||
assertJpgOrJpeg(item.getExtension());
|
assertJpgOrJpeg(item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWideError() throws Exception {
|
public void testWideError() throws Exception {
|
||||||
AttachmentHeader h = new AttachmentHeader(msgId, "image/jpeg");
|
AttachmentHeader h = new AttachmentHeader(groupId, msgId, "image/jpeg");
|
||||||
InputStream is = getAssetInputStream("error_wide.jpg");
|
InputStream is = getAssetInputStream("error_wide.jpg");
|
||||||
Attachment a = new Attachment(h, is);
|
Attachment a = new Attachment(h, is);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, true);
|
AttachmentItem item = retriever.createAttachmentItem(a, true);
|
||||||
assertEquals(1920, item.getWidth());
|
assertEquals(1920, item.getWidth());
|
||||||
assertEquals(1, item.getHeight());
|
assertEquals(1, item.getHeight());
|
||||||
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
assertEquals(dimensions.maxWidth, item.getThumbnailWidth());
|
||||||
assertEquals(dimensions.minHeight, item.getThumbnailHeight());
|
assertEquals(dimensions.minHeight, item.getThumbnailHeight());
|
||||||
assertEquals("image/jpeg", item.getMimeType());
|
assertEquals("image/jpeg", item.getMimeType());
|
||||||
assertJpgOrJpeg(item.getExtension());
|
assertJpgOrJpeg(item.getExtension());
|
||||||
assertFalse(item.hasError());
|
assertEquals(AVAILABLE, item.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputStream getAssetInputStream(String name) throws Exception {
|
private InputStream getAssetInputStream(String name) throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.Component;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Component(modules = {
|
||||||
|
MediaModule.class
|
||||||
|
})
|
||||||
|
interface AbstractImageCompressorComponent {
|
||||||
|
|
||||||
|
void inject(AbstractImageCompressorTest test);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
|
import android.content.res.AssetManager;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static androidx.test.InstrumentationRegistry.getContext;
|
||||||
|
|
||||||
|
public abstract class AbstractImageCompressorTest {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ImageCompressor imageCompressor;
|
||||||
|
|
||||||
|
public AbstractImageCompressorTest() {
|
||||||
|
AbstractImageCompressorComponent component =
|
||||||
|
DaggerAbstractImageCompressorComponent.builder().build();
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void inject(
|
||||||
|
AbstractImageCompressorComponent component);
|
||||||
|
|
||||||
|
void testCompress(String filename, String contentType)
|
||||||
|
throws IOException {
|
||||||
|
InputStream is = getAssetManager().open(filename);
|
||||||
|
imageCompressor.compressImage(is, contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AssetManager getAssetManager() {
|
||||||
|
// pm.getResourcesForApplication(packageName).getAssets() did not work
|
||||||
|
//noinspection deprecation
|
||||||
|
return getContext().getAssets();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.Component;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Component(modules = {
|
||||||
|
MediaModule.class
|
||||||
|
})
|
||||||
|
interface AbstractImageSizeCalculatorComponent {
|
||||||
|
|
||||||
|
void inject(AbstractImageSizeCalculatorTest test);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
|
import android.content.res.AssetManager;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static androidx.test.InstrumentationRegistry.getContext;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public abstract class AbstractImageSizeCalculatorTest {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ImageSizeCalculator imageSizeCalculator;
|
||||||
|
|
||||||
|
public AbstractImageSizeCalculatorTest() {
|
||||||
|
AbstractImageSizeCalculatorComponent component =
|
||||||
|
DaggerAbstractImageSizeCalculatorComponent.builder().build();
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void inject(
|
||||||
|
AbstractImageSizeCalculatorComponent component);
|
||||||
|
|
||||||
|
void testCanCalculateSize(String filename, String contentType, int width,
|
||||||
|
int height) throws IOException {
|
||||||
|
InputStream is = getAssetManager().open(filename);
|
||||||
|
Size size = imageSizeCalculator.getSize(is, contentType);
|
||||||
|
assertFalse(size.hasError());
|
||||||
|
assertEquals(width, size.getWidth());
|
||||||
|
assertEquals(height, size.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
void testCannotCalculateSize(String filename, String contentType)
|
||||||
|
throws IOException {
|
||||||
|
InputStream is = getAssetManager().open(filename);
|
||||||
|
Size size = imageSizeCalculator.getSize(is, contentType);
|
||||||
|
assertTrue(size.hasError());
|
||||||
|
}
|
||||||
|
|
||||||
|
static AssetManager getAssetManager() {
|
||||||
|
// pm.getResourcesForApplication(packageName).getAssets() did not work
|
||||||
|
//noinspection deprecation
|
||||||
|
return getContext().getAssets();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject.briar.android.attachment;
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -9,8 +9,13 @@ import static android.os.Build.VERSION.SDK_INT;
|
|||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class AttachmentCreationTaskTest
|
public class ImageCompressorTest
|
||||||
extends AbstractAttachmentCreationTaskTest {
|
extends AbstractImageCompressorTest {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void inject(AbstractImageCompressorComponent component) {
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompressSmallPng() throws Exception {
|
public void testCompressSmallPng() throws Exception {
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ImageSizeCalculatorTest
|
||||||
|
extends AbstractImageSizeCalculatorTest {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void inject(AbstractImageSizeCalculatorComponent component) {
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeKittenSmall() throws Exception {
|
||||||
|
testCanCalculateSize("kitten_small.jpg", "image/jpeg", 160, 240);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeKittenSmallNoExif() throws Exception {
|
||||||
|
testCanCalculateSize("kitten_small_noexif.jpg", "image/jpeg", 160, 240);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeSmallPng() throws Exception {
|
||||||
|
testCanCalculateSize("red-100x100.png", "image/png", 100, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeMediumPng() throws Exception {
|
||||||
|
testCanCalculateSize("blue-500x500.png", "image/png", 500, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeLargePng() throws Exception {
|
||||||
|
testCanCalculateSize("green-1000x2000.png", "image/png", 1000, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeTransparentPng() throws Exception {
|
||||||
|
testCanCalculateSize("transparent-100x100.png", "image/png", 100, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeVeryHighJpg() throws Exception {
|
||||||
|
testCanCalculateSize("error_high.jpg", "image/jpeg", 1, 10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeVeryWideJpg() throws Exception {
|
||||||
|
testCanCalculateSize("error_wide.jpg", "image/jpeg", 1920, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeAnimatedGif1() throws Exception {
|
||||||
|
// TODO: Remove this assumption when we support large messages
|
||||||
|
assumeTrue(SDK_INT >= 24);
|
||||||
|
testCanCalculateSize("animated.gif", "image/gif", 65535, 65535);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeAnimatedGif2() throws Exception {
|
||||||
|
// TODO: Remove this assumption when we support large messages
|
||||||
|
assumeTrue(SDK_INT >= 24);
|
||||||
|
testCanCalculateSize("animated2.gif", "image/gif", 10000, 10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculateSizeVeryLargeGif() throws Exception {
|
||||||
|
// TODO: Remove this assumption when we support large messages
|
||||||
|
assumeTrue(SDK_INT >= 24);
|
||||||
|
testCanCalculateSize("error_large.gif", "image/gif", 16384, 16384);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject.briar.android.attachment;
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -17,11 +17,16 @@ import static org.junit.Assert.fail;
|
|||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public class PngSuiteAttachmentCreationTaskTest
|
public class PngSuiteImageCompressorTest
|
||||||
extends AbstractAttachmentCreationTaskTest {
|
extends AbstractImageCompressorTest {
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
getLogger(PngSuiteAttachmentCreationTaskTest.class.getName());
|
getLogger(PngSuiteImageCompressorTest.class.getName());
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void inject(AbstractImageCompressorComponent component) {
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Parameters
|
@Parameters
|
||||||
public static Iterable<String> data() throws IOException {
|
public static Iterable<String> data() throws IOException {
|
||||||
@@ -34,14 +39,14 @@ public class PngSuiteAttachmentCreationTaskTest
|
|||||||
|
|
||||||
private final String filename;
|
private final String filename;
|
||||||
|
|
||||||
public PngSuiteAttachmentCreationTaskTest(String filename) {
|
public PngSuiteImageCompressorTest(String filename) {
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPngSuiteCompress() throws Exception {
|
public void testPngSuiteCompress() throws Exception {
|
||||||
assumeTrue(isOptionalTestEnabled(
|
assumeTrue(isOptionalTestEnabled(
|
||||||
PngSuiteAttachmentCreationTaskTest.class));
|
PngSuiteImageCompressorTest.class));
|
||||||
LOG.info("Testing " + filename);
|
LOG.info("Testing " + filename);
|
||||||
if (filename.startsWith("x")) {
|
if (filename.startsWith("x")) {
|
||||||
try {
|
try {
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Parameterized;
|
||||||
|
import org.junit.runners.Parameterized.Parameters;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
|
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
|
||||||
|
import static org.briarproject.bramble.test.TestUtils.isOptionalTestEnabled;
|
||||||
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
|
@RunWith(Parameterized.class)
|
||||||
|
public class PngSuiteImageSizeCalculatorTest
|
||||||
|
extends AbstractImageSizeCalculatorTest {
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
getLogger(PngSuiteImageSizeCalculatorTest.class.getName());
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void inject(AbstractImageSizeCalculatorComponent component) {
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Parameters
|
||||||
|
public static Iterable<String> data() throws IOException {
|
||||||
|
List<String> data = new ArrayList<>();
|
||||||
|
String[] files = requireNonNull(getAssetManager().list("PngSuite"));
|
||||||
|
for (String filename : files)
|
||||||
|
if (filename.endsWith(".png")) data.add(filename);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String filename;
|
||||||
|
|
||||||
|
public PngSuiteImageSizeCalculatorTest(String filename) {
|
||||||
|
this.filename = filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
// some files have sizes other than 32x32
|
||||||
|
private Map<String, Size> customSizes = new HashMap<>();
|
||||||
|
|
||||||
|
{
|
||||||
|
customSizes.put("cdfn2c08.png", new Size(8, 32, "image/png"));
|
||||||
|
customSizes.put("cdhn2c08.png", new Size(32, 8, "image/png"));
|
||||||
|
customSizes.put("cdsn2c08.png", new Size(8, 8, "image/png"));
|
||||||
|
customSizes.put("PngSuite.png", new Size(256, 256, "image/png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPngSuiteCalculateSizes() throws Exception {
|
||||||
|
assumeTrue(isOptionalTestEnabled(
|
||||||
|
PngSuiteImageSizeCalculatorTest.class));
|
||||||
|
LOG.info("Testing " + filename);
|
||||||
|
if (filename.startsWith("x") && !filename.equals("xcsn0g01.png")) {
|
||||||
|
testCannotCalculateSize("PngSuite/" + filename, "image/png");
|
||||||
|
} else if (filename.startsWith("s")) {
|
||||||
|
int size = Integer.parseInt(filename.substring(1, 3));
|
||||||
|
testCanCalculateSize("PngSuite/" + filename, "image/png", size,
|
||||||
|
size);
|
||||||
|
} else {
|
||||||
|
int width = 32;
|
||||||
|
int height = 32;
|
||||||
|
if (customSizes.containsKey(filename)) {
|
||||||
|
Size size = customSizes.get(filename);
|
||||||
|
width = size.getWidth();
|
||||||
|
height = size.getHeight();
|
||||||
|
}
|
||||||
|
testCanCalculateSize("PngSuite/" + filename, "image/png", width,
|
||||||
|
height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import org.briarproject.bramble.BrambleCoreModule;
|
|||||||
import org.briarproject.bramble.account.BriarAccountModule;
|
import org.briarproject.bramble.account.BriarAccountModule;
|
||||||
import org.briarproject.briar.BriarCoreModule;
|
import org.briarproject.briar.BriarCoreModule;
|
||||||
import org.briarproject.briar.android.attachment.AttachmentModule;
|
import org.briarproject.briar.android.attachment.AttachmentModule;
|
||||||
|
import org.briarproject.briar.android.attachment.media.MediaModule;
|
||||||
import org.briarproject.briar.android.conversation.ConversationActivityScreenshotTest;
|
import org.briarproject.briar.android.conversation.ConversationActivityScreenshotTest;
|
||||||
import org.briarproject.briar.android.settings.SettingsActivityScreenshotTest;
|
import org.briarproject.briar.android.settings.SettingsActivityScreenshotTest;
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ import dagger.Component;
|
|||||||
@Component(modules = {
|
@Component(modules = {
|
||||||
AppModule.class,
|
AppModule.class,
|
||||||
AttachmentModule.class,
|
AttachmentModule.class,
|
||||||
|
MediaModule.class,
|
||||||
BriarCoreModule.class,
|
BriarCoreModule.class,
|
||||||
BrambleAndroidModule.class,
|
BrambleAndroidModule.class,
|
||||||
BriarAccountModule.class,
|
BriarAccountModule.class,
|
||||||
@@ -26,6 +28,7 @@ public interface BriarUiTestComponent extends AndroidComponent {
|
|||||||
void inject(SetupDataTest test);
|
void inject(SetupDataTest test);
|
||||||
|
|
||||||
void inject(ConversationActivityScreenshotTest test);
|
void inject(ConversationActivityScreenshotTest test);
|
||||||
|
|
||||||
void inject(SettingsActivityScreenshotTest test);
|
void inject(SettingsActivityScreenshotTest test);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class SetupDataTest extends ScreenshotTest {
|
|||||||
throws DbException {
|
throws DbException {
|
||||||
Context ctx = getApplicationContext();
|
Context ctx = getApplicationContext();
|
||||||
String bobName = ctx.getString(R.string.screenshot_bob);
|
String bobName = ctx.getString(R.string.screenshot_bob);
|
||||||
Contact bob = testDataCreator.addContact(bobName);
|
Contact bob = testDataCreator.addContact(bobName, true);
|
||||||
|
|
||||||
// TODO add messages
|
// TODO add messages
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* Some code was taken from:
|
||||||
|
*
|
||||||
|
* RIG – Random Image Generator
|
||||||
|
* https://github.com/stedi-akk/RandomImageGenerator
|
||||||
|
* licenced under Apache2 license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.briarproject.briar.android.test;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
|
||||||
|
import org.briarproject.briar.android.attachment.media.ImageCompressor;
|
||||||
|
import org.briarproject.briar.api.test.TestAvatarCreator;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
public class TestAvatarCreatorImpl implements TestAvatarCreator {
|
||||||
|
private final int WIDTH = 800;
|
||||||
|
private final int HEIGHT = 640;
|
||||||
|
|
||||||
|
private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
|
private final float[] hsv = new float[3];
|
||||||
|
private final Random random = new Random();
|
||||||
|
|
||||||
|
private final ImageCompressor imageCompressor;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
TestAvatarCreatorImpl(ImageCompressor imageCompressor) {
|
||||||
|
this.imageCompressor = imageCompressor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public InputStream getAvatarInputStream() throws IOException {
|
||||||
|
Bitmap bitmap = generateBitmap();
|
||||||
|
return imageCompressor.compressImage(bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap generateBitmap() {
|
||||||
|
// one pattern is boring, let's at least use two
|
||||||
|
if (random.nextBoolean()) {
|
||||||
|
return generateColoredPixels();
|
||||||
|
} else {
|
||||||
|
return generateColoredCircles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap generateColoredPixels() {
|
||||||
|
Bitmap bitmap = getBitmapWithRandomBackground();
|
||||||
|
Canvas canvas = new Canvas(bitmap);
|
||||||
|
Rect pixel = new Rect();
|
||||||
|
int pixelMultiplier = random.nextInt(500) + 1;
|
||||||
|
for (int x = 0; x < WIDTH; x += pixelMultiplier) {
|
||||||
|
for (int y = 0; y < HEIGHT; y += pixelMultiplier) {
|
||||||
|
pixel.set(x, y, x + pixelMultiplier, y + pixelMultiplier);
|
||||||
|
paint.setColor(getRandomColor());
|
||||||
|
canvas.drawRect(pixel, paint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap generateColoredCircles() {
|
||||||
|
Bitmap bitmap = getBitmapWithRandomBackground();
|
||||||
|
int biggestSide = Math.max(WIDTH, HEIGHT);
|
||||||
|
int selectedCount = random.nextInt(10) + 2;
|
||||||
|
Canvas canvas = new Canvas(bitmap);
|
||||||
|
float radiusFrom = biggestSide / 12f;
|
||||||
|
float radiusTo = biggestSide / 4f;
|
||||||
|
for (int i = 0; i < selectedCount; i++) {
|
||||||
|
float cx = random.nextInt(WIDTH);
|
||||||
|
float cy = random.nextInt(HEIGHT);
|
||||||
|
float radius =
|
||||||
|
random.nextInt((int) (radiusTo - radiusFrom)) + radiusFrom;
|
||||||
|
paint.setColor(getRandomColor());
|
||||||
|
canvas.drawCircle(cx, cy, radius, paint);
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap getBitmapWithRandomBackground() {
|
||||||
|
Bitmap bitmap =
|
||||||
|
Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);
|
||||||
|
bitmap.eraseColor(getRandomColor());
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getRandomColor() {
|
||||||
|
hsv[0] = random.nextInt(360);
|
||||||
|
hsv[1] = random.nextFloat();
|
||||||
|
hsv[2] = 1f;
|
||||||
|
return Color.HSVToColor(hsv);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -65,30 +65,43 @@
|
|||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="org.briarproject.briar.android.NotificationCleanupService"
|
android:name="org.briarproject.briar.android.NotificationCleanupService"
|
||||||
android:exported="false"></service>
|
android:exported="false" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.briarproject.briar.android.reporting.DevReportActivity"
|
android:name="org.briarproject.briar.android.reporting.CrashReportActivity"
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:finishOnTaskLaunch="true"
|
android:finishOnTaskLaunch="true"
|
||||||
android:label="@string/crash_report_title"
|
android:label="@string/crash_report_title"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
|
android:process=":briar_error_handler"
|
||||||
android:theme="@style/BriarTheme.NoActionBar"
|
android:theme="@style/BriarTheme.NoActionBar"
|
||||||
android:windowSoftInputMode="adjustResize|stateHidden"></activity>
|
android:windowSoftInputMode="adjustResize|stateHidden" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="org.briarproject.briar.android.reporting.FeedbackActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:label="@string/feedback_title"
|
||||||
|
android:parentActivityName="org.briarproject.briar.android.settings.SettingsActivity"
|
||||||
|
android:theme="@style/BriarTheme.NoActionBar"
|
||||||
|
android:windowSoftInputMode="adjustResize|stateHidden">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value="org.briarproject.briar.android.settings.SettingsActivity" />
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.briarproject.briar.android.splash.ExpiredActivity"
|
android:name="org.briarproject.briar.android.splash.ExpiredActivity"
|
||||||
android:label="@string/app_name"></activity>
|
android:label="@string/app_name" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.briarproject.briar.android.login.StartupActivity"
|
android:name="org.briarproject.briar.android.login.StartupActivity"
|
||||||
android:label="@string/app_name"></activity>
|
android:label="@string/app_name" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.briarproject.briar.android.account.SetupActivity"
|
android:name="org.briarproject.briar.android.account.SetupActivity"
|
||||||
android:label="@string/setup_title"
|
android:label="@string/setup_title"
|
||||||
android:windowSoftInputMode="adjustResize|stateAlwaysVisible"></activity>
|
android:windowSoftInputMode="adjustResize|stateAlwaysVisible" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.briarproject.briar.android.splash.SplashScreenActivity"
|
android:name="org.briarproject.briar.android.splash.SplashScreenActivity"
|
||||||
@@ -346,7 +359,7 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.briarproject.briar.android.StartupFailureActivity"
|
android:name="org.briarproject.briar.android.StartupFailureActivity"
|
||||||
android:label="@string/startup_failed_activity_title"></activity>
|
android:label="@string/startup_failed_activity_title" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.briarproject.briar.android.settings.SettingsActivity"
|
android:name="org.briarproject.briar.android.settings.SettingsActivity"
|
||||||
@@ -412,11 +425,11 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.briarproject.briar.android.logout.ExitActivity"
|
android:name="org.briarproject.briar.android.logout.ExitActivity"
|
||||||
android:theme="@android:style/Theme.NoDisplay"></activity>
|
android:theme="@android:style/Theme.NoDisplay" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".android.logout.HideUiActivity"
|
android:name=".android.logout.HideUiActivity"
|
||||||
android:theme="@android:style/Theme.NoDisplay"></activity>
|
android:theme="@android:style/Theme.NoDisplay" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".android.account.UnlockActivity"
|
android:name=".android.account.UnlockActivity"
|
||||||
@@ -436,4 +449,29 @@
|
|||||||
android:theme="@style/BriarTheme" />
|
android:theme="@style/BriarTheme" />
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
<queries>
|
||||||
|
<package android:name="info.guardianproject.ripple" />
|
||||||
|
<package android:name="com.huawei.systemmanager" />
|
||||||
|
<package android:name="com.huawei.powergenie" />
|
||||||
|
<package android:name="com.evenwell.PowerMonitor" />
|
||||||
|
|
||||||
|
<intent>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<data android:scheme="https" />
|
||||||
|
</intent>
|
||||||
|
<intent>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<data android:scheme="http" />
|
||||||
|
</intent>
|
||||||
|
<!-- white-listing the intents below does not seem necessary,
|
||||||
|
but they are still included in case modified Android versions require it -->
|
||||||
|
<intent>
|
||||||
|
<action android:name="android.bluetooth.adapter.action.REQUEST_DISCOVERABLE" />
|
||||||
|
</intent>
|
||||||
|
<intent>
|
||||||
|
<action android:name="android.settings.CHANNEL_NOTIFICATION_SETTINGS" />
|
||||||
|
</intent>
|
||||||
|
</queries>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
BIN
briar-android/src/main/ic_launcher-playstore.png
Normal file
BIN
briar-android/src/main/ic_launcher-playstore.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.9 KiB |
@@ -14,6 +14,7 @@ import org.briarproject.bramble.api.contact.ContactManager;
|
|||||||
import org.briarproject.bramble.api.crypto.CryptoExecutor;
|
import org.briarproject.bramble.api.crypto.CryptoExecutor;
|
||||||
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
||||||
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||||
|
import org.briarproject.bramble.api.db.TransactionManager;
|
||||||
import org.briarproject.bramble.api.event.EventBus;
|
import org.briarproject.bramble.api.event.EventBus;
|
||||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||||
import org.briarproject.bramble.api.keyagreement.KeyAgreementTask;
|
import org.briarproject.bramble.api.keyagreement.KeyAgreementTask;
|
||||||
@@ -31,14 +32,15 @@ import org.briarproject.bramble.plugin.tor.CircumventionProvider;
|
|||||||
import org.briarproject.briar.BriarCoreEagerSingletons;
|
import org.briarproject.briar.BriarCoreEagerSingletons;
|
||||||
import org.briarproject.briar.BriarCoreModule;
|
import org.briarproject.briar.BriarCoreModule;
|
||||||
import org.briarproject.briar.android.attachment.AttachmentModule;
|
import org.briarproject.briar.android.attachment.AttachmentModule;
|
||||||
|
import org.briarproject.briar.android.attachment.media.MediaModule;
|
||||||
import org.briarproject.briar.android.conversation.glide.BriarModelLoader;
|
import org.briarproject.briar.android.conversation.glide.BriarModelLoader;
|
||||||
import org.briarproject.briar.android.login.SignInReminderReceiver;
|
import org.briarproject.briar.android.login.SignInReminderReceiver;
|
||||||
import org.briarproject.briar.android.reporting.BriarReportSender;
|
|
||||||
import org.briarproject.briar.android.view.EmojiTextInputView;
|
import org.briarproject.briar.android.view.EmojiTextInputView;
|
||||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||||
import org.briarproject.briar.api.android.DozeWatchdog;
|
import org.briarproject.briar.api.android.DozeWatchdog;
|
||||||
import org.briarproject.briar.api.android.LockManager;
|
import org.briarproject.briar.api.android.LockManager;
|
||||||
import org.briarproject.briar.api.android.ScreenFilterMonitor;
|
import org.briarproject.briar.api.android.ScreenFilterMonitor;
|
||||||
|
import org.briarproject.briar.api.attachment.AttachmentReader;
|
||||||
import org.briarproject.briar.api.blog.BlogManager;
|
import org.briarproject.briar.api.blog.BlogManager;
|
||||||
import org.briarproject.briar.api.blog.BlogPostFactory;
|
import org.briarproject.briar.api.blog.BlogPostFactory;
|
||||||
import org.briarproject.briar.api.blog.BlogSharingManager;
|
import org.briarproject.briar.api.blog.BlogSharingManager;
|
||||||
@@ -47,6 +49,7 @@ import org.briarproject.briar.api.conversation.ConversationManager;
|
|||||||
import org.briarproject.briar.api.feed.FeedManager;
|
import org.briarproject.briar.api.feed.FeedManager;
|
||||||
import org.briarproject.briar.api.forum.ForumManager;
|
import org.briarproject.briar.api.forum.ForumManager;
|
||||||
import org.briarproject.briar.api.forum.ForumSharingManager;
|
import org.briarproject.briar.api.forum.ForumSharingManager;
|
||||||
|
import org.briarproject.briar.api.identity.AuthorManager;
|
||||||
import org.briarproject.briar.api.introduction.IntroductionManager;
|
import org.briarproject.briar.api.introduction.IntroductionManager;
|
||||||
import org.briarproject.briar.api.messaging.MessagingManager;
|
import org.briarproject.briar.api.messaging.MessagingManager;
|
||||||
import org.briarproject.briar.api.messaging.PrivateMessageFactory;
|
import org.briarproject.briar.api.messaging.PrivateMessageFactory;
|
||||||
@@ -71,7 +74,8 @@ import dagger.Component;
|
|||||||
BrambleAndroidModule.class,
|
BrambleAndroidModule.class,
|
||||||
BriarAccountModule.class,
|
BriarAccountModule.class,
|
||||||
AppModule.class,
|
AppModule.class,
|
||||||
AttachmentModule.class
|
AttachmentModule.class,
|
||||||
|
MediaModule.class
|
||||||
})
|
})
|
||||||
public interface AndroidComponent
|
public interface AndroidComponent
|
||||||
extends BrambleCoreEagerSingletons, BrambleAndroidEagerSingletons,
|
extends BrambleCoreEagerSingletons, BrambleAndroidEagerSingletons,
|
||||||
@@ -86,12 +90,18 @@ public interface AndroidComponent
|
|||||||
@DatabaseExecutor
|
@DatabaseExecutor
|
||||||
Executor databaseExecutor();
|
Executor databaseExecutor();
|
||||||
|
|
||||||
|
TransactionManager transactionManager();
|
||||||
|
|
||||||
MessageTracker messageTracker();
|
MessageTracker messageTracker();
|
||||||
|
|
||||||
LifecycleManager lifecycleManager();
|
LifecycleManager lifecycleManager();
|
||||||
|
|
||||||
IdentityManager identityManager();
|
IdentityManager identityManager();
|
||||||
|
|
||||||
|
AttachmentReader attachmentReader();
|
||||||
|
|
||||||
|
AuthorManager authorManager();
|
||||||
|
|
||||||
PluginManager pluginManager();
|
PluginManager pluginManager();
|
||||||
|
|
||||||
EventBus eventBus();
|
EventBus eventBus();
|
||||||
@@ -173,8 +183,6 @@ public interface AndroidComponent
|
|||||||
|
|
||||||
void inject(BriarService briarService);
|
void inject(BriarService briarService);
|
||||||
|
|
||||||
void inject(BriarReportSender briarReportSender);
|
|
||||||
|
|
||||||
void inject(NotificationCleanupService notificationCleanupService);
|
void inject(NotificationCleanupService notificationCleanupService);
|
||||||
|
|
||||||
void inject(EmojiTextInputView textInputView);
|
void inject(EmojiTextInputView textInputView);
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
|||||||
@Nullable
|
@Nullable
|
||||||
private GroupId blockedGroup = null;
|
private GroupId blockedGroup = null;
|
||||||
private boolean blockSignInReminder = false;
|
private boolean blockSignInReminder = false;
|
||||||
private boolean blockBlogs = false;
|
private boolean blockForums = false, blockGroups = false,
|
||||||
|
blockBlogs = false;
|
||||||
private long lastSound = 0;
|
private long lastSound = 0;
|
||||||
|
|
||||||
private volatile Settings settings = new Settings();
|
private volatile Settings settings = new Settings();
|
||||||
@@ -223,8 +224,8 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
|||||||
if (s.getNamespace().equals(SETTINGS_NAMESPACE))
|
if (s.getNamespace().equals(SETTINGS_NAMESPACE))
|
||||||
settings = s.getSettings();
|
settings = s.getSettings();
|
||||||
} else if (e instanceof ConversationMessageReceivedEvent) {
|
} else if (e instanceof ConversationMessageReceivedEvent) {
|
||||||
ConversationMessageReceivedEvent p =
|
ConversationMessageReceivedEvent<?> p =
|
||||||
(ConversationMessageReceivedEvent) e;
|
(ConversationMessageReceivedEvent<?>) e;
|
||||||
showContactNotification(p.getContactId());
|
showContactNotification(p.getContactId());
|
||||||
} else if (e instanceof GroupMessageAddedEvent) {
|
} else if (e instanceof GroupMessageAddedEvent) {
|
||||||
GroupMessageAddedEvent g = (GroupMessageAddedEvent) e;
|
GroupMessageAddedEvent g = (GroupMessageAddedEvent) e;
|
||||||
@@ -254,7 +255,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
|||||||
R.string.ongoing_notification_title;
|
R.string.ongoing_notification_title;
|
||||||
int text = locked ? R.string.lock_tap_to_unlock :
|
int text = locked ? R.string.lock_tap_to_unlock :
|
||||||
R.string.ongoing_notification_text;
|
R.string.ongoing_notification_text;
|
||||||
int icon = locked ? R.drawable.startup_lock :
|
int icon = locked ? R.drawable.notification_lock :
|
||||||
R.drawable.notification_ongoing;
|
R.drawable.notification_ongoing;
|
||||||
// Ongoing foreground notification that shows BriarService is running
|
// Ongoing foreground notification that shows BriarService is running
|
||||||
NotificationCompat.Builder b =
|
NotificationCompat.Builder b =
|
||||||
@@ -385,6 +386,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
|||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
private void showGroupMessageNotification(GroupId g) {
|
private void showGroupMessageNotification(GroupId g) {
|
||||||
|
if (blockGroups) return;
|
||||||
if (g.equals(blockedGroup)) return;
|
if (g.equals(blockedGroup)) return;
|
||||||
groupCounts.add(g);
|
groupCounts.add(g);
|
||||||
updateGroupMessageNotification(true);
|
updateGroupMessageNotification(true);
|
||||||
@@ -452,6 +454,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
|||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
private void showForumPostNotification(GroupId g) {
|
private void showForumPostNotification(GroupId g) {
|
||||||
|
if (blockForums) return;
|
||||||
if (g.equals(blockedGroup)) return;
|
if (g.equals(blockedGroup)) return;
|
||||||
forumCounts.add(g);
|
forumCounts.add(g);
|
||||||
updateForumPostNotification(true);
|
updateForumPostNotification(true);
|
||||||
@@ -621,7 +624,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
|||||||
|
|
||||||
NotificationCompat.Builder b =
|
NotificationCompat.Builder b =
|
||||||
new NotificationCompat.Builder(appContext, REMINDER_CHANNEL_ID);
|
new NotificationCompat.Builder(appContext, REMINDER_CHANNEL_ID);
|
||||||
b.setSmallIcon(R.drawable.ic_signout);
|
b.setSmallIcon(R.drawable.notification_signout);
|
||||||
b.setColor(getColor(appContext, R.color.briar_primary));
|
b.setColor(getColor(appContext, R.color.briar_primary));
|
||||||
b.setContentTitle(
|
b.setContentTitle(
|
||||||
appContext.getText(R.string.reminder_notification_title));
|
appContext.getText(R.string.reminder_notification_title));
|
||||||
@@ -681,6 +684,26 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void blockAllForumPostNotifications() {
|
||||||
|
androidExecutor.runOnUiThread((Runnable) () -> blockForums = true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unblockAllForumPostNotifications() {
|
||||||
|
androidExecutor.runOnUiThread((Runnable) () -> blockForums = false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void blockAllGroupMessageNotifications() {
|
||||||
|
androidExecutor.runOnUiThread((Runnable) () -> blockGroups = true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unblockAllGroupMessageNotifications() {
|
||||||
|
androidExecutor.runOnUiThread((Runnable) () -> blockGroups = false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void blockAllBlogPostNotifications() {
|
public void blockAllBlogPostNotifications() {
|
||||||
androidExecutor.runOnUiThread((Runnable) () -> blockBlogs = true);
|
androidExecutor.runOnUiThread((Runnable) () -> blockBlogs = true);
|
||||||
|
|||||||
@@ -27,15 +27,24 @@ import org.briarproject.bramble.plugin.tcp.AndroidLanTcpPluginFactory;
|
|||||||
import org.briarproject.bramble.plugin.tor.AndroidTorPluginFactory;
|
import org.briarproject.bramble.plugin.tor.AndroidTorPluginFactory;
|
||||||
import org.briarproject.bramble.util.AndroidUtils;
|
import org.briarproject.bramble.util.AndroidUtils;
|
||||||
import org.briarproject.bramble.util.StringUtils;
|
import org.briarproject.bramble.util.StringUtils;
|
||||||
|
import org.briarproject.briar.android.account.DozeHelperModule;
|
||||||
import org.briarproject.briar.android.account.LockManagerImpl;
|
import org.briarproject.briar.android.account.LockManagerImpl;
|
||||||
|
import org.briarproject.briar.android.account.SetupModule;
|
||||||
|
import org.briarproject.briar.android.contact.ContactListModule;
|
||||||
|
import org.briarproject.briar.android.forum.ForumModule;
|
||||||
import org.briarproject.briar.android.keyagreement.ContactExchangeModule;
|
import org.briarproject.briar.android.keyagreement.ContactExchangeModule;
|
||||||
import org.briarproject.briar.android.login.LoginModule;
|
import org.briarproject.briar.android.login.LoginModule;
|
||||||
import org.briarproject.briar.android.navdrawer.NavDrawerModule;
|
import org.briarproject.briar.android.navdrawer.NavDrawerModule;
|
||||||
|
import org.briarproject.briar.android.settings.SettingsModule;
|
||||||
|
import org.briarproject.briar.android.privategroup.list.GroupListModule;
|
||||||
|
import org.briarproject.briar.android.reporting.DevReportModule;
|
||||||
|
import org.briarproject.briar.android.test.TestAvatarCreatorImpl;
|
||||||
import org.briarproject.briar.android.viewmodel.ViewModelModule;
|
import org.briarproject.briar.android.viewmodel.ViewModelModule;
|
||||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||||
import org.briarproject.briar.api.android.DozeWatchdog;
|
import org.briarproject.briar.api.android.DozeWatchdog;
|
||||||
import org.briarproject.briar.api.android.LockManager;
|
import org.briarproject.briar.api.android.LockManager;
|
||||||
import org.briarproject.briar.api.android.ScreenFilterMonitor;
|
import org.briarproject.briar.api.android.ScreenFilterMonitor;
|
||||||
|
import org.briarproject.briar.api.test.TestAvatarCreator;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
@@ -60,10 +69,18 @@ import static org.briarproject.bramble.api.reporting.ReportingConstants.DEV_PUBL
|
|||||||
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
||||||
|
|
||||||
@Module(includes = {
|
@Module(includes = {
|
||||||
|
SetupModule.class,
|
||||||
|
DozeHelperModule.class,
|
||||||
ContactExchangeModule.class,
|
ContactExchangeModule.class,
|
||||||
LoginModule.class,
|
LoginModule.class,
|
||||||
NavDrawerModule.class,
|
NavDrawerModule.class,
|
||||||
ViewModelModule.class
|
ViewModelModule.class,
|
||||||
|
SettingsModule.class,
|
||||||
|
DevReportModule.class,
|
||||||
|
ContactListModule.class,
|
||||||
|
// below need to be within same scope as ViewModelProvider.Factory
|
||||||
|
ForumModule.BindsModule.class,
|
||||||
|
GroupListModule.class,
|
||||||
})
|
})
|
||||||
public class AppModule {
|
public class AppModule {
|
||||||
|
|
||||||
@@ -175,6 +192,12 @@ public class AppModule {
|
|||||||
return devConfig;
|
return devConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
TestAvatarCreator provideTestAvatarCreator(
|
||||||
|
TestAvatarCreatorImpl testAvatarCreator) {
|
||||||
|
return testAvatarCreator;
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
SharedPreferences provideSharedPreferences(Application app) {
|
SharedPreferences provideSharedPreferences(Application app) {
|
||||||
// FIXME unify this with getDefaultSharedPreferences()
|
// FIXME unify this with getDefaultSharedPreferences()
|
||||||
@@ -196,7 +219,10 @@ public class AppModule {
|
|||||||
ScreenFilterMonitor provideScreenFilterMonitor(
|
ScreenFilterMonitor provideScreenFilterMonitor(
|
||||||
LifecycleManager lifecycleManager,
|
LifecycleManager lifecycleManager,
|
||||||
ScreenFilterMonitorImpl screenFilterMonitor) {
|
ScreenFilterMonitorImpl screenFilterMonitor) {
|
||||||
lifecycleManager.registerService(screenFilterMonitor);
|
if (SDK_INT <= 29) {
|
||||||
|
// this keeps track of installed apps and does not work on API 30+
|
||||||
|
lifecycleManager.registerService(screenFilterMonitor);
|
||||||
|
}
|
||||||
return screenFilterMonitor;
|
return screenFilterMonitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,6 +261,17 @@ public class AppModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
FeatureFlags provideFeatureFlags() {
|
FeatureFlags provideFeatureFlags() {
|
||||||
return () -> IS_DEBUG_BUILD;
|
return new FeatureFlags() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldEnableImageAttachments() {
|
||||||
|
return IS_DEBUG_BUILD;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldEnableProfilePictures() {
|
||||||
|
return IS_DEBUG_BUILD;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,19 +14,13 @@ import android.preference.PreferenceManager;
|
|||||||
import com.vanniktech.emoji.EmojiManager;
|
import com.vanniktech.emoji.EmojiManager;
|
||||||
import com.vanniktech.emoji.google.GoogleEmojiProvider;
|
import com.vanniktech.emoji.google.GoogleEmojiProvider;
|
||||||
|
|
||||||
import org.acra.ACRA;
|
|
||||||
import org.acra.ReportingInteractionMode;
|
|
||||||
import org.acra.annotation.ReportsCrashes;
|
|
||||||
import org.briarproject.bramble.BrambleAndroidEagerSingletons;
|
import org.briarproject.bramble.BrambleAndroidEagerSingletons;
|
||||||
import org.briarproject.bramble.BrambleAppComponent;
|
import org.briarproject.bramble.BrambleAppComponent;
|
||||||
import org.briarproject.bramble.BrambleCoreEagerSingletons;
|
import org.briarproject.bramble.BrambleCoreEagerSingletons;
|
||||||
import org.briarproject.briar.BriarCoreEagerSingletons;
|
import org.briarproject.briar.BriarCoreEagerSingletons;
|
||||||
import org.briarproject.briar.BuildConfig;
|
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.logging.CachingLogHandler;
|
import org.briarproject.briar.android.logging.CachingLogHandler;
|
||||||
import org.briarproject.briar.android.reporting.BriarReportPrimer;
|
import org.briarproject.briar.android.reporting.BriarExceptionHandler;
|
||||||
import org.briarproject.briar.android.reporting.BriarReportSenderFactory;
|
|
||||||
import org.briarproject.briar.android.reporting.DevReportActivity;
|
|
||||||
import org.briarproject.briar.android.util.UiUtils;
|
import org.briarproject.briar.android.util.UiUtils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -34,50 +28,14 @@ import java.util.logging.Handler;
|
|||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
|
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
|
||||||
import static java.util.logging.Level.FINE;
|
import static java.util.logging.Level.FINE;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.acra.ReportField.ANDROID_VERSION;
|
|
||||||
import static org.acra.ReportField.APP_VERSION_CODE;
|
|
||||||
import static org.acra.ReportField.APP_VERSION_NAME;
|
|
||||||
import static org.acra.ReportField.BRAND;
|
|
||||||
import static org.acra.ReportField.BUILD_CONFIG;
|
|
||||||
import static org.acra.ReportField.CRASH_CONFIGURATION;
|
|
||||||
import static org.acra.ReportField.CUSTOM_DATA;
|
|
||||||
import static org.acra.ReportField.DEVICE_FEATURES;
|
|
||||||
import static org.acra.ReportField.DISPLAY;
|
|
||||||
import static org.acra.ReportField.INITIAL_CONFIGURATION;
|
|
||||||
import static org.acra.ReportField.PACKAGE_NAME;
|
|
||||||
import static org.acra.ReportField.PHONE_MODEL;
|
|
||||||
import static org.acra.ReportField.PRODUCT;
|
|
||||||
import static org.acra.ReportField.REPORT_ID;
|
|
||||||
import static org.acra.ReportField.STACK_TRACE;
|
|
||||||
import static org.acra.ReportField.USER_APP_START_DATE;
|
|
||||||
import static org.acra.ReportField.USER_CRASH_DATE;
|
|
||||||
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
||||||
|
|
||||||
@ReportsCrashes(
|
|
||||||
reportPrimerClass = BriarReportPrimer.class,
|
|
||||||
logcatArguments = {"-d", "-v", "time", "*:I"},
|
|
||||||
reportSenderFactoryClasses = {BriarReportSenderFactory.class},
|
|
||||||
mode = ReportingInteractionMode.DIALOG,
|
|
||||||
reportDialogClass = DevReportActivity.class,
|
|
||||||
resDialogOkToast = R.string.dev_report_saved,
|
|
||||||
deleteOldUnsentReportsOnApplicationStart = false,
|
|
||||||
buildConfigClass = BuildConfig.class,
|
|
||||||
customReportContent = {
|
|
||||||
REPORT_ID,
|
|
||||||
APP_VERSION_CODE, APP_VERSION_NAME, PACKAGE_NAME,
|
|
||||||
PHONE_MODEL, ANDROID_VERSION, BRAND, PRODUCT,
|
|
||||||
BUILD_CONFIG,
|
|
||||||
CUSTOM_DATA,
|
|
||||||
STACK_TRACE,
|
|
||||||
INITIAL_CONFIGURATION, CRASH_CONFIGURATION,
|
|
||||||
DISPLAY, DEVICE_FEATURES,
|
|
||||||
USER_APP_START_DATE, USER_CRASH_DATE
|
|
||||||
}
|
|
||||||
)
|
|
||||||
public class BriarApplicationImpl extends Application
|
public class BriarApplicationImpl extends Application
|
||||||
implements BriarApplication {
|
implements BriarApplication {
|
||||||
|
|
||||||
@@ -85,12 +43,15 @@ public class BriarApplicationImpl extends Application
|
|||||||
getLogger(BriarApplicationImpl.class.getName());
|
getLogger(BriarApplicationImpl.class.getName());
|
||||||
|
|
||||||
private final CachingLogHandler logHandler = new CachingLogHandler();
|
private final CachingLogHandler logHandler = new CachingLogHandler();
|
||||||
|
private final BriarExceptionHandler exceptionHandler =
|
||||||
|
new BriarExceptionHandler(this);
|
||||||
|
|
||||||
private AndroidComponent applicationComponent;
|
private AndroidComponent applicationComponent;
|
||||||
private volatile SharedPreferences prefs;
|
private volatile SharedPreferences prefs;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(Context base) {
|
protected void attachBaseContext(Context base) {
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler(exceptionHandler);
|
||||||
if (prefs == null)
|
if (prefs == null)
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(base);
|
prefs = PreferenceManager.getDefaultSharedPreferences(base);
|
||||||
// Loading the language needs to be done here.
|
// Loading the language needs to be done here.
|
||||||
@@ -98,7 +59,6 @@ public class BriarApplicationImpl extends Application
|
|||||||
super.attachBaseContext(
|
super.attachBaseContext(
|
||||||
Localizer.getInstance().setLocale(base));
|
Localizer.getInstance().setLocale(base));
|
||||||
setTheme(base, prefs);
|
setTheme(base, prefs);
|
||||||
ACRA.init(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,7 +104,7 @@ public class BriarApplicationImpl extends Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
Localizer.getInstance().setLocale(this);
|
Localizer.getInstance().setLocale(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import android.content.ServiceConnection;
|
|||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.account.AccountManager;
|
import org.briarproject.bramble.api.account.AccountManager;
|
||||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||||
@@ -246,10 +248,13 @@ public class BriarService extends Service {
|
|||||||
LOG.info("Trim memory: near end of LRU list");
|
LOG.info("Trim memory: near end of LRU list");
|
||||||
} else if (level == TRIM_MEMORY_RUNNING_MODERATE) {
|
} else if (level == TRIM_MEMORY_RUNNING_MODERATE) {
|
||||||
LOG.info("Trim memory: running moderately low");
|
LOG.info("Trim memory: running moderately low");
|
||||||
|
Glide.get(getApplicationContext()).clearMemory();
|
||||||
} else if (level == TRIM_MEMORY_RUNNING_LOW) {
|
} else if (level == TRIM_MEMORY_RUNNING_LOW) {
|
||||||
LOG.info("Trim memory: running low");
|
LOG.info("Trim memory: running low");
|
||||||
|
// TODO investigate if we can clear Glide cache here as well
|
||||||
} else if (level == TRIM_MEMORY_RUNNING_CRITICAL) {
|
} else if (level == TRIM_MEMORY_RUNNING_CRITICAL) {
|
||||||
LOG.warning("Trim memory: running critically low");
|
LOG.warning("Trim memory: running critically low");
|
||||||
|
// TODO investigate if we can clear Glide cache here as well
|
||||||
// If we're not in the foreground, clear the UI to save memory
|
// If we're not in the foreground, clear the UI to save memory
|
||||||
if (app.isRunningInBackground()) hideUi();
|
if (app.isRunningInBackground()) hideUi();
|
||||||
} else if (LOG.isLoggable(INFO)) {
|
} else if (LOG.isLoggable(INFO)) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class ScreenFilterMonitorImpl implements ScreenFilterMonitor, Service {
|
|||||||
Logger.getLogger(ScreenFilterMonitorImpl.class.getName());
|
Logger.getLogger(ScreenFilterMonitorImpl.class.getName());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ignore Play Services if it uses this package name and public key - it's
|
* Ignore Play Services if it uses this package name and public key - it's
|
||||||
* effectively a system app, but not flagged as such on older systems
|
* effectively a system app, but not flagged as such on older systems
|
||||||
*/
|
*/
|
||||||
private static final String PLAY_SERVICES_PACKAGE =
|
private static final String PLAY_SERVICES_PACKAGE =
|
||||||
@@ -108,7 +108,7 @@ class ScreenFilterMonitorImpl implements ScreenFilterMonitor, Service {
|
|||||||
Set<String> allowed = prefs.getStringSet(PREF_KEY_ALLOWED,
|
Set<String> allowed = prefs.getStringSet(PREF_KEY_ALLOWED,
|
||||||
Collections.emptySet());
|
Collections.emptySet());
|
||||||
List<AppDetails> apps = new ArrayList<>();
|
List<AppDetails> apps = new ArrayList<>();
|
||||||
List<PackageInfo> packageInfos =
|
@SuppressLint("QueryPermissionsNeeded") List<PackageInfo> packageInfos =
|
||||||
pm.getInstalledPackages(GET_PERMISSIONS);
|
pm.getInstalledPackages(GET_PERMISSIONS);
|
||||||
for (PackageInfo packageInfo : packageInfos) {
|
for (PackageInfo packageInfo : packageInfos) {
|
||||||
if (!allowed.contains(packageInfo.packageName)
|
if (!allowed.contains(packageInfo.packageName)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import org.briarproject.briar.android.activity.ActivityComponent;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static java.util.Objects.requireNonNull;
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||||
import static org.briarproject.bramble.util.StringUtils.toUtf8;
|
import static org.briarproject.bramble.util.StringUtils.toUtf8;
|
||||||
import static org.briarproject.briar.android.util.UiUtils.setError;
|
import static org.briarproject.briar.android.util.UiUtils.setError;
|
||||||
@@ -45,7 +44,7 @@ public class AuthorNameFragment extends SetupFragment {
|
|||||||
public View onCreateView(LayoutInflater inflater,
|
public View onCreateView(LayoutInflater inflater,
|
||||||
@Nullable ViewGroup container,
|
@Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
requireNonNull(getActivity()).setTitle(getString(R.string.setup_title));
|
requireActivity().setTitle(getString(R.string.setup_title));
|
||||||
View v = inflater.inflate(R.layout.fragment_setup_author_name,
|
View v = inflater.inflate(R.layout.fragment_setup_author_name,
|
||||||
container, false);
|
container, false);
|
||||||
authorNameWrapper = v.findViewById(R.id.nickname_entry_wrapper);
|
authorNameWrapper = v.findViewById(R.id.nickname_entry_wrapper);
|
||||||
@@ -82,8 +81,7 @@ public class AuthorNameFragment extends SetupFragment {
|
|||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Editable text = authorNameInput.getText();
|
Editable text = authorNameInput.getText();
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
setupController.setAuthorName(text.toString().trim());
|
viewModel.setAuthorName(text.toString().trim());
|
||||||
setupController.showPasswordFragment();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import androidx.annotation.Nullable;
|
|||||||
|
|
||||||
import static android.view.View.INVISIBLE;
|
import static android.view.View.INVISIBLE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static java.util.Objects.requireNonNull;
|
|
||||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_DOZE_WHITELISTING;
|
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_DOZE_WHITELISTING;
|
||||||
import static org.briarproject.briar.android.util.UiUtils.showOnboardingDialog;
|
import static org.briarproject.briar.android.util.UiUtils.showOnboardingDialog;
|
||||||
|
|
||||||
@@ -50,10 +49,10 @@ public class DozeFragment extends SetupFragment
|
|||||||
public View onCreateView(LayoutInflater inflater,
|
public View onCreateView(LayoutInflater inflater,
|
||||||
@Nullable ViewGroup container,
|
@Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
requireNonNull(getActivity()).setTitle(getString(R.string.setup_doze_title));
|
requireActivity().setTitle(getString(R.string.setup_doze_title));
|
||||||
setHasOptionsMenu(false);
|
setHasOptionsMenu(false);
|
||||||
View v = inflater.inflate(R.layout.fragment_setup_doze, container,
|
View v = inflater.inflate(R.layout.fragment_setup_doze, container,
|
||||||
false);
|
false);
|
||||||
dozeView = v.findViewById(R.id.dozeView);
|
dozeView = v.findViewById(R.id.dozeView);
|
||||||
dozeView.setOnCheckedChangedListener(this);
|
dozeView.setOnCheckedChangedListener(this);
|
||||||
huaweiView = v.findViewById(R.id.huaweiView);
|
huaweiView = v.findViewById(R.id.huaweiView);
|
||||||
@@ -78,7 +77,8 @@ public class DozeFragment extends SetupFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int request, int result, Intent data) {
|
public void onActivityResult(int request, int result,
|
||||||
|
@Nullable Intent data) {
|
||||||
super.onActivityResult(request, result, data);
|
super.onActivityResult(request, result, data);
|
||||||
if (request == REQUEST_DOZE_WHITELISTING) {
|
if (request == REQUEST_DOZE_WHITELISTING) {
|
||||||
if (!dozeView.needsToBeShown() || secondAttempt) {
|
if (!dozeView.needsToBeShown() || secondAttempt) {
|
||||||
@@ -92,11 +92,7 @@ public class DozeFragment extends SetupFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged() {
|
public void onCheckedChanged() {
|
||||||
if (dozeView.isChecked() && huaweiView.isChecked()) {
|
next.setEnabled(dozeView.isChecked() && huaweiView.isChecked());
|
||||||
next.setEnabled(true);
|
|
||||||
} else {
|
|
||||||
next.setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("BatteryLife")
|
@SuppressLint("BatteryLife")
|
||||||
@@ -108,9 +104,15 @@ public class DozeFragment extends SetupFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
next.setVisibility(INVISIBLE);
|
setNextClicked();
|
||||||
progressBar.setVisibility(VISIBLE);
|
viewModel.dozeExceptionConfirmed();
|
||||||
setupController.createAccount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void setNextClicked() {
|
||||||
|
super.setNextClicked();
|
||||||
|
|
||||||
|
next.setVisibility(INVISIBLE);
|
||||||
|
progressBar.setVisibility(VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package org.briarproject.briar.android.account;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
interface DozeHelper {
|
||||||
|
|
||||||
|
boolean needToShowDozeFragment(Context context);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.briarproject.briar.android.account;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import static org.briarproject.briar.android.account.HuaweiView.needsToBeShown;
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.needsDozeWhitelisting;
|
||||||
|
|
||||||
|
class DozeHelperImpl implements DozeHelper {
|
||||||
|
@Override
|
||||||
|
public boolean needToShowDozeFragment(Context context) {
|
||||||
|
return needsDozeWhitelisting(context.getApplicationContext()) ||
|
||||||
|
needsToBeShown(context.getApplicationContext());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package org.briarproject.briar.android.account;
|
||||||
|
|
||||||
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
|
||||||
|
@Module
|
||||||
|
public class DozeHelperModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
DozeHelper provideDozeHelper() {
|
||||||
|
return new DozeHelperImpl();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,14 +24,12 @@ import static android.content.Context.INPUT_METHOD_SERVICE;
|
|||||||
import static android.view.View.INVISIBLE;
|
import static android.view.View.INVISIBLE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
|
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
|
||||||
import static java.util.Objects.requireNonNull;
|
|
||||||
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_WEAK;
|
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_WEAK;
|
||||||
import static org.briarproject.briar.android.util.UiUtils.setError;
|
import static org.briarproject.briar.android.util.UiUtils.setError;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@ParametersNotNullByDefault
|
@ParametersNotNullByDefault
|
||||||
public class SetPasswordFragment extends SetupFragment {
|
public class SetPasswordFragment extends SetupFragment {
|
||||||
|
|
||||||
private final static String TAG = SetPasswordFragment.class.getName();
|
private final static String TAG = SetPasswordFragment.class.getName();
|
||||||
|
|
||||||
private TextInputLayout passwordEntryWrapper;
|
private TextInputLayout passwordEntryWrapper;
|
||||||
@@ -55,9 +53,9 @@ public class SetPasswordFragment extends SetupFragment {
|
|||||||
public View onCreateView(LayoutInflater inflater,
|
public View onCreateView(LayoutInflater inflater,
|
||||||
@Nullable ViewGroup container,
|
@Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
requireNonNull(getActivity()).setTitle(getString(R.string.setup_password_intro));
|
requireActivity().setTitle(getString(R.string.setup_password_intro));
|
||||||
View v = inflater.inflate(R.layout.fragment_setup_password, container,
|
View v = inflater.inflate(R.layout.fragment_setup_password, container,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
strengthMeter = v.findViewById(R.id.strength_meter);
|
strengthMeter = v.findViewById(R.id.strength_meter);
|
||||||
passwordEntryWrapper = v.findViewById(R.id.password_entry_wrapper);
|
passwordEntryWrapper = v.findViewById(R.id.password_entry_wrapper);
|
||||||
@@ -72,7 +70,7 @@ public class SetPasswordFragment extends SetupFragment {
|
|||||||
passwordConfirmation.addTextChangedListener(this);
|
passwordConfirmation.addTextChangedListener(this);
|
||||||
nextButton.setOnClickListener(this);
|
nextButton.setOnClickListener(this);
|
||||||
|
|
||||||
if (!setupController.needToShowDozeFragment()) {
|
if (!viewModel.needToShowDozeFragment()) {
|
||||||
nextButton.setText(R.string.create_account_button);
|
nextButton.setText(R.string.create_account_button);
|
||||||
passwordConfirmation.setImeOptions(IME_ACTION_DONE);
|
passwordConfirmation.setImeOptions(IME_ACTION_DONE);
|
||||||
}
|
}
|
||||||
@@ -98,7 +96,7 @@ public class SetPasswordFragment extends SetupFragment {
|
|||||||
|
|
||||||
strengthMeter
|
strengthMeter
|
||||||
.setVisibility(password1.length() > 0 ? VISIBLE : INVISIBLE);
|
.setVisibility(password1.length() > 0 ? VISIBLE : INVISIBLE);
|
||||||
float strength = setupController.estimatePasswordStrength(password1);
|
float strength = viewModel.estimatePasswordStrength(password1);
|
||||||
strengthMeter.setStrength(strength);
|
strengthMeter.setStrength(strength);
|
||||||
boolean strongEnough = strength >= QUITE_WEAK;
|
boolean strongEnough = strength >= QUITE_WEAK;
|
||||||
|
|
||||||
@@ -118,14 +116,20 @@ public class SetPasswordFragment extends SetupFragment {
|
|||||||
IBinder token = passwordEntry.getWindowToken();
|
IBinder token = passwordEntry.getWindowToken();
|
||||||
Object o = getContext().getSystemService(INPUT_METHOD_SERVICE);
|
Object o = getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||||
((InputMethodManager) o).hideSoftInputFromWindow(token, 0);
|
((InputMethodManager) o).hideSoftInputFromWindow(token, 0);
|
||||||
setupController.setPassword(passwordEntry.getText().toString());
|
|
||||||
if (setupController.needToShowDozeFragment()) {
|
setNextClicked();
|
||||||
setupController.showDozeFragment();
|
viewModel.setPassword(passwordEntry.getText().toString());
|
||||||
} else {
|
|
||||||
nextButton.setVisibility(INVISIBLE);
|
|
||||||
progressBar.setVisibility(VISIBLE);
|
|
||||||
setupController.createAccount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void setNextClicked() {
|
||||||
|
super.setNextClicked();
|
||||||
|
|
||||||
|
passwordEntry.setFocusable(false);
|
||||||
|
passwordConfirmation.setFocusable(false);
|
||||||
|
if (!viewModel.needToShowDozeFragment()) {
|
||||||
|
nextButton.setVisibility(INVISIBLE);
|
||||||
|
progressBar.setVisibility(VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.annotation.TargetApi;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.account.AccountManager;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
@@ -15,28 +14,36 @@ import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
|
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
|
||||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||||
import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME;
|
import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME;
|
||||||
import static org.briarproject.briar.android.BriarApplication.ENTRY_ACTIVITY;
|
import static org.briarproject.briar.android.BriarApplication.ENTRY_ACTIVITY;
|
||||||
|
import static org.briarproject.briar.android.account.SetupViewModel.State.AUTHOR_NAME;
|
||||||
|
import static org.briarproject.briar.android.account.SetupViewModel.State.CREATED;
|
||||||
|
import static org.briarproject.briar.android.account.SetupViewModel.State.DOZE;
|
||||||
|
import static org.briarproject.briar.android.account.SetupViewModel.State.FAILED;
|
||||||
|
import static org.briarproject.briar.android.account.SetupViewModel.State.SET_PASSWORD;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@ParametersNotNullByDefault
|
@ParametersNotNullByDefault
|
||||||
public class SetupActivity extends BaseActivity
|
public class SetupActivity extends BaseActivity
|
||||||
implements BaseFragmentListener {
|
implements BaseFragmentListener {
|
||||||
|
|
||||||
private static final String STATE_KEY_AUTHOR_NAME = "authorName";
|
|
||||||
private static final String STATE_KEY_PASSWORD = "password";
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AccountManager accountManager;
|
ViewModelProvider.Factory viewModelFactory;
|
||||||
|
SetupViewModel viewModel;
|
||||||
|
|
||||||
@Inject
|
@Override
|
||||||
SetupController setupController;
|
public void injectActivity(ActivityComponent component) {
|
||||||
|
component.inject(this);
|
||||||
|
|
||||||
@Nullable
|
viewModel = new ViewModelProvider(this, viewModelFactory)
|
||||||
private String authorName, password;
|
.get(SetupViewModel.class);
|
||||||
|
viewModel.getState().observeEvent(this, this::onStateChanged);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle state) {
|
public void onCreate(@Nullable Bundle state) {
|
||||||
@@ -44,58 +51,27 @@ public class SetupActivity extends BaseActivity
|
|||||||
// fade-in after splash screen instead of default animation
|
// fade-in after splash screen instead of default animation
|
||||||
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
|
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
|
||||||
setContentView(R.layout.activity_fragment_container);
|
setContentView(R.layout.activity_fragment_container);
|
||||||
|
}
|
||||||
|
|
||||||
if (state == null) {
|
private void onStateChanged(SetupViewModel.State state) {
|
||||||
if (accountManager.accountExists()) throw new AssertionError();
|
if (state == AUTHOR_NAME) {
|
||||||
showInitialFragment(AuthorNameFragment.newInstance());
|
showInitialFragment(AuthorNameFragment.newInstance());
|
||||||
} else {
|
} else if (state == SET_PASSWORD) {
|
||||||
authorName = state.getString(STATE_KEY_AUTHOR_NAME);
|
showPasswordFragment();
|
||||||
password = state.getString(STATE_KEY_PASSWORD);
|
} else if (state == DOZE) {
|
||||||
|
showDozeFragment();
|
||||||
|
} else if (state == CREATED || state == FAILED) {
|
||||||
|
// TODO: Show an error if failed
|
||||||
|
showApp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void injectActivity(ActivityComponent component) {
|
|
||||||
component.inject(this);
|
|
||||||
setupController.setSetupActivity(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle state) {
|
|
||||||
super.onSaveInstanceState(state);
|
|
||||||
if (authorName != null)
|
|
||||||
state.putString(STATE_KEY_AUTHOR_NAME, authorName);
|
|
||||||
if (password != null)
|
|
||||||
state.putString(STATE_KEY_PASSWORD, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String getAuthorName() {
|
|
||||||
return authorName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setAuthorName(String authorName) {
|
|
||||||
this.authorName = authorName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
void showPasswordFragment() {
|
void showPasswordFragment() {
|
||||||
if (authorName == null) throw new IllegalStateException();
|
|
||||||
showNextFragment(SetPasswordFragment.newInstance());
|
showNextFragment(SetPasswordFragment.newInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(23)
|
@TargetApi(23)
|
||||||
void showDozeFragment() {
|
void showDozeFragment() {
|
||||||
if (authorName == null) throw new IllegalStateException();
|
|
||||||
if (password == null) throw new IllegalStateException();
|
|
||||||
showNextFragment(DozeFragment.newInstance());
|
showNextFragment(DozeFragment.newInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
package org.briarproject.briar.android.account;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public interface SetupController {
|
|
||||||
|
|
||||||
void setSetupActivity(SetupActivity setupActivity);
|
|
||||||
|
|
||||||
boolean needToShowDozeFragment();
|
|
||||||
|
|
||||||
void setAuthorName(String authorName);
|
|
||||||
|
|
||||||
float estimatePasswordStrength(String password);
|
|
||||||
|
|
||||||
void setPassword(String password);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This should be called after the author name has been set.
|
|
||||||
*/
|
|
||||||
void showPasswordFragment();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This should be called after the author name and the password have been
|
|
||||||
* set.
|
|
||||||
*/
|
|
||||||
void showDozeFragment();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This should be called after the author name and the password have been
|
|
||||||
* set.
|
|
||||||
*/
|
|
||||||
void createAccount();
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
package org.briarproject.briar.android.account;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.account.AccountManager;
|
|
||||||
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
|
||||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
import org.briarproject.briar.android.controller.handler.ResultHandler;
|
|
||||||
import org.briarproject.briar.android.controller.handler.UiResultHandler;
|
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public class SetupControllerImpl implements SetupController {
|
|
||||||
|
|
||||||
private static final Logger LOG =
|
|
||||||
Logger.getLogger(SetupControllerImpl.class.getName());
|
|
||||||
|
|
||||||
private final AccountManager accountManager;
|
|
||||||
private final PasswordStrengthEstimator strengthEstimator;
|
|
||||||
@IoExecutor
|
|
||||||
private final Executor ioExecutor;
|
|
||||||
@Nullable
|
|
||||||
private volatile SetupActivity setupActivity;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
SetupControllerImpl(AccountManager accountManager,
|
|
||||||
@IoExecutor Executor ioExecutor,
|
|
||||||
PasswordStrengthEstimator strengthEstimator) {
|
|
||||||
this.accountManager = accountManager;
|
|
||||||
this.strengthEstimator = strengthEstimator;
|
|
||||||
this.ioExecutor = ioExecutor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSetupActivity(SetupActivity setupActivity) {
|
|
||||||
this.setupActivity = setupActivity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean needToShowDozeFragment() {
|
|
||||||
SetupActivity setupActivity = this.setupActivity;
|
|
||||||
if (setupActivity == null) throw new IllegalStateException();
|
|
||||||
return DozeView.needsToBeShown(setupActivity) ||
|
|
||||||
HuaweiView.needsToBeShown(setupActivity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAuthorName(String authorName) {
|
|
||||||
SetupActivity setupActivity = this.setupActivity;
|
|
||||||
if (setupActivity == null) throw new IllegalStateException();
|
|
||||||
setupActivity.setAuthorName(authorName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float estimatePasswordStrength(String password) {
|
|
||||||
return strengthEstimator.estimateStrength(password);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPassword(String password) {
|
|
||||||
SetupActivity setupActivity = this.setupActivity;
|
|
||||||
if (setupActivity == null) throw new IllegalStateException();
|
|
||||||
setupActivity.setPassword(password);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showPasswordFragment() {
|
|
||||||
SetupActivity setupActivity = this.setupActivity;
|
|
||||||
if (setupActivity == null) throw new IllegalStateException();
|
|
||||||
setupActivity.showPasswordFragment();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showDozeFragment() {
|
|
||||||
SetupActivity setupActivity = this.setupActivity;
|
|
||||||
if (setupActivity == null) throw new IllegalStateException();
|
|
||||||
setupActivity.showDozeFragment();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createAccount() {
|
|
||||||
SetupActivity setupActivity = this.setupActivity;
|
|
||||||
UiResultHandler<Boolean> resultHandler =
|
|
||||||
new UiResultHandler<Boolean>(setupActivity) {
|
|
||||||
@Override
|
|
||||||
public void onResultUi(Boolean result) {
|
|
||||||
// TODO: Show an error if result is false
|
|
||||||
if (setupActivity == null)
|
|
||||||
throw new IllegalStateException();
|
|
||||||
setupActivity.showApp();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
createAccount(resultHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Package access for testing
|
|
||||||
void createAccount(ResultHandler<Boolean> resultHandler) {
|
|
||||||
SetupActivity setupActivity = this.setupActivity;
|
|
||||||
if (setupActivity == null) throw new IllegalStateException();
|
|
||||||
String authorName = setupActivity.getAuthorName();
|
|
||||||
if (authorName == null) throw new IllegalStateException();
|
|
||||||
String password = setupActivity.getPassword();
|
|
||||||
if (password == null) throw new IllegalStateException();
|
|
||||||
ioExecutor.execute(() -> {
|
|
||||||
LOG.info("Creating account");
|
|
||||||
resultHandler.onResult(accountManager.createAccount(authorName,
|
|
||||||
password));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package org.briarproject.briar.android.account;
|
package org.briarproject.briar.android.account;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.TextView.OnEditorActionListener;
|
import android.widget.TextView.OnEditorActionListener;
|
||||||
@@ -17,7 +19,10 @@ import org.briarproject.briar.android.fragment.BaseFragment;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import androidx.annotation.CallSuper;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
|
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
|
||||||
import static android.view.inputmethod.EditorInfo.IME_ACTION_NEXT;
|
import static android.view.inputmethod.EditorInfo.IME_ACTION_NEXT;
|
||||||
@@ -29,8 +34,40 @@ import static org.briarproject.briar.android.util.UiUtils.showOnboardingDialog;
|
|||||||
abstract class SetupFragment extends BaseFragment implements TextWatcher,
|
abstract class SetupFragment extends BaseFragment implements TextWatcher,
|
||||||
OnEditorActionListener, OnClickListener {
|
OnEditorActionListener, OnClickListener {
|
||||||
|
|
||||||
|
private final static String STATE_KEY_CLICKED = "setupFragmentClicked";
|
||||||
|
private boolean clicked = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SetupController setupController;
|
ViewModelProvider.Factory viewModelFactory;
|
||||||
|
SetupViewModel viewModel;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
viewModel = new ViewModelProvider(requireActivity())
|
||||||
|
.get(SetupViewModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
clicked = savedInstanceState.getBoolean(STATE_KEY_CLICKED);
|
||||||
|
}
|
||||||
|
if (clicked) {
|
||||||
|
setNextClicked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putBoolean(STATE_KEY_CLICKED, clicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
@CallSuper
|
||||||
|
void setNextClicked() {
|
||||||
|
this.clicked = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.briarproject.briar.android.account;
|
||||||
|
|
||||||
|
import org.briarproject.briar.android.viewmodel.ViewModelKey;
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
import dagger.Binds;
|
||||||
|
import dagger.Module;
|
||||||
|
import dagger.multibindings.IntoMap;
|
||||||
|
|
||||||
|
@Module
|
||||||
|
public abstract class SetupModule {
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
@IntoMap
|
||||||
|
@ViewModelKey(SetupViewModel.class)
|
||||||
|
abstract ViewModel bindSetupViewModel(
|
||||||
|
SetupViewModel setupViewModel);
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
package org.briarproject.briar.android.account;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.account.AccountManager;
|
||||||
|
import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator;
|
||||||
|
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
|
import org.briarproject.briar.android.viewmodel.LiveEvent;
|
||||||
|
import org.briarproject.briar.android.viewmodel.MutableLiveEvent;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
|
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
|
import static org.briarproject.briar.android.account.SetupViewModel.State.AUTHOR_NAME;
|
||||||
|
import static org.briarproject.briar.android.account.SetupViewModel.State.CREATED;
|
||||||
|
import static org.briarproject.briar.android.account.SetupViewModel.State.DOZE;
|
||||||
|
import static org.briarproject.briar.android.account.SetupViewModel.State.FAILED;
|
||||||
|
import static org.briarproject.briar.android.account.SetupViewModel.State.SET_PASSWORD;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
|
class SetupViewModel extends AndroidViewModel {
|
||||||
|
enum State {AUTHOR_NAME, SET_PASSWORD, DOZE, CREATED, FAILED}
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
getLogger(SetupActivity.class.getName());
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String authorName, password;
|
||||||
|
private final MutableLiveEvent<State> state = new MutableLiveEvent<>();
|
||||||
|
|
||||||
|
private final AccountManager accountManager;
|
||||||
|
private final Executor ioExecutor;
|
||||||
|
private final PasswordStrengthEstimator strengthEstimator;
|
||||||
|
private final DozeHelper dozeHelper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
SetupViewModel(Application app,
|
||||||
|
AccountManager accountManager,
|
||||||
|
@IoExecutor Executor ioExecutor,
|
||||||
|
PasswordStrengthEstimator strengthEstimator,
|
||||||
|
DozeHelper dozeHelper) {
|
||||||
|
super(app);
|
||||||
|
this.accountManager = accountManager;
|
||||||
|
this.ioExecutor = ioExecutor;
|
||||||
|
this.strengthEstimator = strengthEstimator;
|
||||||
|
this.dozeHelper = dozeHelper;
|
||||||
|
|
||||||
|
ioExecutor.execute(() -> {
|
||||||
|
if (accountManager.accountExists()) {
|
||||||
|
throw new AssertionError();
|
||||||
|
} else {
|
||||||
|
state.postEvent(AUTHOR_NAME);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveEvent<State> getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAuthorName(String authorName) {
|
||||||
|
this.authorName = authorName;
|
||||||
|
state.setEvent(SET_PASSWORD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPassword(String password) {
|
||||||
|
if (authorName == null) throw new IllegalStateException();
|
||||||
|
this.password = password;
|
||||||
|
if (needToShowDozeFragment()) {
|
||||||
|
state.setEvent(DOZE);
|
||||||
|
} else {
|
||||||
|
createAccount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float estimatePasswordStrength(String password) {
|
||||||
|
return strengthEstimator.estimateStrength(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean needToShowDozeFragment() {
|
||||||
|
return dozeHelper.needToShowDozeFragment(getApplication());
|
||||||
|
}
|
||||||
|
|
||||||
|
void dozeExceptionConfirmed() {
|
||||||
|
createAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createAccount() {
|
||||||
|
if (authorName == null) throw new IllegalStateException();
|
||||||
|
if (password == null) throw new IllegalStateException();
|
||||||
|
ioExecutor.execute(() -> {
|
||||||
|
if (accountManager.createAccount(authorName, password)) {
|
||||||
|
LOG.info("Created account");
|
||||||
|
state.postEvent(CREATED);
|
||||||
|
} else {
|
||||||
|
LOG.warning("Failed to create account");
|
||||||
|
state.postEvent(FAILED);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,7 +21,6 @@ import org.briarproject.briar.android.blog.RssFeedImportActivity;
|
|||||||
import org.briarproject.briar.android.blog.RssFeedManageActivity;
|
import org.briarproject.briar.android.blog.RssFeedManageActivity;
|
||||||
import org.briarproject.briar.android.blog.WriteBlogPostActivity;
|
import org.briarproject.briar.android.blog.WriteBlogPostActivity;
|
||||||
import org.briarproject.briar.android.contact.ContactListFragment;
|
import org.briarproject.briar.android.contact.ContactListFragment;
|
||||||
import org.briarproject.briar.android.contact.ContactModule;
|
|
||||||
import org.briarproject.briar.android.contact.add.remote.AddContactActivity;
|
import org.briarproject.briar.android.contact.add.remote.AddContactActivity;
|
||||||
import org.briarproject.briar.android.contact.add.remote.LinkExchangeFragment;
|
import org.briarproject.briar.android.contact.add.remote.LinkExchangeFragment;
|
||||||
import org.briarproject.briar.android.contact.add.remote.NicknameFragment;
|
import org.briarproject.briar.android.contact.add.remote.NicknameFragment;
|
||||||
@@ -60,12 +59,15 @@ import org.briarproject.briar.android.privategroup.creation.GroupInviteFragment;
|
|||||||
import org.briarproject.briar.android.privategroup.invitation.GroupInvitationActivity;
|
import org.briarproject.briar.android.privategroup.invitation.GroupInvitationActivity;
|
||||||
import org.briarproject.briar.android.privategroup.invitation.GroupInvitationModule;
|
import org.briarproject.briar.android.privategroup.invitation.GroupInvitationModule;
|
||||||
import org.briarproject.briar.android.privategroup.list.GroupListFragment;
|
import org.briarproject.briar.android.privategroup.list.GroupListFragment;
|
||||||
import org.briarproject.briar.android.privategroup.list.GroupListModule;
|
|
||||||
import org.briarproject.briar.android.privategroup.memberlist.GroupMemberListActivity;
|
import org.briarproject.briar.android.privategroup.memberlist.GroupMemberListActivity;
|
||||||
import org.briarproject.briar.android.privategroup.memberlist.GroupMemberModule;
|
import org.briarproject.briar.android.privategroup.memberlist.GroupMemberModule;
|
||||||
import org.briarproject.briar.android.privategroup.reveal.GroupRevealModule;
|
import org.briarproject.briar.android.privategroup.reveal.GroupRevealModule;
|
||||||
import org.briarproject.briar.android.privategroup.reveal.RevealContactsActivity;
|
import org.briarproject.briar.android.privategroup.reveal.RevealContactsActivity;
|
||||||
import org.briarproject.briar.android.privategroup.reveal.RevealContactsFragment;
|
import org.briarproject.briar.android.privategroup.reveal.RevealContactsFragment;
|
||||||
|
import org.briarproject.briar.android.reporting.CrashFragment;
|
||||||
|
import org.briarproject.briar.android.reporting.CrashReportActivity;
|
||||||
|
import org.briarproject.briar.android.reporting.ReportFormFragment;
|
||||||
|
import org.briarproject.briar.android.settings.ConfirmAvatarDialogFragment;
|
||||||
import org.briarproject.briar.android.settings.SettingsActivity;
|
import org.briarproject.briar.android.settings.SettingsActivity;
|
||||||
import org.briarproject.briar.android.settings.SettingsFragment;
|
import org.briarproject.briar.android.settings.SettingsFragment;
|
||||||
import org.briarproject.briar.android.sharing.BlogInvitationActivity;
|
import org.briarproject.briar.android.sharing.BlogInvitationActivity;
|
||||||
@@ -86,12 +88,10 @@ import dagger.Component;
|
|||||||
@Component(modules = {
|
@Component(modules = {
|
||||||
ActivityModule.class,
|
ActivityModule.class,
|
||||||
BlogModule.class,
|
BlogModule.class,
|
||||||
ContactModule.class,
|
|
||||||
CreateGroupModule.class,
|
CreateGroupModule.class,
|
||||||
ForumModule.class,
|
ForumModule.class,
|
||||||
GroupInvitationModule.class,
|
GroupInvitationModule.class,
|
||||||
GroupConversationModule.class,
|
GroupConversationModule.class,
|
||||||
GroupListModule.class,
|
|
||||||
GroupMemberModule.class,
|
GroupMemberModule.class,
|
||||||
GroupRevealModule.class,
|
GroupRevealModule.class,
|
||||||
SharingModule.class
|
SharingModule.class
|
||||||
@@ -184,6 +184,8 @@ public interface ActivityComponent {
|
|||||||
|
|
||||||
void inject(PendingContactListActivity activity);
|
void inject(PendingContactListActivity activity);
|
||||||
|
|
||||||
|
void inject(CrashReportActivity crashReportActivity);
|
||||||
|
|
||||||
// Fragments
|
// Fragments
|
||||||
|
|
||||||
void inject(AuthorNameFragment fragment);
|
void inject(AuthorNameFragment fragment);
|
||||||
@@ -234,4 +236,10 @@ public interface ActivityComponent {
|
|||||||
|
|
||||||
void inject(ImageFragment imageFragment);
|
void inject(ImageFragment imageFragment);
|
||||||
|
|
||||||
|
void inject(ReportFormFragment reportFormFragment);
|
||||||
|
|
||||||
|
void inject(CrashFragment crashFragment);
|
||||||
|
|
||||||
|
void inject(ConfirmAvatarDialogFragment fragment);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package org.briarproject.briar.android.activity;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
|
||||||
import org.briarproject.briar.android.account.SetupController;
|
|
||||||
import org.briarproject.briar.android.account.SetupControllerImpl;
|
|
||||||
import org.briarproject.briar.android.controller.BriarController;
|
import org.briarproject.briar.android.controller.BriarController;
|
||||||
import org.briarproject.briar.android.controller.BriarControllerImpl;
|
import org.briarproject.briar.android.controller.BriarControllerImpl;
|
||||||
import org.briarproject.briar.android.controller.DbController;
|
import org.briarproject.briar.android.controller.DbController;
|
||||||
@@ -35,13 +33,6 @@ public class ActivityModule {
|
|||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ActivityScope
|
|
||||||
@Provides
|
|
||||||
SetupController provideSetupController(
|
|
||||||
SetupControllerImpl setupController) {
|
|
||||||
return setupController;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ActivityScope
|
@ActivityScope
|
||||||
@Provides
|
@Provides
|
||||||
protected BriarController provideBriarController(
|
protected BriarController provideBriarController(
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
@@ -18,7 +17,6 @@ import org.briarproject.briar.android.controller.ActivityLifecycleController;
|
|||||||
import org.briarproject.briar.android.forum.ForumModule;
|
import org.briarproject.briar.android.forum.ForumModule;
|
||||||
import org.briarproject.briar.android.fragment.BaseFragment;
|
import org.briarproject.briar.android.fragment.BaseFragment;
|
||||||
import org.briarproject.briar.android.fragment.ScreenFilterDialogFragment;
|
import org.briarproject.briar.android.fragment.ScreenFilterDialogFragment;
|
||||||
import org.briarproject.briar.android.reporting.DevReportActivity;
|
|
||||||
import org.briarproject.briar.android.util.UiUtils;
|
import org.briarproject.briar.android.util.UiUtils;
|
||||||
import org.briarproject.briar.android.widget.TapSafeFrameLayout;
|
import org.briarproject.briar.android.widget.TapSafeFrameLayout;
|
||||||
import org.briarproject.briar.android.widget.TapSafeFrameLayout.OnTapFilteredListener;
|
import org.briarproject.briar.android.widget.TapSafeFrameLayout.OnTapFilteredListener;
|
||||||
@@ -40,9 +38,11 @@ import androidx.appcompat.widget.Toolbar;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||||
import static androidx.lifecycle.Lifecycle.State.STARTED;
|
import static androidx.lifecycle.Lifecycle.State.STARTED;
|
||||||
|
import static java.util.Collections.emptyList;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.briar.android.TestingConstants.PREVENT_SCREENSHOTS;
|
import static org.briarproject.briar.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||||
@@ -50,7 +50,6 @@ import static org.briarproject.briar.android.util.UiUtils.hideSoftKeyboard;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Warning: Some activities don't extend {@link BaseActivity}.
|
* Warning: Some activities don't extend {@link BaseActivity}.
|
||||||
* E.g. {@link DevReportActivity}
|
|
||||||
*/
|
*/
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@ParametersNotNullByDefault
|
@ParametersNotNullByDefault
|
||||||
@@ -123,6 +122,7 @@ public abstract class BaseActivity extends AppCompatActivity
|
|||||||
return new ActivityModule(this);
|
return new ActivityModule(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO use a test module where this is used in tests
|
||||||
protected ForumModule getForumModule() {
|
protected ForumModule getForumModule() {
|
||||||
return new ForumModule();
|
return new ForumModule();
|
||||||
}
|
}
|
||||||
@@ -202,9 +202,15 @@ public abstract class BaseActivity extends AppCompatActivity
|
|||||||
// If the dialog is already visible, filter the tap
|
// If the dialog is already visible, filter the tap
|
||||||
ScreenFilterDialogFragment f = findDialogFragment();
|
ScreenFilterDialogFragment f = findDialogFragment();
|
||||||
if (f != null && f.isVisible()) return false;
|
if (f != null && f.isVisible()) return false;
|
||||||
Collection<AppDetails> apps = screenFilterMonitor.getApps();
|
Collection<AppDetails> apps;
|
||||||
// If all overlay apps have been allowed, allow the tap
|
// querying all apps is only possible at API 29 and below
|
||||||
if (apps.isEmpty()) return true;
|
if (SDK_INT <= 29) {
|
||||||
|
apps = screenFilterMonitor.getApps();
|
||||||
|
// If all overlay apps have been allowed, allow the tap
|
||||||
|
if (apps.isEmpty()) return true;
|
||||||
|
} else {
|
||||||
|
apps = emptyList();
|
||||||
|
}
|
||||||
// Show dialog unless onSaveInstanceState() has been called, see #1112
|
// Show dialog unless onSaveInstanceState() has been called, see #1112
|
||||||
FragmentManager fm = getSupportFragmentManager();
|
FragmentManager fm = getSupportFragmentManager();
|
||||||
if (!fm.isStateSaved()) {
|
if (!fm.isStateSaved()) {
|
||||||
@@ -241,7 +247,7 @@ public abstract class BaseActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
public void handleDbException(DbException e) {
|
public void handleException(Exception e) {
|
||||||
supportFinishAfterTransition();
|
supportFinishAfterTransition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +272,12 @@ public abstract class BaseActivity extends AppCompatActivity
|
|||||||
private void protectToolbar() {
|
private void protectToolbar() {
|
||||||
findToolbar();
|
findToolbar();
|
||||||
if (toolbar != null) {
|
if (toolbar != null) {
|
||||||
boolean filter = !screenFilterMonitor.getApps().isEmpty();
|
boolean filter;
|
||||||
|
if (SDK_INT <= 29) {
|
||||||
|
filter = !screenFilterMonitor.getApps().isEmpty();
|
||||||
|
} else {
|
||||||
|
filter = true;
|
||||||
|
}
|
||||||
UiUtils.setFilterTouchesWhenObscured(toolbar, filter);
|
UiUtils.setFilterTouchesWhenObscured(toolbar, filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,10 +129,6 @@ public abstract class BriarActivity extends BaseActivity {
|
|||||||
lockManager.onActivityStop();
|
lockManager.onActivityStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean signedIn() {
|
|
||||||
return briarController.accountSignedIn();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the transition animations.
|
* Sets the transition animations.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -16,5 +16,6 @@ public interface RequestCodes {
|
|||||||
int REQUEST_KEYGUARD_UNLOCK = 12;
|
int REQUEST_KEYGUARD_UNLOCK = 12;
|
||||||
int REQUEST_ATTACH_IMAGE = 13;
|
int REQUEST_ATTACH_IMAGE = 13;
|
||||||
int REQUEST_SAVE_ATTACHMENT = 14;
|
int REQUEST_SAVE_ATTACHMENT = 14;
|
||||||
|
int REQUEST_AVATAR_IMAGE = 15;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,24 @@
|
|||||||
package org.briarproject.briar.android.attachment;
|
package org.briarproject.briar.android.attachment;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory.Options;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.briar.api.messaging.AttachmentHeader;
|
import org.briarproject.briar.android.attachment.media.ImageCompressor;
|
||||||
|
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||||
import org.briarproject.briar.api.messaging.MessagingManager;
|
import org.briarproject.briar.api.messaging.MessagingManager;
|
||||||
import org.jsoup.UnsupportedMimeTypeException;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
|
|
||||||
import static android.graphics.Bitmap.CompressFormat.JPEG;
|
|
||||||
import static android.graphics.BitmapFactory.decodeStream;
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.logging.Level.INFO;
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.util.AndroidUtils.getSupportedImageContentTypes;
|
import static org.briarproject.bramble.util.AndroidUtils.getSupportedImageContentTypes;
|
||||||
@@ -35,19 +26,16 @@ import static org.briarproject.bramble.util.IoUtils.tryToClose;
|
|||||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
import static org.briarproject.bramble.util.LogUtils.now;
|
import static org.briarproject.bramble.util.LogUtils.now;
|
||||||
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_IMAGE_SIZE;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
class AttachmentCreationTask {
|
class AttachmentCreationTask {
|
||||||
|
|
||||||
private static Logger LOG =
|
private static final Logger LOG =
|
||||||
getLogger(AttachmentCreationTask.class.getName());
|
getLogger(AttachmentCreationTask.class.getName());
|
||||||
|
|
||||||
private static final int MAX_ATTACHMENT_DIMENSION = 1000;
|
|
||||||
|
|
||||||
private final MessagingManager messagingManager;
|
private final MessagingManager messagingManager;
|
||||||
private final ContentResolver contentResolver;
|
private final ContentResolver contentResolver;
|
||||||
private final ImageSizeCalculator imageSizeCalculator;
|
private final ImageCompressor imageCompressor;
|
||||||
private final GroupId groupId;
|
private final GroupId groupId;
|
||||||
private final Collection<Uri> uris;
|
private final Collection<Uri> uris;
|
||||||
private final boolean needsSize;
|
private final boolean needsSize;
|
||||||
@@ -59,11 +47,11 @@ class AttachmentCreationTask {
|
|||||||
AttachmentCreationTask(MessagingManager messagingManager,
|
AttachmentCreationTask(MessagingManager messagingManager,
|
||||||
ContentResolver contentResolver,
|
ContentResolver contentResolver,
|
||||||
AttachmentCreator attachmentCreator,
|
AttachmentCreator attachmentCreator,
|
||||||
ImageSizeCalculator imageSizeCalculator,
|
ImageCompressor imageCompressor,
|
||||||
GroupId groupId, Collection<Uri> uris, boolean needsSize) {
|
GroupId groupId, Collection<Uri> uris, boolean needsSize) {
|
||||||
this.messagingManager = messagingManager;
|
this.messagingManager = messagingManager;
|
||||||
this.contentResolver = contentResolver;
|
this.contentResolver = contentResolver;
|
||||||
this.imageSizeCalculator = imageSizeCalculator;
|
this.imageCompressor = imageCompressor;
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
this.uris = uris;
|
this.uris = uris;
|
||||||
this.needsSize = needsSize;
|
this.needsSize = needsSize;
|
||||||
@@ -110,66 +98,19 @@ class AttachmentCreationTask {
|
|||||||
String contentType = contentResolver.getType(uri);
|
String contentType = contentResolver.getType(uri);
|
||||||
if (contentType == null) throw new IOException("null content type");
|
if (contentType == null) throw new IOException("null content type");
|
||||||
if (!asList(getSupportedImageContentTypes()).contains(contentType)) {
|
if (!asList(getSupportedImageContentTypes()).contains(contentType)) {
|
||||||
String uriString = uri.toString();
|
throw new UnsupportedMimeTypeException(contentType, uri);
|
||||||
throw new UnsupportedMimeTypeException("", contentType, uriString);
|
|
||||||
}
|
}
|
||||||
InputStream is = contentResolver.openInputStream(uri);
|
InputStream is = contentResolver.openInputStream(uri);
|
||||||
if (is == null) throw new IOException();
|
if (is == null) throw new IOException();
|
||||||
is = compressImage(is, contentType);
|
is = imageCompressor
|
||||||
contentType = "image/jpeg";
|
.compressImage(is, contentType);
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
AttachmentHeader h = messagingManager
|
AttachmentHeader h = messagingManager
|
||||||
.addLocalAttachment(groupId, timestamp, contentType, is);
|
.addLocalAttachment(groupId, timestamp,
|
||||||
|
ImageCompressor.MIME_TYPE, is);
|
||||||
tryToClose(is, LOG, WARNING);
|
tryToClose(is, LOG, WARNING);
|
||||||
logDuration(LOG, "Storing attachment", start);
|
logDuration(LOG, "Storing attachment", start);
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
InputStream compressImage(InputStream is, String contentType)
|
|
||||||
throws IOException {
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
Bitmap bitmap = createBitmap(is, contentType);
|
|
||||||
for (int quality = 100; quality >= 0; quality -= 10) {
|
|
||||||
if (!bitmap.compress(JPEG, quality, out))
|
|
||||||
throw new IOException();
|
|
||||||
if (out.size() <= MAX_IMAGE_SIZE) {
|
|
||||||
if (LOG.isLoggable(INFO)) {
|
|
||||||
LOG.info("Compressed image to "
|
|
||||||
+ out.size() + " bytes, quality " + quality);
|
|
||||||
}
|
|
||||||
return new ByteArrayInputStream(out.toByteArray());
|
|
||||||
}
|
|
||||||
out.reset();
|
|
||||||
}
|
|
||||||
throw new IOException();
|
|
||||||
} finally {
|
|
||||||
tryToClose(is, LOG, WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Bitmap createBitmap(InputStream is, String contentType)
|
|
||||||
throws IOException {
|
|
||||||
is = new BufferedInputStream(is);
|
|
||||||
Size size = imageSizeCalculator.getSize(is, contentType);
|
|
||||||
if (size.error) throw new IOException();
|
|
||||||
if (LOG.isLoggable(INFO))
|
|
||||||
LOG.info("Original image size: " + size.width + "x" + size.height);
|
|
||||||
int dimension = Math.max(size.width, size.height);
|
|
||||||
int inSampleSize = 1;
|
|
||||||
while (dimension > MAX_ATTACHMENT_DIMENSION) {
|
|
||||||
inSampleSize *= 2;
|
|
||||||
dimension /= 2;
|
|
||||||
}
|
|
||||||
if (LOG.isLoggable(INFO))
|
|
||||||
LOG.info("Scaling attachment by factor of " + inSampleSize);
|
|
||||||
Options options = new Options();
|
|
||||||
options.inSampleSize = inSampleSize;
|
|
||||||
if (contentType.equals("image/png"))
|
|
||||||
options.inPreferredConfig = Bitmap.Config.RGB_565;
|
|
||||||
Bitmap bitmap = decodeStream(is, null, options);
|
|
||||||
if (bitmap == null) throw new IOException();
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.briarproject.bramble.api.lifecycle.IoExecutor;
|
|||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.api.messaging.AttachmentHeader;
|
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.api.messaging.Attachment;
|
import org.briarproject.briar.android.attachment.media.ImageCompressor;
|
||||||
import org.briarproject.briar.api.messaging.AttachmentHeader;
|
import org.briarproject.briar.api.attachment.Attachment;
|
||||||
import org.briarproject.briar.api.messaging.FileTooBigException;
|
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||||
|
import org.briarproject.briar.api.attachment.FileTooBigException;
|
||||||
import org.briarproject.briar.api.messaging.MessagingManager;
|
import org.briarproject.briar.api.messaging.MessagingManager;
|
||||||
import org.jsoup.UnsupportedMimeTypeException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -34,13 +34,14 @@ import androidx.lifecycle.MutableLiveData;
|
|||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
|
import static org.briarproject.briar.android.attachment.AttachmentItem.State.ERROR;
|
||||||
import static org.briarproject.briar.android.util.UiUtils.observeForeverOnce;
|
import static org.briarproject.briar.android.util.UiUtils.observeForeverOnce;
|
||||||
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_IMAGE_SIZE;
|
import static org.briarproject.briar.api.attachment.MediaConstants.MAX_IMAGE_SIZE;
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
class AttachmentCreatorImpl implements AttachmentCreator {
|
class AttachmentCreatorImpl implements AttachmentCreator {
|
||||||
|
|
||||||
private static Logger LOG =
|
private static final Logger LOG =
|
||||||
getLogger(AttachmentCreatorImpl.class.getName());
|
getLogger(AttachmentCreatorImpl.class.getName());
|
||||||
|
|
||||||
private final Application app;
|
private final Application app;
|
||||||
@@ -48,7 +49,7 @@ class AttachmentCreatorImpl implements AttachmentCreator {
|
|||||||
private final Executor ioExecutor;
|
private final Executor ioExecutor;
|
||||||
private final MessagingManager messagingManager;
|
private final MessagingManager messagingManager;
|
||||||
private final AttachmentRetriever retriever;
|
private final AttachmentRetriever retriever;
|
||||||
private final ImageSizeCalculator imageSizeCalculator;
|
private final ImageCompressor imageCompressor;
|
||||||
|
|
||||||
private final CopyOnWriteArrayList<Uri> uris = new CopyOnWriteArrayList<>();
|
private final CopyOnWriteArrayList<Uri> uris = new CopyOnWriteArrayList<>();
|
||||||
private final CopyOnWriteArrayList<AttachmentItemResult> itemResults =
|
private final CopyOnWriteArrayList<AttachmentItemResult> itemResults =
|
||||||
@@ -63,20 +64,24 @@ class AttachmentCreatorImpl implements AttachmentCreator {
|
|||||||
@Inject
|
@Inject
|
||||||
AttachmentCreatorImpl(Application app, @IoExecutor Executor ioExecutor,
|
AttachmentCreatorImpl(Application app, @IoExecutor Executor ioExecutor,
|
||||||
MessagingManager messagingManager, AttachmentRetriever retriever,
|
MessagingManager messagingManager, AttachmentRetriever retriever,
|
||||||
ImageSizeCalculator imageSizeCalculator) {
|
ImageCompressor imageCompressor) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.ioExecutor = ioExecutor;
|
this.ioExecutor = ioExecutor;
|
||||||
this.messagingManager = messagingManager;
|
this.messagingManager = messagingManager;
|
||||||
this.retriever = retriever;
|
this.retriever = retriever;
|
||||||
this.imageSizeCalculator = imageSizeCalculator;
|
this.imageCompressor = imageCompressor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@UiThread
|
@UiThread
|
||||||
public LiveData<AttachmentResult> storeAttachments(
|
public LiveData<AttachmentResult> storeAttachments(
|
||||||
LiveData<GroupId> groupId, Collection<Uri> newUris) {
|
LiveData<GroupId> groupId, Collection<Uri> newUris) {
|
||||||
if (task != null || result != null || !uris.isEmpty())
|
if (task != null || result != null || !uris.isEmpty()) {
|
||||||
|
if (task != null) LOG.warning("Task already exists!");
|
||||||
|
if (result != null) LOG.warning("Result already exists!");
|
||||||
|
if (!uris.isEmpty()) LOG.warning("Uris available: " + uris);
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
MutableLiveData<AttachmentResult> result = new MutableLiveData<>();
|
MutableLiveData<AttachmentResult> result = new MutableLiveData<>();
|
||||||
this.result = result;
|
this.result = result;
|
||||||
uris.addAll(newUris);
|
uris.addAll(newUris);
|
||||||
@@ -84,7 +89,7 @@ class AttachmentCreatorImpl implements AttachmentCreator {
|
|||||||
if (id == null) throw new IllegalStateException();
|
if (id == null) throw new IllegalStateException();
|
||||||
boolean needsSize = uris.size() == 1;
|
boolean needsSize = uris.size() == 1;
|
||||||
task = new AttachmentCreationTask(messagingManager,
|
task = new AttachmentCreationTask(messagingManager,
|
||||||
app.getContentResolver(), this, imageSizeCalculator, id,
|
app.getContentResolver(), this, imageCompressor, id,
|
||||||
uris, needsSize);
|
uris, needsSize);
|
||||||
ioExecutor.execute(() -> task.storeAttachments());
|
ioExecutor.execute(() -> task.storeAttachments());
|
||||||
});
|
});
|
||||||
@@ -95,8 +100,12 @@ class AttachmentCreatorImpl implements AttachmentCreator {
|
|||||||
@UiThread
|
@UiThread
|
||||||
public LiveData<AttachmentResult> getLiveAttachments() {
|
public LiveData<AttachmentResult> getLiveAttachments() {
|
||||||
MutableLiveData<AttachmentResult> result = this.result;
|
MutableLiveData<AttachmentResult> result = this.result;
|
||||||
if (task == null || result == null || uris.isEmpty())
|
if (task == null || result == null || uris.isEmpty()) {
|
||||||
|
if (task == null) LOG.warning("No Task!");
|
||||||
|
if (result == null) LOG.warning("No Result!");
|
||||||
|
if (uris.isEmpty()) LOG.warning("Uris empty!");
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
// A task is already running. It will update the result LiveData.
|
// A task is already running. It will update the result LiveData.
|
||||||
// So nothing more to do here.
|
// So nothing more to do here.
|
||||||
return result;
|
return result;
|
||||||
@@ -109,8 +118,8 @@ class AttachmentCreatorImpl implements AttachmentCreator {
|
|||||||
// get and cache AttachmentItem for ImagePreview
|
// get and cache AttachmentItem for ImagePreview
|
||||||
try {
|
try {
|
||||||
Attachment a = retriever.getMessageAttachment(h);
|
Attachment a = retriever.getMessageAttachment(h);
|
||||||
AttachmentItem item = retriever.getAttachmentItem(a, needsSize);
|
AttachmentItem item = retriever.createAttachmentItem(a, needsSize);
|
||||||
if (item.hasError()) throw new IOException();
|
if (item.getState() == ERROR) throw new IOException();
|
||||||
AttachmentItemResult itemResult =
|
AttachmentItemResult itemResult =
|
||||||
new AttachmentItemResult(uri, item);
|
new AttachmentItemResult(uri, item);
|
||||||
itemResults.add(itemResult);
|
itemResults.add(itemResult);
|
||||||
@@ -167,21 +176,13 @@ class AttachmentCreatorImpl implements AttachmentCreator {
|
|||||||
@Override
|
@Override
|
||||||
@UiThread
|
@UiThread
|
||||||
public void onAttachmentsSent(MessageId id) {
|
public void onAttachmentsSent(MessageId id) {
|
||||||
List<AttachmentItem> items = new ArrayList<>(itemResults.size());
|
|
||||||
for (AttachmentItemResult itemResult : itemResults) {
|
|
||||||
// check if we are trying to send attachment items with errors
|
|
||||||
if (itemResult.getItem() == null) throw new IllegalStateException();
|
|
||||||
items.add(itemResult.getItem());
|
|
||||||
}
|
|
||||||
retriever.cachePut(id, items);
|
|
||||||
resetState();
|
resetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@UiThread
|
@UiThread
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
if (task == null) throw new AssertionError();
|
if (task != null) task.cancel();
|
||||||
task.cancel();
|
|
||||||
deleteUnsentAttachments();
|
deleteUnsentAttachments();
|
||||||
resetState();
|
resetState();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,27 +4,37 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.api.messaging.AttachmentHeader;
|
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import static java.lang.System.arraycopy;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
import static org.briarproject.bramble.util.StringUtils.toHexString;
|
||||||
|
import static org.briarproject.briar.android.attachment.AttachmentItem.State.LOADING;
|
||||||
|
import static org.briarproject.briar.android.attachment.AttachmentItem.State.MISSING;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class AttachmentItem implements Parcelable {
|
public class AttachmentItem implements Parcelable {
|
||||||
|
|
||||||
|
public enum State {
|
||||||
|
LOADING, MISSING, AVAILABLE, ERROR;
|
||||||
|
|
||||||
|
public boolean isFinal() {
|
||||||
|
return this == AVAILABLE || this == ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final AttachmentHeader header;
|
private final AttachmentHeader header;
|
||||||
private final int width, height;
|
private final int width, height;
|
||||||
private final String extension;
|
private final String extension;
|
||||||
private final int thumbnailWidth, thumbnailHeight;
|
private final int thumbnailWidth, thumbnailHeight;
|
||||||
private final boolean hasError;
|
private final State state;
|
||||||
private final long instanceId;
|
|
||||||
|
|
||||||
public static final Creator<AttachmentItem> CREATOR =
|
public static final Creator<AttachmentItem> CREATOR =
|
||||||
new Creator<AttachmentItem>() {
|
new Creator<AttachmentItem>() {
|
||||||
@@ -39,22 +49,39 @@ public class AttachmentItem implements Parcelable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final AtomicLong NEXT_INSTANCE_ID = new AtomicLong(0);
|
|
||||||
|
|
||||||
AttachmentItem(AttachmentHeader header, int width, int height,
|
AttachmentItem(AttachmentHeader header, int width, int height,
|
||||||
String extension, int thumbnailWidth, int thumbnailHeight,
|
String extension, int thumbnailWidth, int thumbnailHeight,
|
||||||
boolean hasError) {
|
State state) {
|
||||||
this.header = header;
|
this.header = header;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.extension = extension;
|
this.extension = extension;
|
||||||
this.thumbnailWidth = thumbnailWidth;
|
this.thumbnailWidth = thumbnailWidth;
|
||||||
this.thumbnailHeight = thumbnailHeight;
|
this.thumbnailHeight = thumbnailHeight;
|
||||||
this.hasError = hasError;
|
this.state = state;
|
||||||
instanceId = NEXT_INSTANCE_ID.getAndIncrement();
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use only for {@link State MISSING} or {@link State LOADING} items.
|
||||||
|
*/
|
||||||
|
AttachmentItem(AttachmentHeader header, int width, int height,
|
||||||
|
State state) {
|
||||||
|
this(header, width, height, "", width, height, state);
|
||||||
|
if (state != MISSING && state != LOADING)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use when the item does not need a size.
|
||||||
|
*/
|
||||||
|
AttachmentItem(AttachmentHeader header, String extension, State state) {
|
||||||
|
this(header, 0, 0, extension, 0, 0, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AttachmentItem(Parcel in) {
|
protected AttachmentItem(Parcel in) {
|
||||||
|
byte[] groupIdByte = new byte[GroupId.LENGTH];
|
||||||
|
in.readByteArray(groupIdByte);
|
||||||
|
GroupId groupId = new GroupId(groupIdByte);
|
||||||
byte[] messageIdByte = new byte[MessageId.LENGTH];
|
byte[] messageIdByte = new byte[MessageId.LENGTH];
|
||||||
in.readByteArray(messageIdByte);
|
in.readByteArray(messageIdByte);
|
||||||
MessageId messageId = new MessageId(messageIdByte);
|
MessageId messageId = new MessageId(messageIdByte);
|
||||||
@@ -64,9 +91,8 @@ public class AttachmentItem implements Parcelable {
|
|||||||
extension = requireNonNull(in.readString());
|
extension = requireNonNull(in.readString());
|
||||||
thumbnailWidth = in.readInt();
|
thumbnailWidth = in.readInt();
|
||||||
thumbnailHeight = in.readInt();
|
thumbnailHeight = in.readInt();
|
||||||
hasError = in.readByte() != 0;
|
state = State.valueOf(requireNonNull(in.readString()));
|
||||||
instanceId = in.readLong();
|
header = new AttachmentHeader(groupId, messageId, mimeType);
|
||||||
header = new AttachmentHeader(messageId, mimeType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AttachmentHeader getHeader() {
|
public AttachmentHeader getHeader() {
|
||||||
@@ -101,12 +127,16 @@ public class AttachmentItem implements Parcelable {
|
|||||||
return thumbnailHeight;
|
return thumbnailHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasError() {
|
public State getState() {
|
||||||
return hasError;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTransitionName() {
|
public String getTransitionName(MessageId conversationItemId) {
|
||||||
return String.valueOf(instanceId);
|
int len = MessageId.LENGTH;
|
||||||
|
byte[] instanceId = new byte[len * 2];
|
||||||
|
arraycopy(header.getMessageId().getBytes(), 0, instanceId, 0, len);
|
||||||
|
arraycopy(conversationItemId.getBytes(), 0, instanceId, len, len);
|
||||||
|
return toHexString(instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -116,6 +146,7 @@ public class AttachmentItem implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeByteArray(header.getGroupId().getBytes());
|
||||||
dest.writeByteArray(header.getMessageId().getBytes());
|
dest.writeByteArray(header.getMessageId().getBytes());
|
||||||
dest.writeInt(width);
|
dest.writeInt(width);
|
||||||
dest.writeInt(height);
|
dest.writeInt(height);
|
||||||
@@ -123,14 +154,23 @@ public class AttachmentItem implements Parcelable {
|
|||||||
dest.writeString(extension);
|
dest.writeString(extension);
|
||||||
dest.writeInt(thumbnailWidth);
|
dest.writeInt(thumbnailWidth);
|
||||||
dest.writeInt(thumbnailHeight);
|
dest.writeInt(thumbnailHeight);
|
||||||
dest.writeByte((byte) (hasError ? 1 : 0));
|
dest.writeString(state.name());
|
||||||
dest.writeLong(instanceId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is used to identity if two items are the same,
|
||||||
|
* irrespective of their state or size.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object o) {
|
public boolean equals(@Nullable Object o) {
|
||||||
return o instanceof AttachmentItem &&
|
return o instanceof AttachmentItem &&
|
||||||
instanceId == ((AttachmentItem) o).instanceId;
|
header.getMessageId().equals(
|
||||||
|
((AttachmentItem) o).header.getMessageId()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return header.getMessageId().hashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package org.briarproject.briar.android.attachment;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.briar.api.messaging.AttachmentHeader;
|
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -12,16 +12,6 @@ import static org.briarproject.briar.android.attachment.AttachmentDimensions.get
|
|||||||
@Module
|
@Module
|
||||||
public class AttachmentModule {
|
public class AttachmentModule {
|
||||||
|
|
||||||
@Provides
|
|
||||||
ImageHelper provideImageHelper(ImageHelperImpl imageHelper) {
|
|
||||||
return imageHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
ImageSizeCalculator provideImageSizeCalculator(ImageHelper imageHelper) {
|
|
||||||
return new ImageSizeCalculator(imageHelper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
AttachmentDimensions provideAttachmentDimensions(Application app) {
|
AttachmentDimensions provideAttachmentDimensions(Application app) {
|
||||||
return getAttachmentDimensions(app.getResources());
|
return getAttachmentDimensions(app.getResources());
|
||||||
|
|||||||
@@ -1,29 +1,63 @@
|
|||||||
package org.briarproject.briar.android.attachment;
|
package org.briarproject.briar.android.attachment;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.api.messaging.Attachment;
|
import org.briarproject.briar.api.attachment.Attachment;
|
||||||
import org.briarproject.briar.api.messaging.AttachmentHeader;
|
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||||
|
import org.briarproject.briar.api.messaging.PrivateMessageHeader;
|
||||||
|
import org.briarproject.briar.api.messaging.event.AttachmentReceivedEvent;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public interface AttachmentRetriever {
|
public interface AttachmentRetriever {
|
||||||
|
|
||||||
void cachePut(MessageId messageId, List<AttachmentItem> attachments);
|
@DatabaseExecutor
|
||||||
|
|
||||||
@Nullable
|
|
||||||
List<AttachmentItem> cacheGet(MessageId messageId);
|
|
||||||
|
|
||||||
Attachment getMessageAttachment(AttachmentHeader h) throws DbException;
|
Attachment getMessageAttachment(AttachmentHeader h) throws DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of observable {@link LiveData}
|
||||||
|
* that get updated as the state of their {@link AttachmentItem}s changes.
|
||||||
|
*/
|
||||||
|
List<LiveData<AttachmentItem>> getAttachmentItems(
|
||||||
|
PrivateMessageHeader messageHeader);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves item size and adds the item to the cache, if available.
|
||||||
|
* <p>
|
||||||
|
* Use this to eagerly load the attachment size before it gets displayed.
|
||||||
|
* This is needed for messages containing a single attachment.
|
||||||
|
* Messages with more than one attachment use a standard size.
|
||||||
|
*/
|
||||||
|
@DatabaseExecutor
|
||||||
|
void cacheAttachmentItemWithSize(MessageId conversationMessageId,
|
||||||
|
AttachmentHeader h) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an {@link AttachmentItem} from the {@link Attachment}'s
|
* Creates an {@link AttachmentItem} from the {@link Attachment}'s
|
||||||
* {@link InputStream} which will be closed when this method returns.
|
* {@link InputStream} which will be closed when this method returns.
|
||||||
*/
|
*/
|
||||||
AttachmentItem getAttachmentItem(Attachment a, boolean needsSize);
|
AttachmentItem createAttachmentItem(Attachment a, boolean needsSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads an {@link AttachmentItem}
|
||||||
|
* that arrived via an {@link AttachmentReceivedEvent}
|
||||||
|
* and notifies the associated {@link LiveData}.
|
||||||
|
* <p>
|
||||||
|
* Note that you need to call {@link #getAttachmentItems(PrivateMessageHeader)}
|
||||||
|
* first to get the LiveData.
|
||||||
|
* <p>
|
||||||
|
* It is possible that no LiveData is available,
|
||||||
|
* because the message of the AttachmentItem did not arrive, yet.
|
||||||
|
* In this case, the load wil be deferred until the message arrives.
|
||||||
|
*/
|
||||||
|
@DatabaseExecutor
|
||||||
|
void loadAttachmentItem(MessageId attachmentId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,42 @@
|
|||||||
package org.briarproject.briar.android.attachment;
|
package org.briarproject.briar.android.attachment;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
|
import org.briarproject.bramble.api.db.NoSuchMessageException;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.api.messaging.Attachment;
|
import org.briarproject.briar.android.attachment.AttachmentItem.State;
|
||||||
import org.briarproject.briar.api.messaging.AttachmentHeader;
|
import org.briarproject.briar.android.attachment.media.ImageHelper;
|
||||||
import org.briarproject.briar.api.messaging.MessagingManager;
|
import org.briarproject.briar.android.attachment.media.ImageSizeCalculator;
|
||||||
|
import org.briarproject.briar.android.attachment.media.Size;
|
||||||
|
import org.briarproject.briar.api.attachment.Attachment;
|
||||||
|
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||||
|
import org.briarproject.briar.api.attachment.AttachmentReader;
|
||||||
|
import org.briarproject.briar.api.messaging.PrivateMessageHeader;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
|
import static org.briarproject.bramble.util.IoUtils.tryToClose;
|
||||||
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
|
import static org.briarproject.briar.android.attachment.AttachmentItem.State.AVAILABLE;
|
||||||
|
import static org.briarproject.briar.android.attachment.AttachmentItem.State.ERROR;
|
||||||
|
import static org.briarproject.briar.android.attachment.AttachmentItem.State.LOADING;
|
||||||
|
import static org.briarproject.briar.android.attachment.AttachmentItem.State.MISSING;
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
class AttachmentRetrieverImpl implements AttachmentRetriever {
|
class AttachmentRetrieverImpl implements AttachmentRetriever {
|
||||||
@@ -27,21 +44,26 @@ class AttachmentRetrieverImpl implements AttachmentRetriever {
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
getLogger(AttachmentRetrieverImpl.class.getName());
|
getLogger(AttachmentRetrieverImpl.class.getName());
|
||||||
|
|
||||||
private final MessagingManager messagingManager;
|
@DatabaseExecutor
|
||||||
|
private final Executor dbExecutor;
|
||||||
|
private final AttachmentReader attachmentReader;
|
||||||
private final ImageHelper imageHelper;
|
private final ImageHelper imageHelper;
|
||||||
private final ImageSizeCalculator imageSizeCalculator;
|
private final ImageSizeCalculator imageSizeCalculator;
|
||||||
private final int defaultSize;
|
private final int defaultSize;
|
||||||
private final int minWidth, maxWidth;
|
private final int minWidth, maxWidth;
|
||||||
private final int minHeight, maxHeight;
|
private final int minHeight, maxHeight;
|
||||||
|
|
||||||
private final Map<MessageId, List<AttachmentItem>> attachmentCache =
|
private final ConcurrentMap<MessageId, MutableLiveData<AttachmentItem>>
|
||||||
new ConcurrentHashMap<>();
|
itemsWithSize = new ConcurrentHashMap<>();
|
||||||
|
private final ConcurrentMap<MessageId, MutableLiveData<AttachmentItem>>
|
||||||
|
itemsWithoutSize = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AttachmentRetrieverImpl(MessagingManager messagingManager,
|
AttachmentRetrieverImpl(@DatabaseExecutor Executor dbExecutor,
|
||||||
AttachmentDimensions dimensions, ImageHelper imageHelper,
|
AttachmentReader attachmentReader, AttachmentDimensions dimensions,
|
||||||
ImageSizeCalculator imageSizeCalculator) {
|
ImageHelper imageHelper, ImageSizeCalculator imageSizeCalculator) {
|
||||||
this.messagingManager = messagingManager;
|
this.dbExecutor = dbExecutor;
|
||||||
|
this.attachmentReader = attachmentReader;
|
||||||
this.imageHelper = imageHelper;
|
this.imageHelper = imageHelper;
|
||||||
this.imageSizeCalculator = imageSizeCalculator;
|
this.imageSizeCalculator = imageSizeCalculator;
|
||||||
defaultSize = dimensions.defaultSize;
|
defaultSize = dimensions.defaultSize;
|
||||||
@@ -52,60 +74,166 @@ class AttachmentRetrieverImpl implements AttachmentRetriever {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cachePut(MessageId messageId,
|
@DatabaseExecutor
|
||||||
List<AttachmentItem> attachments) {
|
|
||||||
attachmentCache.put(messageId, attachments);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public List<AttachmentItem> cacheGet(MessageId messageId) {
|
|
||||||
return attachmentCache.get(messageId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Attachment getMessageAttachment(AttachmentHeader h)
|
public Attachment getMessageAttachment(AttachmentHeader h)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
return messagingManager.getAttachment(h);
|
return attachmentReader.getAttachment(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttachmentItem getAttachmentItem(Attachment a, boolean needsSize) {
|
public List<LiveData<AttachmentItem>> getAttachmentItems(
|
||||||
|
PrivateMessageHeader messageHeader) {
|
||||||
|
List<AttachmentHeader> headers = messageHeader.getAttachmentHeaders();
|
||||||
|
List<LiveData<AttachmentItem>> items = new ArrayList<>(headers.size());
|
||||||
|
boolean needsSize = headers.size() == 1;
|
||||||
|
for (AttachmentHeader h : headers) {
|
||||||
|
// try cache for existing item live data
|
||||||
|
MutableLiveData<AttachmentItem> liveData =
|
||||||
|
itemsWithSize.get(h.getMessageId());
|
||||||
|
if (!needsSize && liveData == null) {
|
||||||
|
// check cache for items that don't need the size
|
||||||
|
liveData = itemsWithoutSize.get(h.getMessageId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// create new live data with LOADING item if cache miss
|
||||||
|
if (liveData == null) {
|
||||||
|
AttachmentItem item = new AttachmentItem(h,
|
||||||
|
defaultSize, defaultSize, LOADING);
|
||||||
|
liveData = new MutableLiveData<>(item);
|
||||||
|
// add new LiveData to cache, checking for concurrent updates
|
||||||
|
MutableLiveData<AttachmentItem> oldLiveData;
|
||||||
|
if (needsSize) {
|
||||||
|
oldLiveData = itemsWithSize.putIfAbsent(h.getMessageId(),
|
||||||
|
liveData);
|
||||||
|
} else {
|
||||||
|
oldLiveData = itemsWithoutSize.putIfAbsent(h.getMessageId(),
|
||||||
|
liveData);
|
||||||
|
}
|
||||||
|
if (oldLiveData == null) {
|
||||||
|
// kick-off loading of attachment, will post to live data
|
||||||
|
MutableLiveData<AttachmentItem> finalLiveData = liveData;
|
||||||
|
dbExecutor.execute(() ->
|
||||||
|
loadAttachmentItem(h, needsSize, finalLiveData));
|
||||||
|
} else {
|
||||||
|
// Concurrent cache update - use the existing live data
|
||||||
|
liveData = oldLiveData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items.add(liveData);
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@DatabaseExecutor
|
||||||
|
public void cacheAttachmentItemWithSize(MessageId conversationMessageId,
|
||||||
|
AttachmentHeader h) throws DbException {
|
||||||
|
// If a live data is already cached we don't need to do anything
|
||||||
|
if (itemsWithSize.containsKey(h.getMessageId())) return;
|
||||||
|
try {
|
||||||
|
Attachment a = attachmentReader.getAttachment(h);
|
||||||
|
AttachmentItem item = createAttachmentItem(a, true);
|
||||||
|
MutableLiveData<AttachmentItem> liveData =
|
||||||
|
new MutableLiveData<>(item);
|
||||||
|
// If a live data was concurrently cached, don't replace it
|
||||||
|
itemsWithSize.putIfAbsent(h.getMessageId(), liveData);
|
||||||
|
} catch (NoSuchMessageException e) {
|
||||||
|
LOG.info("Attachment not received yet");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@DatabaseExecutor
|
||||||
|
public void loadAttachmentItem(MessageId attachmentId) {
|
||||||
|
// try to find LiveData for attachment in both caches
|
||||||
|
MutableLiveData<AttachmentItem> liveData;
|
||||||
|
boolean needsSize = true;
|
||||||
|
liveData = itemsWithSize.get(attachmentId);
|
||||||
|
if (liveData == null) {
|
||||||
|
needsSize = false;
|
||||||
|
liveData = itemsWithoutSize.get(attachmentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no LiveData for the attachment exists,
|
||||||
|
// its message did not yet arrive and we can ignore it for now.
|
||||||
|
if (liveData == null) return;
|
||||||
|
|
||||||
|
// actually load the attachment item
|
||||||
|
AttachmentHeader h = requireNonNull(liveData.getValue()).getHeader();
|
||||||
|
loadAttachmentItem(h, needsSize, liveData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads an {@link AttachmentItem} from the database
|
||||||
|
* and notifies the given {@link LiveData}.
|
||||||
|
*/
|
||||||
|
@DatabaseExecutor
|
||||||
|
private void loadAttachmentItem(AttachmentHeader h, boolean needsSize,
|
||||||
|
MutableLiveData<AttachmentItem> liveData) {
|
||||||
|
Attachment a;
|
||||||
|
AttachmentItem item;
|
||||||
|
try {
|
||||||
|
a = attachmentReader.getAttachment(h);
|
||||||
|
item = createAttachmentItem(a, needsSize);
|
||||||
|
} catch (NoSuchMessageException e) {
|
||||||
|
LOG.info("Attachment not received yet");
|
||||||
|
item = new AttachmentItem(h, defaultSize, defaultSize, MISSING);
|
||||||
|
} catch (DbException e) {
|
||||||
|
logException(LOG, WARNING, e);
|
||||||
|
item = new AttachmentItem(h, "", ERROR);
|
||||||
|
}
|
||||||
|
liveData.postValue(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AttachmentItem createAttachmentItem(Attachment a,
|
||||||
|
boolean needsSize) {
|
||||||
|
AttachmentItem item;
|
||||||
AttachmentHeader h = a.getHeader();
|
AttachmentHeader h = a.getHeader();
|
||||||
if (!needsSize) {
|
if (needsSize) {
|
||||||
|
InputStream is = new BufferedInputStream(a.getStream());
|
||||||
|
Size size = imageSizeCalculator.getSize(is, h.getContentType());
|
||||||
|
tryToClose(is, LOG, WARNING);
|
||||||
|
item = createAttachmentItem(h, size);
|
||||||
|
} else {
|
||||||
String extension =
|
String extension =
|
||||||
imageHelper.getExtensionFromMimeType(h.getContentType());
|
imageHelper.getExtensionFromMimeType(h.getContentType());
|
||||||
boolean hasError = false;
|
State state = AVAILABLE;
|
||||||
if (extension == null) {
|
if (extension == null) {
|
||||||
extension = "";
|
extension = "";
|
||||||
hasError = true;
|
state = ERROR;
|
||||||
}
|
}
|
||||||
return new AttachmentItem(h, 0, 0, extension, 0, 0, hasError);
|
item = new AttachmentItem(h, extension, state);
|
||||||
}
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
InputStream is = new BufferedInputStream(a.getStream());
|
private AttachmentItem createAttachmentItem(AttachmentHeader h, Size size) {
|
||||||
Size size = imageSizeCalculator.getSize(is, h.getContentType());
|
|
||||||
|
|
||||||
// calculate thumbnail size
|
// calculate thumbnail size
|
||||||
Size thumbnailSize = new Size(defaultSize, defaultSize, size.mimeType);
|
Size thumbnailSize =
|
||||||
if (!size.error) {
|
new Size(defaultSize, defaultSize, size.getMimeType());
|
||||||
|
if (!size.hasError()) {
|
||||||
thumbnailSize =
|
thumbnailSize =
|
||||||
getThumbnailSize(size.width, size.height, size.mimeType);
|
getThumbnailSize(size.getWidth(), size.getHeight(),
|
||||||
|
size.getMimeType());
|
||||||
}
|
}
|
||||||
// get file extension
|
// get file extension
|
||||||
String extension = imageHelper.getExtensionFromMimeType(size.mimeType);
|
String extension =
|
||||||
boolean hasError = extension == null || size.error;
|
imageHelper.getExtensionFromMimeType(size.getMimeType());
|
||||||
if (!h.getContentType().equals(size.mimeType)) {
|
boolean hasError = extension == null || size.hasError();
|
||||||
|
if (!h.getContentType().equals(size.getMimeType())) {
|
||||||
if (LOG.isLoggable(WARNING)) {
|
if (LOG.isLoggable(WARNING)) {
|
||||||
LOG.warning("Header has different mime type (" +
|
LOG.warning("Header has different mime type (" +
|
||||||
h.getContentType() + ") than image (" + size.mimeType +
|
h.getContentType() + ") than image (" +
|
||||||
").");
|
size.getMimeType() + ").");
|
||||||
}
|
}
|
||||||
hasError = true;
|
hasError = true;
|
||||||
}
|
}
|
||||||
if (extension == null) extension = "";
|
if (extension == null) extension = "";
|
||||||
return new AttachmentItem(h, size.width, size.height, extension,
|
State state = hasError ? ERROR : AVAILABLE;
|
||||||
thumbnailSize.width, thumbnailSize.height, hasError);
|
return new AttachmentItem(h, size.getWidth(), size.getHeight(),
|
||||||
|
extension, thumbnailSize.getWidth(), thumbnailSize.getHeight(),
|
||||||
|
state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Size getThumbnailSize(int width, int height, String mimeType) {
|
private Size getThumbnailSize(int width, int height, String mimeType) {
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
package org.briarproject.briar.android.attachment;
|
|
||||||
|
|
||||||
class Size {
|
|
||||||
|
|
||||||
final int width;
|
|
||||||
final int height;
|
|
||||||
final String mimeType;
|
|
||||||
final boolean error;
|
|
||||||
|
|
||||||
Size(int width, int height, String mimeType) {
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
this.mimeType = mimeType;
|
|
||||||
this.error = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Size() {
|
|
||||||
this.width = 0;
|
|
||||||
this.height = 0;
|
|
||||||
this.mimeType = "";
|
|
||||||
this.error = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package org.briarproject.briar.android.attachment;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class UnsupportedMimeTypeException extends IOException {
|
||||||
|
|
||||||
|
private final String mimeType;
|
||||||
|
private final Uri uri;
|
||||||
|
|
||||||
|
public UnsupportedMimeTypeException(String mimeType, Uri uri) {
|
||||||
|
this.mimeType = mimeType;
|
||||||
|
this.uri = uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMimeType() {
|
||||||
|
return mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Uri getUri() {
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public interface ImageCompressor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The MIME type of compressed images
|
||||||
|
*/
|
||||||
|
String MIME_TYPE = "image/jpeg";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load an image from {@code is}, compress it and return an InputStream
|
||||||
|
* from which the resulting image can be read. The image will be compressed
|
||||||
|
* as a JPEG image such that it fits into a message.
|
||||||
|
*
|
||||||
|
* @param is the stream to read the source image from
|
||||||
|
* @param contentType the mimetype of the source image such as "image/jpeg"
|
||||||
|
* as obtained by {@link android.content.ContentResolver#getType(Uri)}
|
||||||
|
* @return a stream from which the resulting image can be read
|
||||||
|
*/
|
||||||
|
InputStream compressImage(InputStream is, String contentType)
|
||||||
|
throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compress an image and return an InputStream from which the resulting
|
||||||
|
* image can be read. The image will be compressed as a JPEG image such that
|
||||||
|
* it fits into a message.
|
||||||
|
*
|
||||||
|
* @param bitmap the source image
|
||||||
|
* @return a stream from which the resulting image can be read
|
||||||
|
*/
|
||||||
|
InputStream compressImage(Bitmap bitmap) throws IOException;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static android.graphics.Bitmap.CompressFormat.JPEG;
|
||||||
|
import static android.graphics.BitmapFactory.decodeStream;
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static java.util.logging.Level.WARNING;
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
|
import static org.briarproject.bramble.util.IoUtils.tryToClose;
|
||||||
|
import static org.briarproject.briar.api.attachment.MediaConstants.MAX_IMAGE_SIZE;
|
||||||
|
|
||||||
|
class ImageCompressorImpl implements ImageCompressor {
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
getLogger(ImageCompressorImpl.class.getName());
|
||||||
|
|
||||||
|
private static final int MAX_ATTACHMENT_DIMENSION = 1000;
|
||||||
|
|
||||||
|
private final ImageSizeCalculator imageSizeCalculator;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ImageCompressorImpl(ImageSizeCalculator imageSizeCalculator) {
|
||||||
|
this.imageSizeCalculator = imageSizeCalculator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream compressImage(InputStream is, String contentType)
|
||||||
|
throws IOException {
|
||||||
|
try {
|
||||||
|
Bitmap bitmap =
|
||||||
|
createBitmap(is, contentType, MAX_ATTACHMENT_DIMENSION);
|
||||||
|
return compressImage(bitmap);
|
||||||
|
} finally {
|
||||||
|
tryToClose(is, LOG, WARNING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream compressImage(Bitmap bitmap) throws IOException {
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
for (int quality = 100; quality >= 0; quality -= 10) {
|
||||||
|
if (!bitmap.compress(JPEG, quality, out))
|
||||||
|
throw new IOException();
|
||||||
|
if (out.size() <= MAX_IMAGE_SIZE) {
|
||||||
|
if (LOG.isLoggable(INFO)) {
|
||||||
|
LOG.info("Compressed image to "
|
||||||
|
+ out.size() + " bytes, quality " + quality);
|
||||||
|
}
|
||||||
|
return new ByteArrayInputStream(out.toByteArray());
|
||||||
|
}
|
||||||
|
out.reset();
|
||||||
|
}
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap createBitmap(InputStream is, String contentType, int maxSize)
|
||||||
|
throws IOException {
|
||||||
|
is = new BufferedInputStream(is);
|
||||||
|
Size size = imageSizeCalculator.getSize(is, contentType);
|
||||||
|
if (size.hasError()) throw new IOException();
|
||||||
|
if (LOG.isLoggable(INFO))
|
||||||
|
LOG.info("Original image size: " + size.getWidth() + "x" +
|
||||||
|
size.getHeight());
|
||||||
|
int dimension = Math.max(size.getWidth(), size.getHeight());
|
||||||
|
int inSampleSize = 1;
|
||||||
|
while (dimension > maxSize) {
|
||||||
|
inSampleSize *= 2;
|
||||||
|
dimension /= 2;
|
||||||
|
}
|
||||||
|
if (LOG.isLoggable(INFO))
|
||||||
|
LOG.info("Scaling attachment by factor of " + inSampleSize);
|
||||||
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
|
options.inSampleSize = inSampleSize;
|
||||||
|
if (contentType.equals("image/png"))
|
||||||
|
options.inPreferredConfig = Bitmap.Config.RGB_565;
|
||||||
|
Bitmap bitmap = decodeStream(is, null, options);
|
||||||
|
if (bitmap == null) throw new IOException();
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject.briar.android.attachment;
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.briarproject.briar.android.attachment;
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.briarproject.briar.android.attachment.media;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
@NotNullByDefault
|
||||||
|
public interface ImageSizeCalculator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the size of the image that can be read from {@code is}.
|
||||||
|
*
|
||||||
|
* @param contentType the mime type of the image. If "image/jpeg" is passed,
|
||||||
|
* the implementation will try to determine the size from the Exif header
|
||||||
|
*/
|
||||||
|
Size getSize(InputStream is, String contentType);
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user