Remove-SMS-integration.patch 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. From: csagan5 <32685696+csagan5@users.noreply.github.com>
  2. Date: Sun, 3 Nov 2019 08:22:29 +0100
  3. Subject: Remove SMS integration
  4. ---
  5. .../browser/language/AppLocaleUtils.java | 38 ---------------
  6. .../content/browser/sms/SmsProviderGms.java | 27 ++---------
  7. .../browser/sms/SmsUserConsentReceiver.java | 46 ++-----------------
  8. .../browser/sms/SmsVerificationReceiver.java | 38 ++++-----------
  9. .../content/browser/sms/Wrappers.java | 28 +----------
  10. 5 files changed, 18 insertions(+), 159 deletions(-)
  11. diff --git a/chrome/browser/language/android/java/src/org/chromium/chrome/browser/language/AppLocaleUtils.java b/chrome/browser/language/android/java/src/org/chromium/chrome/browser/language/AppLocaleUtils.java
  12. --- a/chrome/browser/language/android/java/src/org/chromium/chrome/browser/language/AppLocaleUtils.java
  13. +++ b/chrome/browser/language/android/java/src/org/chromium/chrome/browser/language/AppLocaleUtils.java
  14. @@ -70,44 +70,6 @@ public class AppLocaleUtils {
  15. ChromePreferenceKeys.APPLICATION_OVERRIDE_LANGUAGE, APP_LOCALE_USE_SYSTEM_LANGUAGE);
  16. }
  17. - /**
  18. - * Download the language split. If successful set the application language shared preference.
  19. - * If set to null the system language will be used.
  20. - * @param languageName String BCP-47 code of language to download.
  21. - */
  22. - public static void setAppLanguagePref(String languageName) {
  23. - setAppLanguagePref(languageName, success -> {});
  24. - }
  25. -
  26. - /**
  27. - * Download the language split using the provided listener for callbacks. If successful set the
  28. - * application language shared preference. If called from an APK build where no bundle needs to
  29. - * be downloaded the listener's on complete function is immediately called. If languageName is
  30. - * null the system language will be used.
  31. - * @param languageName String BCP-47 code of language to download.
  32. - * @param listener LanguageSplitInstaller.InstallListener to use for callbacks.
  33. - */
  34. - public static void setAppLanguagePref(
  35. - String languageName, LanguageSplitInstaller.InstallListener listener) {
  36. - // Wrap the install listener so that on success the app override preference is set.
  37. - LanguageSplitInstaller.InstallListener wrappedListener = (success) -> {
  38. - if (success) {
  39. - SharedPreferencesManager.getInstance().writeString(
  40. - ChromePreferenceKeys.APPLICATION_OVERRIDE_LANGUAGE, languageName);
  41. - }
  42. - listener.onComplete(success);
  43. - };
  44. -
  45. - // If this is not a bundle build or the default system language is being used the language
  46. - // split should not be installed. Instead indicate that the listener completed successfully
  47. - // since the language resources will already be present.
  48. - if (!BundleUtils.isBundle() || isFollowSystemLanguage(languageName)) {
  49. - wrappedListener.onComplete(true);
  50. - } else {
  51. - LanguageSplitInstaller.getInstance().installLanguage(languageName, wrappedListener);
  52. - }
  53. - }
  54. -
  55. /**
  56. * Return true if the base language of |languageCode| has multiple UI language variants (e.g.
  57. * pt-BR and pt-PT).
  58. diff --git a/content/public/android/java/src/org/chromium/content/browser/sms/SmsProviderGms.java b/content/public/android/java/src/org/chromium/content/browser/sms/SmsProviderGms.java
  59. --- a/content/public/android/java/src/org/chromium/content/browser/sms/SmsProviderGms.java
  60. +++ b/content/public/android/java/src/org/chromium/content/browser/sms/SmsProviderGms.java
  61. @@ -6,9 +6,6 @@ package org.chromium.content.browser.sms;
  62. import androidx.annotation.VisibleForTesting;
  63. -import com.google.android.gms.common.ConnectionResult;
  64. -import com.google.android.gms.common.GoogleApiAvailability;
  65. -
  66. import org.chromium.base.ContextUtils;
  67. import org.chromium.base.Log;
  68. import org.chromium.base.annotations.CalledByNative;
  69. @@ -45,17 +42,11 @@ public class SmsProviderGms {
  70. @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
  71. public SmsProviderGms(long smsProviderGmsAndroid, @GmsBackend int backend,
  72. - boolean isVerificationBackendAvailable) {
  73. + boolean ignored) {
  74. mSmsProviderGmsAndroid = smsProviderGmsAndroid;
  75. mBackend = backend;
  76. mContext = new Wrappers.WebOTPServiceContext(ContextUtils.getApplicationContext(), this);
  77. - // Creates an mVerificationReceiver regardless of the backend to support requests from
  78. - // remote devices.
  79. - if (isVerificationBackendAvailable) {
  80. - mVerificationReceiver = new SmsVerificationReceiver(this, mContext);
  81. - }
  82. -
  83. if (mBackend == GmsBackend.AUTO || mBackend == GmsBackend.USER_CONSENT) {
  84. mUserConsentReceiver = new SmsUserConsentReceiver(this, mContext);
  85. }
  86. @@ -87,12 +78,7 @@ public class SmsProviderGms {
  87. @CalledByNative
  88. private static SmsProviderGms create(long smsProviderGmsAndroid, @GmsBackend int backend) {
  89. Log.d(TAG, "Creating SmsProviderGms");
  90. - boolean isVerificationBackendAvailable =
  91. - GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
  92. - ContextUtils.getApplicationContext(),
  93. - MIN_GMS_VERSION_NUMBER_WITH_CODE_BROWSER_BACKEND)
  94. - == ConnectionResult.SUCCESS;
  95. - return new SmsProviderGms(smsProviderGmsAndroid, backend, isVerificationBackendAvailable);
  96. + return new SmsProviderGms(smsProviderGmsAndroid, backend, false);
  97. }
  98. @CalledByNative
  99. @@ -181,13 +167,6 @@ public class SmsProviderGms {
  100. }
  101. public Wrappers.SmsRetrieverClientWrapper getClient() {
  102. - if (mClient != null) {
  103. - return mClient;
  104. - }
  105. - mClient = new Wrappers.SmsRetrieverClientWrapper(
  106. - mUserConsentReceiver != null ? mUserConsentReceiver.createClient() : null,
  107. - mVerificationReceiver != null ? mVerificationReceiver.createClient() : null);
  108. -
  109. return mClient;
  110. }
  111. @@ -209,4 +188,4 @@ public class SmsProviderGms {
  112. void onCancel(long nativeSmsProviderGms);
  113. void onNotAvailable(long nativeSmsProviderGms);
  114. }
  115. -}
  116. \ No newline at end of file
  117. +}
  118. diff --git a/content/public/android/java/src/org/chromium/content/browser/sms/SmsUserConsentReceiver.java b/content/public/android/java/src/org/chromium/content/browser/sms/SmsUserConsentReceiver.java
  119. --- a/content/public/android/java/src/org/chromium/content/browser/sms/SmsUserConsentReceiver.java
  120. +++ b/content/public/android/java/src/org/chromium/content/browser/sms/SmsUserConsentReceiver.java
  121. @@ -10,13 +10,6 @@ import android.content.Context;
  122. import android.content.Intent;
  123. import android.content.IntentFilter;
  124. -import com.google.android.gms.auth.api.phone.SmsRetriever;
  125. -import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
  126. -import com.google.android.gms.common.api.CommonStatusCodes;
  127. -import com.google.android.gms.common.api.Status;
  128. -import com.google.android.gms.tasks.OnFailureListener;
  129. -import com.google.android.gms.tasks.Task;
  130. -
  131. import org.chromium.base.Log;
  132. import org.chromium.ui.base.WindowAndroid;
  133. @@ -34,29 +27,12 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
  134. mDestroyed = false;
  135. mProvider = provider;
  136. mContext = context;
  137. -
  138. - // A broadcast receiver is registered upon the creation of this class
  139. - // which happens when the SMS Retriever API is used for the first time
  140. - // since chrome last restarted (which, on android, happens frequently).
  141. - // The broadcast receiver is fairly lightweight (e.g. it responds
  142. - // quickly without much computation).
  143. - // If this broadcast receiver becomes more heavyweight, we should make
  144. - // this registration expire after the SMS message is received.
  145. - if (DEBUG) Log.d(TAG, "Registering intent filters.");
  146. - IntentFilter filter = new IntentFilter();
  147. - filter.addAction(SmsRetriever.SMS_RETRIEVED_ACTION);
  148. - mContext.registerReceiver(this, filter);
  149. - }
  150. -
  151. - public SmsRetrieverClient createClient() {
  152. - return SmsRetriever.getClient(mContext);
  153. }
  154. public void destroy() {
  155. if (mDestroyed) return;
  156. if (DEBUG) Log.d(TAG, "Destroying SmsUserConsentReceiver.");
  157. mDestroyed = true;
  158. - mContext.unregisterReceiver(this);
  159. }
  160. @Override
  161. @@ -67,7 +43,7 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
  162. return;
  163. }
  164. - if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
  165. + /*if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
  166. return;
  167. }
  168. @@ -101,28 +77,14 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
  169. if (DEBUG) Log.d(TAG, "Timeout");
  170. mProvider.onTimeout();
  171. break;
  172. - }
  173. + } */
  174. }
  175. void onConsentResult(int resultCode, Intent data) {
  176. - if (resultCode == Activity.RESULT_OK) {
  177. - String message = data.getStringExtra(SmsRetriever.EXTRA_SMS_MESSAGE);
  178. - mProvider.onReceive(message, GmsBackend.USER_CONSENT);
  179. - } else if (resultCode == Activity.RESULT_CANCELED) {
  180. - if (DEBUG) Log.d(TAG, "Activity result cancelled.");
  181. - mProvider.onCancel();
  182. - }
  183. + if (DEBUG) Log.d(TAG, "Activity result discarded.");
  184. }
  185. public void listen(WindowAndroid windowAndroid) {
  186. - Task<Void> task = mProvider.getClient().startSmsUserConsent(null);
  187. -
  188. - task.addOnFailureListener(new OnFailureListener() {
  189. - @Override
  190. - public void onFailure(Exception e) {
  191. - Log.e(TAG, "Task failed to start", e);
  192. - }
  193. - });
  194. - if (DEBUG) Log.d(TAG, "Installed task");
  195. + if (DEBUG) Log.d(TAG, "Ignored task");
  196. }
  197. }
  198. diff --git a/content/public/android/java/src/org/chromium/content/browser/sms/SmsVerificationReceiver.java b/content/public/android/java/src/org/chromium/content/browser/sms/SmsVerificationReceiver.java
  199. --- a/content/public/android/java/src/org/chromium/content/browser/sms/SmsVerificationReceiver.java
  200. +++ b/content/public/android/java/src/org/chromium/content/browser/sms/SmsVerificationReceiver.java
  201. @@ -11,16 +11,6 @@ import android.content.Context;
  202. import android.content.Intent;
  203. import android.content.IntentFilter;
  204. -import com.google.android.gms.auth.api.phone.SmsCodeBrowserClient;
  205. -import com.google.android.gms.auth.api.phone.SmsCodeRetriever;
  206. -import com.google.android.gms.auth.api.phone.SmsRetriever;
  207. -import com.google.android.gms.auth.api.phone.SmsRetrieverStatusCodes;
  208. -import com.google.android.gms.common.api.ApiException;
  209. -import com.google.android.gms.common.api.CommonStatusCodes;
  210. -import com.google.android.gms.common.api.ResolvableApiException;
  211. -import com.google.android.gms.common.api.Status;
  212. -import com.google.android.gms.tasks.Task;
  213. -
  214. import org.chromium.base.Log;
  215. import org.chromium.base.metrics.RecordHistogram;
  216. import org.chromium.content.browser.sms.Wrappers.WebOTPServiceContext;
  217. @@ -62,27 +52,18 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
  218. // lightweight (e.g. it responds quickly without much computation). If this broadcast
  219. // receiver becomes more heavyweight, we should make this registration expire after the SMS
  220. // message is received.
  221. - if (DEBUG) Log.i(TAG, "Registering intent filters.");
  222. - IntentFilter filter = new IntentFilter();
  223. - filter.addAction(SmsCodeRetriever.SMS_CODE_RETRIEVED_ACTION);
  224. -
  225. - mContext.registerReceiver(this, filter);
  226. - }
  227. -
  228. - public SmsCodeBrowserClient createClient() {
  229. - return SmsCodeRetriever.getBrowserClient(mContext);
  230. }
  231. public void destroy() {
  232. - if (mDestroyed) return;
  233. + /*if (mDestroyed) return;
  234. if (DEBUG) Log.d(TAG, "Destroying SmsVerificationReceiver.");
  235. mDestroyed = true;
  236. - mContext.unregisterReceiver(this);
  237. + mContext.unregisterReceiver(this); */
  238. }
  239. @Override
  240. public void onReceive(Context context, Intent intent) {
  241. - if (DEBUG) Log.d(TAG, "Received something!");
  242. + /*if (DEBUG) Log.d(TAG, "Received something!");
  243. if (mDestroyed) {
  244. return;
  245. @@ -115,7 +96,7 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
  246. if (DEBUG) Log.d(TAG, "Timeout");
  247. mProvider.onTimeout();
  248. break;
  249. - }
  250. + }*/
  251. }
  252. public void onPermissionDone(int resultCode, boolean isLocalRequest) {
  253. @@ -135,7 +116,7 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
  254. * task.
  255. */
  256. public void onRetrieverTaskFailure(boolean isLocalRequest, Exception e) {
  257. - if (DEBUG) Log.d(TAG, "Task failed. Attempting recovery.", e);
  258. + /* if (DEBUG) Log.d(TAG, "Task failed. Attempting recovery.", e);
  259. ApiException exception = (ApiException) e;
  260. if (exception.getStatusCode() == SmsRetrieverStatusCodes.API_NOT_CONNECTED) {
  261. reportBackendAvailability(BackendAvailability.API_NOT_CONNECTED);
  262. @@ -177,12 +158,12 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
  263. }
  264. }
  265. } else {
  266. - Log.w(TAG, "Unexpected exception", e);
  267. - }
  268. + Log.w(TAG, "Unexpected exception", e); // marker
  269. + } */
  270. }
  271. public void listen(boolean isLocalRequest) {
  272. - Wrappers.SmsRetrieverClientWrapper client = mProvider.getClient();
  273. + /* Wrappers.SmsRetrieverClientWrapper client = mProvider.getClient();
  274. Task<Void> task = client.startSmsCodeBrowserRetriever();
  275. task.addOnSuccessListener(unused -> {
  276. @@ -194,7 +175,8 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
  277. mProvider.verificationReceiverFailed(isLocalRequest);
  278. });
  279. - if (DEBUG) Log.d(TAG, "Installed task");
  280. + if (DEBUG) Log.d(TAG, "Installed task"); */
  281. + if (DEBUG) Log.d(TAG, "Ignored task");
  282. }
  283. public void reportBackendAvailability(BackendAvailability availability) {
  284. diff --git a/content/public/android/java/src/org/chromium/content/browser/sms/Wrappers.java b/content/public/android/java/src/org/chromium/content/browser/sms/Wrappers.java
  285. --- a/content/public/android/java/src/org/chromium/content/browser/sms/Wrappers.java
  286. +++ b/content/public/android/java/src/org/chromium/content/browser/sms/Wrappers.java
  287. @@ -10,11 +10,6 @@ import android.content.ContextWrapper;
  288. import android.content.Intent;
  289. import android.content.IntentFilter;
  290. -import com.google.android.gms.auth.api.phone.SmsCodeBrowserClient;
  291. -import com.google.android.gms.auth.api.phone.SmsCodeRetriever;
  292. -import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
  293. -import com.google.android.gms.tasks.Task;
  294. -
  295. class Wrappers {
  296. // Prevent instantiation.
  297. private Wrappers() {}
  298. @@ -23,16 +18,9 @@ class Wrappers {
  299. * Wraps com.google.android.gms.auth.api.phone.SmsRetrieverClient.
  300. */
  301. static class SmsRetrieverClientWrapper {
  302. - // Used for user consent flow.
  303. - private final SmsRetrieverClient mSmsRetrieverClient;
  304. - // Used for browser code flow.
  305. - private final SmsCodeBrowserClient mSmsCodeBrowserClient;
  306. private WebOTPServiceContext mContext;
  307. - public SmsRetrieverClientWrapper(
  308. - SmsRetrieverClient smsRetrieverClient, SmsCodeBrowserClient smsCodeBrowserClient) {
  309. - mSmsRetrieverClient = smsRetrieverClient;
  310. - mSmsCodeBrowserClient = smsCodeBrowserClient;
  311. + public SmsRetrieverClientWrapper() {
  312. }
  313. public void setContext(WebOTPServiceContext context) {
  314. @@ -42,14 +30,6 @@ class Wrappers {
  315. public WebOTPServiceContext getContext() {
  316. return mContext;
  317. }
  318. -
  319. - public Task<Void> startSmsCodeBrowserRetriever() {
  320. - return mSmsCodeBrowserClient.startSmsCodeRetriever();
  321. - }
  322. -
  323. - public Task<Void> startSmsUserConsent(String senderAddress) {
  324. - return mSmsRetrieverClient.startSmsUserConsent(senderAddress);
  325. - }
  326. }
  327. /**
  328. @@ -83,12 +63,6 @@ class Wrappers {
  329. @Override
  330. public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
  331. - if (filter.hasAction(SmsCodeRetriever.SMS_CODE_RETRIEVED_ACTION)) {
  332. - mVerificationReceiver = receiver;
  333. - } else {
  334. - mUserConsentReceiver = receiver;
  335. - }
  336. -
  337. return super.registerReceiver(receiver, filter);
  338. }
  339. --
  340. 2.20.1