0004-Bug-28051-Rename-the-Hidden-Service-content-provider.patch 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. From b8ce28e8487772deaa9655245c3b43055e32937d Mon Sep 17 00:00:00 2001
  2. From: Matthew Finkel <Matthew.Finkel@gmail.com>
  3. Date: Sat, 24 Nov 2018 04:40:57 +0000
  4. Subject: [PATCH 04/13] Bug 28051 - Rename the Hidden Service content provider
  5. ---
  6. app/src/main/AndroidManifest.xml | 13 ++++++++-----
  7. .../org/torproject/android/OrbotMainActivity.java | 2 +-
  8. .../ui/hiddenservices/ClientCookiesActivity.java | 2 +-
  9. .../ui/hiddenservices/HiddenServicesActivity.java | 2 +-
  10. .../adapters/ClientCookiesAdapter.java | 2 +-
  11. .../hiddenservices/adapters/OnionListAdapter.java | 2 +-
  12. .../ui/hiddenservices/backup/BackupUtils.java | 4 ++--
  13. .../hiddenservices/dialogs/AddCookieDialog.java | 2 +-
  14. .../dialogs/CookieDeleteDialog.java | 2 +-
  15. .../ui/hiddenservices/dialogs/HSCookieDialog.java | 2 +-
  16. .../ui/hiddenservices/dialogs/HSDataDialog.java | 2 +-
  17. .../ui/hiddenservices/dialogs/HSDeleteDialog.java | 2 +-
  18. .../providers/CookieContentProvider.java | 4 ++--
  19. .../providers/HSContentProvider.java | 4 ++--
  20. app/src/minimalperm/AndroidManifest.xml | 15 +++++++++------
  21. .../torproject/android/service/TorService.java | 6 ++++--
  22. 16 files changed, 37 insertions(+), 29 deletions(-)
  23. diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
  24. index 2cd00888..3c6262c2 100644
  25. --- a/app/src/main/AndroidManifest.xml
  26. +++ b/app/src/main/AndroidManifest.xml
  27. @@ -135,13 +135,15 @@
  28. android:value=".OrbotMainActivity" />
  29. </activity>
  30. + <!-- Modify the Content Provider name so it doesn't collide with Orbot (when Orbot is installed, too).
  31. + TBA fails while starting when this happens -->
  32. <provider
  33. - android:name=".ui.hiddenservices.providers.HSContentProvider"
  34. - android:authorities="org.torproject.android.ui.hiddenservices.providers"
  35. + android:name="org.torproject.torbrowser.ui.hiddenservices.providers.HSContentProvider"
  36. + android:authorities="org.torproject.torbrowser.ui.hiddenservices.providers"
  37. android:exported="false" />
  38. <provider
  39. android:name="android.support.v4.content.FileProvider"
  40. - android:authorities="org.torproject.android.ui.hiddenservices.storage"
  41. + android:authorities="org.torproject.torbrowser.ui.hiddenservices.storage"
  42. android:exported="false"
  43. android:grantUriPermissions="true">
  44. <meta-data
  45. @@ -163,9 +165,10 @@
  46. <!--<activity android:name=".ui.onboarding.OnboardingActivity"/>-->
  47. <activity android:name=".ui.onboarding.BridgeWizardActivity"/>
  48. + <!-- Modify the Content Provider name -->
  49. <provider
  50. - android:name=".ui.hiddenservices.providers.CookieContentProvider"
  51. - android:authorities="org.torproject.android.ui.hiddenservices.providers.cookie"
  52. + android:name="org.torproject.torbrowser.ui.hiddenservices.providers.CookieContentProvider"
  53. + android:authorities="org.torproject.torbrowser.ui.hiddenservices.providers.cookie"
  54. android:exported="false" />
  55. </application>
  56. diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
  57. index 7ad979ff..ff5dd120 100644
  58. --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
  59. +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
  60. @@ -33,7 +33,7 @@ import org.torproject.android.ui.hiddenservices.ClientCookiesActivity;
  61. import org.torproject.android.ui.hiddenservices.HiddenServicesActivity;
  62. import org.torproject.android.ui.hiddenservices.backup.BackupUtils;
  63. import org.torproject.android.ui.hiddenservices.permissions.PermissionManager;
  64. -import org.torproject.android.ui.hiddenservices.providers.HSContentProvider;
  65. +import org.torproject.torbrowser.ui.hiddenservices.providers.HSContentProvider;
  66. import org.torproject.android.vpn.VPNEnableActivity;
  67. import android.annotation.SuppressLint;
  68. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/ClientCookiesActivity.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/ClientCookiesActivity.java
  69. index e6939800..933915d0 100644
  70. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/ClientCookiesActivity.java
  71. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/ClientCookiesActivity.java
  72. @@ -31,7 +31,7 @@ import org.torproject.android.ui.hiddenservices.dialogs.AddCookieDialog;
  73. import org.torproject.android.ui.hiddenservices.dialogs.CookieActionsDialog;
  74. import org.torproject.android.ui.hiddenservices.dialogs.SelectCookieBackupDialog;
  75. import org.torproject.android.ui.hiddenservices.permissions.PermissionManager;
  76. -import org.torproject.android.ui.hiddenservices.providers.CookieContentProvider;
  77. +import org.torproject.torbrowser.ui.hiddenservices.providers.CookieContentProvider;
  78. public class ClientCookiesActivity extends AppCompatActivity {
  79. public final int WRITE_EXTERNAL_STORAGE_FROM_COOKIE_ACTIONBAR = 3;
  80. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
  81. index d7c1f313..3e2d9c3c 100644
  82. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
  83. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
  84. @@ -28,7 +28,7 @@ import org.torproject.android.ui.hiddenservices.dialogs.HSActionsDialog;
  85. import org.torproject.android.ui.hiddenservices.dialogs.HSDataDialog;
  86. import org.torproject.android.ui.hiddenservices.dialogs.SelectHSBackupDialog;
  87. import org.torproject.android.ui.hiddenservices.permissions.PermissionManager;
  88. -import org.torproject.android.ui.hiddenservices.providers.HSContentProvider;
  89. +import org.torproject.torbrowser.ui.hiddenservices.providers.HSContentProvider;
  90. public class HiddenServicesActivity extends AppCompatActivity {
  91. public final int WRITE_EXTERNAL_STORAGE_FROM_ACTIONBAR = 1;
  92. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/ClientCookiesAdapter.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/ClientCookiesAdapter.java
  93. index bbc317a6..670c108a 100644
  94. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/ClientCookiesAdapter.java
  95. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/ClientCookiesAdapter.java
  96. @@ -14,7 +14,7 @@ import android.widget.TextView;
  97. import android.widget.Toast;
  98. import org.torproject.android.R;
  99. -import org.torproject.android.ui.hiddenservices.providers.CookieContentProvider;
  100. +import org.torproject.torbrowser.ui.hiddenservices.providers.CookieContentProvider;
  101. public class ClientCookiesAdapter extends CursorAdapter {
  102. private LayoutInflater cursorInflater;
  103. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java
  104. index 9824c773..0079bce3 100644
  105. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java
  106. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java
  107. @@ -14,7 +14,7 @@ import android.widget.TextView;
  108. import android.widget.Toast;
  109. import org.torproject.android.R;
  110. -import org.torproject.android.ui.hiddenservices.providers.HSContentProvider;
  111. +import org.torproject.torbrowser.ui.hiddenservices.providers.HSContentProvider;
  112. public class OnionListAdapter extends CursorAdapter {
  113. private LayoutInflater cursorInflater;
  114. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/backup/BackupUtils.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/backup/BackupUtils.java
  115. index a4790dd8..06606039 100644
  116. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/backup/BackupUtils.java
  117. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/backup/BackupUtils.java
  118. @@ -12,8 +12,8 @@ import org.json.JSONException;
  119. import org.json.JSONObject;
  120. import org.torproject.android.R;
  121. import org.torproject.android.service.TorServiceConstants;
  122. -import org.torproject.android.ui.hiddenservices.providers.CookieContentProvider;
  123. -import org.torproject.android.ui.hiddenservices.providers.HSContentProvider;
  124. +import org.torproject.torbrowser.ui.hiddenservices.providers.CookieContentProvider;
  125. +import org.torproject.torbrowser.ui.hiddenservices.providers.HSContentProvider;
  126. import org.torproject.android.ui.hiddenservices.storage.ExternalStorage;
  127. import java.io.File;
  128. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java
  129. index 75663648..d6e280db 100644
  130. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java
  131. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java
  132. @@ -14,7 +14,7 @@ import android.widget.EditText;
  133. import android.widget.Toast;
  134. import org.torproject.android.R;
  135. -import org.torproject.android.ui.hiddenservices.providers.CookieContentProvider;
  136. +import org.torproject.torbrowser.ui.hiddenservices.providers.CookieContentProvider;
  137. public class AddCookieDialog extends DialogFragment {
  138. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieDeleteDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieDeleteDialog.java
  139. index 60c4d8e3..fc183981 100644
  140. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieDeleteDialog.java
  141. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/CookieDeleteDialog.java
  142. @@ -10,7 +10,7 @@ import android.support.v4.app.DialogFragment;
  143. import android.support.v7.app.AlertDialog;
  144. import org.torproject.android.R;
  145. -import org.torproject.android.ui.hiddenservices.providers.CookieContentProvider;
  146. +import org.torproject.torbrowser.ui.hiddenservices.providers.CookieContentProvider;
  147. public class CookieDeleteDialog extends DialogFragment {
  148. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSCookieDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSCookieDialog.java
  149. index 39c1b510..0ae7dae5 100644
  150. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSCookieDialog.java
  151. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSCookieDialog.java
  152. @@ -18,7 +18,7 @@ import com.google.zxing.integration.android.IntentIntegrator;
  153. import org.json.JSONException;
  154. import org.json.JSONObject;
  155. import org.torproject.android.R;
  156. -import org.torproject.android.ui.hiddenservices.providers.CookieContentProvider;
  157. +import org.torproject.torbrowser.ui.hiddenservices.providers.CookieContentProvider;
  158. public class HSCookieDialog extends DialogFragment {
  159. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java
  160. index 98255604..bc1754b9 100644
  161. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java
  162. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java
  163. @@ -15,7 +15,7 @@ import android.widget.EditText;
  164. import android.widget.Toast;
  165. import org.torproject.android.R;
  166. -import org.torproject.android.ui.hiddenservices.providers.HSContentProvider;
  167. +import org.torproject.torbrowser.ui.hiddenservices.providers.HSContentProvider;
  168. public class HSDataDialog extends DialogFragment {
  169. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
  170. index ac5df743..0a60f22b 100644
  171. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
  172. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
  173. @@ -11,7 +11,7 @@ import android.support.v7.app.AlertDialog;
  174. import org.torproject.android.R;
  175. import org.torproject.android.service.TorServiceConstants;
  176. -import org.torproject.android.ui.hiddenservices.providers.HSContentProvider;
  177. +import org.torproject.torbrowser.ui.hiddenservices.providers.HSContentProvider;
  178. import java.io.File;
  179. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/providers/CookieContentProvider.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/providers/CookieContentProvider.java
  180. index f420a6d8..4a371933 100644
  181. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/providers/CookieContentProvider.java
  182. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/providers/CookieContentProvider.java
  183. @@ -1,4 +1,4 @@
  184. -package org.torproject.android.ui.hiddenservices.providers;
  185. +package org.torproject.torbrowser.ui.hiddenservices.providers;
  186. import android.content.ContentProvider;
  187. import android.content.ContentUris;
  188. @@ -22,7 +22,7 @@ public class CookieContentProvider extends ContentProvider {
  189. ClientCookie.AUTH_COOKIE_VALUE,
  190. ClientCookie.ENABLED
  191. };
  192. - private static final String AUTH = "org.torproject.android.ui.hiddenservices.providers.cookie";
  193. + private static final String AUTH = "org.torproject.torbrowser.ui.hiddenservices.providers.cookie";
  194. public static final Uri CONTENT_URI =
  195. Uri.parse("content://" + AUTH + "/cookie");
  196. //UriMatcher
  197. diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/providers/HSContentProvider.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/providers/HSContentProvider.java
  198. index d7b558fd..be7d2de2 100644
  199. --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/providers/HSContentProvider.java
  200. +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/providers/HSContentProvider.java
  201. @@ -1,4 +1,4 @@
  202. -package org.torproject.android.ui.hiddenservices.providers;
  203. +package org.torproject.torbrowser.ui.hiddenservices.providers;
  204. import android.content.ContentProvider;
  205. import android.content.ContentUris;
  206. @@ -27,7 +27,7 @@ public class HSContentProvider extends ContentProvider {
  207. HiddenService.CREATED_BY_USER,
  208. HiddenService.ENABLED
  209. };
  210. - private static final String AUTH = "org.torproject.android.ui.hiddenservices.providers";
  211. + private static final String AUTH = "org.torproject.torbrowser.ui.hiddenservices.providers";
  212. public static final Uri CONTENT_URI =
  213. Uri.parse("content://" + AUTH + "/hs");
  214. //UriMatcher
  215. diff --git a/app/src/minimalperm/AndroidManifest.xml b/app/src/minimalperm/AndroidManifest.xml
  216. index adf74209..fedadd9b 100644
  217. --- a/app/src/minimalperm/AndroidManifest.xml
  218. +++ b/app/src/minimalperm/AndroidManifest.xml
  219. @@ -122,8 +122,10 @@
  220. </intent-filter>
  221. </receiver>
  222. + <!-- Modify the Content Provider name so it doesn't collide with Orbot (when Orbot is installed, too).
  223. + TBA fails while starting when this happens -->
  224. <activity
  225. - android:name=".ui.hiddenservices.HiddenServicesActivity"
  226. + android:name="org.torproject.torbrowser.ui.hiddenservices.HiddenServicesActivity"
  227. android:label="@string/title_activity_hidden_services"
  228. android:theme="@style/DefaultTheme">
  229. <meta-data
  230. @@ -132,12 +134,12 @@
  231. </activity>
  232. <provider
  233. - android:name=".ui.hiddenservices.providers.HSContentProvider"
  234. - android:authorities="org.torproject.android.ui.hiddenservices.providers"
  235. + android:name="org.torproject.torbrowser.ui.hiddenservices.providers.HSContentProvider"
  236. + android:authorities="org.torproject.torbrowser.ui.hiddenservices.providers"
  237. android:exported="false" />
  238. <provider
  239. android:name="android.support.v4.content.FileProvider"
  240. - android:authorities="org.torproject.android.ui.hiddenservices.storage"
  241. + android:authorities="org.torproject.torbrowser.ui.hiddenservices.storage"
  242. android:exported="false"
  243. android:grantUriPermissions="true">
  244. <meta-data
  245. @@ -154,9 +156,10 @@
  246. android:value=".OrbotMainActivity" />
  247. </activity>
  248. + <!-- Modify the Content Provider name -->
  249. <provider
  250. - android:name=".ui.hiddenservices.providers.CookieContentProvider"
  251. - android:authorities="org.torproject.android.ui.hiddenservices.providers.cookie"
  252. + android:name="org.torproject.torbrowser.ui.hiddenservices.providers.CookieContentProvider"
  253. + android:authorities="org.torproject.torbrowser.ui.hiddenservices.providers.cookie"
  254. android:exported="false" />
  255. </application>
  256. diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
  257. index fec88b1f..edd0e3d5 100644
  258. --- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java
  259. +++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
  260. @@ -138,8 +138,10 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
  261. private ArrayList<Bridge> alBridges = null;
  262. - private static final Uri HS_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers/hs");
  263. - private static final Uri COOKIE_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers.cookie/cookie");
  264. + // Modify the Content Provider name so it doesn't collide with Orbot (when Orbot is installed, too).
  265. + // TBA fails while starting when this happens
  266. + private static final Uri HS_CONTENT_URI = Uri.parse("content://org.torproject.torbrowser.ui.hiddenservices.providers/hs");
  267. + private static final Uri COOKIE_CONTENT_URI = Uri.parse("content://org.torproject.torbrowser.ui.hiddenservices.providers.cookie/cookie");
  268. public static final class HiddenService implements BaseColumns {
  269. public static final String NAME = "name";
  270. --
  271. 2.17.1