From 8a2042e756dbe072a72931918c2ba99e1fd9a752 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 30 Mar 2018 20:44:00 +0200 Subject: [PATCH 1/2] Print firebase token --- OsmAnd/build.gradle | 36 +++++++++++-------- .../src/net/osmand/plus/AppInitializer.java | 1 - .../net/osmand/plus/OsmandApplication.java | 19 +++++++++- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 58ecc319d8..7516be99c4 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -19,6 +19,7 @@ apply plugin: 'com.github.ksoichiro.eclipse.aar' // Less important // Configure eclipse-aar plugin +def analytics = !System.getenv("APP_FEATURES") || System.getenv("APP_FEATURES").contains("+play_market") eclipseAar { // See "Configurations" for details @@ -312,8 +313,8 @@ task copyStyleIcons(type: Copy) { include "**/*.png" } -task collectExternalResources << {} -collectExternalResources.dependsOn collectVoiceAssets, +task collectExternalResources { + dependsOn collectVoiceAssets, collectFonts, collectHelpContentsAssets, collectHelpContentsStyle, @@ -324,11 +325,7 @@ collectExternalResources.dependsOn collectVoiceAssets, copyStyleIcons, updateNoTranslate, validateTranslate -// tasks.whenTaskAdded { task -> -// if (task.name.startsWith("generate") && task.name.endsWith("Resources")) { -// task.dependsOn collectExternalResources -// } -// } +} // Legacy core build import org.apache.tools.ant.taskdefs.condition.Os @@ -357,9 +354,14 @@ task cleanupDuplicatesInCore() { file("libs/x86/libgnustl_shared.so").renameTo(file("libgnustl/x86/libgnustl_shared.so")) } } -tasks.withType(JavaCompile) { - compileTask -> compileTask.dependsOn << [collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore] +afterEvaluate { + android.applicationVariants.all { variant -> + variant.javaCompiler.dependsOn(collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore) + } } +//tasks.withType(JavaCompile) { + //compileTask -> compileTask.dependsOn << [collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore] +//} task appStart(type: Exec) { // linux @@ -383,14 +385,20 @@ repositories { } } -def analytics = (System.getenv("APP_FEATURES") && System.getenv("APP_FEATURES").contains("+play_market") && - ["net.osmand", "net.osmand.dev"].contains(System.getenv("PACKAGE_TO_BUILT")) ) || System.getenv("USE_FIREBASE") +// project.logger.warn("Analytics enabled for free version: $analytics") dependencies { compile project(path: ':OsmAnd-java', configuration: 'android') if (analytics) { - compile 'com.google.firebase:firebase-core:12.0.1' - compile 'com.google.firebase:firebase-config:12.0.1' - compile 'com.facebook.android:facebook-android-sdk:[4,5)' + def analyticsDependencies = [ + 'com.google.firebase:firebase-core:12.0.1', + 'com.google.firebase:firebase-iid:12.0.1', + 'com.google.firebase:firebase-config:12.0.1', + 'com.facebook.android:facebook-android-sdk:[4,5)' + ] + freeCompile(analyticsDependencies) + freedevCompile(analyticsDependencies) + freeresCompile(analyticsDependencies) + } compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:gridlayout-v7:27.1.0' diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index e278b39a3c..749c5dcb44 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -609,7 +609,6 @@ public class AppInitializer implements IProgress { app.mapMarkersHelper.syncAllGroupsAsync(); app.searchUICore.initSearchUICore(); - /// Log.i("Firebase token", com.google.firebase.iid.FirebaseInstanceId.getInstance().getToken()); checkLiveUpdatesAlerts(); } catch (RuntimeException e) { diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index dd284ecb20..e2de108feb 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -18,12 +18,12 @@ import android.support.multidex.MultiDex; import android.support.multidex.MultiDexApplication; import android.support.v7.app.AlertDialog; import android.text.format.DateFormat; +import android.util.Log; import android.view.View; import android.view.accessibility.AccessibilityManager; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; - import net.osmand.CallbackWithObject; import net.osmand.PlatformUtil; import net.osmand.access.AccessibilityPlugin; @@ -168,6 +168,7 @@ public class OsmandApplication extends MultiDexApplication { InAppHelper.initialize(this); initRemoteConfig(); + printFirebasetoken(); startApplication(); System.out.println("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms"); timeToStart = System.currentTimeMillis(); @@ -893,6 +894,22 @@ public class OsmandApplication extends MultiDexApplication { e.printStackTrace(); } } + + + public void printFirebasetoken() { + try { + if (Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) { + Class cl = Class.forName("com.google.firebase.iid.FirebaseInstanceId"); + Method mm = cl.getMethod("getInstance"); + Object inst = mm.invoke(null); + Method getToken = cl.getMethod("getToken"); + String firebaseToken = (String) getToken.invoke(inst); + LOG.info("Fbase token: " + firebaseToken); + } + } catch (Exception e) { + e.printStackTrace(); + } + } public void fetchRemoteParams() { try { From d2e7893f1def92fed614c312af23d95b48d2fcf3 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 30 Mar 2018 21:08:06 +0200 Subject: [PATCH 2/2] Update analytics script --- OsmAnd/build.gradle | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 7516be99c4..db5d639a78 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -19,7 +19,8 @@ apply plugin: 'com.github.ksoichiro.eclipse.aar' // Less important // Configure eclipse-aar plugin -def analytics = !System.getenv("APP_FEATURES") || System.getenv("APP_FEATURES").contains("+play_market") +def analytics = (!System.getenv("APP_FEATURES") || System.getenv("APP_FEATURES").contains("+play_market")) && + getGradle().getStartParameter().getTaskRequests().toString().contains("Free") eclipseAar { // See "Configurations" for details @@ -385,20 +386,14 @@ repositories { } } -// project.logger.warn("Analytics enabled for free version: $analytics") +project.logger.warn("Analytics enabled for free version: $analytics") dependencies { compile project(path: ':OsmAnd-java', configuration: 'android') if (analytics) { - def analyticsDependencies = [ - 'com.google.firebase:firebase-core:12.0.1', - 'com.google.firebase:firebase-iid:12.0.1', - 'com.google.firebase:firebase-config:12.0.1', - 'com.facebook.android:facebook-android-sdk:[4,5)' - ] - freeCompile(analyticsDependencies) - freedevCompile(analyticsDependencies) - freeresCompile(analyticsDependencies) - + compile 'com.google.firebase:firebase-core:12.0.1' + compile 'com.google.firebase:firebase-iid:12.0.1' + compile 'com.google.firebase:firebase-config:12.0.1' + compile 'com.facebook.android:facebook-android-sdk:[4,5)' } compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:gridlayout-v7:27.1.0'