From 10a614f428a6e2ffe51e5661c1ee10ca07752800 Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Tue, 10 Apr 2018 16:33:55 +0300 Subject: [PATCH] Revert "[android] Integrated libnotify library" This reverts commit 64a3ad3b16ba52c7bbfa503ff4b0fee62e6bf7ec. --- android/AndroidManifest.xml | 19 ++--- android/build.gradle | 15 ---- android/flavors/beta/res/values/libnotify.xml | 27 ------- .../flavors/debug/res/values/libnotify.xml | 27 ------- android/res/values/libnotify.xml | 27 ------- .../com/mapswithme/maps/MwmApplication.java | 20 ----- .../maps/search/SearchFragment.java | 7 -- .../util/log/LibnotifyLogReceiver.java | 45 ----------- .../mapswithme/util/log/LoggerFactory.java | 8 +- .../util/push/GCMListenerRouterService.java | 75 ------------------- .../GcmInstanceIDRouterListenerService.java | 24 ------ .../util/statistics/PushwooshHelper.java | 4 - 12 files changed, 8 insertions(+), 290 deletions(-) delete mode 100644 android/flavors/beta/res/values/libnotify.xml delete mode 100644 android/flavors/debug/res/values/libnotify.xml delete mode 100644 android/res/values/libnotify.xml delete mode 100644 android/src/com/mapswithme/util/log/LibnotifyLogReceiver.java delete mode 100644 android/src/com/mapswithme/util/push/GCMListenerRouterService.java delete mode 100644 android/src/com/mapswithme/util/push/GcmInstanceIDRouterListenerService.java diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 2f89c9d509..795a683e4b 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -474,21 +474,17 @@ - - - + android:name="com.pushwoosh.GCMListenerService" + android:exported="false"> + + + android:name="com.pushwoosh.GCMInstanceIDListenerService" + android:exported="false"> @@ -500,8 +496,7 @@ - - + diff --git a/android/build.gradle b/android/build.gradle index 12f3ec82a0..d7d3f08dd7 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -28,9 +28,6 @@ repositories { maven { url 'https://s3.amazonaws.com/moat-sdk-builds' } - maven { - url 'https://dl.bintray.com/libverify/android' - } } apply plugin: 'com.android.application' @@ -92,18 +89,6 @@ dependencies { implementation 'net.jcip:jcip-annotations:1.0' implementation 'com.android.support:multidex:1.0.3' implementation 'com.appsflyer:af-android-sdk:4.8.3' - implementation ("ru.mail:libnotify:0.1.163-notify-support-v96@aar") { - transitive = true; - changing = true; - exclude group: 'com.android.support' - exclude group: 'com.google.android.gms' - } - implementation ("ru.mail:libnotify-debug:0.1.163-notify-support-v96@aar") { - transitive = true; - changing = true; - exclude group: 'com.android.support' - exclude group: 'com.google.android.gms' - } } def getDate() { diff --git a/android/flavors/beta/res/values/libnotify.xml b/android/flavors/beta/res/values/libnotify.xml deleted file mode 100644 index 0fe07311e4..0000000000 --- a/android/flavors/beta/res/values/libnotify.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - MapsMeBeta - - Notify secured properties will be used here - - drawable/ic_notification - - color/base_accent - - color/text_dark - diff --git a/android/flavors/debug/res/values/libnotify.xml b/android/flavors/debug/res/values/libnotify.xml deleted file mode 100644 index 7c85764e37..0000000000 --- a/android/flavors/debug/res/values/libnotify.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - MapsMeDebug - - Notify secured properties will be used here - - drawable/ic_notification - - color/base_accent - - color/text_dark - diff --git a/android/res/values/libnotify.xml b/android/res/values/libnotify.xml deleted file mode 100644 index b3e6922031..0000000000 --- a/android/res/values/libnotify.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - MapsMe - - Notify secured properties will be used here - - drawable/ic_notification - - color/base_accent - - color/text_dark - diff --git a/android/src/com/mapswithme/maps/MwmApplication.java b/android/src/com/mapswithme/maps/MwmApplication.java index bb005118c5..b24dc0a22e 100644 --- a/android/src/com/mapswithme/maps/MwmApplication.java +++ b/android/src/com/mapswithme/maps/MwmApplication.java @@ -41,9 +41,6 @@ import com.my.tracker.MyTracker; import com.my.tracker.MyTrackerParams; import com.pushwoosh.PushManager; import io.fabric.sdk.android.Fabric; -import ru.mail.libnotify.api.NotificationFactory; -import ru.mail.notify.core.api.BackgroundAwakeMode; -import ru.mail.notify.core.api.NetworkSyncMode; import java.util.List; @@ -168,7 +165,6 @@ public class MwmApplication extends Application private void initCoreIndependentSdks() { initCrashlytics(); - initLibnotify(); initPushWoosh(); initAppsFlyer(); initTracker(); @@ -337,22 +333,6 @@ public class MwmApplication extends Application } } - private void initLibnotify() - { - if (BuildConfig.DEBUG || BuildConfig.BUILD_TYPE.equals("beta")) - { - NotificationFactory.enableDebugMode(); - NotificationFactory.setLogReceiver(LoggerFactory.INSTANCE.createLibnotifyLogger()); - NotificationFactory.setUncaughtExceptionListener((thread, throwable) -> { - Logger l = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.THIRD_PARTY); - l.e("LIBNOTIFY", "Thread: " + thread, throwable); - }); - } - NotificationFactory.setNetworkSyncMode(NetworkSyncMode.WIFI_ONLY); - NotificationFactory.setBackgroundAwakeMode(BackgroundAwakeMode.DISABLED); - NotificationFactory.initialize(this); - } - private void initAppsFlyer() { // There is no necessary to use a conversion data listener for a while. diff --git a/android/src/com/mapswithme/maps/search/SearchFragment.java b/android/src/com/mapswithme/maps/search/SearchFragment.java index d8ce890d48..f52b8a3a4d 100644 --- a/android/src/com/mapswithme/maps/search/SearchFragment.java +++ b/android/src/com/mapswithme/maps/search/SearchFragment.java @@ -41,7 +41,6 @@ import com.mapswithme.util.UiUtils; import com.mapswithme.util.Utils; import com.mapswithme.util.concurrency.UiThread; import com.mapswithme.util.statistics.Statistics; -import ru.mail.libnotify.debug.NotifyDebugActivity; import java.util.ArrayList; import java.util.LinkedList; @@ -519,12 +518,6 @@ public class SearchFragment extends BaseMwmFragment return true; } - if (str.equals("?libnotifyId")) - { - startActivity(new Intent(getContext(), NotifyDebugActivity.class)); - return true; - } - return false; } diff --git a/android/src/com/mapswithme/util/log/LibnotifyLogReceiver.java b/android/src/com/mapswithme/util/log/LibnotifyLogReceiver.java deleted file mode 100644 index a5c3ad2a63..0000000000 --- a/android/src/com/mapswithme/util/log/LibnotifyLogReceiver.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.mapswithme.util.log; - -import ru.mail.notify.core.utils.LogReceiver; - -class LibnotifyLogReceiver implements LogReceiver -{ - private static final Logger LOGGER - = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.THIRD_PARTY); - private static final String TAG = "LIBNOTIFY_"; - @Override - public void v(String tag, String msg) - { - LOGGER.v(TAG + tag, msg); - } - - @Override - public void v(String tag, String msg, Throwable throwable) - { - LOGGER.v(TAG + tag, msg, throwable); - } - - @Override - public void e(String tag, String msg) - { - LOGGER.e(TAG + tag, msg); - } - - @Override - public void e(String tag, String msg, Throwable throwable) - { - LOGGER.e(tag, msg, throwable); - } - - @Override - public void d(String tag, String msg) - { - LOGGER.d(TAG + tag, msg); - } - - @Override - public void d(String tag, String msg, Throwable throwable) - { - LOGGER.d(TAG + tag, msg, throwable); - } -} diff --git a/android/src/com/mapswithme/util/log/LoggerFactory.java b/android/src/com/mapswithme/util/log/LoggerFactory.java index 89782bf4b2..de130074f5 100644 --- a/android/src/com/mapswithme/util/log/LoggerFactory.java +++ b/android/src/com/mapswithme/util/log/LoggerFactory.java @@ -12,7 +12,6 @@ import com.mapswithme.maps.R; import com.mapswithme.util.StorageUtils; import net.jcip.annotations.GuardedBy; import net.jcip.annotations.ThreadSafe; -import ru.mail.notify.core.utils.LogReceiver; import java.io.File; import java.util.EnumMap; @@ -25,7 +24,7 @@ public class LoggerFactory public enum Type { MISC, LOCATION, TRAFFIC, GPS_TRACKING, TRACK_RECORDER, ROUTING, NETWORK, STORAGE, DOWNLOADER, - CORE, THIRD_PARTY + CORE } public interface OnZipCompletedListener @@ -136,11 +135,6 @@ public class LoggerFactory return mFileLoggerExecutor; } - @NonNull - public LogReceiver createLibnotifyLogger() - { - return new LibnotifyLogReceiver(); - } // Called from JNI. @SuppressWarnings("unused") private static void logCoreMessage(int level, String msg) diff --git a/android/src/com/mapswithme/util/push/GCMListenerRouterService.java b/android/src/com/mapswithme/util/push/GCMListenerRouterService.java deleted file mode 100644 index 4bd025a03e..0000000000 --- a/android/src/com/mapswithme/util/push/GCMListenerRouterService.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.mapswithme.util.push; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.text.TextUtils; - -import com.google.android.gms.gcm.GcmListenerService; -import com.google.android.gms.gcm.GcmReceiver; -import com.mapswithme.util.log.Logger; -import com.mapswithme.util.log.LoggerFactory; -import com.pushwoosh.GCMListenerService; -import ru.mail.libnotify.api.NotificationFactory; - -// It's temporary class, it may be deleted along with Pushwoosh sdk. -// The base of this code is taken from https://www.pushwoosh.com/docs/gcm-integration-legacy. -public class GCMListenerRouterService extends GcmListenerService -{ - private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.THIRD_PARTY); - private static final String TAG = GCMListenerRouterService.class.getSimpleName(); - @Override - public void onMessageReceived(@Nullable String from, @Nullable Bundle data) { - LOGGER.i(TAG, "Gcm router service received message: " - + (data != null ? data.toString() : "") + " from: " + from); - - if (data == null || TextUtils.isEmpty(from)) - return; - - // Base GCM listener service removes this extra before calling onMessageReceived. - // Need to set it again to pass intent to another service. - data.putString("from", from); - - String pwProjectId = getPWProjectId(getApplicationContext()); - if (!TextUtils.isEmpty(pwProjectId) && pwProjectId.contains(from)) { - dispatchMessage(GCMListenerService.class.getName(), data); - return; - } - - NotificationFactory.deliverGcmMessageIntent(this, from, data); - } - - @Nullable - private static String getPWProjectId(@NonNull Context context) - { - PackageManager pMngr = context.getPackageManager(); - try - { - ApplicationInfo ai = pMngr.getApplicationInfo(context.getPackageName(), PackageManager - .GET_META_DATA); - Bundle metaData = ai.metaData; - if (metaData == null) - return null; - return metaData.getString("PW_PROJECT_ID"); - } - catch (PackageManager.NameNotFoundException e) - { - LOGGER.e(TAG, "Failed to get push woosh projectId: ", e); - } - return null; - } - - private void dispatchMessage(@NonNull String component, @NonNull Bundle data) { - Intent intent = new Intent(); - intent.putExtras(data); - intent.setAction("com.google.android.c2dm.intent.RECEIVE"); - intent.setComponent(new ComponentName(getPackageName(), component)); - - GcmReceiver.startWakefulService(getApplicationContext(), intent); - } -} diff --git a/android/src/com/mapswithme/util/push/GcmInstanceIDRouterListenerService.java b/android/src/com/mapswithme/util/push/GcmInstanceIDRouterListenerService.java deleted file mode 100644 index 06658a2c5e..0000000000 --- a/android/src/com/mapswithme/util/push/GcmInstanceIDRouterListenerService.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.mapswithme.util.push; - -import android.content.Intent; - -import com.google.android.gms.iid.InstanceIDListenerService; -import com.mapswithme.util.log.Logger; -import com.mapswithme.util.log.LoggerFactory; -import com.pushwoosh.GCMInstanceIDListenerService; -import ru.mail.libnotify.api.NotificationFactory; - -public class GcmInstanceIDRouterListenerService extends InstanceIDListenerService -{ - @Override - public void onTokenRefresh() - { - super.onTokenRefresh(); - Logger l = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.THIRD_PARTY); - l.i(GcmInstanceIDRouterListenerService.class.getSimpleName(), "onTokenRefresh()"); - Intent pwIntent = new Intent(this, GCMInstanceIDListenerService.class); - pwIntent.setAction("com.google.android.gms.iid.InstanceID"); - startService(pwIntent); - NotificationFactory.refreshGcmToken(this); - } -} diff --git a/android/src/com/mapswithme/util/statistics/PushwooshHelper.java b/android/src/com/mapswithme/util/statistics/PushwooshHelper.java index f59031d1a6..f72f033ee0 100644 --- a/android/src/com/mapswithme/util/statistics/PushwooshHelper.java +++ b/android/src/com/mapswithme/util/statistics/PushwooshHelper.java @@ -5,12 +5,10 @@ import android.os.AsyncTask; import android.os.Handler; import android.os.Looper; -import com.mapswithme.maps.MwmApplication; import com.mapswithme.util.log.Logger; import com.mapswithme.util.log.LoggerFactory; import com.pushwoosh.PushManager; import com.pushwoosh.SendPushTagsCallBack; -import ru.mail.libnotify.api.NotificationFactory; import java.lang.ref.WeakReference; import java.util.HashMap; @@ -55,8 +53,6 @@ public final class PushwooshHelper implements SendPushTagsCallBack private void sendTags(Map tags) { - //TODO: move notifylib code to another place when Pushwoosh is deleted. - NotificationFactory.get(MwmApplication.get()).collectEventBatch(tags); synchronized (mSyncObject) { if (!canSendTags())