123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- From: csagan5 <32685696+csagan5@users.noreply.github.com>
- Date: Sun, 3 Nov 2019 08:22:29 +0100
- Subject: Remove SMS integration
- ---
- .../browser/language/AppLocaleUtils.java | 38 ---------------
- .../content/browser/sms/SmsProviderGms.java | 27 ++---------
- .../browser/sms/SmsUserConsentReceiver.java | 46 ++-----------------
- .../browser/sms/SmsVerificationReceiver.java | 38 ++++-----------
- .../content/browser/sms/Wrappers.java | 28 +----------
- 5 files changed, 18 insertions(+), 159 deletions(-)
- 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
- --- 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
- @@ -70,44 +70,6 @@ public class AppLocaleUtils {
- ChromePreferenceKeys.APPLICATION_OVERRIDE_LANGUAGE, APP_LOCALE_USE_SYSTEM_LANGUAGE);
- }
-
- - /**
- - * Download the language split. If successful set the application language shared preference.
- - * If set to null the system language will be used.
- - * @param languageName String BCP-47 code of language to download.
- - */
- - public static void setAppLanguagePref(String languageName) {
- - setAppLanguagePref(languageName, success -> {});
- - }
- -
- - /**
- - * Download the language split using the provided listener for callbacks. If successful set the
- - * application language shared preference. If called from an APK build where no bundle needs to
- - * be downloaded the listener's on complete function is immediately called. If languageName is
- - * null the system language will be used.
- - * @param languageName String BCP-47 code of language to download.
- - * @param listener LanguageSplitInstaller.InstallListener to use for callbacks.
- - */
- - public static void setAppLanguagePref(
- - String languageName, LanguageSplitInstaller.InstallListener listener) {
- - // Wrap the install listener so that on success the app override preference is set.
- - LanguageSplitInstaller.InstallListener wrappedListener = (success) -> {
- - if (success) {
- - SharedPreferencesManager.getInstance().writeString(
- - ChromePreferenceKeys.APPLICATION_OVERRIDE_LANGUAGE, languageName);
- - }
- - listener.onComplete(success);
- - };
- -
- - // If this is not a bundle build or the default system language is being used the language
- - // split should not be installed. Instead indicate that the listener completed successfully
- - // since the language resources will already be present.
- - if (!BundleUtils.isBundle() || isFollowSystemLanguage(languageName)) {
- - wrappedListener.onComplete(true);
- - } else {
- - LanguageSplitInstaller.getInstance().installLanguage(languageName, wrappedListener);
- - }
- - }
- -
- /**
- * Return true if the base language of |languageCode| has multiple UI language variants (e.g.
- * pt-BR and pt-PT).
- 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
- --- 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
- @@ -6,9 +6,6 @@ package org.chromium.content.browser.sms;
-
- import androidx.annotation.VisibleForTesting;
-
- -import com.google.android.gms.common.ConnectionResult;
- -import com.google.android.gms.common.GoogleApiAvailability;
- -
- import org.chromium.base.ContextUtils;
- import org.chromium.base.Log;
- import org.chromium.base.annotations.CalledByNative;
- @@ -45,17 +42,11 @@ public class SmsProviderGms {
-
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
- public SmsProviderGms(long smsProviderGmsAndroid, @GmsBackend int backend,
- - boolean isVerificationBackendAvailable) {
- + boolean ignored) {
- mSmsProviderGmsAndroid = smsProviderGmsAndroid;
- mBackend = backend;
- mContext = new Wrappers.WebOTPServiceContext(ContextUtils.getApplicationContext(), this);
-
- - // Creates an mVerificationReceiver regardless of the backend to support requests from
- - // remote devices.
- - if (isVerificationBackendAvailable) {
- - mVerificationReceiver = new SmsVerificationReceiver(this, mContext);
- - }
- -
- if (mBackend == GmsBackend.AUTO || mBackend == GmsBackend.USER_CONSENT) {
- mUserConsentReceiver = new SmsUserConsentReceiver(this, mContext);
- }
- @@ -87,12 +78,7 @@ public class SmsProviderGms {
- @CalledByNative
- private static SmsProviderGms create(long smsProviderGmsAndroid, @GmsBackend int backend) {
- Log.d(TAG, "Creating SmsProviderGms");
- - boolean isVerificationBackendAvailable =
- - GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
- - ContextUtils.getApplicationContext(),
- - MIN_GMS_VERSION_NUMBER_WITH_CODE_BROWSER_BACKEND)
- - == ConnectionResult.SUCCESS;
- - return new SmsProviderGms(smsProviderGmsAndroid, backend, isVerificationBackendAvailable);
- + return new SmsProviderGms(smsProviderGmsAndroid, backend, false);
- }
-
- @CalledByNative
- @@ -181,13 +167,6 @@ public class SmsProviderGms {
- }
-
- public Wrappers.SmsRetrieverClientWrapper getClient() {
- - if (mClient != null) {
- - return mClient;
- - }
- - mClient = new Wrappers.SmsRetrieverClientWrapper(
- - mUserConsentReceiver != null ? mUserConsentReceiver.createClient() : null,
- - mVerificationReceiver != null ? mVerificationReceiver.createClient() : null);
- -
- return mClient;
- }
-
- @@ -209,4 +188,4 @@ public class SmsProviderGms {
- void onCancel(long nativeSmsProviderGms);
- void onNotAvailable(long nativeSmsProviderGms);
- }
- -}
- \ No newline at end of file
- +}
- 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
- --- 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
- @@ -10,13 +10,6 @@ import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
-
- -import com.google.android.gms.auth.api.phone.SmsRetriever;
- -import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
- -import com.google.android.gms.common.api.CommonStatusCodes;
- -import com.google.android.gms.common.api.Status;
- -import com.google.android.gms.tasks.OnFailureListener;
- -import com.google.android.gms.tasks.Task;
- -
- import org.chromium.base.Log;
- import org.chromium.ui.base.WindowAndroid;
-
- @@ -34,29 +27,12 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
- mDestroyed = false;
- mProvider = provider;
- mContext = context;
- -
- - // A broadcast receiver is registered upon the creation of this class
- - // which happens when the SMS Retriever API is used for the first time
- - // since chrome last restarted (which, on android, happens frequently).
- - // The broadcast receiver is fairly lightweight (e.g. it responds
- - // quickly without much computation).
- - // If this broadcast receiver becomes more heavyweight, we should make
- - // this registration expire after the SMS message is received.
- - if (DEBUG) Log.d(TAG, "Registering intent filters.");
- - IntentFilter filter = new IntentFilter();
- - filter.addAction(SmsRetriever.SMS_RETRIEVED_ACTION);
- - mContext.registerReceiver(this, filter);
- - }
- -
- - public SmsRetrieverClient createClient() {
- - return SmsRetriever.getClient(mContext);
- }
-
- public void destroy() {
- if (mDestroyed) return;
- if (DEBUG) Log.d(TAG, "Destroying SmsUserConsentReceiver.");
- mDestroyed = true;
- - mContext.unregisterReceiver(this);
- }
-
- @Override
- @@ -67,7 +43,7 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
- return;
- }
-
- - if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
- + /*if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
- return;
- }
-
- @@ -101,28 +77,14 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
- if (DEBUG) Log.d(TAG, "Timeout");
- mProvider.onTimeout();
- break;
- - }
- + } */
- }
-
- void onConsentResult(int resultCode, Intent data) {
- - if (resultCode == Activity.RESULT_OK) {
- - String message = data.getStringExtra(SmsRetriever.EXTRA_SMS_MESSAGE);
- - mProvider.onReceive(message, GmsBackend.USER_CONSENT);
- - } else if (resultCode == Activity.RESULT_CANCELED) {
- - if (DEBUG) Log.d(TAG, "Activity result cancelled.");
- - mProvider.onCancel();
- - }
- + if (DEBUG) Log.d(TAG, "Activity result discarded.");
- }
-
- public void listen(WindowAndroid windowAndroid) {
- - Task<Void> task = mProvider.getClient().startSmsUserConsent(null);
- -
- - task.addOnFailureListener(new OnFailureListener() {
- - @Override
- - public void onFailure(Exception e) {
- - Log.e(TAG, "Task failed to start", e);
- - }
- - });
- - if (DEBUG) Log.d(TAG, "Installed task");
- + if (DEBUG) Log.d(TAG, "Ignored task");
- }
- }
- 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
- --- 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
- @@ -11,16 +11,6 @@ import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
-
- -import com.google.android.gms.auth.api.phone.SmsCodeBrowserClient;
- -import com.google.android.gms.auth.api.phone.SmsCodeRetriever;
- -import com.google.android.gms.auth.api.phone.SmsRetriever;
- -import com.google.android.gms.auth.api.phone.SmsRetrieverStatusCodes;
- -import com.google.android.gms.common.api.ApiException;
- -import com.google.android.gms.common.api.CommonStatusCodes;
- -import com.google.android.gms.common.api.ResolvableApiException;
- -import com.google.android.gms.common.api.Status;
- -import com.google.android.gms.tasks.Task;
- -
- import org.chromium.base.Log;
- import org.chromium.base.metrics.RecordHistogram;
- import org.chromium.content.browser.sms.Wrappers.WebOTPServiceContext;
- @@ -62,27 +52,18 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
- // lightweight (e.g. it responds quickly without much computation). If this broadcast
- // receiver becomes more heavyweight, we should make this registration expire after the SMS
- // message is received.
- - if (DEBUG) Log.i(TAG, "Registering intent filters.");
- - IntentFilter filter = new IntentFilter();
- - filter.addAction(SmsCodeRetriever.SMS_CODE_RETRIEVED_ACTION);
- -
- - mContext.registerReceiver(this, filter);
- - }
- -
- - public SmsCodeBrowserClient createClient() {
- - return SmsCodeRetriever.getBrowserClient(mContext);
- }
-
- public void destroy() {
- - if (mDestroyed) return;
- + /*if (mDestroyed) return;
- if (DEBUG) Log.d(TAG, "Destroying SmsVerificationReceiver.");
- mDestroyed = true;
- - mContext.unregisterReceiver(this);
- + mContext.unregisterReceiver(this); */
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- - if (DEBUG) Log.d(TAG, "Received something!");
- + /*if (DEBUG) Log.d(TAG, "Received something!");
-
- if (mDestroyed) {
- return;
- @@ -115,7 +96,7 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
- if (DEBUG) Log.d(TAG, "Timeout");
- mProvider.onTimeout();
- break;
- - }
- + }*/
- }
-
- public void onPermissionDone(int resultCode, boolean isLocalRequest) {
- @@ -135,7 +116,7 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
- * task.
- */
- public void onRetrieverTaskFailure(boolean isLocalRequest, Exception e) {
- - if (DEBUG) Log.d(TAG, "Task failed. Attempting recovery.", e);
- + /* if (DEBUG) Log.d(TAG, "Task failed. Attempting recovery.", e);
- ApiException exception = (ApiException) e;
- if (exception.getStatusCode() == SmsRetrieverStatusCodes.API_NOT_CONNECTED) {
- reportBackendAvailability(BackendAvailability.API_NOT_CONNECTED);
- @@ -177,12 +158,12 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
- }
- }
- } else {
- - Log.w(TAG, "Unexpected exception", e);
- - }
- + Log.w(TAG, "Unexpected exception", e); // marker
- + } */
- }
-
- public void listen(boolean isLocalRequest) {
- - Wrappers.SmsRetrieverClientWrapper client = mProvider.getClient();
- + /* Wrappers.SmsRetrieverClientWrapper client = mProvider.getClient();
- Task<Void> task = client.startSmsCodeBrowserRetriever();
-
- task.addOnSuccessListener(unused -> {
- @@ -194,7 +175,8 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
- mProvider.verificationReceiverFailed(isLocalRequest);
- });
-
- - if (DEBUG) Log.d(TAG, "Installed task");
- + if (DEBUG) Log.d(TAG, "Installed task"); */
- + if (DEBUG) Log.d(TAG, "Ignored task");
- }
-
- public void reportBackendAvailability(BackendAvailability availability) {
- 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
- --- 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
- @@ -10,11 +10,6 @@ import android.content.ContextWrapper;
- import android.content.Intent;
- import android.content.IntentFilter;
-
- -import com.google.android.gms.auth.api.phone.SmsCodeBrowserClient;
- -import com.google.android.gms.auth.api.phone.SmsCodeRetriever;
- -import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
- -import com.google.android.gms.tasks.Task;
- -
- class Wrappers {
- // Prevent instantiation.
- private Wrappers() {}
- @@ -23,16 +18,9 @@ class Wrappers {
- * Wraps com.google.android.gms.auth.api.phone.SmsRetrieverClient.
- */
- static class SmsRetrieverClientWrapper {
- - // Used for user consent flow.
- - private final SmsRetrieverClient mSmsRetrieverClient;
- - // Used for browser code flow.
- - private final SmsCodeBrowserClient mSmsCodeBrowserClient;
- private WebOTPServiceContext mContext;
-
- - public SmsRetrieverClientWrapper(
- - SmsRetrieverClient smsRetrieverClient, SmsCodeBrowserClient smsCodeBrowserClient) {
- - mSmsRetrieverClient = smsRetrieverClient;
- - mSmsCodeBrowserClient = smsCodeBrowserClient;
- + public SmsRetrieverClientWrapper() {
- }
-
- public void setContext(WebOTPServiceContext context) {
- @@ -42,14 +30,6 @@ class Wrappers {
- public WebOTPServiceContext getContext() {
- return mContext;
- }
- -
- - public Task<Void> startSmsCodeBrowserRetriever() {
- - return mSmsCodeBrowserClient.startSmsCodeRetriever();
- - }
- -
- - public Task<Void> startSmsUserConsent(String senderAddress) {
- - return mSmsRetrieverClient.startSmsUserConsent(senderAddress);
- - }
- }
-
- /**
- @@ -83,12 +63,6 @@ class Wrappers {
-
- @Override
- public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
- - if (filter.hasAction(SmsCodeRetriever.SMS_CODE_RETRIEVED_ACTION)) {
- - mVerificationReceiver = receiver;
- - } else {
- - mUserConsentReceiver = receiver;
- - }
- -
- return super.registerReceiver(receiver, filter);
- }
-
- --
- 2.20.1
|