Skip to content

Commit

Permalink
Support for using Signal without Play Services
Browse files Browse the repository at this point in the history
This is now possible with beta calling, so non-GCM users are a
part of beta calling by default.

// FREEBIE
  • Loading branch information
moxie0 committed Feb 20, 2017
1 parent 4112f23 commit 1669731
Show file tree
Hide file tree
Showing 15 changed files with 354 additions and 114 deletions.
7 changes: 7 additions & 0 deletions AndroidManifest.xml
Expand Up @@ -84,6 +84,7 @@
<uses-permission android:name="android.permission.READ_CALL_STATE"/>
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>

<permission android:name="org.thoughtcrime.securesms.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
Expand Down Expand Up @@ -533,6 +534,12 @@
</intent-filter>
</receiver>

<receiver android:name=".service.PersistentConnectionBootListener">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>

<receiver android:name=".notifications.MessageNotifier$ReminderReceiver">
<intent-filter>
<action android:name="org.thoughtcrime.securesms.MessageNotifier.REMINDER_ACTION"/>
Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Expand Up @@ -57,7 +57,7 @@ dependencies {

compile 'org.whispersystems:jobmanager:1.0.2'
compile 'org.whispersystems:libpastelog:1.0.7'
compile 'org.whispersystems:signal-service-android:2.5.0'
compile 'org.whispersystems:signal-service-android:2.5.1'
compile 'org.whispersystems:webrtc-android:M56-S1'

compile "me.leolin:ShortcutBadger:1.10-WS1"
Expand Down Expand Up @@ -127,7 +127,7 @@ dependencyVerification {
'com.google.android.gms:play-services-places:abf3a4a3b146ec7e6e753be62775e512868cf37d6f88ffe2d81167b33b57132b',
'org.whispersystems:jobmanager:506f679fc2fcf7bb6d10f00f41d6f6ea0abf75c70dc95b913398661ad538a181',
'org.whispersystems:libpastelog:bb331d9a98240fc139101128ba836c1edec3c40e000597cdbb29ebf4cbf34d88',
'org.whispersystems:signal-service-android:f207fcf8f17b5a1f04053151cad518f9520f8fbfb2e5563a19828f6b2c2b7b6d',
'org.whispersystems:signal-service-android:b0329b155cc9ad5e7fc08e4660538df1827c6d9485b05cab41946f36ad7ee0ab',
'org.whispersystems:webrtc-android:776a2769348f62aec28b9be6e97dcfea9c07b472ddbe24ac1ca1c46567cf8a8e',
'me.leolin:ShortcutBadger:e8e39df8a59d8211a30f40b1eeab21b3fa57b3f3e0f03abb995f82d66588778c',
'se.emilsjolander:stickylistheaders:a08ca948aa6b220f09d82f16bbbac395f6b78897e9eeac6a9f0b0ba755928eeb',
Expand Down Expand Up @@ -162,22 +162,22 @@ dependencyVerification {
'com.google.android.gms:play-services-base:0ca636a8fc9a5af45e607cdcd61783bf5d561cbbb0f862021ce69606eee5ad49',
'com.google.android.gms:play-services-basement:95dd882c5ffba15b9a99de3fefb05d3a01946623af67454ca00055d222f85a8d',
'com.google.android.gms:play-services-iid:54e919f9957b8b7820da7ee9b83471d00d0cac1cf08ddea8b5b41aea80bb1a70',
'org.whispersystems:signal-service-java:e0b9c41fcf614d58a71afcbb290d1864275b65364ca8fafeb5fbcbdc2d59a57a',
'org.whispersystems:signal-protocol-android:1b4b9d557c8eaf861797ff683990d482d4aa8e9f23d9b17ff0cc67a02f38cb19',
'org.whispersystems:signal-service-java:910ed96e928355d118454e1dff6c11b9f95daa801f3b4022e5c8999bff47a888',
'com.nineoldandroids:library:68025a14e3e7673d6ad2f95e4b46d78d7d068343aa99256b686fe59de1b3163a',
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
'com.madgag.spongycastle:core:8d6240b974b0aca4d3da9c7dd44d42339d8a374358aca5fc98e50a995764511f',
'com.google.android.gms:play-services-tasks:69ec265168e601d0203d04cd42e34bb019b2f029aa1e16fabd38a5153eea2086',
'org.whispersystems:curve25519-android:bf6c34223d45d2f2813a8efcab9923caf99115115c760c9acea680bcb42d23c0',
'org.whispersystems:signal-protocol-java:a835cd0609cf116a74651bd0aa748db9392bba48c2d2af787757b8a1b50d131c',
'com.googlecode.libphonenumber:libphonenumber:7214dc6dfc6243e34fb1a3e02ad15331bfff6ab902d679e3ba337695265c21ca',
'com.google.protobuf:protobuf-java:e0c1c64575c005601725e7c6a02cebf9e1285e888f756b2a1d73ffa8d725cc74',
'com.googlecode.libphonenumber:libphonenumber:141ebcafba7070a13d879c44e7648ddbe10beab665cb64d7b0c1bea93afb8dc2',
'com.fasterxml.jackson.core:jackson-databind:835097bcdd11f5bc8a08378c70d4c8054dfa4b911691cc2752063c75534d198d',
'com.squareup.okhttp3:okhttp:eecd834b09d12c3cd568b811522b97012619f7f00378c3c719a1957fac6458ef',
'org.whispersystems:curve25519-java:00f1d4919f759055f41f7853a3d475dc7c8decf0dbf045ae93414f8f23b066cc',
'com.squareup.okhttp3:okhttp:a992938d7203ca557cd7a116f002e8c427ec9cdae7ea852441abb8aec891f948',
'org.whispersystems:curve25519-android:bf6c34223d45d2f2813a8efcab9923caf99115115c760c9acea680bcb42d23c0',
'org.whispersystems:signal-protocol-java:a835cd0609cf116a74651bd0aa748db9392bba48c2d2af787757b8a1b50d131c',
'com.fasterxml.jackson.core:jackson-annotations:0ca408c24202a7626ec8b861e99d85eca5e38b73311dd6dd12e3e9deecc3fe94',
'com.fasterxml.jackson.core:jackson-core:cbf4604784b4de226262845447a1ad3bb38a6728cebe86562e2c5afada8be2c0',
'com.squareup.okio:okio:8c5436cadfab36bbd97db5f5c43b7bfdb5bf2f5f894ec8709b1929f14bdd010c',
'org.whispersystems:curve25519-java:00f1d4919f759055f41f7853a3d475dc7c8decf0dbf045ae93414f8f23b066cc',
'com.android.support:support-media-compat:8d6a1a5ba3d9eb1a25cb8f21bb312ac6280202e3d2900cb0b447d065d0d8a125',
'com.android.support:support-core-utils:a7649e18c04143dde40c218c5ce9a030e7ae674089cd7b18c6cf8ed2a22cf01a',
'com.android.support:support-fragment:1294500b357f52cf3779e2521c79f54ae7844f3b9a5f6727495dbbda7f231377',
Expand Down
15 changes: 9 additions & 6 deletions res/values/strings.xml
Expand Up @@ -370,6 +370,10 @@
<string name="MessageDetailsRecipient_failed_to_send">Failed to send</string>
<string name="MessageDetailsRecipient_new_safety_number">New safety number</string>

<!-- MessageRetrievalService -->
<string name="MessageRetrievalService_signal">Signal</string>
<string name="MessageRetrievalService_background_connection_enabled">Background connection enabled</string>

<!-- MmsDownloader -->
<string name="MmsDownloader_error_storing_mms">Error storing MMS!</string>
<string name="MmsDownloader_error_connecting_to_mms_provider">Error connecting to MMS provider</string>
Expand Down Expand Up @@ -501,17 +505,16 @@
<string name="RegistrationActivity_the_number_you_specified_s_is_invalid">The number you
specified (%s) is invalid.
</string>
<string name="RegistrationActivity_unsupported">Unsupported</string>
<string name="RegistrationActivity_sorry_this_device_is_not_supported_for_data_messaging">Sorry,
this device is not supported for data messaging. Devices running versions of Android older
than 4.0 must have a registered Google Account. Devices running Android 4.0 or newer do not
require a Google account, but must have the Play Store app installed.
</string>
<string name="RegistrationActivity_we_will_now_verify_that_the_following_number_is_associated_with_your_device_s">
Double-check that this is your number! We\'re about to verify it with an SMS.
</string>
<string name="RegistrationActivity_continue">Continue</string>
<string name="RegistrationActivity_edit">Edit</string>
<string name="RegistrationActivity_missing_google_play_services">Missing Google Play Services</string>
<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>
<string name="RegistrationActivity_i_understand">I understand</string>
<string name="RegistrationActivity_play_services_error">Play Services Error</string>
<string name="RegistrationActivity_google_play_services_is_updating_or_unavailable">Google Play Services is updating or temporarily unavailable. Please try again.</string>

<!-- RegistrationProblemsActivity -->
<string name="RegistrationProblemsActivity_possible_problems">Possible problems</string>
Expand Down
3 changes: 3 additions & 0 deletions src/org/thoughtcrime/securesms/ConversationListFragment.java
Expand Up @@ -54,6 +54,7 @@
import org.thoughtcrime.securesms.ConversationListAdapter.ItemClickListener;
import org.thoughtcrime.securesms.components.recyclerview.DeleteItemAnimator;
import org.thoughtcrime.securesms.components.reminder.DefaultSmsReminder;
import org.thoughtcrime.securesms.components.reminder.DozeReminder;
import org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder;
import org.thoughtcrime.securesms.components.reminder.OutdatedBuildReminder;
import org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder;
Expand Down Expand Up @@ -184,6 +185,8 @@ private void updateReminders() {
return Optional.of((new PushRegistrationReminder(context, masterSecret)));
} else if (ShareReminder.isEligible(context)) {
return Optional.of(new ShareReminder(context));
} else if (DozeReminder.isEligible(context)) {
return Optional.of(new DozeReminder(context));
} else {
return Optional.absent();
}
Expand Down
81 changes: 68 additions & 13 deletions src/org/thoughtcrime/securesms/RegistrationActivity.java
@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
Expand All @@ -20,6 +21,7 @@
import android.widget.Toast;

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

private enum PlayServicesStatus {
SUCCESS,
MISSING,
NEEDS_UPDATE,
TRANSIENT_ERROR
}

private AsYouTypeFormatter countryFormatter;
private ArrayAdapter<String> countrySpinnerAdapter;
private Spinner countrySpinner;
Expand Down Expand Up @@ -211,35 +220,81 @@ public void onClick(View v) {
return;
}

int gcmStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(self);
PlayServicesStatus gcmStatus = checkPlayServices(self);

if (gcmStatus != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(gcmStatus)) {
GooglePlayServicesUtil.getErrorDialog(gcmStatus, self, 9000).show();
} else {
Dialogs.showAlertDialog(self, getString(R.string.RegistrationActivity_unsupported),
getString(R.string.RegistrationActivity_sorry_this_device_is_not_supported_for_data_messaging));
}
return;
if (gcmStatus == PlayServicesStatus.SUCCESS) {
promptForRegistrationStart(self, e164number, true);
} else if (gcmStatus == PlayServicesStatus.MISSING) {
promptForNoPlayServices(self, e164number);
} else if (gcmStatus == PlayServicesStatus.NEEDS_UPDATE) {
GoogleApiAvailability.getInstance().getErrorDialog(self, ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED, 0);
} else {
Dialogs.showAlertDialog(self, getString(R.string.RegistrationActivity_play_services_error),
getString(R.string.RegistrationActivity_google_play_services_is_updating_or_unavailable));
}
}

AlertDialog.Builder dialog = new AlertDialog.Builder(self);
private void promptForRegistrationStart(final Context context, final String e164number, final boolean gcmSupported) {
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
dialog.setTitle(PhoneNumberFormatter.getInternationalFormatFromE164(e164number));
dialog.setMessage(R.string.RegistrationActivity_we_will_now_verify_that_the_following_number_is_associated_with_your_device_s);
dialog.setPositiveButton(getString(R.string.RegistrationActivity_continue),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(self, RegistrationProgressActivity.class);
intent.putExtra("e164number", e164number);
intent.putExtra("master_secret", masterSecret);
Intent intent = new Intent(context, RegistrationProgressActivity.class);
intent.putExtra(RegistrationProgressActivity.NUMBER_EXTRA, e164number);
intent.putExtra(RegistrationProgressActivity.MASTER_SECRET_EXTRA, masterSecret);
intent.putExtra(RegistrationProgressActivity.GCM_SUPPORTED_EXTRA, gcmSupported);
startActivity(intent);
finish();
}
});
dialog.setNegativeButton(getString(R.string.RegistrationActivity_edit), null);
dialog.show();
}

private void promptForNoPlayServices(final Context context, final String e164number) {
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
dialog.setTitle(R.string.RegistrationActivity_missing_google_play_services);
dialog.setMessage(R.string.RegistrationActivity_this_device_is_missing_google_play_services);
dialog.setPositiveButton(R.string.RegistrationActivity_i_understand, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
promptForRegistrationStart(context, e164number, false);
}
});
dialog.setNegativeButton(android.R.string.cancel, null);
dialog.show();
}

private PlayServicesStatus checkPlayServices(Context context) {
int gcmStatus = 0;

try {
gcmStatus = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
} catch (Throwable t) {
Log.w(TAG, t);
return PlayServicesStatus.MISSING;
}

Log.w(TAG, "Play Services: " + gcmStatus);

switch (gcmStatus) {
case ConnectionResult.SUCCESS:
return PlayServicesStatus.SUCCESS;
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
return PlayServicesStatus.NEEDS_UPDATE;
case ConnectionResult.SERVICE_DISABLED:
case ConnectionResult.SERVICE_MISSING:
case ConnectionResult.SERVICE_INVALID:
case ConnectionResult.API_UNAVAILABLE:
case ConnectionResult.SERVICE_MISSING_PERMISSION:
return PlayServicesStatus.MISSING;
default:
return PlayServicesStatus.TRANSIENT_ERROR;
}
}
}

private class CountryCodeChangedListener implements TextWatcher {
Expand Down

19 comments on commit 1669731

@nrizzio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit fixes issue #1000.

@Stanzi97
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And issue #127 and issue #560 and issue #2530!! 👍

@nrizzio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Stanzi97 This commit doesn't really address #127

@johanw666
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just being curious: what happens when a user with a too old (< 9.6.1) version of GPS starts this version of Signal?

@anarcat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks so much for this!!! i am really glad to see this move forward. i have documented what i think are the remaining issues blocking signal from being released completely outside the google app store in xmikos/fdroiddata#29 (comment), for those who are interested.

@moxie0
Copy link
Contributor Author

@moxie0 moxie0 commented on 1669731 Feb 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anarcat What I'd like is:

  1. A small well-written library that we can link into Signal which does crash reporting, checking for updates (and posting notifications for the user), and reporting basic stats.
  2. A simple web-app that looks like the Play Store console, which allows us to publish new APKs, display crash reports, and display basic stats.

Then we could link to the signed APK from our website, get crash reports and stats, and make sure users are keeping up to date.

FYI the server side is here (released/licensed): https://github.com/whispersystems/signal-server

@anarcat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moxie0 did you see the ACRA library that f-droid mentions in release 0.98? I haven't reviewed it at all, but it could be interesting.

thanks for the response, and really happy to see the server side public now!

PS: people over the fdroid side are wondering where it would be best to discuss this - should there be an issue in the Signal-Android repo? or do we continue in xmikos/fdroiddata#29 (comment)...

@nrizzio
Copy link
Contributor

@nrizzio nrizzio commented on 1669731 Feb 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anarcat Discussion should go in this thread in the community forum, as OWS prefers using places other than GitHub for discussion.

@anarcat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nrizzio thanks. i ended posting a new thread before i saw your edit, sorry about that... but i cross-linked it with the non-GCM thread you linked to and peppered it on other related threads as well.

cheers, and thanks again folks!

@Be-ing
Copy link

@Be-ing Be-ing commented on 1669731 Feb 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been using this the last two days and the battery usage is reasonable. Big thanks!

@breznak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And issue #6154

@Be-ing
Copy link

@Be-ing Be-ing commented on 1669731 Feb 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, text messaging works fine. If you want to make calls (audio or video), until WebRTC audio/video calls are turned on by default, whoever you call needs to have the beta video support turned on in their preferences.

@6w9wy7
Copy link

@6w9wy7 6w9wy7 commented on 1669731 Mar 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to update google play services in order to run it. #6371 Doesnt this mean it needs it?
I didnt bother to check the code.

@jospoortvliet
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@6w9wy7 you HAVE Gplay services so it uses it. If you don't have it, things still work as there's a fallback, your phone will just suck more battery than a Gplay services version would need...

@StyXman
Copy link

@StyXman StyXman commented on 1669731 Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this been released? I have Signal 4.12.3 from https://signal.org/android/apk/ and it still needs Google Play Services to run; when I disable and stop it, Signal complains. Does it continue to work for text messaging?

@michael-thayer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to force Signal to use WebSockets instead of GCM even if the second is available, without changing the code? I see the GCM_DISABLED_PREF in the source, but I am new to Android and not sure how to configure it. Of course, I could change the source and rebuild if there is no other way.

@haffenloher
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep the amount of email notifications at a manageable level, OWS uses Github only for tracking issues and reviewing pull requests. For discussion please head to the community forums.

@poetapabon
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

que buena inf

@ramast
Copy link

@ramast ramast commented on 1669731 Jan 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using signal without google play and with battery optimization disabled for signal and yet I never get notification for messages or calls. In fact even if signal app is open I don't get notification. I have to keep switching between the chat windows and friends list to make signal retrieve latest messages. I had this issue with one phone before and now same issue with a new phone. (Using lineageos if that helps)

Please sign in to comment.