diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8326e189..7686765c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -22,6 +22,7 @@ jobs:
java_version: [1.8]
node_version: [16]
ruby_version: ['3.0']
+ rust_build: [false] # if true, will build aw-server-rust, otherwise will fetch artifact from recent CI run
steps:
- uses: actions/checkout@v2
with:
@@ -42,11 +43,8 @@ jobs:
# Android SDK & NDK
- name: Set up Android SDK
uses: android-actions/setup-android@v2
- - name: Set up Android NDK
- uses: nttld/setup-ndk@v1
- id: setup-ndk
- with:
- ndk-version: r21d
+ - name: Install NDK
+ run: sdkmanager "ndk;25.0.8775105"
- name: Set up Node
uses: actions/setup-node@v1
@@ -79,6 +77,7 @@ jobs:
${{ runner.os }}-${{ env.cache-name }}-
- name: Cache cargo build
uses: actions/cache@v1
+ if: ${{ matrix.rust_build == 'true' }}
env:
cache-name: cargo-build-target
with:
@@ -90,26 +89,54 @@ jobs:
# Install fastlane
- name: Install fastlane
run: |
- gem install bundle
+ gem install bundler
bundle install
# Set up Rust toolchain
- name: Set up Rust toolchain for Android NDK
- env:
- ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
- ./aw-server-rust/install-ndk.sh
+ ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk-bundle ./aw-server-rust/install-ndk.sh
# Test
- name: Test
run: |
make test
- # Build
- - name: Build
+ # Build webui
+ - name: Build webui
+ run: |
+ make aw-webui
+
+ # Build or fetch aw-server-rust artifacts
+ - name: Build aw-server-rust
+ if: ${{ matrix.rust_build == 'true' }}
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
- make build
+ make aw-server-rust
+ - name: Download artifact
+ uses: dawidd6/action-download-artifact@v2
+ if: ${{ !(matrix.rust_build == 'true') }}
+ with:
+ repo: ActivityWatch/aw-server-rust
+ branch: master
+ workflow: build.yml
+ # Optional, uploaded artifact name,
+ # will download all artifacts if not specified
+ # and extract them in respective subdirectories
+ # https://github.com/actions/download-artifact#download-all-artifacts
+ name: binaries-android
+ path: aw-server-rust/
+ # Optional, the status or conclusion of a completed workflow to search for
+ # Can be one of a workflow conculsion::
+ # "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required"
+ # Or a workflow status:
+ # "completed", "in_progress", "queued"
+ # Default: "completed"
+ workflow_conclusion: success
- # TODO: Do release stuff
+ - name: Assemble APK
+ run: |
+ # TODO: Replace with ./scripts/build_apk.sh and related stuff in .travis.yml
+ ./gradlew assembleRelease
+ # TODO: Do other release stuff
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 00000000..61a9130c
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 00000000..a5f05cd8
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 10118312..acbf1e13 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 85849833..94a25f7f 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,9 +2,5 @@
-
-
-
-
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 42712ccd..d4c55139 100644
--- a/Makefile
+++ b/Makefile
@@ -50,14 +50,15 @@ $(JNI_x64)/libaw_server.so: $(TARGET_x64)/$(RELEASE_TYPE)/libaw_server.so
mkdir -p $$(dirname $@)
ln -sfnv $$(pwd)/$^ $@
+RUSTFLAGS_ANDROID="-C debuginfo=2 -Awarnings"
+# Explanation of RUSTFLAGS:
+# `-Awarnings` allows all warnings, for cleaner output (warnings should be detected in aw-server-rust CI anyway)
+# `-C debuginfo=2` is to keep debug symbols, even in release builds (later stripped by gradle on production builds, non-stripped versions needed for stack resymbolizing with ndk-stack)
+
# This target runs multiple times because it's matched multiple times, not sure how to fix
$(RS_SRCDIR)/target/%/$(RELEASE_TYPE)/libaw_server.so: $(RS_SOURCES)
echo $@
- cd aw-server-rust && env RUSTFLAGS="-C debuginfo=2 -Awarnings" bash compile-android.sh
-# Explanation of RUSTFLAGS:
-# `-Awarnings` allows all warnings, for cleaner output (warnings should be detected in aw-server-rust CI anyway)
-# `-C debuginfo=2` is to keep debug symbols, even in release builds (later stripped by gradle on production builds, non-stripped versions needed for stack resymbolizing with ndk-stack)
-
+ env RUSTFLAGS=$(RUSTFLAGS_ANDROID) make -C aw-server-rust android
# aw-webui
diff --git a/build.gradle b/build.gradle
index cc4a60fb..aa773a3e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = '1.2.71'
+ ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
@@ -10,7 +10,7 @@ buildscript {
}
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.2.1'
+ classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.8.3'
@@ -26,6 +26,16 @@ allprojects {
}
}
+// Ignore indexing of some subdirectories
+apply plugin: 'idea'
+idea {
+ module {
+ excludeDirs += file('aw-server-rust')
+ excludeDirs += file('vendor')
+ excludeDirs += file('NDK')
+ }
+}
+
task clean(type: Delete) {
delete rootProject.buildDir
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 9a4163a4..622ab64a 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/mobile/build.gradle b/mobile/build.gradle
index daafb8d3..2a9ae149 100644
--- a/mobile/build.gradle
+++ b/mobile/build.gradle
@@ -1,28 +1,29 @@
apply plugin: 'com.android.application'
-
apply plugin: 'kotlin-android'
-
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
+ buildToolsVersion = '29.0.3'
+ ndkVersion "25.0.8775105"
+
defaultConfig {
applicationId "net.activitywatch.android"
minSdkVersion 23
targetSdkVersion 29
// Set in CI on tagged commit
- versionName "0.10-dev"
+ versionName "0.10.0"
// Set in CI by `bundle exec fastlane update_version`
- versionCode 22
+ versionCode 25
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// WARNING: Never commit this uncommented!
- //packagingOptions {
- // doNotStrip '**/*.so'
- //}
+ packagingOptions {
+ doNotStrip '**/*.so'
+ }
}
buildTypes {
release {
@@ -37,7 +38,6 @@ android {
sourceCompatibility = "1.8"
targetCompatibility = 1.8
}
- buildToolsVersion = '29.0.3'
// Never got this to work...
//if (project.hasProperty("doNotStrip")) {
@@ -57,20 +57,20 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.annotation:annotation:1.1.0'
- implementation 'com.google.android.material:material:1.1.0'
+ implementation 'com.google.android.material:material:1.3.0'
implementation 'com.jakewharton.threetenabp:threetenabp:1.1.1'
testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test.ext:junit:1.1.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
// Can be used to build with: ./gradlew cargoBuild
diff --git a/mobile/src/main/java/net/activitywatch/android/RustInterface.kt b/mobile/src/main/java/net/activitywatch/android/RustInterface.kt
index ddc9ab45..e6a9f007 100644
--- a/mobile/src/main/java/net/activitywatch/android/RustInterface.kt
+++ b/mobile/src/main/java/net/activitywatch/android/RustInterface.kt
@@ -17,7 +17,7 @@ class RustInterface constructor(context: Context? = null) {
init {
// NOTE: This doesn't work, probably because I can't get gradle to not strip symbols on release builds
- //Os.setenv("RUST_BACKTRACE", "1", true)
+ Os.setenv("RUST_BACKTRACE", "1", true)
if(context != null) {
Os.setenv("SQLITE_TMPDIR", context.cacheDir.absolutePath, true)
diff --git a/mobile/src/main/java/net/activitywatch/android/watcher/UsageStatsWatcher.kt b/mobile/src/main/java/net/activitywatch/android/watcher/UsageStatsWatcher.kt
index b339cbdc..8e04fc8f 100644
--- a/mobile/src/main/java/net/activitywatch/android/watcher/UsageStatsWatcher.kt
+++ b/mobile/src/main/java/net/activitywatch/android/watcher/UsageStatsWatcher.kt
@@ -152,11 +152,18 @@ class UsageStatsWatcher constructor(val context: Context) {
val usm = getUSM() ?: return 0
+ // Store activities here that have had a RESUMED but not a PAUSED event.
+ // (to handle out-of-order events)
+ //val activeActivities = [];
+
+ // TODO: Fix issues that occur when usage stats events are out of order (RESUME before PAUSED)
var heartbeatsSent = 0
val usageEvents = usm.queryEvents(lastUpdated?.toEpochMilli() ?: 0L, Long.MAX_VALUE)
nextEvent@ while(usageEvents.hasNextEvent()) {
val event = UsageEvents.Event()
usageEvents.getNextEvent(event)
+
+ // Log screen unlock
if(event.eventType !in arrayListOf(UsageEvents.Event.ACTIVITY_RESUMED, UsageEvents.Event.ACTIVITY_PAUSED)) {
if(event.eventType == UsageEvents.Event.KEYGUARD_HIDDEN){
val timestamp = DateTimeUtils.toInstant(java.util.Date(event.timeStamp))
@@ -169,6 +176,8 @@ class UsageStatsWatcher constructor(val context: Context) {
//Log.d(TAG, "Rare eventType: ${event.eventType}, skipping")
continue@nextEvent
}
+
+ // Log activity
val awEvent = Event.fromUsageEvent(event, context, includeClassname = true)
val pulsetime: Double
when(event.eventType) {
diff --git a/mobile/src/main/res/values/strings.xml b/mobile/src/main/res/values/strings.xml
index 95f5d8af..bda38f7d 100644
--- a/mobile/src/main/res/values/strings.xml
+++ b/mobile/src/main/res/values/strings.xml
@@ -21,6 +21,9 @@
Click me to log data!
Allows ActivityWatch to read the URL and title from your browser.
+
+ unknown version
+
Hello blank fragment