diff --git a/.github/workflows/android-ci.yml b/.github/workflows/android-ci.yml
new file mode 100644
index 0000000..6734619
--- /dev/null
+++ b/.github/workflows/android-ci.yml
@@ -0,0 +1,87 @@
+name: CloudflareWarpSpeedTest Android CI/CD
+
+on:
+ push:
+ branches: [ "*", "*/*" ]
+ tags:
+ - 'v*'
+ pull_request:
+ branches: [ "*", "*/*" ]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ java-version: '17'
+ distribution: 'temurin'
+ cache: gradle
+
+ - name: Grant execute permission for gradlew
+ run: chmod +x android/gradlew
+
+ - name: Cache Gradle packages
+ uses: actions/cache@v3
+ with:
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
+ restore-keys: |
+ ${{ runner.os }}-gradle-
+
+ - name: Setup Android SDK
+ uses: android-actions/setup-android@v3
+ with:
+ sdk-platform: '34'
+ build-tools: '34.0.0'
+
+ - name: Build with Gradle
+ working-directory: ./android
+ run: ./gradlew build
+
+ - name: Run Tests
+ working-directory: ./android
+ run: ./gradlew test
+
+ - name: Run Lint
+ working-directory: ./android
+ run: ./gradlew lint
+
+ - name: Upload Build Reports
+ if: always()
+ uses: actions/upload-artifact@v3
+ with:
+ name: build-reports
+ path: android/app/build/reports
+
+ - name: Build Release APK
+ if: startsWith(github.ref, 'refs/tags/v')
+ working-directory: ./android
+ run: ./gradlew assembleRelease
+
+ - name: Sign Release APK
+ if: startsWith(github.ref, 'refs/tags/v')
+ uses: r0adkll/sign-android-release@v1
+ with:
+ releaseDirectory: android/app/build/outputs/apk/release
+ signingKeyBase64: ${{ secrets.SIGNING_KEY }}
+ alias: ${{ secrets.KEY_ALIAS }}
+ keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
+ keyPassword: ${{ secrets.KEY_PASSWORD }}
+ env:
+ BUILD_TOOLS_VERSION: "34.0.0"
+
+ - name: Create Release
+ if: startsWith(github.ref, 'refs/tags/v')
+ uses: softprops/action-gh-release@v2
+ with:
+ files: |
+ ${{ env.SIGNED_RELEASE_FILE }}
+ draft: true
+ prerelease: true
+
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 888ed8b..086ca67 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -5,9 +5,9 @@ name: Go Build and Test
on:
push:
- branches: [ "*" ]
+ branches: [ "*", "*/*" ]
pull_request:
- branches: [ "*" ]
+ branches: [ "*", "*/*" ]
jobs:
build-and-test:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 290ad5b..9117a62 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -3,6 +3,9 @@ name: Release for multiple platforms
on:
release:
types: [created]
+ push:
+ tags:
+ - 'v*'
permissions:
contents: write
diff --git a/.gitignore b/.gitignore
index 13221d2..03c3ce1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,43 @@
dist
Releases
-CloudflareWarpSpeedTest
+# CloudflareWarpSpeedTest
*.exe
*.csv
.idea
.vscode
+
+# Go build artifacts
+*.o
+*.a
+*.so
+
+# Android build artifacts
+*.aar
+*.apk
+*.aab
+*.dex
+*.class
+android/app/build/
+android/.gradle/
+android/local.properties
+android/.idea/
+android/app/release/
+android/app/debug/
+android/captures/
+android/app/libs/
+android/build/
+
+# Keep Gradle Wrapper
+!android/gradle/wrapper/gradle-wrapper.jar
+!android/gradle/wrapper/gradle-wrapper.properties
+!android/gradlew
+!android/gradlew.bat
+
+# macOS system files
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+
+# IDE files
diff --git a/android/app/build.gradle b/android/app/build.gradle
new file mode 100644
index 0000000..6666a80
--- /dev/null
+++ b/android/app/build.gradle
@@ -0,0 +1,55 @@
+plugins {
+ id 'com.android.application'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ namespace 'com.peanut996.cloudflarewarpspeedtest'
+ compileSdk 34
+
+ defaultConfig {
+ applicationId "com.peanut996.cloudflarewarpspeedtest"
+ minSdk 24
+ targetSdk 34
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
+ }
+
+ kotlinOptions {
+ jvmTarget = '17'
+ }
+
+ buildFeatures {
+ viewBinding true
+ }
+ buildToolsVersion '34.0.0'
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.aar'])
+ implementation 'androidx.core:core-ktx:1.12.0'
+ implementation 'androidx.appcompat:appcompat:1.6.1'
+ implementation 'com.google.android.material:material:1.10.0'
+ implementation 'com.google.code.gson:gson:2.10.1'
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
+ implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
+
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.5'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
+}
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..3064058
--- /dev/null
+++ b/android/app/src/main/AndroidManifest.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/MainActivity.kt b/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/MainActivity.kt
new file mode 100644
index 0000000..b10b38c
--- /dev/null
+++ b/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/MainActivity.kt
@@ -0,0 +1,173 @@
+package com.peanut996.cloudflarewarpspeedtest
+
+import android.os.Bundle
+import android.util.Log
+import android.view.View
+import android.widget.Button
+import android.widget.ProgressBar
+import android.widget.TextView
+import androidx.appcompat.app.AppCompatActivity
+import androidx.lifecycle.lifecycleScope
+import com.peanut996.cloudflarewarpspeedtest.models.SpeedTestConfig
+import com.peanut996.cloudflarewarpspeedtest.models.SpeedTestResult
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+
+class MainActivity : AppCompatActivity() {
+ private val TAG = "MainActivity"
+ private lateinit var speedTest: SpeedTest
+ private lateinit var resultTextView: TextView
+ private lateinit var progressTextView: TextView
+ private lateinit var progressBar: ProgressBar
+ private lateinit var startButton: Button
+ private lateinit var stopButton: Button
+ private lateinit var ipPortTextView: TextView
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+
+ speedTest = SpeedTest()
+ setupViews()
+ setupClickListeners()
+ configureSpeedTest()
+ }
+
+ private fun setupViews() {
+ resultTextView = findViewById(R.id.resultText)
+ progressTextView = findViewById(R.id.progressText)
+ progressBar = findViewById(R.id.progressBar)
+ startButton = findViewById(R.id.startButton)
+ stopButton = findViewById(R.id.stopButton)
+ ipPortTextView = findViewById(R.id.ipPortText)
+
+ // Initially disable stop button and hide progress
+ stopButton.isEnabled = false
+ progressBar.visibility = View.GONE
+ progressTextView.visibility = View.GONE
+ }
+
+ private fun setupClickListeners() {
+ startButton.setOnClickListener {
+ startSpeedTest()
+ }
+
+ stopButton.setOnClickListener {
+ stopSpeedTest()
+ }
+ }
+
+ private fun configureSpeedTest() {
+ val config = SpeedTestConfig()
+ try {
+ speedTest.configure(config)
+ } catch (e: Exception) {
+ Log.e(TAG, "Failed to configure speed test: ${e.message}")
+ resultTextView.text = "Configuration error: ${e.message}"
+ }
+ }
+
+ private fun startSpeedTest() {
+ lifecycleScope.launch {
+ try {
+ startButton.isEnabled = false
+ stopButton.isEnabled = true
+ progressBar.visibility = View.VISIBLE
+ progressTextView.visibility = View.VISIBLE
+ resultTextView.text = "Starting speed test..."
+
+ speedTest.start()
+
+ // Poll for results while the test is running
+ while (speedTest.isRunning()) {
+ val result = speedTest.getResults()
+ if (result != null) {
+ withContext(Dispatchers.Main) {
+ updateProgress(result)
+ }
+ }
+ delay(500) // Update every 500ms
+ }
+
+ // Process any remaining results in the channel
+ var finalResult: Any?
+ do {
+ finalResult = speedTest.getResults()
+ if (finalResult != null) {
+ withContext(Dispatchers.Main) {
+ updateProgress(finalResult)
+ }
+ }
+ } while (finalResult != null)
+ } catch (e: Exception) {
+ Log.e(TAG, "Error during speed test: ${e.message}")
+ withContext(Dispatchers.Main) {
+ resultTextView.text = "Error: ${e.message}"
+ progressBar.visibility = View.GONE
+ progressTextView.visibility = View.GONE
+ }
+ } finally {
+ withContext(Dispatchers.Main) {
+ startButton.isEnabled = true
+ stopButton.isEnabled = false
+ }
+ }
+ }
+ }
+
+ private fun stopSpeedTest() {
+ speedTest.stop()
+ startButton.isEnabled = true
+ stopButton.isEnabled = false
+ progressBar.visibility = View.GONE
+ progressTextView.visibility = View.GONE
+ resultTextView.text = "Speed test stopped"
+ }
+
+ private fun updateProgress(result: Any) {
+ when (result) {
+ is List<*> -> {
+ @Suppress("UNCHECKED_CAST")
+ val results = result as List
+ resultTextView.text = formatResults(results)
+ progressBar.visibility = View.GONE
+ progressTextView.visibility = View.GONE
+ }
+ is String -> {
+ val progressMatch = Regex("Progress: (\\d+)/(\\d+) \\((\\d+)%\\)").find(result)
+ if (progressMatch != null) {
+ val (current, total, percentage) = progressMatch.destructured
+ progressBar.progress = percentage.toInt()
+ progressTextView.text = "Testing endpoints: $current/$total ($percentage%)"
+ } else if (result.startsWith("Found working endpoint")) {
+ // Append the new endpoint to existing text while keeping progress
+ val currentText = resultTextView.text.toString()
+ resultTextView.text = if (currentText.startsWith("Starting")) {
+ result + "\n"
+ } else {
+ currentText + result + "\n"
+ }
+ } else {
+ resultTextView.text = result
+ }
+ }
+ }
+ }
+
+ private fun formatResults(results: List): String {
+ if (results.isEmpty()) {
+ return "No results yet"
+ }
+
+ return buildString {
+ appendLine("Test Results:")
+ results.forEachIndexed { index, result ->
+ appendLine("${index + 1}. IP: ${result.ip}:${result.port}")
+ appendLine(" Delay: ${result.delay}ms")
+ appendLine(" Loss Rate: ${String.format("%.2f", result.lossRate * 100)}%")
+ }
+ }
+ }
+}
diff --git a/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/SpeedTest.kt b/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/SpeedTest.kt
new file mode 100644
index 0000000..3c12e3f
--- /dev/null
+++ b/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/SpeedTest.kt
@@ -0,0 +1,236 @@
+package com.peanut996.cloudflarewarpspeedtest
+
+import android.util.Log
+import android.widget.TextView
+import com.peanut996.cloudflarewarpspeedtest.models.SpeedTestConfig
+import com.peanut996.cloudflarewarpspeedtest.models.SpeedTestResult
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.SupervisorJob
+import kotlinx.coroutines.async
+import kotlinx.coroutines.awaitAll
+import kotlinx.coroutines.channels.Channel
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import java.net.DatagramPacket
+import java.net.DatagramSocket
+import java.net.InetAddress
+import java.util.concurrent.atomic.AtomicBoolean
+import kotlin.math.log
+
+class SpeedTest {
+ private val TAG = "SpeedTest"
+ private val isRunning = AtomicBoolean(false)
+ private var job: Job? = null
+ private val coroutineScope = CoroutineScope(Dispatchers.Default + SupervisorJob())
+ private val resultQueue = Channel(Channel.UNLIMITED)
+ private var config = SpeedTestConfig()
+
+ companion object {
+ private val warpHandshakePacket: ByteArray by lazy {
+ val hexString = "013cbdafb4135cac96a29484d7a0175ab152dd3e59be35049beadf758b8d48af14ca65f25a168934746fe8bc8867b1c17113d71c0fac5c141ef9f35783ffa5357c9871f4a006662b83ad71245a862495376a5fe3b4f2e1f06974d748416670e5f9b086297f652e6dfbf742fbfc63c3d8aeb175a3e9b7582fbc67c77577e4c0b32b05f92900000000000000000000000000000000"
+ hexString.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
+ }
+
+ private val ports = listOf(500, 854, 859, 864, 878, 880, 890, 891, 894, 903, 908, 928, 934, 939, 942, 943, 945, 946, 955, 968, 987, 988, 1002, 1010, 1014, 1018, 1070, 1074, 1180, 1387, 1701, 2408, 4500, 5050, 5242, 6515, 7103, 7152, 7156, 7281, 7559, 8319, 8742, 8854, 8886)
+ }
+
+ fun configure(config: SpeedTestConfig) {
+ this.config = config
+ }
+
+ fun isRunning(): Boolean = isRunning.get()
+
+ suspend fun getResults(): Any? = resultQueue.tryReceive().getOrNull()
+
+ fun stop() {
+ job?.cancel()
+ isRunning.set(false)
+ }
+
+ private fun loadWarpIPRanges(): List {
+ val ipRanges = mutableListOf()
+
+ // Add IPv4 CIDR ranges
+ val ipv4Ranges = if (!config.ipv6Mode) {
+ listOf(
+ "162.159.192.0/24",
+ "162.159.193.0/24",
+ "162.159.195.0/24",
+ "162.159.204.0/24",
+ "188.114.96.0/24",
+ "188.114.97.0/24",
+ "188.114.98.0/24",
+ "188.114.99.0/24"
+ )
+ } else emptyList()
+
+ // Process IPv4 ranges
+ for (cidr in ipv4Ranges) {
+ try {
+ val (baseIP, mask) = cidr.split("/")
+ val baseIPParts = baseIP.split(".").map { it.toInt() }
+ val maskBits = mask.toInt()
+
+ if (maskBits < 0 || maskBits > 32) continue
+
+ val hostBits = 32 - maskBits
+ val numHosts = 1 shl hostBits
+
+ // Only generate IPs within the subnet
+ for (i in 0 until numHosts) {
+ val lastOctet = baseIPParts[3] + i
+ if (lastOctet > 255) break
+
+ val ip = "${baseIPParts[0]}.${baseIPParts[1]}.${baseIPParts[2]}.$lastOctet"
+ ipRanges.add(ip)
+
+ if (ipRanges.size >= config.maxScanCount) break
+ }
+ } catch (e: Exception) {
+ Log.e(TAG, "Error processing CIDR $cidr: ${e.message}")
+ continue
+ }
+ }
+
+ // Add IPv6 CIDR ranges if enabled
+ val ipv6Ranges = if (config.ipv6Mode) {
+ listOf(
+ "2606:4700:d0::/48",
+ "2606:4700:d1::/48"
+ )
+ } else emptyList()
+
+ // TODO: Add IPv6 support
+ return ipRanges.take(config.maxScanCount)
+ }
+
+ fun start() {
+ if (isRunning.get()) {
+ Log.w(TAG, "Speed test is already running")
+ return
+ }
+
+ isRunning.set(true)
+ job = coroutineScope.launch {
+ try {
+ val ipRanges = loadWarpIPRanges()
+ val results = mutableListOf()
+ var testedCount = 0
+ val endpoints = ipRanges.flatMap { ip ->
+ ports.map { port -> Pair(ip, port) }
+ }.take(config.maxScanCount)
+ val totalCount = endpoints.size
+ Log.d(TAG, "total count: $totalCount")
+
+ withContext(Dispatchers.IO) {
+ val jobs = endpoints.map { (ip, port) ->
+ async {
+ val result = testEndpoint(ip, port) {
+ testedCount++
+ // Calculate percentage and update progress
+ val percentage = (testedCount.toFloat() / totalCount.toFloat() * 100).toInt()
+ launch {
+ resultQueue.send("Progress: $testedCount/$totalCount ($percentage%)")
+ // Send intermediate result if all tests are complete
+ if (testedCount == totalCount) {
+ if (results.isEmpty()) {
+ resultQueue.send("No available endpoints found after testing ${endpoints.size} combinations")
+ }
+ }
+ }
+ }
+ result
+ }
+ }
+ jobs.awaitAll().filterNotNull().forEach { results.add(it) }
+ }
+
+ // Sort results by delay and filter based on config
+ val filteredResults = results
+ .filter { it.delay >= config.minDelay && it.delay <= config.maxDelay }
+ .filter { it.lossRate <= config.maxLossRate }
+ .sortedBy { it.delay }
+ .take(config.resultDisplayCount)
+
+ // Send final results or "No available endpoints" message
+ if (filteredResults.isEmpty()) {
+ resultQueue.send("No available endpoints found after testing ${endpoints.size} combinations")
+ } else {
+ resultQueue.send(filteredResults)
+ }
+ } catch (e: Exception) {
+ Log.e(TAG, "Error during speed test: ${e.message}")
+ resultQueue.send("Error during speed test: ${e.message}")
+ } finally {
+ isRunning.set(false)
+ }
+ }
+ }
+
+ private suspend fun testEndpoint(ipAddr: String, port: Int, onTested: () -> Unit): SpeedTestResult? = withContext(Dispatchers.IO) {
+ Log.d(TAG, "Testing endpoint: $ipAddr:$port")
+ var socket: DatagramSocket? = null
+
+ try {
+ socket = DatagramSocket()
+ socket.soTimeout = 2000 // 2 second timeout
+
+ val address = InetAddress.getByName(ipAddr)
+ var successfulPings = 0
+ var totalDelay = 0L
+ var lastError: String? = null
+
+ repeat(config.pingTimes) {
+ val startTime = System.currentTimeMillis()
+ val packet = DatagramPacket(warpHandshakePacket, warpHandshakePacket.size, address, port)
+
+ try {
+ socket.send(packet)
+
+ val receiveData = ByteArray(92) // WireGuard handshake response size
+ val receivePacket = DatagramPacket(receiveData, receiveData.size)
+ socket.receive(receivePacket)
+ val delay = System.currentTimeMillis() - startTime
+ if (delay <= config.maxDelay) { // Only count responses within maxDelay
+ totalDelay += delay
+ successfulPings++
+ // Send immediate success notification
+ if (successfulPings == 1) { // Only send on first success to avoid spam
+ resultQueue.send("Found working endpoint - IP: $ipAddr, Port: $port, Latency: ${delay}ms")
+ }
+ }
+ } catch (e: Exception) {
+ lastError = e.message
+ Log.d(TAG, "Ping attempt ${it + 1}/${config.pingTimes} failed for $ipAddr:$port: ${e.message}")
+ }
+ }
+
+ if (successfulPings > 0) {
+ val avgDelay = totalDelay / successfulPings
+ val lossRate = 1.0 - (successfulPings.toDouble() / config.pingTimes)
+
+ if (avgDelay <= config.maxDelay && lossRate <= config.maxLossRate) {
+ Log.d(TAG, "Ping successful for $ipAddr:$port")
+ return@withContext SpeedTestResult(
+ ip = ipAddr,
+ port = port,
+ delay = avgDelay.toInt(),
+ lossRate = lossRate
+ )
+ } else {
+ Log.d(TAG, "Endpoint $ipAddr:$port excluded: delay=$avgDelay, lossRate=$lossRate")
+ }
+ } else {
+ Log.d(TAG, "All pings failed for $ipAddr:$port. Last error: $lastError")
+ }
+ } catch (e: Exception) {
+ Log.e(TAG, "Error testing endpoint $ipAddr:$port: ${e.message}")
+ } finally {
+ socket?.close()
+ onTested() // Ensure we count the attempt
+ }
+ null
+ }
+}
diff --git a/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/models/SpeedTestConfig.kt b/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/models/SpeedTestConfig.kt
new file mode 100644
index 0000000..dcbceb3
--- /dev/null
+++ b/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/models/SpeedTestConfig.kt
@@ -0,0 +1,13 @@
+package com.peanut996.cloudflarewarpspeedtest.models
+
+data class SpeedTestConfig(
+ val threadCount: Int = 200,
+ val pingTimes: Int = 1,
+ val maxScanCount: Int = 100,
+ val maxDelay: Int = 300,
+ val minDelay: Int = 0,
+ val maxLossRate: Double = 1.0,
+ val testAllCombos: Boolean = false,
+ val ipv6Mode: Boolean = false,
+ val resultDisplayCount: Int = 10
+)
diff --git a/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/models/SpeedTestResult.kt b/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/models/SpeedTestResult.kt
new file mode 100644
index 0000000..46dc48a
--- /dev/null
+++ b/android/app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest/models/SpeedTestResult.kt
@@ -0,0 +1,8 @@
+package com.peanut996.cloudflarewarpspeedtest.models
+
+data class SpeedTestResult(
+ val ip: String,
+ val port: Int,
+ val delay: Int,
+ val lossRate: Double
+)
diff --git a/android/app/src/main/res/drawable/ic_launcher_foreground.xml b/android/app/src/main/res/drawable/ic_launcher_foreground.xml
new file mode 100644
index 0000000..319627c
--- /dev/null
+++ b/android/app/src/main/res/drawable/ic_launcher_foreground.xml
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..3ae4da7
--- /dev/null
+++ b/android/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..5ed0a2d
--- /dev/null
+++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..5ed0a2d
--- /dev/null
+++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..f42ada6
--- /dev/null
+++ b/android/app/src/main/res/values/colors.xml
@@ -0,0 +1,4 @@
+
+
+ #FFFFFF
+
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..ef6a145
--- /dev/null
+++ b/android/app/src/main/res/values/strings.xml
@@ -0,0 +1,4 @@
+
+
+ Cloudflare WARP Speed Test
+
diff --git a/android/app/src/main/res/values/themes.xml b/android/app/src/main/res/values/themes.xml
new file mode 100644
index 0000000..8f0baea
--- /dev/null
+++ b/android/app/src/main/res/values/themes.xml
@@ -0,0 +1,8 @@
+
+
+
+
diff --git a/android/build.gradle b/android/build.gradle
new file mode 100644
index 0000000..4f5fb6a
--- /dev/null
+++ b/android/build.gradle
@@ -0,0 +1,9 @@
+plugins {
+ id 'com.android.application' version '8.2.0' apply false
+ id 'com.android.library' version '8.2.0' apply false
+ id 'org.jetbrains.kotlin.android' version '1.9.0' apply false
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/android/gradle.properties b/android/gradle.properties
new file mode 100644
index 0000000..23e535d
--- /dev/null
+++ b/android/gradle.properties
@@ -0,0 +1,27 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+
+# Automatically convert third-party libraries to use AndroidX
+android.enableJetifier=true
+
+# Kotlin code style for this project: "official" or "obsolete":
+kotlin.code.style=official
diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..a4b76b9
Binary files /dev/null and b/android/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..62f495d
--- /dev/null
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/android/gradlew b/android/gradlew
new file mode 100755
index 0000000..f5feea6
--- /dev/null
+++ b/android/gradlew
@@ -0,0 +1,252 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/android/gradlew.bat b/android/gradlew.bat
new file mode 100644
index 0000000..9d21a21
--- /dev/null
+++ b/android/gradlew.bat
@@ -0,0 +1,94 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/android/settings.gradle b/android/settings.gradle
new file mode 100644
index 0000000..3833b25
--- /dev/null
+++ b/android/settings.gradle
@@ -0,0 +1,18 @@
+pluginManagement {
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+rootProject.name = "CloudflareWarpSpeedTest"
+include ':app'
diff --git a/android/setup.sh b/android/setup.sh
new file mode 100755
index 0000000..4897721
--- /dev/null
+++ b/android/setup.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# Create necessary directories
+mkdir -p app/src/main/res/values
+mkdir -p app/src/main/kotlin/com/peanut996/cloudflarewarpspeedtest
+mkdir -p app/libs
+
+# Copy the AAR file
+cp ../mobile/build/cloudflare_warp_speedtest.aar app/libs/
+
+# Create strings.xml
+cat > android/app/src/main/res/values/strings.xml << EOL
+
+
+ Cloudflare WARP Speed Test
+
+EOL
+
+# Create styles.xml
+cat > android/app/src/main/res/values/themes.xml << EOL
+
+
+
+
+EOL
+
+echo "Android project setup completed!"
+echo "To build the project:"
+echo "1. Open the 'android' folder in Android Studio"
+echo "2. Let the project sync and download dependencies"
+echo "3. Click 'Run' to build and run the app on your device or emulator"