diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
index 5d99727475..3122eb73e5 100644
--- a/android/AndroidManifest.xml
+++ b/android/AndroidManifest.xml
@@ -26,6 +26,15 @@
+
@@ -260,12 +269,7 @@
android:name="com.mapswithme.maps.settings.DrivingOptionsActivity"
android:label="@string/driving_options_title"/>
-
-
@@ -279,20 +283,6 @@
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false"/>
-
-
-
-
-
-
-
-
-
diff --git a/android/src/com/mapswithme/maps/MwmBroadcastReceiver.java b/android/src/com/mapswithme/maps/MwmBroadcastReceiver.java
index 10fd316ab8..ab22750aec 100644
--- a/android/src/com/mapswithme/maps/MwmBroadcastReceiver.java
+++ b/android/src/com/mapswithme/maps/MwmBroadcastReceiver.java
@@ -3,21 +3,40 @@ package com.mapswithme.maps;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.util.Log;
import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-public abstract class MwmBroadcastReceiver extends BroadcastReceiver {
+import com.mapswithme.util.CrashlyticsUtils;
+import com.mapswithme.util.log.Logger;
+import com.mapswithme.util.log.LoggerFactory;
- protected abstract void onReceiveInitialized(@NonNull Context context, @Nullable Intent intent);
+public abstract class MwmBroadcastReceiver extends BroadcastReceiver
+{
+ private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
- @Override
- public final void onReceive(Context context, Intent intent)
+ @NonNull
+ protected String getTag()
+ {
+ return getClass().getSimpleName();
+ }
+
+ protected abstract void onReceiveInitialized(@NonNull Context context, @NonNull Intent intent);
+
+ @Override
+ public final void onReceive(@NonNull Context context, @NonNull Intent intent)
+ {
+ MwmApplication app = MwmApplication.from(context);
+ String msg = "onReceive: " + intent;
+ LOGGER.i(getTag(), msg);
+ CrashlyticsUtils.INSTANCE.log(Log.INFO, getTag(), msg);
+ if (!app.arePlatformAndCoreInitialized() && !app.initCore())
{
- MwmApplication app = MwmApplication.from(context);
- if (!app.arePlatformAndCoreInitialized() && !app.initCore())
- return;
- onReceiveInitialized(context, intent);
+ LOGGER.w(getTag(), "Application is not initialized, ignoring " + intent);
+ return;
}
+ onReceiveInitialized(context, intent);
+ }
+
}
diff --git a/android/src/com/mapswithme/maps/MwmJobIntentService.java b/android/src/com/mapswithme/maps/MwmJobIntentService.java
new file mode 100644
index 0000000000..178e9a7345
--- /dev/null
+++ b/android/src/com/mapswithme/maps/MwmJobIntentService.java
@@ -0,0 +1,39 @@
+package com.mapswithme.maps;
+
+import android.content.Intent;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+import androidx.core.app.JobIntentService;
+
+import com.mapswithme.util.CrashlyticsUtils;
+import com.mapswithme.util.log.Logger;
+import com.mapswithme.util.log.LoggerFactory;
+
+public abstract class MwmJobIntentService extends JobIntentService
+{
+ private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
+
+ @NonNull
+ protected String getTag()
+ {
+ return getClass().getSimpleName();
+ }
+
+ protected abstract void onHandleWorkInitialized(@NonNull Intent intent);
+
+ @Override
+ protected void onHandleWork(@NonNull Intent intent)
+ {
+ MwmApplication app = MwmApplication.from(this);
+ String msg = "onHandleWork: " + intent;
+ LOGGER.i(getTag(), msg);
+ CrashlyticsUtils.INSTANCE.log(Log.INFO, getTag(), msg);
+ if (!app.arePlatformAndCoreInitialized() && !app.initCore())
+ {
+ LOGGER.w(getTag(), "Application is not initialized, ignoring " + intent);
+ return;
+ }
+ onHandleWorkInitialized(intent);
+ }
+}
diff --git a/android/src/com/mapswithme/maps/background/AbstractLogBroadcastReceiver.java b/android/src/com/mapswithme/maps/background/AbstractLogBroadcastReceiver.java
deleted file mode 100644
index a8bb0b7a6f..0000000000
--- a/android/src/com/mapswithme/maps/background/AbstractLogBroadcastReceiver.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.mapswithme.maps.background;
-
-import static com.mapswithme.maps.MwmApplication.backgroundTracker;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.text.TextUtils;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-
-import com.mapswithme.util.CrashlyticsUtils;
-import com.mapswithme.util.log.Logger;
-import com.mapswithme.util.log.LoggerFactory;
-
-public abstract class AbstractLogBroadcastReceiver extends BroadcastReceiver
-{
- private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
-
- @Override
- public final void onReceive(Context context, Intent intent)
- {
- String action = intent != null ? intent.getAction() : null;
- if (!TextUtils.equals(getAssertAction(), action))
- {
- LOGGER.w(getTag(), "An intent with wrong action detected: " + action);
- return;
- }
-
- String msg = "onReceive: " + intent + " app in background = "
- + !backgroundTracker(context).isForeground();
- LOGGER.i(getTag(), msg);
- CrashlyticsUtils.INSTANCE.log(Log.INFO, getTag(), msg);
- onReceiveInternal(context, intent);
- }
-
- @NonNull
- protected String getTag()
- {
- return getClass().getSimpleName();
- }
-
- @NonNull
- protected abstract String getAssertAction();
-
- @SuppressWarnings("unused")
- public abstract void onReceiveInternal(@NonNull Context context, @NonNull Intent intent);
-}
diff --git a/android/src/com/mapswithme/maps/background/ConnectivityChangedReceiver.java b/android/src/com/mapswithme/maps/background/ConnectivityChangedReceiver.java
deleted file mode 100644
index 3f1ce9fea1..0000000000
--- a/android/src/com/mapswithme/maps/background/ConnectivityChangedReceiver.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.mapswithme.maps.background;
-
-import android.content.Context;
-import android.content.Intent;
-import android.net.ConnectivityManager;
-
-import androidx.annotation.NonNull;
-
-public class ConnectivityChangedReceiver extends AbstractLogBroadcastReceiver
-{
-
- @Override
- public void onReceiveInternal(@NonNull Context context, @NonNull Intent intent)
- {
- }
-
- @NonNull
- @Override
- protected String getAssertAction()
- {
- return ConnectivityManager.CONNECTIVITY_ACTION;
- }
-}
diff --git a/android/src/com/mapswithme/maps/background/NotificationService.java b/android/src/com/mapswithme/maps/background/NotificationService.java
deleted file mode 100644
index 0ac6bd0cf4..0000000000
--- a/android/src/com/mapswithme/maps/background/NotificationService.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package com.mapswithme.maps.background;
-
-import static android.net.ConnectivityManager.CONNECTIVITY_ACTION;
-import static com.mapswithme.maps.MwmApplication.prefs;
-
-import android.content.Context;
-import android.content.Intent;
-import android.net.ConnectivityManager;
-
-import androidx.annotation.NonNull;
-import androidx.core.app.JobIntentService;
-
-import com.mapswithme.maps.MwmApplication;
-import com.mapswithme.maps.routing.RoutingController;
-import com.mapswithme.maps.scheduling.JobIdMap;
-import com.mapswithme.util.PermissionsUtils;
-import com.mapswithme.util.log.Logger;
-import com.mapswithme.util.log.LoggerFactory;
-
-public class NotificationService extends JobIntentService
-{
- private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
- private static final String TAG = NotificationService.class.getSimpleName();
- private static final String LAST_AUTH_NOTIFICATION_TIMESTAMP = "DownloadOrUpdateTimestamp";
-
- private interface NotificationExecutor
- {
- boolean tryToNotify();
- }
-
- public static void startOnConnectivityChanged(@NonNull Context context)
- {
- final Intent intent = new Intent(context, NotificationService.class)
- .setAction(CONNECTIVITY_ACTION);
-
- int id = JobIdMap.getId(NotificationService.class);
- JobIntentService.enqueueWork(context, NotificationService.class, id, intent);
- }
-
- private boolean notifyIsNotAuthenticated()
- {
- final long lastEventTimestamp = prefs(this)
- .getLong(LAST_AUTH_NOTIFICATION_TIMESTAMP, 0);
-
-// if (System.currentTimeMillis() - lastEventTimestamp > MIN_AUTH_EVENT_DELTA_MILLIS)
-// {
-// LOGGER.d(TAG, "Authentication notification will be sent.");
-//
-// prefs(this).edit().putLong(LAST_AUTH_NOTIFICATION_TIMESTAMP, System.currentTimeMillis()).apply();
-//
-// Notifier notifier = Notifier.from(getApplication());
-// notifier.notifyAuthentication();
-//
-// return true;
-// }
- LOGGER.d(TAG, "Authentication notification is rejected. Last event timestamp: " +
- lastEventTimestamp + "Current time milliseconds: " + System.currentTimeMillis());
- return false;
- }
-
- private boolean notifySmart()
- {
- return false;
- }
-
- @Override
- protected void onHandleWork(@NonNull Intent intent)
- {
- final String action = intent.getAction();
-
- if (ConnectivityManager.CONNECTIVITY_ACTION.equals(action))
- tryToShowNotification();
- }
-
- private void tryToShowNotification()
- {
- if (!PermissionsUtils.isLocationGranted(this))
- {
- LOGGER.d(TAG, "Notification is rejected. Location permission is not granted.");
- return;
- }
-
- // Do not show push when user is in the navigation mode.
- if (MwmApplication.from(this).arePlatformAndCoreInitialized()
- && RoutingController.get().isNavigating())
- {
- LOGGER.d(TAG, "Notification is rejected. The user is in navigation mode.");
- return;
- }
-
- final NotificationExecutor[] notifyOrder =
- {
- this::notifyIsNotAuthenticated,
- this::notifySmart
- };
-
- // Only one notification should be shown at a time.
- for (NotificationExecutor executor : notifyOrder)
- {
- if (executor.tryToNotify())
- return;
- }
- }
-}
diff --git a/android/src/com/mapswithme/maps/background/Notifier.java b/android/src/com/mapswithme/maps/background/Notifier.java
index 084497c517..1941249def 100644
--- a/android/src/com/mapswithme/maps/background/Notifier.java
+++ b/android/src/com/mapswithme/maps/background/Notifier.java
@@ -57,25 +57,6 @@ public final class Notifier
placeNotification(title, content, pi, ID_DOWNLOAD_FAILED, channel);
}
-// void notifyAuthentication()
-// {
-// Intent authIntent = MwmActivity.createAuthenticateIntent(mContext);
-// authIntent.putExtra(EXTRA_CANCEL_NOTIFICATION, Notifier.ID_IS_NOT_AUTHENTICATED);
-// PendingIntent pi = PendingIntent.getActivity(mContext, 0, authIntent,
-// PendingIntent.FLAG_UPDATE_CURRENT);
-//
-// String channel = NotificationChannelFactory.createProvider(mContext).getUGCChannel();
-// NotificationCompat.Builder builder =
-// getBuilder(mContext.getString(R.string.notification_unsent_reviews_title),
-// mContext.getString(R.string.notification_unsent_reviews_message),
-// pi, channel);
-//
-// builder.addAction(0, mContext.getString(R.string.authorization_button_sign_in), pi);
-//
-// getNotificationManager().notify(ID_IS_NOT_AUTHENTICATED, builder.build());
-//
-// }
-
public void cancelNotification(@NotificationId int id)
{
if (id == ID_NONE)
@@ -95,11 +76,6 @@ public final class Notifier
int notificationId = intent.getIntExtra(Notifier.EXTRA_CANCEL_NOTIFICATION, Notifier.ID_NONE);
cancelNotification(notificationId);
}
-
- if (intent.hasExtra(Notifier.EXTRA_NOTIFICATION_CLICKED))
- {
- String eventName = intent.getStringExtra(Notifier.EXTRA_NOTIFICATION_CLICKED);
- }
}
private void placeNotification(String title, String content, PendingIntent pendingIntent,
diff --git a/android/src/com/mapswithme/maps/background/OreoCompatNotificationChannelProvider.java b/android/src/com/mapswithme/maps/background/OreoCompatNotificationChannelProvider.java
index e262e3c310..34c31191dc 100644
--- a/android/src/com/mapswithme/maps/background/OreoCompatNotificationChannelProvider.java
+++ b/android/src/com/mapswithme/maps/background/OreoCompatNotificationChannelProvider.java
@@ -15,12 +15,11 @@ import java.util.Objects;
@TargetApi(Build.VERSION_CODES.O)
public class OreoCompatNotificationChannelProvider extends StubNotificationChannelProvider
{
- private static final String AUTH_NOTIFICATION_CHANNEL = "auth_notification_channel";
private static final String DOWNLOADING_NOTIFICATION_CHANNEL = "downloading_notification_channel";
OreoCompatNotificationChannelProvider(@NonNull Application app)
{
- super(app, AUTH_NOTIFICATION_CHANNEL, DOWNLOADING_NOTIFICATION_CHANNEL);
+ super(app, DOWNLOADING_NOTIFICATION_CHANNEL);
}
private void setChannelInternal(@NonNull String id, @NonNull String name)
diff --git a/android/src/com/mapswithme/maps/background/OsmUploadService.java b/android/src/com/mapswithme/maps/background/OsmUploadService.java
new file mode 100644
index 0000000000..e9b02e2472
--- /dev/null
+++ b/android/src/com/mapswithme/maps/background/OsmUploadService.java
@@ -0,0 +1,31 @@
+package com.mapswithme.maps.background;
+
+import android.content.Context;
+import android.content.Intent;
+
+import androidx.annotation.NonNull;
+import androidx.core.app.JobIntentService;
+
+import com.mapswithme.maps.MwmJobIntentService;
+import com.mapswithme.maps.editor.Editor;
+import com.mapswithme.maps.scheduling.JobIdMap;
+
+public class OsmUploadService extends MwmJobIntentService
+{
+ /**
+ * Starts this service to upload map edits to osm servers.
+ */
+ public static void startActionUploadOsmChanges(@NonNull Context context)
+ {
+ final Intent intent = new Intent(context, OsmUploadService.class);
+ JobIntentService.enqueueWork(context.getApplicationContext(), OsmUploadService.class,
+ JobIdMap.getId(OsmUploadService.class), intent);
+ }
+
+ @Override
+ protected void onHandleWorkInitialized(@NonNull Intent intent)
+ {
+ final Context context = getApplicationContext();
+ Editor.uploadChanges(context);
+ }
+}
diff --git a/android/src/com/mapswithme/maps/background/StubNotificationChannelProvider.java b/android/src/com/mapswithme/maps/background/StubNotificationChannelProvider.java
index e0a2d64b8c..6c562fb915 100644
--- a/android/src/com/mapswithme/maps/background/StubNotificationChannelProvider.java
+++ b/android/src/com/mapswithme/maps/background/StubNotificationChannelProvider.java
@@ -11,24 +11,19 @@ public class StubNotificationChannelProvider implements NotificationChannelProvi
@NonNull
private final Application mApplication;
- @NonNull
- private final String mAuthChannel;
-
@NonNull
private final String mDownloadingChannel;
- StubNotificationChannelProvider(@NonNull Application context, @NonNull String authChannel,
- @NonNull String downloadingChannel)
+ StubNotificationChannelProvider(@NonNull Application context, @NonNull String downloadingChannel)
{
mApplication = context;
- mAuthChannel = authChannel;
mDownloadingChannel = downloadingChannel;
}
StubNotificationChannelProvider(@NonNull Application context)
{
- this(context, DEFAULT_NOTIFICATION_CHANNEL, DEFAULT_NOTIFICATION_CHANNEL);
+ this(context, DEFAULT_NOTIFICATION_CHANNEL);
}
@NonNull
diff --git a/android/src/com/mapswithme/maps/background/WorkerService.java b/android/src/com/mapswithme/maps/background/WorkerService.java
deleted file mode 100644
index 96c835366b..0000000000
--- a/android/src/com/mapswithme/maps/background/WorkerService.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.mapswithme.maps.background;
-
-import android.content.Context;
-import android.content.Intent;
-import android.text.TextUtils;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.core.app.JobIntentService;
-
-import com.mapswithme.maps.MwmApplication;
-import com.mapswithme.maps.editor.Editor;
-import com.mapswithme.maps.scheduling.JobIdMap;
-import com.mapswithme.util.CrashlyticsUtils;
-import com.mapswithme.util.log.Logger;
-import com.mapswithme.util.log.LoggerFactory;
-
-public class WorkerService extends JobIntentService
-{
- private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
- private static final String TAG = WorkerService.class.getSimpleName();
- private static final String ACTION_UPLOAD_OSM_CHANGES = "com.mapswithme.maps.action.upload_osm_changes";
-
- /**
- * Starts this service to upload map edits to osm servers.
- */
- public static void startActionUploadOsmChanges(@NonNull Context context)
- {
- final Intent intent = new Intent(context, WorkerService.class);
- intent.setAction(WorkerService.ACTION_UPLOAD_OSM_CHANGES);
- JobIntentService.enqueueWork(context.getApplicationContext(), WorkerService.class,
- JobIdMap.getId(WorkerService.class), intent);
- }
-
- @Override
- protected void onHandleWork(@NonNull Intent intent)
- {
- final Context context = getApplicationContext();
- String msg = "onHandleIntent: " + intent + " app in background = "
- + !MwmApplication.backgroundTracker(context).isForeground();
- LOGGER.i(TAG, msg);
- CrashlyticsUtils.INSTANCE.log(Log.INFO, TAG, msg);
- final String action = intent.getAction();
-
- if (TextUtils.isEmpty(action))
- return;
-
- if (!MwmApplication.from(context).arePlatformAndCoreInitialized())
- return;
-
- switch (action)
- {
- case ACTION_UPLOAD_OSM_CHANGES:
- handleActionUploadOsmChanges(context);
- break;
- }
- }
-
- private static void handleActionUploadOsmChanges(@NonNull Context context)
- {
- Editor.uploadChanges(context);
- }
-}
diff --git a/android/src/com/mapswithme/maps/bookmarks/SystemDownloadCompletedReceiver.java b/android/src/com/mapswithme/maps/bookmarks/SystemDownloadCompletedReceiver.java
deleted file mode 100644
index 5d4591d284..0000000000
--- a/android/src/com/mapswithme/maps/bookmarks/SystemDownloadCompletedReceiver.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.mapswithme.maps.bookmarks;
-
-import android.app.DownloadManager;
-import android.content.Context;
-import android.content.Intent;
-
-import androidx.annotation.NonNull;
-import androidx.core.app.JobIntentService;
-
-import com.mapswithme.maps.background.AbstractLogBroadcastReceiver;
-import com.mapswithme.maps.scheduling.JobIdMap;
-
-public class SystemDownloadCompletedReceiver extends AbstractLogBroadcastReceiver
-{
- @NonNull
- @Override
- protected String getAssertAction()
- {
- return DownloadManager.ACTION_DOWNLOAD_COMPLETE;
- }
-
- @Override
- public void onReceiveInternal(@NonNull Context context, @NonNull Intent intent)
- {
- DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
- if (manager == null)
- return;
- intent.setClass(context, SystemDownloadCompletedService.class);
- int jobId = JobIdMap.getId(SystemDownloadCompletedService.class);
- JobIntentService.enqueueWork(context, SystemDownloadCompletedService.class, jobId, intent);
- }
-}
diff --git a/android/src/com/mapswithme/maps/bookmarks/SystemDownloadCompletedService.java b/android/src/com/mapswithme/maps/bookmarks/SystemDownloadCompletedService.java
deleted file mode 100644
index 07b492413f..0000000000
--- a/android/src/com/mapswithme/maps/bookmarks/SystemDownloadCompletedService.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package com.mapswithme.maps.bookmarks;
-
-import android.app.DownloadManager;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.net.Uri;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.app.JobIntentService;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-
-import com.mapswithme.maps.MwmApplication;
-import com.mapswithme.maps.bookmarks.data.Error;
-import com.mapswithme.maps.bookmarks.data.Result;
-import com.mapswithme.util.Utils;
-import com.mapswithme.util.concurrency.UiThread;
-import com.mapswithme.util.log.Logger;
-import com.mapswithme.util.log.LoggerFactory;
-
-import java.io.IOException;
-
-public class SystemDownloadCompletedService extends JobIntentService
-{
- public final static String ACTION_DOWNLOAD_COMPLETED = "action_download_completed";
- public final static String EXTRA_DOWNLOAD_STATUS = "extra_download_status";
-
- @Override
- public void onCreate()
- {
- super.onCreate();
- MwmApplication app = (MwmApplication) getApplication();
- if (app.arePlatformAndCoreInitialized())
- return;
- app.initCore();
- }
-
- @Override
- protected void onHandleWork(@NonNull Intent intent)
- {
- DownloadManager manager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
- if (manager == null)
- throw new IllegalStateException("Failed to get a download manager");
-
- final OperationStatus status = calculateStatus(manager, intent);
- Logger logger = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.BILLING);
- String tag = SystemDownloadCompletedService.class.getSimpleName();
- logger.i(tag, "Download status: " + status);
- UiThread.run(new SendStatusTask(getApplicationContext(), status));
- }
-
- @NonNull
- private OperationStatus calculateStatus(@NonNull DownloadManager manager, @NonNull Intent intent)
- {
- try
- {
- return calculateStatusInternal(manager, intent);
- }
- catch (Exception e)
- {
- return new OperationStatus(null, new Error(e.getMessage()));
- }
- }
-
- @NonNull
- private OperationStatus calculateStatusInternal(
- @NonNull DownloadManager manager, @NonNull Intent intent) throws IOException
- {
- Cursor cursor = null;
- try
- {
- final long id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
- DownloadManager.Query query = new DownloadManager.Query().setFilterById(id);
- cursor = manager.query(query);
- if (cursor.moveToFirst())
- {
-
- if (isDownloadFailed(cursor))
- {
- Error error = new Error(getHttpStatus(cursor), getErrorMessage(cursor));
- return new OperationStatus(null, error);
- }
-
- Result result = new Result(getFilePath(cursor), getArchiveId(cursor));
- return new OperationStatus(result, null);
- }
- throw new IOException("Failed to move the cursor at first row");
- }
- finally
- {
- Utils.closeSafely(cursor);
- }
- }
-
- private static boolean isDownloadFailed(@NonNull Cursor cursor)
- {
- int status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS));
- return status != DownloadManager.STATUS_SUCCESSFUL;
- }
-
- @Nullable
- private static String getFilePath(@NonNull Cursor cursor)
- {
- String localUri = getColumnValue(cursor, DownloadManager.COLUMN_LOCAL_URI);
- return localUri == null ? null : Uri.parse(localUri).getPath();
- }
-
- @Nullable
- private static String getArchiveId(@NonNull Cursor cursor)
- {
- return Uri.parse(getColumnValue(cursor, DownloadManager.COLUMN_URI)).getLastPathSegment();
- }
-
- @Nullable
- private static String getColumnValue(@NonNull Cursor cursor, @NonNull String columnName)
- {
- return cursor.getString(cursor.getColumnIndex(columnName));
- }
-
- private static int getHttpStatus(@NonNull Cursor cursor)
- {
- String rawStatus = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS));
- return Integer.parseInt(rawStatus);
- }
-
- @Nullable
- private static String getErrorMessage(@NonNull Cursor cursor)
- {
- return cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_REASON));
- }
-
- private static class SendStatusTask implements Runnable
- {
- @NonNull
- private final Context mAppContext;
- @NonNull
- private final OperationStatus mStatus;
-
- private SendStatusTask(@NonNull Context applicationContext,
- @NonNull OperationStatus status)
- {
- mAppContext = applicationContext;
- mStatus = status;
- }
-
- @Override
- public void run()
- {
- Intent intent = new Intent(ACTION_DOWNLOAD_COMPLETED);
- intent.putExtra(EXTRA_DOWNLOAD_STATUS, mStatus);
- LocalBroadcastManager.getInstance(mAppContext).sendBroadcast(intent);
- }
- }
-}
diff --git a/android/src/com/mapswithme/maps/editor/Editor.java b/android/src/com/mapswithme/maps/editor/Editor.java
index 9ad1ad6ae0..16900afe94 100644
--- a/android/src/com/mapswithme/maps/editor/Editor.java
+++ b/android/src/com/mapswithme/maps/editor/Editor.java
@@ -11,7 +11,7 @@ import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.background.AppBackgroundTracker;
-import com.mapswithme.maps.background.WorkerService;
+import com.mapswithme.maps.background.OsmUploadService;
import com.mapswithme.maps.editor.data.FeatureCategory;
import com.mapswithme.maps.editor.data.Language;
import com.mapswithme.maps.editor.data.LocalizedName;
@@ -199,7 +199,7 @@ public final class Editor
if (foreground)
return;
- WorkerService.startActionUploadOsmChanges(mContext);
+ OsmUploadService.startActionUploadOsmChanges(mContext);
}
}
}
diff --git a/android/src/com/mapswithme/maps/location/GPSCheck.java b/android/src/com/mapswithme/maps/location/GPSCheck.java
index e7b0b673e2..e51387f0cb 100644
--- a/android/src/com/mapswithme/maps/location/GPSCheck.java
+++ b/android/src/com/mapswithme/maps/location/GPSCheck.java
@@ -1,28 +1,23 @@
package com.mapswithme.maps.location;
-import static com.mapswithme.maps.MwmApplication.backgroundTracker;
-
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.location.LocationManager;
+import android.text.TextUtils;
import com.mapswithme.maps.MwmApplication;
-import com.mapswithme.util.log.Logger;
-import com.mapswithme.util.log.LoggerFactory;
+import com.mapswithme.maps.MwmBroadcastReceiver;
-public class GPSCheck extends BroadcastReceiver
+public class GPSCheck extends MwmBroadcastReceiver
{
- private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.LOCATION);
- private static final String TAG = GPSCheck.class.getSimpleName();
-
@Override
- public void onReceive(Context context, Intent intent)
+ public void onReceiveInitialized(Context context, Intent intent)
{
- String msg = "onReceive: " + intent + " app in background = "
- + !backgroundTracker(context).isForeground();
- LOGGER.i(TAG, msg);
- if (MwmApplication.from(context).arePlatformAndCoreInitialized() &&
- MwmApplication.backgroundTracker(context).isForeground())
+ if (!TextUtils.equals(intent.getAction(), LocationManager.PROVIDERS_CHANGED_ACTION))
+ {
+ throw new AssertionError("An intent with wrong action detected: " + intent.getAction());
+ }
+ if (MwmApplication.backgroundTracker(context).isForeground())
{
LocationHelper.INSTANCE.restart();
}
diff --git a/android/src/com/mapswithme/maps/location/TrackRecorderWakeReceiver.java b/android/src/com/mapswithme/maps/location/TrackRecorderWakeReceiver.java
index 4896b7f6a8..6629812363 100644
--- a/android/src/com/mapswithme/maps/location/TrackRecorderWakeReceiver.java
+++ b/android/src/com/mapswithme/maps/location/TrackRecorderWakeReceiver.java
@@ -1,31 +1,17 @@
package com.mapswithme.maps.location;
-import static com.mapswithme.maps.MwmApplication.backgroundTracker;
-
import android.content.Context;
import android.content.Intent;
-import android.util.Log;
import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import com.mapswithme.maps.MwmBroadcastReceiver;
-import com.mapswithme.util.CrashlyticsUtils;
-import com.mapswithme.util.log.Logger;
-import com.mapswithme.util.log.LoggerFactory;
public class TrackRecorderWakeReceiver extends MwmBroadcastReceiver
{
- private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
- private static final String TAG = TrackRecorderWakeReceiver.class.getSimpleName();
-
@Override
- public void onReceiveInitialized(@NonNull Context context, @Nullable Intent intent)
+ public void onReceiveInitialized(@NonNull Context context, @NonNull Intent intent)
{
- String msg = "onReceive: " + intent + " app in background = "
- + !backgroundTracker(context).isForeground();
- LOGGER.i(TAG, msg);
- CrashlyticsUtils.INSTANCE.log(Log.INFO, TAG, msg);
TrackRecorder.INSTANCE.onWakeAlarm();
}
}
diff --git a/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java b/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java
index 8be9ca5ebd..7b556ecfd2 100644
--- a/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java
+++ b/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java
@@ -9,7 +9,7 @@ import android.util.Log;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
-import com.mapswithme.maps.MwmApplication;
+import com.mapswithme.maps.MwmJobIntentService;
import com.mapswithme.maps.scheduling.JobIdMap;
import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.log.Logger;
@@ -21,7 +21,7 @@ import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-public class TrackRecorderWakeService extends JobIntentService
+public class TrackRecorderWakeService extends MwmJobIntentService
{
private static final String TAG = TrackRecorderWakeService.class.getSimpleName();
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.TRACK_RECORDER);
@@ -30,13 +30,8 @@ public class TrackRecorderWakeService extends JobIntentService
private final CountDownLatch mWaitMonitor = new CountDownLatch(1);
@Override
- protected void onHandleWork(@NonNull Intent intent)
+ protected void onHandleWorkInitialized(@NonNull Intent intent)
{
- String msg = "onHandleIntent: " + intent + " app in background = "
- + !MwmApplication.backgroundTracker(getApplicationContext()).isForeground();
- LOGGER.i(TAG, msg);
- CrashlyticsUtils.INSTANCE.log(Log.INFO, TAG, msg);
-
synchronized (sLock)
{
sService = this;
diff --git a/android/src/com/mapswithme/maps/scheduling/JobIdMap.java b/android/src/com/mapswithme/maps/scheduling/JobIdMap.java
index 57012b3cdd..a6b182e8db 100644
--- a/android/src/com/mapswithme/maps/scheduling/JobIdMap.java
+++ b/android/src/com/mapswithme/maps/scheduling/JobIdMap.java
@@ -1,8 +1,6 @@
package com.mapswithme.maps.scheduling;
-import com.mapswithme.maps.background.NotificationService;
-import com.mapswithme.maps.background.WorkerService;
-import com.mapswithme.maps.bookmarks.SystemDownloadCompletedService;
+import com.mapswithme.maps.background.OsmUploadService;
import com.mapswithme.maps.location.TrackRecorderWakeService;
import java.util.HashMap;
@@ -13,10 +11,8 @@ public class JobIdMap
private static final Map, Integer> MAP = new HashMap<>();
static {
- MAP.put(NotificationService.class, calcIdentifier(MAP.size()));
MAP.put(TrackRecorderWakeService.class, calcIdentifier(MAP.size()));
- MAP.put(SystemDownloadCompletedService.class, calcIdentifier(MAP.size()));
- MAP.put(WorkerService.class, calcIdentifier(MAP.size()));
+ MAP.put(OsmUploadService.class, calcIdentifier(MAP.size()));
}
private static final int ID_BASIC = 1070;