Skip to content

Commit 812ec6c

Browse files
committed
wip
1 parent 25f6218 commit 812ec6c

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

mobile/src/main/java/net/activitywatch/android/RustInterface.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class RustInterface (context: Context? = null) {
4848
external fun createBucket(bucket: String): String
4949
external fun getEvents(bucket_id: String, limit: Int): String
5050
external fun heartbeat(bucket_id: String, event: String, pulsetime: Double): String
51+
external fun query(query: String, timeperiods: String): String
5152

5253
fun sayHello(to: String): String {
5354
return greeting(to)
@@ -172,6 +173,8 @@ class RustInterface (context: Context? = null) {
172173
?: android.os.Build.MODEL ?: "Unknown"
173174
}
174175

176+
fun query
177+
175178
fun test() {
176179
// TODO: Move to instrumented test
177180
Log.w(TAG, sayHello("Android"))
@@ -182,6 +185,9 @@ class RustInterface (context: Context? = null) {
182185
Log.w(TAG, event)
183186
Log.w(TAG, heartbeat("test", event, 60.0))
184187
Log.w(TAG, getBucketsJSON().toString(2))
188+
Log.w(TAG, getBucketsJSON().toString(2))
185189
Log.w(TAG, getEventsJSON("test").toString(2))
190+
val timeintervals = "[${"\""}${Instant.now()}/${Instant.now()}${"\""}]"
191+
Log.w(TAG, query("events = query_bucket(\"test\"); RETURN = events;", timeintervals))
186192
}
187193
}

mobile/src/main/java/net/activitywatch/android/watcher/WebWatcher.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ class WebWatcher : AccessibilityService() {
145145

146146
private fun logBrowserEvent(url: String, browser: String, windowTitle: String, lastUrlTimestamp : Instant) {
147147
val now = Instant.ofEpochMilli(System.currentTimeMillis())
148-
val start = lastUrlTimestamp
149148
val duration = Duration.between(lastUrlTimestamp, now)
150149

151150
val data = JSONObject()
@@ -156,7 +155,7 @@ class WebWatcher : AccessibilityService() {
156155
.put("incognito", false) // TODO
157156

158157
Log.i(tag, "Registered event: $data")
159-
ri?.heartbeatHelper(bucketId, start, duration.seconds.toDouble(), data, 1.0)
158+
ri?.heartbeatHelper(bucketId, lastUrlTimestamp, duration.seconds.toDouble(), data, 1.0)
160159
}
161160

162161
override fun onInterrupt() {}

0 commit comments

Comments
 (0)