Skip to content

Commit a1d66c1

Browse files
authored
feat: Android SDK Testing Relay Client (#70)
1 parent ae5adb8 commit a1d66c1

34 files changed

+1163
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea
5+
.DS_Store
6+
**/build
7+
/captures
8+
.externalNativeBuild
9+
.cxx
10+
local.properties
11+
.idea
12+
tmp
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Eppo SDK Relay App
2+
3+
This app connects to an Eppo Packing Test Runner Server and relays assignment requests to the SDK.
4+
5+
## Running
6+
7+
Build and run the app
8+
9+
```shell
10+
# Uses default version of the SDK (4.2.0)
11+
./gradlew installDebug && \
12+
adb shell am start -n cloud.eppo.android.sdkrelay/.TestClientActivity
13+
```
14+
15+
## Build and run the app with a specific version of the SDK
16+
SDK_VERSION=4.2.0 ./build-and-run.sh
17+
18+
## Build and run the app with the SDK at a specific Github REF
19+
SDK_REF=my/branch/name ./build-and-run.sh
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
2+
3+
plugins {
4+
alias(libs.plugins.android.application)
5+
alias(libs.plugins.jetbrains.kotlin.android)
6+
7+
id("com.ncorti.ktfmt.gradle") version "0.20.1"
8+
}
9+
10+
val apiKey: String = gradleLocalProperties(
11+
project.rootDir,
12+
providers
13+
).getProperty("cloud.eppo.apiKey")
14+
15+
val testRunnerHost: String = System.getenv("TEST_RUNNER_HOST") ?: "http://10.0.2.2"
16+
val testRunnerPort: String = System.getenv("TEST_RUNNER_PORT") ?: "3000"
17+
18+
val eppoAPIHost: String = System.getenv("EPPO_API_HOST") ?: "http://10.0.2.2"
19+
val eppoAPIPort: String = System.getenv("EPPO_API_PORT") ?: "5000"
20+
21+
22+
android {
23+
buildFeatures.buildConfig = true
24+
25+
namespace = "cloud.eppo.android.sdkrelay"
26+
compileSdk = 34
27+
28+
defaultConfig {
29+
applicationId = "cloud.eppo.android.sdkrelay"
30+
minSdk = 26
31+
targetSdk = 34
32+
versionCode = 1
33+
versionName = "1.0"
34+
35+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
36+
vectorDrawables {
37+
useSupportLibrary = true
38+
}
39+
40+
buildConfigField( "String", "API_KEY", "\"" + apiKey + "\"")
41+
buildConfigField( "String", "TEST_RUNNER_HOST", "\"" +testRunnerHost+ "\"")
42+
buildConfigField( "String", "TEST_RUNNER_PORT", "\"" +testRunnerPort+ "\"")
43+
buildConfigField( "String", "EPPO_API_HOST", "\"" +eppoAPIHost+ "\"")
44+
buildConfigField( "String", "EPPO_API_PORT", "\"" +eppoAPIPort+ "\"")
45+
}
46+
47+
buildTypes {
48+
debug {
49+
enableUnitTestCoverage = true
50+
enableAndroidTestCoverage = true
51+
}
52+
release {
53+
isMinifyEnabled = true
54+
isShrinkResources = true
55+
proguardFiles(
56+
getDefaultProguardFile("proguard-android-optimize.txt"),
57+
"proguard-rules.pro"
58+
)
59+
}
60+
}
61+
compileOptions {
62+
sourceCompatibility = JavaVersion.VERSION_1_8
63+
targetCompatibility = JavaVersion.VERSION_1_8
64+
}
65+
kotlinOptions {
66+
jvmTarget = "1.8"
67+
}
68+
buildFeatures {
69+
compose = true
70+
}
71+
composeOptions {
72+
kotlinCompilerExtensionVersion = "1.5.1"
73+
}
74+
packaging {
75+
resources {
76+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
77+
}
78+
}
79+
}
80+
81+
val sdkVersion = System.getenv("SDK_VERSION") ?: ""
82+
val sdkRef = System.getenv("SDK_REF") ?: ""
83+
84+
dependencies {
85+
implementation(libs.socketio)
86+
implementation(libs.jackson.databind)
87+
implementation(libs.androidx.core.ktx)
88+
implementation(libs.androidx.lifecycle.runtime.ktx)
89+
implementation(libs.androidx.activity.compose)
90+
implementation(platform(libs.androidx.compose.bom))
91+
implementation(libs.androidx.ui)
92+
implementation(libs.androidx.ui.graphics)
93+
implementation(libs.androidx.ui.tooling.preview)
94+
implementation(libs.androidx.material3)
95+
implementation(libs.androidx.runtime.livedata)
96+
testImplementation(libs.junit)
97+
androidTestImplementation(libs.androidx.junit)
98+
androidTestImplementation(libs.androidx.espresso.core)
99+
androidTestImplementation(platform(libs.androidx.compose.bom))
100+
androidTestImplementation(libs.androidx.ui.test.junit4)
101+
debugImplementation(libs.androidx.ui.tooling)
102+
debugImplementation(libs.androidx.ui.test.manifest)
103+
104+
if (sdkVersion != "") {
105+
implementation("cloud.eppo:android-sdk:${sdkVersion}")
106+
} else if (sdkRef != "") {
107+
implementation(project(":android-sdk")) // Requires the repo be cloned prior to building
108+
} else {
109+
// Default implementation
110+
implementation(libs.eppo.android.sdk)
111+
}
112+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
6+
<application
7+
android:allowBackup="true"
8+
android:dataExtractionRules="@xml/data_extraction_rules"
9+
android:fullBackupContent="@xml/backup_rules"
10+
android:icon="@mipmap/ic_launcher"
11+
android:name=".EppoSdkRelayApplication"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:usesCleartextTraffic="true"
16+
tools:targetApi="31">
17+
<activity
18+
android:name=".TestClientActivity"
19+
android:exported="true"
20+
android:label="@string/label_automated_test">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
</activity>
27+
</application>
28+
29+
</manifest>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package cloud.eppo.android.sdkrelay
2+
3+
import android.app.Application
4+
5+
class EppoSdkRelayApplication : Application() {}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package cloud.eppo.android.sdkrelay
2+
3+
import io.socket.client.IO
4+
import io.socket.client.Socket
5+
import java.net.URISyntaxException
6+
7+
class SocketHandler {
8+
9+
private lateinit var _socket: Socket
10+
val socket
11+
get() = this._socket
12+
13+
@Synchronized
14+
fun setSocket(host: String, port: String) {
15+
try {
16+
_socket = IO.socket("$host:$port")
17+
} catch (_: URISyntaxException) {}
18+
}
19+
20+
@Synchronized
21+
fun establishConnection() {
22+
_socket.connect()
23+
}
24+
25+
@Synchronized
26+
fun closeConnection() {
27+
_socket.disconnect()
28+
_socket.off()
29+
}
30+
}

0 commit comments

Comments
 (0)