diff --git a/FloconAndroid/app/build.gradle.kts b/FloconAndroid/app/build.gradle.kts index 7476ece0..7371f623 100644 --- a/FloconAndroid/app/build.gradle.kts +++ b/FloconAndroid/app/build.gradle.kts @@ -50,12 +50,10 @@ dependencies { implementation("io.github.openflocon:flocon:$floconVersion") implementation("io.github.openflocon:flocon-grpc-interceptor:$floconVersion") implementation("io.github.openflocon:flocon-okhttp-interceptor:$floconVersion") - implementation("io.github.openflocon:flocon-graphql-interceptor:$floconVersion") } else { implementation(project(":core")) implementation(project(":okhttp-interceptor")) implementation(project(":grpc-interceptor")) - implementation(project(":graphql-interceptor")) } diff --git a/FloconAndroid/app/src/main/java/io/github/openflocon/flocon/myapplication/graphql/GraphQlTester.kt b/FloconAndroid/app/src/main/java/io/github/openflocon/flocon/myapplication/graphql/GraphQlTester.kt index 35ce6487..f4f22ed7 100644 --- a/FloconAndroid/app/src/main/java/io/github/openflocon/flocon/myapplication/graphql/GraphQlTester.kt +++ b/FloconAndroid/app/src/main/java/io/github/openflocon/flocon/myapplication/graphql/GraphQlTester.kt @@ -8,7 +8,6 @@ import com.apollographql.apollo.network.http.HttpInterceptorChain import com.apollographql.apollo.network.okHttpClient import com.github.GetUserInfoQuery import io.github.openflocon.flocon.myapplication.BuildConfig -import io.github.openflocon.flocon.okhttp.FloconApolloInterceptor import okhttp3.OkHttpClient class GraphQlTester(val client: OkHttpClient) { diff --git a/FloconAndroid/graphql-interceptor/.gitignore b/FloconAndroid/graphql-interceptor/.gitignore deleted file mode 100644 index 42afabfd..00000000 --- a/FloconAndroid/graphql-interceptor/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/FloconAndroid/graphql-interceptor/build.gradle.kts b/FloconAndroid/graphql-interceptor/build.gradle.kts deleted file mode 100644 index b62ad902..00000000 --- a/FloconAndroid/graphql-interceptor/build.gradle.kts +++ /dev/null @@ -1,92 +0,0 @@ -plugins { - alias(libs.plugins.android.library) - alias(libs.plugins.kotlin.android) - id("com.vanniktech.maven.publish") version "0.34.0" -} - -android { - namespace = "io.github.openflocon.flocon.graphql" - compileSdk = 36 - - defaultConfig { - minSdk = 24 - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles("consumer-rules.pro") - } - - buildTypes { - release { - isMinifyEnabled = false - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" - ) - } - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - kotlinOptions { - jvmTarget = "11" - } -} - -dependencies { - - implementation(project(":core")) - - // not sure - implementation(libs.androidx.core.ktx) - - implementation(platform(libs.kotlinx.coroutines.bom)) - implementation(libs.jetbrains.kotlinx.coroutines.core) - implementation(libs.jetbrains.kotlinx.coroutines.android) - - implementation(libs.apollo.runtime) -} - - -mavenPublishing { - publishToMavenCentral() - - if (project.hasProperty("signing.required") && project.property("signing.required") == "false") { - // Skip signing - } else { - signAllPublications() - } - - coordinates( - groupId = project.property("floconGroupId") as String, - artifactId = "flocon-graphql-interceptor", - version = project.property("floconVersion") as String - ) - - pom { - name = "Flocon Graphql Interceptor" - description = project.property("floconDescription") as String - inceptionYear = "2025" - url = "https://github.com/openflocon/Flocon" - licenses { - license { - name = "The Apache License, Version 2.0" - url = "https://www.apache.org/licenses/LICENSE-2.0.txt" - distribution = "https://www.apache.org/licenses/LICENSE-2.0.txt" - } - } - developers { - developer { - id = "openflocon" - name = "Open Flocon" - url = "https://github.com/openflocon" - } - } - scm { - url = "https://github.com/openflocon/Flocon" - connection = "scm:git:git://github.com/openflocon/Flocon.git" - developerConnection = "scm:git:ssh://git@github.com/openflocon/Flocon.git" - } - } -} \ No newline at end of file diff --git a/FloconAndroid/graphql-interceptor/consumer-rules.pro b/FloconAndroid/graphql-interceptor/consumer-rules.pro deleted file mode 100644 index e69de29b..00000000 diff --git a/FloconAndroid/graphql-interceptor/proguard-rules.pro b/FloconAndroid/graphql-interceptor/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/FloconAndroid/graphql-interceptor/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 \ No newline at end of file diff --git a/FloconAndroid/graphql-interceptor/src/main/AndroidManifest.xml b/FloconAndroid/graphql-interceptor/src/main/AndroidManifest.xml deleted file mode 100644 index 74b7379f..00000000 --- a/FloconAndroid/graphql-interceptor/src/main/AndroidManifest.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/FloconAndroid/graphql-interceptor/src/main/java/io/github/openflocon/flocon/okhttp/FloconApolloInterceptor.kt b/FloconAndroid/graphql-interceptor/src/main/java/io/github/openflocon/flocon/okhttp/FloconApolloInterceptor.kt deleted file mode 100644 index 8a4fe25b..00000000 --- a/FloconAndroid/graphql-interceptor/src/main/java/io/github/openflocon/flocon/okhttp/FloconApolloInterceptor.kt +++ /dev/null @@ -1,91 +0,0 @@ -package io.github.openflocon.flocon.okhttp - -import com.apollographql.apollo.api.http.ByteStringHttpBody -import io.github.openflocon.flocon.Flocon -import io.github.openflocon.flocon.Protocol -import io.github.openflocon.flocon.okhttp.model.FloconGrpcRequest -import com.apollographql.apollo.api.http.HttpMethod -import com.apollographql.apollo.api.http.HttpRequest -import com.apollographql.apollo.api.http.HttpResponse -import com.apollographql.apollo.network.http.HttpInterceptor -import com.apollographql.apollo.network.http.HttpInterceptorChain -import okio.Buffer -import java.nio.charset.StandardCharsets - -class FloconApolloInterceptor( - private val floconClient: Flocon.Client? = null, -) : HttpInterceptor { - - override suspend fun intercept(request: HttpRequest, chain: HttpInterceptorChain): HttpResponse { - val requestedAt = System.currentTimeMillis() - - val requestHeadersMap = request.headers.associate { it.name to it.value } - - val startTime = System.nanoTime() - - var requestBodyString: String? = null - - val requestBody = request.body - val newRequest = if (requestBody == null) { - request - } else { - val buffer = Buffer() - requestBody.writeTo(buffer) - val bodyByteString = buffer.readByteString() - requestBodyString = bodyByteString.utf8() - request.newBuilder() - .body(ByteStringHttpBody(contentType = requestBody.contentType, bodyByteString)) - .build() - } - val requestSize = requestBodyString?.toByteArray(StandardCharsets.UTF_8)?.size?.toLong() - - val httpResponse = chain.proceed(newRequest) - val endTime = System.nanoTime() - - val durationMs = (endTime - startTime) / 1e6 - - val responseBody = httpResponse.body - val bodyByteString = responseBody?.readByteString() - val responseBodyString = bodyByteString?.utf8() - val responseSize = responseBodyString?.toByteArray(StandardCharsets.UTF_8)?.size?.toLong() - val responseHeadersMap = httpResponse.headers.associate { it.name to it.value } - - val isImage = httpResponse.headers.firstOrNull { it.name.equals("Content-Type", ignoreCase = true) }?.value?.startsWith("image/") == true - - val floconRequest = FloconGrpcRequest( - url = request.url, - method = when (request.method) { - HttpMethod.Get -> "GET" - HttpMethod.Post -> "POST" - }, - startTime = requestedAt, - durationMs = durationMs, - requestHeaders = requestHeadersMap, - requestBody = requestBodyString, - requestSize = requestSize, - responseHttpCode = httpResponse.statusCode, - responseContentType = httpResponse.headers.firstOrNull { it.name.equals("Content-Type", ignoreCase = true) }?.value, - responseBody = responseBodyString.takeUnless { isImage }, - responseHeaders = responseHeadersMap, - responseSize = responseSize, - ) - - val json = floconRequest.toJson() - (floconClient ?: Flocon.client)?.send( - plugin = Protocol.FromDevice.GraphQl.Plugin, - method = Protocol.FromDevice.GraphQl.Method.LogNetworkCall, - body = json.toString(), - ) - - return if (responseBody == null || bodyByteString == null) { - httpResponse - } else { - @Suppress("DEPRECATION") - HttpResponse.Builder(statusCode = httpResponse.statusCode) - .body(bodyByteString) - .addHeaders(httpResponse.headers) - .build() - } - } - -} \ No newline at end of file diff --git a/FloconAndroid/graphql-interceptor/src/main/java/io/github/openflocon/flocon/okhttp/model/FloconGrpcRequest.kt b/FloconAndroid/graphql-interceptor/src/main/java/io/github/openflocon/flocon/okhttp/model/FloconGrpcRequest.kt deleted file mode 100644 index 92929597..00000000 --- a/FloconAndroid/graphql-interceptor/src/main/java/io/github/openflocon/flocon/okhttp/model/FloconGrpcRequest.kt +++ /dev/null @@ -1,41 +0,0 @@ -package io.github.openflocon.flocon.okhttp.model - -import org.json.JSONObject - -data class FloconGrpcRequest( - val url: String, - val method: String, - val startTime: Long, - val durationMs: Double, - // request - val requestHeaders: Map, - val requestBody: String?, - val requestSize: Long?, - // response - val responseHttpCode: Int, - val responseContentType: String?, - val responseBody: String?, - val responseSize: Long?, - val responseHeaders: Map, -) { - fun toJson(): JSONObject { - val json = JSONObject() - - json.put("url", url) - json.put("method", method) - json.put("startTime", startTime) - json.put("durationMs", durationMs) - - requestBody?.let { json.put("requestBody", it) } - json.put("requestHeaders", JSONObject(requestHeaders)) - json.put("requestSize", requestSize) - - json.put("responseHttpCode", responseHttpCode) - responseContentType?.let { json.put("responseContentType", it) } - responseBody?.let { json.put("responseBody", it) } - json.put("responseHeaders", JSONObject(responseHeaders)) - json.put("responseSize", responseSize) - - return json - } -} \ No newline at end of file diff --git a/FloconAndroid/settings.gradle.kts b/FloconAndroid/settings.gradle.kts index 32a230c4..fc7e5a46 100644 --- a/FloconAndroid/settings.gradle.kts +++ b/FloconAndroid/settings.gradle.kts @@ -18,4 +18,3 @@ include(":app") include(":core") include(":okhttp-interceptor") include(":grpc-interceptor") -include(":graphql-interceptor")