220 lines
8.9 KiB
Diff
220 lines
8.9 KiB
Diff
From: csagan5 <32685696+csagan5@users.noreply.github.com>
|
|
Date: Sun, 3 Nov 2019 08:22:29 +0100
|
|
Subject: Remove SMS integration
|
|
|
|
---
|
|
.../browser/sms/SmsUserConsentReceiver.java | 42 ++-----------------
|
|
.../browser/sms/SmsVerificationReceiver.java | 30 +------------
|
|
.../content/browser/sms/Wrappers.java | 14 +------
|
|
3 files changed, 7 insertions(+), 79 deletions(-)
|
|
|
|
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
|
|
@@ -12,12 +12,6 @@ import android.content.IntentFilter;
|
|
|
|
import androidx.annotation.VisibleForTesting;
|
|
|
|
-import com.google.android.gms.auth.api.phone.SmsRetriever;
|
|
-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.ContextUtils;
|
|
import org.chromium.base.Log;
|
|
import org.chromium.base.annotations.CalledByNative;
|
|
@@ -46,18 +40,6 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
|
|
mSmsProviderAndroid = smsProviderAndroid;
|
|
|
|
mContext = new Wrappers.SmsReceiverContext(ContextUtils.getApplicationContext());
|
|
-
|
|
- // 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);
|
|
}
|
|
|
|
@CalledByNative
|
|
@@ -70,7 +52,6 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
|
|
private void destroy() {
|
|
if (DEBUG) Log.d(TAG, "Destroying SmsUserConsentReceiver.");
|
|
mDestroyed = true;
|
|
- mContext.unregisterReceiver(this);
|
|
}
|
|
|
|
@Override
|
|
@@ -83,7 +64,7 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
|
|
return;
|
|
}
|
|
|
|
- if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
|
|
+ /*if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
|
|
return;
|
|
}
|
|
|
|
@@ -115,35 +96,20 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
|
|
if (DEBUG) Log.d(TAG, "Timeout");
|
|
SmsUserConsentReceiverJni.get().onTimeout(mSmsProviderAndroid);
|
|
break;
|
|
- }
|
|
+ }*/
|
|
}
|
|
|
|
void onConsentResult(int resultCode, Intent data) {
|
|
- if (resultCode == Activity.RESULT_OK) {
|
|
- String message = data.getStringExtra(SmsRetriever.EXTRA_SMS_MESSAGE);
|
|
- SmsUserConsentReceiverJni.get().onReceive(mSmsProviderAndroid, message);
|
|
- } else if (resultCode == Activity.RESULT_CANCELED) {
|
|
- if (DEBUG) Log.d(TAG, "Activity result cancelled.");
|
|
- }
|
|
+ if (DEBUG) Log.d(TAG, "Activity result discarded.");
|
|
}
|
|
|
|
@CalledByNative
|
|
private void listen(WindowAndroid windowAndroid) {
|
|
mWindowAndroid = windowAndroid;
|
|
- Task<Void> task = 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");
|
|
+ Log.d(TAG, "Ignored task");
|
|
}
|
|
|
|
private Wrappers.SmsRetrieverClientWrapper getClient() {
|
|
- if (mClient != null) return mClient;
|
|
- mClient = new Wrappers.SmsRetrieverClientWrapper(SmsRetriever.getClient(mContext));
|
|
return mClient;
|
|
}
|
|
|
|
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,11 +11,6 @@ import android.content.IntentFilter;
|
|
|
|
import androidx.annotation.VisibleForTesting;
|
|
|
|
-import com.google.android.gms.auth.api.phone.SmsRetriever;
|
|
-import com.google.android.gms.common.api.CommonStatusCodes;
|
|
-import com.google.android.gms.common.api.Status;
|
|
-import com.google.android.gms.tasks.Task;
|
|
-
|
|
import org.chromium.base.ContextUtils;
|
|
import org.chromium.base.Log;
|
|
import org.chromium.base.annotations.CalledByNative;
|
|
@@ -42,18 +37,6 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
|
|
mSmsProviderAndroid = smsProviderAndroid;
|
|
|
|
mContext = new Wrappers.SmsReceiverContext(ContextUtils.getApplicationContext());
|
|
-
|
|
- // 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);
|
|
}
|
|
|
|
@CalledByNative
|
|
@@ -66,7 +49,6 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
|
|
private void destroy() {
|
|
if (DEBUG) Log.d(TAG, "Destroying SmsVerificationReceiver.");
|
|
mDestroyed = true;
|
|
- mContext.unregisterReceiver(this);
|
|
}
|
|
|
|
@Override
|
|
@@ -77,7 +59,7 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
|
|
return;
|
|
}
|
|
|
|
- if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
|
|
+/* if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
|
|
return;
|
|
}
|
|
|
|
@@ -104,22 +86,14 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
|
|
if (DEBUG) Log.d(TAG, "Timeout");
|
|
SmsVerificationReceiverJni.get().onTimeout(mSmsProviderAndroid);
|
|
break;
|
|
- }
|
|
+ }*/
|
|
}
|
|
|
|
@CalledByNative
|
|
private void listen() {
|
|
- Wrappers.SmsRetrieverClientWrapper client = getClient();
|
|
- Task<Void> task = client.startSmsRetriever();
|
|
-
|
|
- if (DEBUG) Log.d(TAG, "Installed task");
|
|
}
|
|
|
|
private Wrappers.SmsRetrieverClientWrapper getClient() {
|
|
- if (mClient != null) {
|
|
- return mClient;
|
|
- }
|
|
- mClient = new Wrappers.SmsRetrieverClientWrapper(SmsRetriever.getClient(mContext));
|
|
return mClient;
|
|
}
|
|
|
|
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,9 +10,6 @@ import android.content.ContextWrapper;
|
|
import android.content.Intent;
|
|
import android.content.IntentFilter;
|
|
|
|
-import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
|
|
-import com.google.android.gms.tasks.Task;
|
|
-
|
|
class Wrappers {
|
|
// Prevent instantiation.
|
|
private Wrappers() {}
|
|
@@ -21,11 +18,9 @@ class Wrappers {
|
|
* Wraps com.google.android.gms.auth.api.phone.SmsRetrieverClient.
|
|
*/
|
|
static class SmsRetrieverClientWrapper {
|
|
- private final SmsRetrieverClient mSmsRetrieverClient;
|
|
private SmsReceiverContext mContext;
|
|
|
|
- public SmsRetrieverClientWrapper(SmsRetrieverClient smsRetrieverClient) {
|
|
- mSmsRetrieverClient = smsRetrieverClient;
|
|
+ public SmsRetrieverClientWrapper() {
|
|
}
|
|
|
|
public void setContext(SmsReceiverContext context) {
|
|
@@ -36,13 +31,6 @@ class Wrappers {
|
|
return mContext;
|
|
}
|
|
|
|
- public Task<Void> startSmsRetriever() {
|
|
- return mSmsRetrieverClient.startSmsRetriever();
|
|
- }
|
|
-
|
|
- public Task<Void> startSmsUserConsent(String senderAddress) {
|
|
- return mSmsRetrieverClient.startSmsUserConsent(senderAddress);
|
|
- }
|
|
}
|
|
|
|
/**
|
|
--
|
|
2.17.1
|
|
|