Skip to content

Commit

Permalink
Include version in User-Agent via BuildConfig (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave authored Nov 15, 2023
1 parent b1fb189 commit e425133
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 8 additions & 0 deletions divviup/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ android {

ndkVersion = "26.1.10909125"

buildFeatures {
buildConfig = true
}

defaultConfig {
minSdk = 21

version = "0.1.0-SNAPSHOT"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")

buildConfigField("String", "VERSION", "\"" + version.toString() + "\"")
}

buildTypes {
Expand Down
7 changes: 1 addition & 6 deletions divviup/src/main/java/org/divviup/android/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,7 @@ private HpkeConfigList fetchHPKEConfigList(URI aggregatorEndpoint, TaskId taskId
}

private static String getUserAgent() {
Package pkg = Client.class.getPackage();
if (pkg != null) {
return "divviup-android/" + pkg.getImplementationVersion();
} else {
return "divviup-android";
}
return "divviup-android/" + BuildConfig.VERSION;
}

private long reportTimestamp() {
Expand Down

0 comments on commit e425133

Please sign in to comment.