blob: 84fa4842b4086d560658ba5d187ff907a0cc7074 (
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
50
51
52
53
54
55
|
package com.mapswithme.maps.background;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
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)
{
if (intent == null)
{
LOGGER.w(getTag(), "An intent with null intent detected");
return;
}
String action = intent.getAction();
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);
}
|