Skip to content
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
53 changes: 40 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 12 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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'

Expand All @@ -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
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
26 changes: 13 additions & 13 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -37,7 +38,6 @@ android {
sourceCompatibility = "1.8"
targetCompatibility = 1.8
}
buildToolsVersion = '29.0.3'

// Never got this to work...
//if (project.hasProperty("doNotStrip")) {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<string name="button_log_text">Click me to log data!</string>
<string name="accessibility_service_description">Allows ActivityWatch to read the URL and title from your browser.</string>

<!-- This is overridden by gradle config -->
<string name="versionName">unknown version</string>

<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>