mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-22 14:11:00 +00:00
Log foreground status
This commit is contained in:
parent
6422b7924f
commit
704a994c7d
2 changed files with 18 additions and 0 deletions
|
@ -897,6 +897,20 @@ public class Helper {
|
|||
SdkExtensions.getExtensionVersion(Build.VERSION_CODES.R) >= 2));
|
||||
}
|
||||
|
||||
static Boolean isOnForeground() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
|
||||
return null;
|
||||
try {
|
||||
ActivityManager.RunningAppProcessInfo appProcessInfo = new ActivityManager.RunningAppProcessInfo();
|
||||
ActivityManager.getMyMemoryState(appProcessInfo);
|
||||
return (appProcessInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND ||
|
||||
appProcessInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// View
|
||||
|
||||
static void setStatusBarColor(Activity activity, Integer color) {
|
||||
|
|
|
@ -468,6 +468,10 @@ public class Log {
|
|||
event.addMetadata("extra", "theme", theme);
|
||||
event.addMetadata("extra", "package", BuildConfig.APPLICATION_ID);
|
||||
event.addMetadata("extra", "locale", Locale.getDefault().toString());
|
||||
|
||||
Boolean foreground = Helper.isOnForeground();
|
||||
if (foreground != null)
|
||||
event.addMetadata("extra", "foreground", Boolean.toString(foreground));
|
||||
}
|
||||
|
||||
return should;
|
||||
|
|
Loading…
Reference in a new issue