Remove-SMS-integration.patch 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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/sms/SmsUserConsentReceiver.java | 33 ++-----------------
  6. .../browser/sms/SmsVerificationReceiver.java | 30 ++---------------
  7. .../content/browser/sms/Wrappers.java | 14 +-------
  8. 3 files changed, 6 insertions(+), 71 deletions(-)
  9. 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
  10. --- a/content/public/android/java/src/org/chromium/content/browser/sms/SmsUserConsentReceiver.java
  11. +++ b/content/public/android/java/src/org/chromium/content/browser/sms/SmsUserConsentReceiver.java
  12. @@ -12,11 +12,6 @@ import android.content.IntentFilter;
  13. import androidx.annotation.VisibleForTesting;
  14. -import com.google.android.gms.auth.api.phone.SmsRetriever;
  15. -import com.google.android.gms.common.api.CommonStatusCodes;
  16. -import com.google.android.gms.common.api.Status;
  17. -import com.google.android.gms.tasks.Task;
  18. -
  19. import org.chromium.base.ContextUtils;
  20. import org.chromium.base.Log;
  21. import org.chromium.base.annotations.CalledByNative;
  22. @@ -45,18 +40,6 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
  23. mSmsProviderAndroid = smsProviderAndroid;
  24. mContext = new Wrappers.SmsReceiverContext(ContextUtils.getApplicationContext());
  25. -
  26. - // A broadcast receiver is registered upon the creation of this class
  27. - // which happens when the SMS Retriever API is used for the first time
  28. - // since chrome last restarted (which, on android, happens frequently).
  29. - // The broadcast receiver is fairly lightweight (e.g. it responds
  30. - // quickly without much computation).
  31. - // If this broadcast receiver becomes more heavyweight, we should make
  32. - // this registration expire after the SMS message is received.
  33. - if (DEBUG) Log.d(TAG, "Registering intent filters.");
  34. - IntentFilter filter = new IntentFilter();
  35. - filter.addAction(SmsRetriever.SMS_RETRIEVED_ACTION);
  36. - mContext.registerReceiver(this, filter);
  37. }
  38. @CalledByNative
  39. @@ -69,7 +52,6 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
  40. private void destroy() {
  41. if (DEBUG) Log.d(TAG, "Destroying SmsUserConsentReceiver.");
  42. mDestroyed = true;
  43. - mContext.unregisterReceiver(this);
  44. }
  45. @Override
  46. @@ -82,7 +64,7 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
  47. return;
  48. }
  49. - if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
  50. + /*if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
  51. return;
  52. }
  53. @@ -114,28 +96,19 @@ public class SmsUserConsentReceiver extends BroadcastReceiver {
  54. if (DEBUG) Log.d(TAG, "Timeout");
  55. SmsUserConsentReceiverJni.get().onTimeout(mSmsProviderAndroid);
  56. break;
  57. - }
  58. + }*/
  59. }
  60. void onConsentResult(int resultCode, Intent data) {
  61. - if (resultCode == Activity.RESULT_OK) {
  62. - String message = data.getStringExtra(SmsRetriever.EXTRA_SMS_MESSAGE);
  63. - SmsUserConsentReceiverJni.get().onReceive(mSmsProviderAndroid, message);
  64. - } else if (resultCode == Activity.RESULT_CANCELED) {
  65. - if (DEBUG) Log.d(TAG, "Activity result cancelled.");
  66. - }
  67. + Log.d(TAG, "Activity result discarded.");
  68. }
  69. @CalledByNative
  70. private void listen(WindowAndroid windowAndroid) {
  71. mWindowAndroid = windowAndroid;
  72. - Task<Void> task = getClient().startSmsUserConsent(null);
  73. - if (DEBUG) Log.d(TAG, "Installed task");
  74. }
  75. private Wrappers.SmsRetrieverClientWrapper getClient() {
  76. - if (mClient != null) return mClient;
  77. - mClient = new Wrappers.SmsRetrieverClientWrapper(SmsRetriever.getClient(mContext));
  78. return mClient;
  79. }
  80. 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
  81. --- a/content/public/android/java/src/org/chromium/content/browser/sms/SmsVerificationReceiver.java
  82. +++ b/content/public/android/java/src/org/chromium/content/browser/sms/SmsVerificationReceiver.java
  83. @@ -11,11 +11,6 @@ import android.content.IntentFilter;
  84. import androidx.annotation.VisibleForTesting;
  85. -import com.google.android.gms.auth.api.phone.SmsRetriever;
  86. -import com.google.android.gms.common.api.CommonStatusCodes;
  87. -import com.google.android.gms.common.api.Status;
  88. -import com.google.android.gms.tasks.Task;
  89. -
  90. import org.chromium.base.ContextUtils;
  91. import org.chromium.base.Log;
  92. import org.chromium.base.annotations.CalledByNative;
  93. @@ -42,18 +37,6 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
  94. mSmsProviderAndroid = smsProviderAndroid;
  95. mContext = new Wrappers.SmsReceiverContext(ContextUtils.getApplicationContext());
  96. -
  97. - // A broadcast receiver is registered upon the creation of this class
  98. - // which happens when the SMS Retriever API is used for the first time
  99. - // since chrome last restarted (which, on android, happens frequently).
  100. - // The broadcast receiver is fairly lightweight (e.g. it responds
  101. - // quickly without much computation).
  102. - // If this broadcast receiver becomes more heavyweight, we should make
  103. - // this registration expire after the SMS message is received.
  104. - if (DEBUG) Log.d(TAG, "Registering intent filters.");
  105. - IntentFilter filter = new IntentFilter();
  106. - filter.addAction(SmsRetriever.SMS_RETRIEVED_ACTION);
  107. - mContext.registerReceiver(this, filter);
  108. }
  109. @CalledByNative
  110. @@ -66,7 +49,6 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
  111. private void destroy() {
  112. if (DEBUG) Log.d(TAG, "Destroying SmsVerificationReceiver.");
  113. mDestroyed = true;
  114. - mContext.unregisterReceiver(this);
  115. }
  116. @Override
  117. @@ -77,7 +59,7 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
  118. return;
  119. }
  120. - if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
  121. +/* if (!SmsRetriever.SMS_RETRIEVED_ACTION.equals(intent.getAction())) {
  122. return;
  123. }
  124. @@ -104,22 +86,14 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
  125. if (DEBUG) Log.d(TAG, "Timeout");
  126. SmsVerificationReceiverJni.get().onTimeout(mSmsProviderAndroid);
  127. break;
  128. - }
  129. + }*/
  130. }
  131. @CalledByNative
  132. private void listen() {
  133. - Wrappers.SmsRetrieverClientWrapper client = getClient();
  134. - Task<Void> task = client.startSmsRetriever();
  135. -
  136. - if (DEBUG) Log.d(TAG, "Installed task");
  137. }
  138. private Wrappers.SmsRetrieverClientWrapper getClient() {
  139. - if (mClient != null) {
  140. - return mClient;
  141. - }
  142. - mClient = new Wrappers.SmsRetrieverClientWrapper(SmsRetriever.getClient(mContext));
  143. return mClient;
  144. }
  145. 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
  146. --- a/content/public/android/java/src/org/chromium/content/browser/sms/Wrappers.java
  147. +++ b/content/public/android/java/src/org/chromium/content/browser/sms/Wrappers.java
  148. @@ -10,9 +10,6 @@ import android.content.ContextWrapper;
  149. import android.content.Intent;
  150. import android.content.IntentFilter;
  151. -import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
  152. -import com.google.android.gms.tasks.Task;
  153. -
  154. class Wrappers {
  155. // Prevent instantiation.
  156. private Wrappers() {}
  157. @@ -21,11 +18,9 @@ class Wrappers {
  158. * Wraps com.google.android.gms.auth.api.phone.SmsRetrieverClient.
  159. */
  160. static class SmsRetrieverClientWrapper {
  161. - private final SmsRetrieverClient mSmsRetrieverClient;
  162. private SmsReceiverContext mContext;
  163. - public SmsRetrieverClientWrapper(SmsRetrieverClient smsRetrieverClient) {
  164. - mSmsRetrieverClient = smsRetrieverClient;
  165. + public SmsRetrieverClientWrapper() {
  166. }
  167. public void setContext(SmsReceiverContext context) {
  168. @@ -36,13 +31,6 @@ class Wrappers {
  169. return mContext;
  170. }
  171. - public Task<Void> startSmsRetriever() {
  172. - return mSmsRetrieverClient.startSmsRetriever();
  173. - }
  174. -
  175. - public Task<Void> startSmsUserConsent(String senderAddress) {
  176. - return mSmsRetrieverClient.startSmsUserConsent(senderAddress);
  177. - }
  178. }
  179. /**
  180. --
  181. 2.17.1