Skip to content

Commit 1669731

Browse files
committed
Support for using Signal without Play Services
This is now possible with beta calling, so non-GCM users are a part of beta calling by default. // FREEBIE
1 parent 4112f23 commit 1669731

15 files changed

+354
-114
lines changed

‎AndroidManifest.xml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<uses-permission android:name="android.permission.READ_CALL_STATE"/>
8585
<uses-permission android:name="android.permission.READ_LOGS"/>
8686
<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
87+
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
8788

8889
<permission android:name="org.thoughtcrime.securesms.permission.C2D_MESSAGE"
8990
android:protectionLevel="signature" />
@@ -533,6 +534,12 @@
533534
</intent-filter>
534535
</receiver>
535536

537+
<receiver android:name=".service.PersistentConnectionBootListener">
538+
<intent-filter>
539+
<action android:name="android.intent.action.BOOT_COMPLETED"/>
540+
</intent-filter>
541+
</receiver>
542+
536543
<receiver android:name=".notifications.MessageNotifier$ReminderReceiver">
537544
<intent-filter>
538545
<action android:name="org.thoughtcrime.securesms.MessageNotifier.REMINDER_ACTION"/>

‎build.gradle‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ dependencies {
5757

5858
compile 'org.whispersystems:jobmanager:1.0.2'
5959
compile 'org.whispersystems:libpastelog:1.0.7'
60-
compile 'org.whispersystems:signal-service-android:2.5.0'
60+
compile 'org.whispersystems:signal-service-android:2.5.1'
6161
compile 'org.whispersystems:webrtc-android:M56-S1'
6262

6363
compile "me.leolin:ShortcutBadger:1.10-WS1"
@@ -127,7 +127,7 @@ dependencyVerification {
127127
'com.google.android.gms:play-services-places:abf3a4a3b146ec7e6e753be62775e512868cf37d6f88ffe2d81167b33b57132b',
128128
'org.whispersystems:jobmanager:506f679fc2fcf7bb6d10f00f41d6f6ea0abf75c70dc95b913398661ad538a181',
129129
'org.whispersystems:libpastelog:bb331d9a98240fc139101128ba836c1edec3c40e000597cdbb29ebf4cbf34d88',
130-
'org.whispersystems:signal-service-android:f207fcf8f17b5a1f04053151cad518f9520f8fbfb2e5563a19828f6b2c2b7b6d',
130+
'org.whispersystems:signal-service-android:b0329b155cc9ad5e7fc08e4660538df1827c6d9485b05cab41946f36ad7ee0ab',
131131
'org.whispersystems:webrtc-android:776a2769348f62aec28b9be6e97dcfea9c07b472ddbe24ac1ca1c46567cf8a8e',
132132
'me.leolin:ShortcutBadger:e8e39df8a59d8211a30f40b1eeab21b3fa57b3f3e0f03abb995f82d66588778c',
133133
'se.emilsjolander:stickylistheaders:a08ca948aa6b220f09d82f16bbbac395f6b78897e9eeac6a9f0b0ba755928eeb',
@@ -162,22 +162,22 @@ dependencyVerification {
162162
'com.google.android.gms:play-services-base:0ca636a8fc9a5af45e607cdcd61783bf5d561cbbb0f862021ce69606eee5ad49',
163163
'com.google.android.gms:play-services-basement:95dd882c5ffba15b9a99de3fefb05d3a01946623af67454ca00055d222f85a8d',
164164
'com.google.android.gms:play-services-iid:54e919f9957b8b7820da7ee9b83471d00d0cac1cf08ddea8b5b41aea80bb1a70',
165+
'org.whispersystems:signal-service-java:e0b9c41fcf614d58a71afcbb290d1864275b65364ca8fafeb5fbcbdc2d59a57a',
165166
'org.whispersystems:signal-protocol-android:1b4b9d557c8eaf861797ff683990d482d4aa8e9f23d9b17ff0cc67a02f38cb19',
166-
'org.whispersystems:signal-service-java:910ed96e928355d118454e1dff6c11b9f95daa801f3b4022e5c8999bff47a888',
167167
'com.nineoldandroids:library:68025a14e3e7673d6ad2f95e4b46d78d7d068343aa99256b686fe59de1b3163a',
168168
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
169169
'com.madgag.spongycastle:core:8d6240b974b0aca4d3da9c7dd44d42339d8a374358aca5fc98e50a995764511f',
170170
'com.google.android.gms:play-services-tasks:69ec265168e601d0203d04cd42e34bb019b2f029aa1e16fabd38a5153eea2086',
171-
'org.whispersystems:curve25519-android:bf6c34223d45d2f2813a8efcab9923caf99115115c760c9acea680bcb42d23c0',
172-
'org.whispersystems:signal-protocol-java:a835cd0609cf116a74651bd0aa748db9392bba48c2d2af787757b8a1b50d131c',
173-
'com.googlecode.libphonenumber:libphonenumber:7214dc6dfc6243e34fb1a3e02ad15331bfff6ab902d679e3ba337695265c21ca',
174171
'com.google.protobuf:protobuf-java:e0c1c64575c005601725e7c6a02cebf9e1285e888f756b2a1d73ffa8d725cc74',
172+
'com.googlecode.libphonenumber:libphonenumber:141ebcafba7070a13d879c44e7648ddbe10beab665cb64d7b0c1bea93afb8dc2',
175173
'com.fasterxml.jackson.core:jackson-databind:835097bcdd11f5bc8a08378c70d4c8054dfa4b911691cc2752063c75534d198d',
176-
'com.squareup.okhttp3:okhttp:eecd834b09d12c3cd568b811522b97012619f7f00378c3c719a1957fac6458ef',
177-
'org.whispersystems:curve25519-java:00f1d4919f759055f41f7853a3d475dc7c8decf0dbf045ae93414f8f23b066cc',
174+
'com.squareup.okhttp3:okhttp:a992938d7203ca557cd7a116f002e8c427ec9cdae7ea852441abb8aec891f948',
175+
'org.whispersystems:curve25519-android:bf6c34223d45d2f2813a8efcab9923caf99115115c760c9acea680bcb42d23c0',
176+
'org.whispersystems:signal-protocol-java:a835cd0609cf116a74651bd0aa748db9392bba48c2d2af787757b8a1b50d131c',
178177
'com.fasterxml.jackson.core:jackson-annotations:0ca408c24202a7626ec8b861e99d85eca5e38b73311dd6dd12e3e9deecc3fe94',
179178
'com.fasterxml.jackson.core:jackson-core:cbf4604784b4de226262845447a1ad3bb38a6728cebe86562e2c5afada8be2c0',
180179
'com.squareup.okio:okio:8c5436cadfab36bbd97db5f5c43b7bfdb5bf2f5f894ec8709b1929f14bdd010c',
180+
'org.whispersystems:curve25519-java:00f1d4919f759055f41f7853a3d475dc7c8decf0dbf045ae93414f8f23b066cc',
181181
'com.android.support:support-media-compat:8d6a1a5ba3d9eb1a25cb8f21bb312ac6280202e3d2900cb0b447d065d0d8a125',
182182
'com.android.support:support-core-utils:a7649e18c04143dde40c218c5ce9a030e7ae674089cd7b18c6cf8ed2a22cf01a',
183183
'com.android.support:support-fragment:1294500b357f52cf3779e2521c79f54ae7844f3b9a5f6727495dbbda7f231377',

‎res/values/strings.xml‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@
370370
<string name="MessageDetailsRecipient_failed_to_send">Failed to send</string>
371371
<string name="MessageDetailsRecipient_new_safety_number">New safety number</string>
372372

373+
<!-- MessageRetrievalService -->
374+
<string name="MessageRetrievalService_signal">Signal</string>
375+
<string name="MessageRetrievalService_background_connection_enabled">Background connection enabled</string>
376+
373377
<!-- MmsDownloader -->
374378
<string name="MmsDownloader_error_storing_mms">Error storing MMS!</string>
375379
<string name="MmsDownloader_error_connecting_to_mms_provider">Error connecting to MMS provider</string>
@@ -501,17 +505,16 @@
501505
<string name="RegistrationActivity_the_number_you_specified_s_is_invalid">The number you
502506
specified (%s) is invalid.
503507
</string>
504-
<string name="RegistrationActivity_unsupported">Unsupported</string>
505-
<string name="RegistrationActivity_sorry_this_device_is_not_supported_for_data_messaging">Sorry,
506-
this device is not supported for data messaging. Devices running versions of Android older
507-
than 4.0 must have a registered Google Account. Devices running Android 4.0 or newer do not
508-
require a Google account, but must have the Play Store app installed.
509-
</string>
510508
<string name="RegistrationActivity_we_will_now_verify_that_the_following_number_is_associated_with_your_device_s">
511509
Double-check that this is your number! We\'re about to verify it with an SMS.
512510
</string>
513511
<string name="RegistrationActivity_continue">Continue</string>
514512
<string name="RegistrationActivity_edit">Edit</string>
513+
<string name="RegistrationActivity_missing_google_play_services">Missing Google Play Services</string>
514+
<string name="RegistrationActivity_this_device_is_missing_google_play_services">This device is missing Google Play Services. You can still use Signal, but this configuration may result in reduced reliability or performance.\n\nIf you are not an advanced user, are not running an aftermarket Android ROM, or believe that you are seeing this in error, please contact support@whispersystems.org for help trouble shooting.</string>
515+
<string name="RegistrationActivity_i_understand">I understand</string>
516+
<string name="RegistrationActivity_play_services_error">Play Services Error</string>
517+
<string name="RegistrationActivity_google_play_services_is_updating_or_unavailable">Google Play Services is updating or temporarily unavailable. Please try again.</string>
515518

516519
<!-- RegistrationProblemsActivity -->
517520
<string name="RegistrationProblemsActivity_possible_problems">Possible problems</string>

‎src/org/thoughtcrime/securesms/ConversationListFragment.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.thoughtcrime.securesms.ConversationListAdapter.ItemClickListener;
5555
import org.thoughtcrime.securesms.components.recyclerview.DeleteItemAnimator;
5656
import org.thoughtcrime.securesms.components.reminder.DefaultSmsReminder;
57+
import org.thoughtcrime.securesms.components.reminder.DozeReminder;
5758
import org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder;
5859
import org.thoughtcrime.securesms.components.reminder.OutdatedBuildReminder;
5960
import org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder;
@@ -184,6 +185,8 @@ private void updateReminders() {
184185
return Optional.of((new PushRegistrationReminder(context, masterSecret)));
185186
} else if (ShareReminder.isEligible(context)) {
186187
return Optional.of(new ShareReminder(context));
188+
} else if (DozeReminder.isEligible(context)) {
189+
return Optional.of(new DozeReminder(context));
187190
} else {
188191
return Optional.absent();
189192
}

‎src/org/thoughtcrime/securesms/RegistrationActivity.java‎

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.thoughtcrime.securesms;
22

33
import android.content.ActivityNotFoundException;
4+
import android.content.Context;
45
import android.content.DialogInterface;
56
import android.content.Intent;
67
import android.net.Uri;
@@ -20,6 +21,7 @@
2021
import android.widget.Toast;
2122

2223
import com.google.android.gms.common.ConnectionResult;
24+
import com.google.android.gms.common.GoogleApiAvailability;
2325
import com.google.android.gms.common.GooglePlayServicesUtil;
2426
import com.google.i18n.phonenumbers.AsYouTypeFormatter;
2527
import com.google.i18n.phonenumbers.NumberParseException;
@@ -44,6 +46,13 @@ public class RegistrationActivity extends BaseActionBarActivity {
4446
private static final int PICK_COUNTRY = 1;
4547
private static final String TAG = RegistrationActivity.class.getSimpleName();
4648

49+
private enum PlayServicesStatus {
50+
SUCCESS,
51+
MISSING,
52+
NEEDS_UPDATE,
53+
TRANSIENT_ERROR
54+
}
55+
4756
private AsYouTypeFormatter countryFormatter;
4857
private ArrayAdapter<String> countrySpinnerAdapter;
4958
private Spinner countrySpinner;
@@ -211,35 +220,81 @@ public void onClick(View v) {
211220
return;
212221
}
213222

214-
int gcmStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(self);
223+
PlayServicesStatus gcmStatus = checkPlayServices(self);
215224

216-
if (gcmStatus != ConnectionResult.SUCCESS) {
217-
if (GooglePlayServicesUtil.isUserRecoverableError(gcmStatus)) {
218-
GooglePlayServicesUtil.getErrorDialog(gcmStatus, self, 9000).show();
219-
} else {
220-
Dialogs.showAlertDialog(self, getString(R.string.RegistrationActivity_unsupported),
221-
getString(R.string.RegistrationActivity_sorry_this_device_is_not_supported_for_data_messaging));
222-
}
223-
return;
225+
if (gcmStatus == PlayServicesStatus.SUCCESS) {
226+
promptForRegistrationStart(self, e164number, true);
227+
} else if (gcmStatus == PlayServicesStatus.MISSING) {
228+
promptForNoPlayServices(self, e164number);
229+
} else if (gcmStatus == PlayServicesStatus.NEEDS_UPDATE) {
230+
GoogleApiAvailability.getInstance().getErrorDialog(self, ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED, 0);
231+
} else {
232+
Dialogs.showAlertDialog(self, getString(R.string.RegistrationActivity_play_services_error),
233+
getString(R.string.RegistrationActivity_google_play_services_is_updating_or_unavailable));
224234
}
235+
}
225236

226-
AlertDialog.Builder dialog = new AlertDialog.Builder(self);
237+
private void promptForRegistrationStart(final Context context, final String e164number, final boolean gcmSupported) {
238+
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
227239
dialog.setTitle(PhoneNumberFormatter.getInternationalFormatFromE164(e164number));
228240
dialog.setMessage(R.string.RegistrationActivity_we_will_now_verify_that_the_following_number_is_associated_with_your_device_s);
229241
dialog.setPositiveButton(getString(R.string.RegistrationActivity_continue),
230242
new DialogInterface.OnClickListener() {
231243
@Override
232244
public void onClick(DialogInterface dialog, int which) {
233-
Intent intent = new Intent(self, RegistrationProgressActivity.class);
234-
intent.putExtra("e164number", e164number);
235-
intent.putExtra("master_secret", masterSecret);
245+
Intent intent = new Intent(context, RegistrationProgressActivity.class);
246+
intent.putExtra(RegistrationProgressActivity.NUMBER_EXTRA, e164number);
247+
intent.putExtra(RegistrationProgressActivity.MASTER_SECRET_EXTRA, masterSecret);
248+
intent.putExtra(RegistrationProgressActivity.GCM_SUPPORTED_EXTRA, gcmSupported);
236249
startActivity(intent);
237250
finish();
238251
}
239252
});
240253
dialog.setNegativeButton(getString(R.string.RegistrationActivity_edit), null);
241254
dialog.show();
242255
}
256+
257+
private void promptForNoPlayServices(final Context context, final String e164number) {
258+
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
259+
dialog.setTitle(R.string.RegistrationActivity_missing_google_play_services);
260+
dialog.setMessage(R.string.RegistrationActivity_this_device_is_missing_google_play_services);
261+
dialog.setPositiveButton(R.string.RegistrationActivity_i_understand, new DialogInterface.OnClickListener() {
262+
@Override
263+
public void onClick(DialogInterface dialog, int which) {
264+
promptForRegistrationStart(context, e164number, false);
265+
}
266+
});
267+
dialog.setNegativeButton(android.R.string.cancel, null);
268+
dialog.show();
269+
}
270+
271+
private PlayServicesStatus checkPlayServices(Context context) {
272+
int gcmStatus = 0;
273+
274+
try {
275+
gcmStatus = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
276+
} catch (Throwable t) {
277+
Log.w(TAG, t);
278+
return PlayServicesStatus.MISSING;
279+
}
280+
281+
Log.w(TAG, "Play Services: " + gcmStatus);
282+
283+
switch (gcmStatus) {
284+
case ConnectionResult.SUCCESS:
285+
return PlayServicesStatus.SUCCESS;
286+
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
287+
return PlayServicesStatus.NEEDS_UPDATE;
288+
case ConnectionResult.SERVICE_DISABLED:
289+
case ConnectionResult.SERVICE_MISSING:
290+
case ConnectionResult.SERVICE_INVALID:
291+
case ConnectionResult.API_UNAVAILABLE:
292+
case ConnectionResult.SERVICE_MISSING_PERMISSION:
293+
return PlayServicesStatus.MISSING;
294+
default:
295+
return PlayServicesStatus.TRANSIENT_ERROR;
296+
}
297+
}
243298
}
244299

245300
private class CountryCodeChangedListener implements TextWatcher {

0 commit comments

Comments
 (0)