Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed zero-duration bug #40

Merged
merged 4 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aw-server-rust
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class UsageStatsWatcher constructor(val context: Context) {
nextEvent@ while(usageEvents.hasNextEvent()) {
val event = UsageEvents.Event()
usageEvents.getNextEvent(event)
if(event.eventType !in arrayListOf(UsageEvents.Event.ACTIVITY_RESUMED, UsageEvents.Event.ACTIVITY_PAUSED, UsageEvents.Event.SCREEN_INTERACTIVE, UsageEvents.Event.SCREEN_NON_INTERACTIVE)) {
if(event.eventType !in arrayListOf(UsageEvents.Event.ACTIVITY_RESUMED, UsageEvents.Event.ACTIVITY_PAUSED)) {
// Not sure which events are triggered here, so we use a (probably safe) fallback
//Log.d(TAG, "Rare eventType: ${event.eventType}, skipping")
continue@nextEvent
Expand All @@ -164,14 +164,12 @@ class UsageStatsWatcher constructor(val context: Context) {
val awEvent = Event.fromUsageEvent(event, context, includeClassname = true)
val pulsetime: Double
when(event.eventType) {
UsageEvents.Event.ACTIVITY_RESUMED, UsageEvents.Event.SCREEN_INTERACTIVE -> {
// MOVE_TO_FOREGROUND: New Activity was opened
// SCREEN_INTERACTIVE: Screen just became interactive, user was previously therefore not active on the device
UsageEvents.Event.ACTIVITY_RESUMED -> {
// ACTIVITY_RESUMED: Activity was opened/reopened
pulsetime = 1.0
}
UsageEvents.Event.ACTIVITY_PAUSED, UsageEvents.Event.SCREEN_NON_INTERACTIVE -> {
// MOVE_TO_BACKGROUND: Activity was moved to background
// SCREEN_NOT_INTERACTIVE: Screen locked/turned off, user is therefore now AFK, and this is the last event
UsageEvents.Event.ACTIVITY_PAUSED -> {
// ACTIVITY_PAUSED: Activity was moved to background
pulsetime = 24 * 60 * 60.0 // 24h, we will assume events should never grow longer than that
}
else -> {
Expand Down