forked from openthread/ot-commissioner
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
81 changed files
with
4,537 additions
and
14 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,50 @@ | ||
# | ||
# Copyright (c) 2020, The OpenThread Commissioner Authors. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the | ||
# names of its contributors may be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
|
||
name: Android App Build | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
nightly-build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
android-abi: [x86, x86_64] | ||
os: [macos-10.15, ubuntu-20.04] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Bootstrap | ||
run: | | ||
script/bootstrap.sh | ||
- name: Build | ||
run: | | ||
cd android | ||
ANDROID_ABI=${{ matrix.android-abi }} ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle ./build-commissioner-libs.sh | ||
cd openthread_commissioner | ||
./gradlew build |
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,86 @@ | ||
# | ||
# Copyright (c) 2020, The OpenThread Commissioner Authors. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the | ||
# names of its contributors may be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
# This file runs Android App release build and publish | ||
# releases automatically. | ||
# | ||
|
||
name: Android App Release | ||
|
||
on: | ||
pull_request: | ||
types: [assigned, opened, synchronize, reopened, closed] | ||
|
||
jobs: | ||
release-build: | ||
# We run this job only when the PR branch starts with 'android-release/'. | ||
if: startsWith(github.head_ref, 'android-release/') | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Check Release Version | ||
run: | | ||
echo "github.event.action : ${{ github.event.action }}" | ||
echo "github.event_name : ${{ github.event_name }}" | ||
echo "github.event.pull_request.merged : ${{ github.event.pull_request.merged }}" | ||
GITHUB_HEAD_REF=${{ github.head_ref }} | ||
# The PR branch should has the format 'android-release/<release-version>'. | ||
# <release-version> should equal to versionName defined in the gradle file. | ||
branch_version="${GITHUB_HEAD_REF##*/}" | ||
gradle_version="$(cd android/openthread_commissioner && ./gradlew -q printVersionName)" | ||
if [ $branch_version != $gradle_version ]; then | ||
echo "branch name should be android-release/${gradle_version}!" | ||
exit 1 | ||
fi | ||
export release_version=$gradle_version | ||
- name: Bootstrap | ||
run: | | ||
script/bootstrap.sh | ||
- name: Build | ||
run: | | ||
cd android | ||
ANDROID_ABI=armeabi-v7a ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle ./build-commissioner-libs.sh | ||
ANDROID_ABI=arm64-v8a ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle ./build-commissioner-libs.sh | ||
cd openthread_commissioner | ||
./gradlew assembleDebug | ||
cp app/build/outputs/apk/debug/app-debug.apk ot-commissioner-app-debug-${release_version}.apk | ||
- name: Release | ||
# We create the release only when this PR is merged. | ||
if: ${{ github.event.pull_request.merged }} == 'true' | ||
uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: "android-app-v${release_version}" | ||
prerelease: false | ||
title: "OT Commissioner App" | ||
files: | | ||
./android/openthread_commissioner/ot-commissioner-app-debug-${release_version}.apk |
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
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,24 @@ | ||
# Build OpenThread Commissioner App | ||
|
||
This documents describes instructions to build the OT Commissioner (Android) App. | ||
|
||
## Prerequisites | ||
|
||
- macOS or Linux computer. | ||
- Install latest Android Studio from [here](https://developer.android.com/studio). | ||
|
||
## Build shared library | ||
|
||
The Commissioner Android App is built atop of the native OT Commissioner library. There is a `build-commissioner-libs.sh` script in current directory to help building the required libraries: | ||
|
||
```shell | ||
ANDROID_ABI=arm64-v8a ANDROID_NDK_HOME=$HOME/Library/Android/sdk/ndk/21.3.6528147 ./build-commissioner-libs.sh | ||
``` | ||
|
||
This script creates a build directory (`.build-${ANDROID_ABI}`) in current directory and copies generated libraries into target sub-folders in `openthread_commissioner`. | ||
|
||
_Note: you need to set env `ANDROID_ABI` to the ABI of your phone. This value can be got with command `adb shell getprop ro.product.cpu.abi` after connecting the phone to your computer._ | ||
|
||
## Build the App with Android Studio | ||
|
||
Connect the phone to your computer and we can now open the `openthread_commissioner` directory with Android Studio. Click the `Gradle Sync` and `Run` buttons to run the Commissioner App on your phone. |
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,7 @@ | ||
# OpenThread Commissioner Android App | ||
|
||
The OpenThread (OT) Commissioner sample app commissions a new Thread 1.1 Device into existing Thread Network. | ||
|
||
## Build | ||
|
||
See [BUILDING.md](./BUILDING.md). |
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,83 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2020, The OpenThread Commissioner Authors. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the | ||
# names of its contributors may be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
|
||
readonly CUR_DIR="$(dirname "$(realpath -s "$0")")" | ||
|
||
set -e | ||
|
||
if [ -z "${ANDROID_ABI}" ]; then | ||
echo "ANDROID_ABI not set! Candidates: armeabi-v7a, arm64-v8a, x86 and x86_64" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${ANDROID_NDK_HOME}" ]; then | ||
echo "ANDROID_NDK_HOME not set! Please set it to your Android NDK location!" | ||
exit 1 | ||
fi | ||
|
||
cd "${CUR_DIR}" | ||
|
||
readonly BUILD_DIR=".build-$ANDROID_ABI" | ||
|
||
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR" | ||
cmake -GNinja \ | ||
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME"/build/cmake/android.toolchain.cmake \ | ||
-DANDROID_ABI="$ANDROID_ABI" \ | ||
-DANDROID_ARM_NEON=ON \ | ||
-DANDROID_NATIVE_API_LEVEL=21 \ | ||
-DBUILD_SHARED_LIBS=OFF \ | ||
-DCMAKE_CXX_STANDARD=11 \ | ||
-DCMAKE_CXX_STANDARD_REQUIRED=ON \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DOT_COMM_ANDROID=ON \ | ||
-DOT_COMM_JAVA_BINDING=ON \ | ||
-DOT_COMM_APP=OFF \ | ||
-DOT_COMM_TEST=OFF \ | ||
-DOT_COMM_CCM=OFF \ | ||
../.. | ||
|
||
ninja commissioner-java | ||
cd ../ | ||
|
||
rm -rf "$BUILD_DIR"/libs && mkdir -p "$BUILD_DIR"/libs | ||
|
||
## Create JAR library | ||
javac -source 8 -target 8 "$BUILD_DIR"/src/java/io/openthread/commissioner/*.java | ||
|
||
cd "$BUILD_DIR"/src/java | ||
find ./io/openthread/commissioner -name "*.class" | xargs jar cvf ../../libs/libotcommissioner.jar | ||
cd ../../../ | ||
|
||
## Copy shared native libraries | ||
cp "$BUILD_DIR"/src/java/libcommissioner-java.so "$BUILD_DIR"/libs | ||
|
||
mkdir -p openthread_commissioner/service/libs | ||
mkdir -p openthread_commissioner/service/src/main/jniLibs/"${ANDROID_ABI}" | ||
cp "$BUILD_DIR"/libs/libotcommissioner.jar openthread_commissioner/service/libs | ||
cp "$BUILD_DIR"/libs/*.so openthread_commissioner/service/src/main/jniLibs/"${ANDROID_ABI}" |
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,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
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 @@ | ||
/build |
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,60 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
def getGitHash = { -> | ||
def stdout = new ByteArrayOutputStream() | ||
exec { | ||
commandLine 'git', 'rev-parse', '--short', 'HEAD' | ||
standardOutput = stdout | ||
} | ||
return stdout.toString().trim() | ||
} | ||
|
||
// Print App version. | ||
task printVersionName { | ||
doLast { | ||
println android.defaultConfig.versionName | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion "30.0.1" | ||
ndkVersion "21.3.6528147" | ||
|
||
defaultConfig { | ||
applicationId "io.openthread.commissioner.app" | ||
minSdkVersion 24 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "0.0.1" | ||
|
||
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\"" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':service') | ||
|
||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
implementation 'com.google.android.material:material:1.2.1' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1' | ||
testImplementation 'junit:junit:4.0' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.2' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' | ||
} |
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 |
26 changes: 26 additions & 0 deletions
26
...oner/app/src/androidTest/java/io/openthread/commissioner/app/ExampleInstrumentedTest.java
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,26 @@ | ||
package io.openthread.commissioner.app; | ||
|
||
import android.content.Context; | ||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
|
||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("io.openthread.commissioner.app", appContext.getPackageName()); | ||
} | ||
} |
Oops, something went wrong.