-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Android SDK Testing Relay Client (#70)
- Loading branch information
Showing
34 changed files
with
1,163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea | ||
.DS_Store | ||
**/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
.idea | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Eppo SDK Relay App | ||
|
||
This app connects to an Eppo Packing Test Runner Server and relays assignment requests to the SDK. | ||
|
||
## Running | ||
|
||
Build and run the app | ||
|
||
```shell | ||
# Uses default version of the SDK (4.2.0) | ||
./gradlew installDebug && \ | ||
adb shell am start -n cloud.eppo.android.sdkrelay/.TestClientActivity | ||
``` | ||
|
||
## Build and run the app with a specific version of the SDK | ||
SDK_VERSION=4.2.0 ./build-and-run.sh | ||
|
||
## Build and run the app with the SDK at a specific Github REF | ||
SDK_REF=my/branch/name ./build-and-run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties | ||
|
||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.jetbrains.kotlin.android) | ||
|
||
id("com.ncorti.ktfmt.gradle") version "0.20.1" | ||
} | ||
|
||
val apiKey: String = gradleLocalProperties( | ||
project.rootDir, | ||
providers | ||
).getProperty("cloud.eppo.apiKey") | ||
|
||
val testRunnerHost: String = System.getenv("TEST_RUNNER_HOST") ?: "http://10.0.2.2" | ||
val testRunnerPort: String = System.getenv("TEST_RUNNER_PORT") ?: "3000" | ||
|
||
val eppoAPIHost: String = System.getenv("EPPO_API_HOST") ?: "http://10.0.2.2" | ||
val eppoAPIPort: String = System.getenv("EPPO_API_PORT") ?: "5000" | ||
|
||
|
||
android { | ||
buildFeatures.buildConfig = true | ||
|
||
namespace = "cloud.eppo.android.sdkrelay" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "cloud.eppo.android.sdkrelay" | ||
minSdk = 26 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
|
||
buildConfigField( "String", "API_KEY", "\"" + apiKey + "\"") | ||
buildConfigField( "String", "TEST_RUNNER_HOST", "\"" +testRunnerHost+ "\"") | ||
buildConfigField( "String", "TEST_RUNNER_PORT", "\"" +testRunnerPort+ "\"") | ||
buildConfigField( "String", "EPPO_API_HOST", "\"" +eppoAPIHost+ "\"") | ||
buildConfigField( "String", "EPPO_API_PORT", "\"" +eppoAPIPort+ "\"") | ||
} | ||
|
||
buildTypes { | ||
debug { | ||
enableUnitTestCoverage = true | ||
enableAndroidTestCoverage = true | ||
} | ||
release { | ||
isMinifyEnabled = true | ||
isShrinkResources = true | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.1" | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
} | ||
|
||
val sdkVersion = System.getenv("SDK_VERSION") ?: "" | ||
val sdkRef = System.getenv("SDK_REF") ?: "" | ||
|
||
dependencies { | ||
implementation(libs.socketio) | ||
implementation(libs.jackson.databind) | ||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.lifecycle.runtime.ktx) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(platform(libs.androidx.compose.bom)) | ||
implementation(libs.androidx.ui) | ||
implementation(libs.androidx.ui.graphics) | ||
implementation(libs.androidx.ui.tooling.preview) | ||
implementation(libs.androidx.material3) | ||
implementation(libs.androidx.runtime.livedata) | ||
testImplementation(libs.junit) | ||
androidTestImplementation(libs.androidx.junit) | ||
androidTestImplementation(libs.androidx.espresso.core) | ||
androidTestImplementation(platform(libs.androidx.compose.bom)) | ||
androidTestImplementation(libs.androidx.ui.test.junit4) | ||
debugImplementation(libs.androidx.ui.tooling) | ||
debugImplementation(libs.androidx.ui.test.manifest) | ||
|
||
if (sdkVersion != "") { | ||
implementation("cloud.eppo:android-sdk:${sdkVersion}") | ||
} else if (sdkRef != "") { | ||
implementation(project(":android-sdk")) // Requires the repo be cloned prior to building | ||
} else { | ||
// Default implementation | ||
implementation(libs.eppo.android.sdk) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
29 changes: 29 additions & 0 deletions
29
package-testing/android-relay/app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:name=".EppoSdkRelayApplication" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:usesCleartextTraffic="true" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".TestClientActivity" | ||
android:exported="true" | ||
android:label="@string/label_automated_test"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
5 changes: 5 additions & 0 deletions
5
...ng/android-relay/app/src/main/java/cloud/eppo/android/sdkrelay/EppoSdkRelayApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package cloud.eppo.android.sdkrelay | ||
|
||
import android.app.Application | ||
|
||
class EppoSdkRelayApplication : Application() {} |
30 changes: 30 additions & 0 deletions
30
package-testing/android-relay/app/src/main/java/cloud/eppo/android/sdkrelay/SocketHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package cloud.eppo.android.sdkrelay | ||
|
||
import io.socket.client.IO | ||
import io.socket.client.Socket | ||
import java.net.URISyntaxException | ||
|
||
class SocketHandler { | ||
|
||
private lateinit var _socket: Socket | ||
val socket | ||
get() = this._socket | ||
|
||
@Synchronized | ||
fun setSocket(host: String, port: String) { | ||
try { | ||
_socket = IO.socket("$host:$port") | ||
} catch (_: URISyntaxException) {} | ||
} | ||
|
||
@Synchronized | ||
fun establishConnection() { | ||
_socket.connect() | ||
} | ||
|
||
@Synchronized | ||
fun closeConnection() { | ||
_socket.disconnect() | ||
_socket.off() | ||
} | ||
} |
Oops, something went wrong.