blob: c98f80b79b593b7c0d8eb7dc98c6cbb74c8925a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package com.mapswithme.maps.background;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
import static com.mapswithme.maps.MwmApplication.backgroundTracker;
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().isForeground();
LOGGER.i(getTag(), msg);
CrashlyticsUtils.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);
}
|