Skip to content

Commit

Permalink
Reimplement the measurement app in Kotlin (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: achintiii <achintiii@outlook.com>
Co-authored-by: Matt Johnson <matt9j@cs.washington.edu>
Co-authored-by: Sudheesh Singanamalla <sudheesh@cs.washington.edu>
  • Loading branch information
4 people authored Jun 30, 2024
1 parent 8ef5391 commit b37fe7f
Show file tree
Hide file tree
Showing 176 changed files with 6,452 additions and 1,871 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: LCL Measurement Tool CI

env:
# The name of the main module repository
main_project_module: app

on:
push:
branches: [main]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew app:build
- name: Run Tests
run: ./gradlew app:testDemoDebugUnitTest
- name: Generate APK Debug Build with Gradle (Dev)
if: startsWith(github.ref, 'refs/tags/')
run: ./gradlew assembleDevDebug
- name: Generate APK Release Build with Gradle (Full)
if: startsWith(github.ref, 'refs/tags/')
run: ./gradlew assembleFullRelease
- name: Upload to Github Page
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
${{ env.main_project_module }}/build/outputs/apk/dev/debug/app-dev-debug.apk
${{ env.main_project_module }}/build/outputs/apk/full/debug/app-full-release.apk
draft: true
prerelease: true
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
.mtj.tmp/

# Package Files #
*.jar
#*.jar
*.war
*.nar
*.ear
Expand Down Expand Up @@ -54,3 +54,6 @@ captures/
.idea
# Keystore files
*.jks
*.properties
# External native build objects
.cxx/
96 changes: 95 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,97 @@
# LCL Network Performance Measurement Tool

LCL Network Measurement Tool is an Android App that measures a variety of network metrics, including but not limited to *ping*, *upload/download* speed, *signal strength*.
**Warning: This doc is outdated! Will update once the kotlin integration is complete.**

**LCL Network Measurement Tool** is an Android App that measures a variety of network metrics, including but not limited to *ping*, *upload/download* speed, *signal strength*.
It also automatically uploads the testing results to the backend server, which will then be displayed on [our coverage map](https://coverage.seattlecommunitynetwork.org/).

## Project Structure
```
app/src/main/java
└── com
└── lcl
└── lclmeasurementtool
├── Utils
├── Receivers
├── Models
├── Managers
├── Functionality
├── Database
│   ├── Entity
│   └── DB
└── Constants
```

In each sub-directory, there is a README file explaining the module.


## Building, Running, and Installing the project
### Prerequisite
* We use Android Studio for development. Download the latest version of Android Studio [here](https://developer.android.com/studio).
* Android SDK 30 (make sure you have SDK version 30 or above)
* Android NDK (Download the latest NDK either from Android's website or in Android Studio)
* Android Emulator
* Git

### Managing SDK, NDK, and Emulators
Android Studio has tools to help manage the SDK, NDK, and Emulators resources.

![SDK, NDK, Emulator Manager](docs/img/sdk_ndk_emulator.png)

#### SDK and NDK
Android SDK is a component for building apps on Android platform.
Android NDK is a toolset that lets you implement parts of your app in native code, using languages such as C and C++.

To properly configure SDK and NDK for the project. First go to the `SDK Platform` pane, and check the SDK with API level equal to or greater than 30.
![Android SDK](docs/img/android_sdk.png)

Then click `SDK Tools`, make sure at least NDK and CMake are checked.
![Android SDK Tools](docs/img/android_sdk_tools.png)

Finally, click `OK` and wait for these tools to be installed.

#### Emulators
If you do not have a Andriod Phone, you can install emulators to run the app. Click the `Device Manager` button in the middle. Then click `Create device`.
Select a phone target (we recommend using Pixel 4). Then select your system image, which should match your API level. Finally click `Finish` and wait for the emulator to be created.
![Android Device Manager](docs/img/device_manager.png)

For more information, visit [Android Developer Website](https://developer.android.com/studio/releases/platforms)

### Building, Running and Debugging the Code
Android Studio provides out-of-box build tool and debugger to help build, run, and debug.

#### Open the project
* In order to build the code, clone this project repo to your working folder
* using HTTPS: `$ git clone https://github.com/Local-Connectivity-Lab/lcl_measurement_tool.git`
* using SSH if you have set it up: `$ git@github.com:Local-Connectivity-Lab/lcl_measurement_tool.git`
* `cd` into the directory `lcl_measurement_tool` and change the branch from `main` to `develop` to view the latest codebase `$ git checkout dev`
* Open the project using Android Studio. Wait for Android Studio to automatically install Gradle and other dependencies used by the project.
* Under the top-level directory of this project, where this README.md lives, create a new file `iperfkey.properties` and ask either Esther Jang or Zhennan Zhou for the keys.

#### Building the project
* On the top menu bar, find the `Build -> Clean Project` to remove any previous build. Then `Build -> Rebuild Project`.
* [Optional] On the bottom menu bar, find the Build Panel and view the Build process.

#### Running/Debugging the project
After building the project, we can use Android Studio's "Play" button in the toolbar to run the project on an actual Android phone or in the Emulator of your choice.
If you need to debug the code, add breakpoints and then click the `bug` button in the toolbar. Android Studio will pop up a debugger attached to the process.
![AndroidStudio toolbar](docs/img/androidstudio_tool_bar.png) Make sure the target shows as `app`.

#### Profiling and Inspection
If you need to inspect the network packet or checking the app's running state, you can use Android Studio's built-in profiler located at the bottom toolbar.
Make sure you open the profiler when the app is running. To inspect the database, using the App Inspection tool located at the bottom toolbar.


## Contributing to the Project
We are excited to work alongside you, our amazing community, to build and enhance this measurement tool! If you want to contribute to this project, contact Esther Jang(infared) or Zhennan Zhou(Johnnnzhou) in our Discord channel.

### Getting involved with Seattle Community Networks Team
If you are interested in contributing to the community, visit our [website](https://seattlecommunitynetwork.org/), join our [Discord channel](https://discord.gg/sZkK5RpeCE),
and follow us on social media: [Instagram](https://instagram.com/seattlecommnet), [Facebook](https://facebook.com/seattlecommnet), and [Twitter](https://twitter.com/seattlecommnet).

For more information, visit our [Get Started Pro Tips](https://docs.seattlecommunitynetwork.org/get-started.html).





167 changes: 149 additions & 18 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,47 +1,178 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'kotlin-android'
id 'com.google.dagger.hilt.android'
id "com.google.protobuf" version "0.8.17"
id "kotlinx-serialization"
}

android {
compileSdkVersion 30
compileSdkVersion 33
buildToolsVersion "30.0.3"

ndkVersion "23.1.7779620"
defaultConfig {
applicationId "com.lcl.lclmeasurementtool"
minSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"

minSdkVersion 24
targetSdkVersion 31
versionCode 2
versionName "1.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}

// Required when setting minSdkVersion to 20 or lower according to <link>https://developer.android.com/studio/write/java8-support#library-desugaring</link>
multiDexEnabled true
}

flavorDimensions "mode"
productFlavors {

dev {
dimension "mode"
versionNameSuffix "-dev"
}

demo {
dimension "mode"
versionNameSuffix "-demo"
}

full {
dimension "mode"
versionNameSuffix "-full"
}
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}

debug {
// below will add the suffix to the *com.lcl.lclmeasurementtool* => **com.lcl.lclmeasurementtool.debug**
// applicationIdSuffix ".debug"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildFeatures {
viewBinding true
compose true
}

composeOptions {
kotlinCompilerExtensionVersion "1.4.4"
}

kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
implementation project(":libndt7")

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.android.volley:volley:1.2.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
// implementation fileTree(dir: 'libs', include: ['*.jar'])

// Kotlin
implementation 'androidx.core:core-ktx:1.10.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0"

// Worker
implementation 'androidx.work:work-runtime-ktx:2.8.1'
implementation "androidx.hilt:hilt-work:1.0.0"
kapt "androidx.hilt:hilt-compiler:1.0.0"

// Location Service
implementation 'com.google.android.gms:play-services-location:21.0.1'

// DB
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"

// UI
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
def appCenterSdkVersion = '4.1.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
def composeBom = platform('androidx.compose:compose-bom:2022.10.00')
implementation composeBom
androidTestImplementation composeBom
implementation "androidx.compose.material3:material3:1.0.1"
implementation "androidx.compose.material3:material3-window-size-class:1.0.1"
implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.1"
debugImplementation "androidx.compose.ui:ui-tooling-preview:1.3.2"
implementation "androidx.compose.ui:ui-tooling:1.3.2"
implementation "androidx.compose.material:material-icons-extended:1.3.1"
implementation "androidx.navigation:navigation-compose:2.5.3"

// datastore with protobuf preferences
implementation "androidx.datastore:datastore-preferences:1.0.0"
implementation "androidx.datastore:datastore:1.0.0"
implementation "com.google.protobuf:protobuf-javalite:3.21.12"

// hilt dependency injection
implementation 'com.google.dagger:hilt-android:2.44.2'
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
kapt 'com.google.dagger:hilt-compiler:2.44.2'

// start up runtime
implementation "androidx.startup:startup-runtime:1.1.1"

// third-party lib
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation 'com.github.kongzue.DialogX:DialogX:0.0.43.beta13'
implementation 'com.github.getActivity:XXPermissions:16.6'
implementation "io.github.g00fy2.quickie:quickie-bundled:1.6.0"
implementation 'org.bouncycastle:bcpkix-jdk15to18:1.70'
implementation 'org.bouncycastle:bcprov-jdk15to18:1.70'
implementation 'org.apache.commons:commons-csv:1.9.0'
implementation 'io.github.azhon:appupdate:4.3.2'

// Analytics
implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"

// Testing
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
}

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.14.0"
}

// Generates the java Protobuf-lite code for the Protobufs in this project. See
// https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation
// for more information.
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option("lite")
}
}
}
}
}

kapt {
correctErrorTypes true
}
Loading

0 comments on commit b37fe7f

Please sign in to comment.