build: make Firebase optional

Add a "withFirebase" build flavor that add Firebase push notification
support to the App.

The build flavor communicates with the app by sending Intents to DRingService.

The "buildFirebase" gradle variable still defines if Google services are
bundled with the app.

Push support need buildFirebase to true and the withFirebase build flavor.
If buildFirebase is true and withFirebase is not used, Google services are
still included but not used.
If buildFirebase is false and withFirebase is used, Firebase quietly fails
to load and push notifications don't work.

Change-Id: I8db9a0a34d1cebd46b723caeaff6a99674c6c6ab
diff --git a/compile.sh b/compile.sh
index 66d2482..a4827e4 100755
--- a/compile.sh
+++ b/compile.sh
@@ -39,10 +39,16 @@
     echo "$i build OK"
 done
 
+if [ -z "$RING_BUILD_FIREBASE" ]; then
+    echo "Building without Firebase support"
+else
+    GRADLE_PROPERTIES="-PbuildFirebase"
+    echo "Building with Firebase support"
+fi
 if [[ $DAEMON_ONLY -eq 0 ]]; then
     if [[ $RELEASE -eq 1 ]]; then
-        cd $TOP && ./gradlew assembleRelease
+        cd $TOP && ./gradlew $GRADLE_PROPERTIES assembleRelease
     else
-        cd $TOP && ./gradlew assembleDebug
+        cd $TOP && ./gradlew $GRADLE_PROPERTIES assembleDebug
     fi
 fi
diff --git a/ring-android/app/build.gradle b/ring-android/app/build.gradle
index 66ab6e5..972c1df 100644
--- a/ring-android/app/build.gradle
+++ b/ring-android/app/build.gradle
@@ -3,7 +3,75 @@
 def android_support_version = "27.0.2"
 def butterknife_version = "8.8.1"
 def dagger_version = "2.12"
-def useFirebase = rootProject.useFirebase
+def buildFirebase = project.hasProperty('buildFirebase')
+
+android {
+    compileSdkVersion 27
+    buildToolsVersion "26.0.3"
+
+    defaultConfig {
+        minSdkVersion 18
+        targetSdkVersion 27
+        vectorDrawables.useSupportLibrary = true
+    }
+
+    sourceSets {
+        main {
+            aidl.srcDirs = ['src/main/java']
+            jniLibs.srcDir 'src/main/libs'
+            jni.srcDirs = []
+        }
+
+        // Move the tests to tests/java, tests/res, etc...
+        instrumentTest.setRoot('tests')
+
+        // Move the build types to build-types/<type>
+        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
+        // This moves them out of them default location under src/<type>/... which would
+        // conflict with src/ being used by the main source set.
+        // Adding new build types or product flavors should be accompanied
+        // by a similar customization.
+        debug.setRoot('build-types/debug')
+        release.setRoot('build-types/release')
+    }
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+    buildTypes {
+        release {
+            minifyEnabled true
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+    flavorDimensions "push"
+    productFlavors {
+        noPush {
+            dimension "push"
+        }
+        withFirebase {
+            dimension "push"
+        }
+    }
+    signingConfigs {
+        config {
+            keyAlias 'ring'
+            storeFile file('../keystore.bin')
+        }
+    }
+    lintOptions {
+        disable 'MissingTranslation'
+    }
+    splits {
+        abi {
+            enable true
+            reset()
+            def sp = archs.split(',')
+            include(sp)
+            universalApk true
+        }
+    }
+}
 
 dependencies {
     implementation fileTree(include: '*.jar', dir: 'libs')
@@ -41,75 +109,10 @@
     // RxAndroid
     implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
 
-    if (useFirebase) {
-        compile 'com.google.firebase:firebase-messaging:11.8.0'
-    }
-
+    withFirebaseImplementation 'com.google.firebase:firebase-messaging:11.8.0'
 }
 
-android {
-    compileSdkVersion 27
-    buildToolsVersion "26.0.3"
-
-    defaultConfig {
-        minSdkVersion 18
-        targetSdkVersion 27
-        vectorDrawables.useSupportLibrary = true
-    }
-
-    sourceSets {
-        main {
-            java.srcDirs = ['src/main/java']
-            if (useFirebase) {
-                java.srcDirs += 'src/main/javaFirebase'
-            }
-            aidl.srcDirs = ['src/main/java']
-            jniLibs.srcDir 'src/main/libs'
-            jni.srcDirs = []
-        }
-
-        // Move the tests to tests/java, tests/res, etc...
-        instrumentTest.setRoot('tests')
-
-        // Move the build types to build-types/<type>
-        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
-        // This moves them out of them default location under src/<type>/... which would
-        // conflict with src/ being used by the main source set.
-        // Adding new build types or product flavors should be accompanied
-        // by a similar customization.
-        debug.setRoot('build-types/debug')
-        release.setRoot('build-types/release')
-    }
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_8
-        targetCompatibility JavaVersion.VERSION_1_8
-    }
-    buildTypes {
-        release {
-            minifyEnabled true
-            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
-        }
-    }
-    signingConfigs {
-        config {
-            keyAlias 'ring'
-            storeFile file('../keystore.bin')
-        }
-    }
-    lintOptions {
-        disable 'MissingTranslation'
-    }
-    splits {
-        abi {
-            enable true
-            reset()
-            def sp = archs.split(',')
-            include(sp)
-            universalApk true
-        }
-    }
-}
-
-if (useFirebase) {
+if (buildFirebase) {
+    println 'apply plugin ' + buildFirebase
     apply plugin: 'com.google.gms.google-services'
 }
\ No newline at end of file
diff --git a/ring-android/app/src/main/AndroidManifest.xml b/ring-android/app/src/main/AndroidManifest.xml
index 496fdb4..e427c67 100644
--- a/ring-android/app/src/main/AndroidManifest.xml
+++ b/ring-android/app/src/main/AndroidManifest.xml
@@ -78,7 +78,6 @@
         android:required="false" />
 
     <application
-        android:name=".application.RingApplication"
         android:allowBackup="false"
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
@@ -86,6 +85,13 @@
         android:supportsRtl="true"
         tools:ignore="UnusedAttribute">
 
+        <meta-data
+            android:name="firebase_analytics_collection_deactivated"
+            android:value="true" />
+        <meta-data
+            android:name="google_analytics_adid_collection_enabled"
+            android:value="false" />
+
         <activity
             android:name=".launch.LaunchActivity"
             android:configChanges="screenSize|screenLayout|smallestScreenSize"
@@ -302,23 +308,6 @@
             android:name=".tv.account.TVSettingsActivity"
             android:theme="@style/LeanbackPreferences" />
 
-        <service
-            android:name=".services.RingFirebaseMessagingService"
-            android:exported="false">
-            <intent-filter>
-                <action android:name="com.google.firebase.MESSAGING_EVENT" />
-            </intent-filter>
-        </service>
-
-        <service
-            android:name=".services.RingFirebaseInstanceIdService"
-            android:exported="false">
-            <intent-filter>
-                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
-            </intent-filter>
-        </service>
-
-
     </application>
 
 </manifest>
diff --git a/ring-android/app/src/main/java/cx/ring/application/RingApplication.java b/ring-android/app/src/main/java/cx/ring/application/RingApplication.java
index 778967a..91af02a 100644
--- a/ring-android/app/src/main/java/cx/ring/application/RingApplication.java
+++ b/ring-android/app/src/main/java/cx/ring/application/RingApplication.java
@@ -31,8 +31,6 @@
 import android.os.IBinder;
 import android.os.Looper;
 
-import com.google.firebase.iid.FirebaseInstanceId;
-
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
@@ -59,7 +57,7 @@
 import cx.ring.services.PresenceService;
 import cx.ring.utils.Log;
 
-public class RingApplication extends Application {
+public abstract class RingApplication extends Application {
 
     public final static String DRING_CONNECTION_CHANGED = BuildConfig.APPLICATION_ID + ".event.DRING_CONNECTION_CHANGE";
     public static final int PERMISSIONS_REQUEST = 57;
@@ -69,7 +67,7 @@
     public static final Handler uiHandler = new Handler(Looper.getMainLooper());
     private final static String TAG = RingApplication.class.getSimpleName();
     static private final IntentFilter RINGER_FILTER = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
-    private static RingApplication sInstance;
+    private static RingApplication sInstance = null;
     @Inject
     @Named("DaemonExecutor")
     ExecutorService mExecutor;
@@ -100,6 +98,8 @@
     private RingInjectionComponent mRingInjectionComponent;
     private Map<String, Boolean> mPermissionsBeingAsked;
 
+    public abstract String getPushToken();
+
     private boolean mBound = false;
     private final ServiceConnection mConnection = new ServiceConnection() {
 
@@ -162,7 +162,7 @@
                 mAccountService.loadAccountsFromDaemon(mPreferencesService.hasNetworkConnected());
 
                 if (mPreferencesService.getUserSettings().isAllowPushNotifications()) {
-                    String token = FirebaseInstanceId.getInstance().getToken();
+                    String token = getPushToken();
                     Log.w(TAG, "Setting Firebase push token: " + token);
                     Ringservice.setPushNotificationToken(token);
                 } else {
diff --git a/ring-android/app/src/main/java/cx/ring/dependencyinjection/RingInjectionComponent.java b/ring-android/app/src/main/java/cx/ring/dependencyinjection/RingInjectionComponent.java
index 377ec0a..eae1806 100755
--- a/ring-android/app/src/main/java/cx/ring/dependencyinjection/RingInjectionComponent.java
+++ b/ring-android/app/src/main/java/cx/ring/dependencyinjection/RingInjectionComponent.java
@@ -127,10 +127,6 @@
 
     void inject(DRingService service);
 
-    void inject(cx.ring.services.RingFirebaseMessagingService service);
-
-    void inject(cx.ring.services.RingFirebaseInstanceIdService service);
-
     void inject(DeviceRuntimeServiceImpl service);
 
     void inject(DaemonService service);
diff --git a/ring-android/app/src/main/java/cx/ring/service/DRingService.java b/ring-android/app/src/main/java/cx/ring/service/DRingService.java
index 34a678b..50518d7 100644
--- a/ring-android/app/src/main/java/cx/ring/service/DRingService.java
+++ b/ring-android/app/src/main/java/cx/ring/service/DRingService.java
@@ -25,7 +25,6 @@
  */
 package cx.ring.service;
 
-import android.app.Application;
 import android.app.Service;
 import android.app.UiModeManager;
 import android.content.BroadcastReceiver;
@@ -49,6 +48,7 @@
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
@@ -95,6 +95,11 @@
     static public final String ACTION_CONV_READ = BuildConfig.APPLICATION_ID + ".action.CONV_READ";
     static public final String ACTION_CONV_DISMISS = BuildConfig.APPLICATION_ID + ".action.CONV_DISMISS";
     static public final String ACTION_CONV_ACCEPT = BuildConfig.APPLICATION_ID + ".action.CONV_ACCEPT";
+    public static final String ACTION_PUSH_RECEIVED = BuildConfig.APPLICATION_ID + ".action.PUSH_RECEIVED";
+    public static final String ACTION_PUSH_TOKEN_CHANGED = BuildConfig.APPLICATION_ID + ".push.PUSH_TOKEN_CHANGED";
+    public static final String PUSH_RECEIVED_FIELD_FROM = "from";
+    public static final String PUSH_RECEIVED_FIELD_DATA = "data";
+    public static final String PUSH_TOKEN_FIELD_TOKEN = "token";
 
     private static final String TAG = DRingService.class.getSimpleName();
     private final ContactsContentObserver contactContentObserver = new ContactsContentObserver();
@@ -632,7 +637,17 @@
             case ACTION_CONV_ACCEPT:
             case ACTION_CONV_DISMISS:
                 if (extras != null) {
-                    handleConvAction(action, intent.getExtras());
+                    handleConvAction(action, extras);
+                }
+                break;
+            case ACTION_PUSH_TOKEN_CHANGED:
+                if (extras != null) {
+                    handlePushTokenChanged(extras);
+                }
+                break;
+            case ACTION_PUSH_RECEIVED:
+                if (extras != null) {
+                    handlePushReceived(extras);
                 }
                 break;
             default:
@@ -640,6 +655,23 @@
         }
     }
 
+    private void handlePushReceived(Bundle extras) {
+        String from = extras.getString(PUSH_RECEIVED_FIELD_FROM);
+        Bundle data = extras.getBundle(PUSH_RECEIVED_FIELD_DATA);
+        if (from == null || data == null) {
+            return;
+        }
+        Map<String, String> map = new HashMap<>(data.size());
+        for (String key : data.keySet()) {
+            map.put(key, data.get(key).toString());
+        }
+        mAccountService.pushNotificationReceived(from, map);
+    }
+
+    private void handlePushTokenChanged(Bundle extras) {
+        mAccountService.setPushNotificationToken(extras.getString(PUSH_TOKEN_FIELD_TOKEN, ""));
+    }
+
     private void handleTrustRequestAction(String action, Bundle extras) {
         String account = extras.getString(NotificationServiceImpl.TRUST_REQUEST_NOTIFICATION_ACCOUNT_ID);
         String from = extras.getString(NotificationServiceImpl.TRUST_REQUEST_NOTIFICATION_FROM);
diff --git a/ring-android/app/src/noPush/AndroidManifest.xml b/ring-android/app/src/noPush/AndroidManifest.xml
new file mode 100644
index 0000000..1c4b410
--- /dev/null
+++ b/ring-android/app/src/noPush/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+Copyright (C) 2018 Savoir-faire Linux Inc.
+
+Author: 	Adrien Beraud <adrien.beraud@savoirfairelinux.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <https://www.gnu.org/licenses/>.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="cx.ring"
+    tools:ignore="ImpliedTouchscreenHardware,MissingLeanbackLauncher,MissingLeanbackSupport">
+
+    <application
+        android:name=".application.RingApplicationNoPush"
+        tools:ignore="GoogleAppIndexingWarning,UnusedAttribute" />
+
+</manifest>
diff --git a/ring-android/app/src/noPush/java/cx/ring/application/RingApplicationNoPush.java b/ring-android/app/src/noPush/java/cx/ring/application/RingApplicationNoPush.java
new file mode 100644
index 0000000..89f3d1f
--- /dev/null
+++ b/ring-android/app/src/noPush/java/cx/ring/application/RingApplicationNoPush.java
@@ -0,0 +1,28 @@
+/*
+ *  Copyright (C) 2018 Savoir-faire Linux Inc.
+ *
+ *  Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+package cx.ring.application;
+
+public class RingApplicationNoPush extends RingApplication {
+
+    @Override
+    public String getPushToken() {
+        return "";
+    }
+
+}
diff --git a/ring-android/app/src/withFirebase/AndroidManifest.xml b/ring-android/app/src/withFirebase/AndroidManifest.xml
new file mode 100644
index 0000000..dd9d634
--- /dev/null
+++ b/ring-android/app/src/withFirebase/AndroidManifest.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+Copyright (C) 2018 Savoir-faire Linux Inc.
+
+Author: 	Adrien Beraud <adrien.beraud@savoirfairelinux.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <https://www.gnu.org/licenses/>.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="cx.ring">
+
+    <application
+        android:name=".application.RingApplicationFirebase"
+        tools:ignore="UnusedAttribute">
+
+        <service
+            android:name=".services.RingFirebaseMessagingService"
+            android:exported="false">
+            <intent-filter>
+                <action android:name="com.google.firebase.MESSAGING_EVENT" />
+            </intent-filter>
+        </service>
+
+        <service
+            android:name=".services.RingFirebaseInstanceIdService"
+            android:exported="false">
+            <intent-filter>
+                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
+            </intent-filter>
+        </service>
+
+    </application>
+
+</manifest>
diff --git a/ring-android/app/src/withFirebase/java/cx/ring/application/RingApplicationFirebase.java b/ring-android/app/src/withFirebase/java/cx/ring/application/RingApplicationFirebase.java
new file mode 100644
index 0000000..88adec0
--- /dev/null
+++ b/ring-android/app/src/withFirebase/java/cx/ring/application/RingApplicationFirebase.java
@@ -0,0 +1,30 @@
+/*
+ *  Copyright (C) 2018 Savoir-faire Linux Inc.
+ *
+ *  Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+package cx.ring.application;
+
+import com.google.firebase.iid.FirebaseInstanceId;
+
+public class RingApplicationFirebase extends RingApplication {
+
+    @Override
+    public String getPushToken() {
+        return FirebaseInstanceId.getInstance().getToken();
+    }
+
+}
diff --git a/ring-android/app/src/main/javaFirebase/cx/ring/services/RingFirebaseInstanceIdService.java b/ring-android/app/src/withFirebase/java/cx/ring/services/RingFirebaseInstanceIdService.java
similarity index 71%
rename from ring-android/app/src/main/javaFirebase/cx/ring/services/RingFirebaseInstanceIdService.java
rename to ring-android/app/src/withFirebase/java/cx/ring/services/RingFirebaseInstanceIdService.java
index e70626d..c5d089b 100644
--- a/ring-android/app/src/main/javaFirebase/cx/ring/services/RingFirebaseInstanceIdService.java
+++ b/ring-android/app/src/withFirebase/java/cx/ring/services/RingFirebaseInstanceIdService.java
@@ -18,38 +18,24 @@
  */
 package cx.ring.services;
 
+import android.content.Intent;
 import android.util.Log;
 
 import com.google.firebase.iid.FirebaseInstanceId;
 import com.google.firebase.iid.FirebaseInstanceIdService;
 
-import javax.inject.Inject;
-
-import cx.ring.application.RingApplication;
-import dagger.Lazy;
+import cx.ring.service.DRingService;
 
 public class RingFirebaseInstanceIdService extends FirebaseInstanceIdService {
     private static final String TAG = RingFirebaseInstanceIdService.class.getSimpleName();
 
-    public RingFirebaseInstanceIdService() {
-        onTokenRefresh();
-    }
-
-    @Inject
-    protected AccountService mAccountService;
-
-    @Override
-    public void onCreate() {
-        super.onCreate();
-        RingApplication.getInstance().getRingInjectionComponent().inject(this);
-    }
-
     @Override
     public void onTokenRefresh() {
         String refreshedToken = FirebaseInstanceId.getInstance().getToken();
         Log.w(TAG, "Refreshed token: " + refreshedToken);
-        if (mAccountService != null)
-            mAccountService.setPushNotificationToken(FirebaseInstanceId.getInstance().getToken());
+        startService(new Intent(DRingService.ACTION_PUSH_TOKEN_CHANGED)
+                .setClass(this, DRingService.class)
+                .putExtra(DRingService.PUSH_TOKEN_FIELD_TOKEN, refreshedToken));
     }
 
 }
diff --git a/ring-android/app/src/main/javaFirebase/cx/ring/services/RingFirebaseMessagingService.java b/ring-android/app/src/withFirebase/java/cx/ring/services/RingFirebaseMessagingService.java
similarity index 69%
rename from ring-android/app/src/main/javaFirebase/cx/ring/services/RingFirebaseMessagingService.java
rename to ring-android/app/src/withFirebase/java/cx/ring/services/RingFirebaseMessagingService.java
index fa393c0..601c7c5 100644
--- a/ring-android/app/src/main/javaFirebase/cx/ring/services/RingFirebaseMessagingService.java
+++ b/ring-android/app/src/withFirebase/java/cx/ring/services/RingFirebaseMessagingService.java
@@ -18,6 +18,8 @@
  */
 package cx.ring.services;
 
+import android.content.Intent;
+import android.os.Bundle;
 import android.util.Log;
 
 import com.google.firebase.messaging.FirebaseMessagingService;
@@ -25,35 +27,22 @@
 
 import java.util.Map;
 
-import javax.inject.Inject;
-
-import cx.ring.application.RingApplication;
+import cx.ring.service.DRingService;
 
 public class RingFirebaseMessagingService extends FirebaseMessagingService {
     private static final String TAG = RingFirebaseMessagingService.class.getSimpleName();
 
-    @Inject
-    protected AccountService mAccountService;
-
-    @Override
-    public void onCreate() {
-        super.onCreate();
-        RingApplication.getInstance().getRingInjectionComponent().inject(this);
-    }
-
     @Override
     public void onMessageReceived(RemoteMessage remoteMessage) {
         Log.d(TAG, "onMessageReceived: " + remoteMessage.getFrom());
         Map<String, String> data = remoteMessage.getData();
-        for (Map.Entry<String, String> e : data.entrySet()) {
-            Log.d(TAG, "entry: " + e.getKey() + " -> " + e.getValue());
+        Bundle bundle = new Bundle();
+        for (Map.Entry<String, String> entry : data.entrySet()) {
+            bundle.putString(entry.getKey(), entry.getValue());
         }
-
-        mAccountService.pushNotificationReceived(remoteMessage.getFrom(), data);
-    }
-
-    @Override
-    public void onMessageSent(String s) {
-        Log.d(TAG, "onMessageSent: " + s);
+        startService(new Intent(DRingService.ACTION_PUSH_RECEIVED)
+                .setClass(this, DRingService.class)
+                .putExtra(DRingService.PUSH_RECEIVED_FIELD_FROM, remoteMessage.getFrom())
+                .putExtra(DRingService.PUSH_RECEIVED_FIELD_DATA, bundle));
     }
 }
diff --git a/ring-android/build.gradle b/ring-android/build.gradle
index bce1286..0fd3ff6 100644
--- a/ring-android/build.gradle
+++ b/ring-android/build.gradle
@@ -1,7 +1,3 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-ext {
-    useFirebase = true
-}
 buildscript {
     repositories {
         jcenter()