Skip to content

Commit

Permalink
Change structure of the project so we can support multiple sample app… (
Browse files Browse the repository at this point in the history
#153)

Change structure of the project so we can support multiple sample applications in the future.
The only sample app we current have ("app") is renamed "3p-ecosystem" so that each sample app is given a proper descriptive name.
  • Loading branch information
pierredelisle authored Jul 25, 2023
1 parent 0e22c14 commit ee11802
Show file tree
Hide file tree
Showing 218 changed files with 370 additions and 348 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set Up JDK
uses: actions/setup-java@v1
with:
java-version: '11'
java-version: '17'

- name: Run Tests
run: ./gradlew test
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ proguard-project.txt
*.iml
.idea

.DS_Store
.DS_Store

# FIXME: from GHP
/captures
.externalNativeBuild
.cxx
_versions.txt
_logs.txt
File renamed without changes.
101 changes: 101 additions & 0 deletions 3p-ecosystem/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Google Home Sample App for Matter -- 3p-ecosystem

The **Google Home Sample App for Matter** (GHSAFM-3p-ecosystem) provides a concrete example of how to
use the [Home Mobile SDK](https://developers.home.google.com/matter/apis/home) to make it
easy to commission and share [Matter](https://developers.home.google.com/matter/overview) devices
across Apps and ecosystems. It also demonstrates how to use commissioning and Cluster libraries
from the
[Matter repo (`connectedhomeip`)](https://github.com/project-chip/connectedhomeip).

This is a sample application that can be used as the starting point to build your
smart home application for Matter devices.

It can also be used as a learning tool to better understand key Matter concepts, as well as a tool
to debug and troubleshoot interactions with Matter devices.

## Clone the repository

The Sample app GitHub repository includes third party libraries from the
[Matter repo (`connectedhomeip`)](https://github.com/project-chip/connectedhomeip).
These native libraries are over 50MB, and require the use of Git Large File
Storage (LFS).

To clone the repository, complete the following steps:

1. Install [Git LFS](https://git-lfs.github.com/).

2. Initialize Git LFS.

```console
$ git lfs install
```

When complete, the console displays the following:

```console
Updated Git hooks.
Git LFS initialized.
```

3. Once Git LFS is installed and initialized, you're ready to clone the
repository. When cloning completes, Git checks out the `main` branch
and downloads the native libraries for you.

```console
$ git clone https://github.com/google-home/sample-apps-for-matter-android.git
```

## Version

Google Home Sample App for Matter follows the [Semantic](http://semver.org/)
and [Android](https://developer.android.com/studio/publish/versioning) versioning guidelines for
release cycle transparency and to maintain backwards compatibility.

## Releases

Always use the latest release as shown at
https://github.com/google-home/sample-apps-for-matter-android/releases

## Get started

* Check the presentation "Building Smart Home Apps with the Google Home Mobile SDK"
(docs/GoogleHomeMobileSDK.pdf) for an overview of the Sample App and key APIs
of the Mobile SDK.
* To make sure that your device has the latest Matter support, review the
[Verify Matter Modules & Services](https://developers.home.google.com/matter/verify-services)
guide.
* Build a Matter device with On/Off capabilities. This sample app works with a virtual device
and an ESP32.
* [Build a Matter Virtual Device](https://developers.home.google.com/codelabs/matter-device-virtual)
with the `rootnode_dimmablelight_bCwGYSDpoe` app. When you
[Create a Matter integration](https://developers.home.google.com/matter/integration/create)
in the [Home Developer Console](https://console.home.google.com/projects),
use `0xFFF1` as your Vendor ID and `0x8000` as your Product ID.
* [Build an Espressif Device](https://developers.home.google.com/matter/vendors/espressif)
with the `all-clusters-app`. When you
[Create a Matter integration](https://developers.home.google.com/matter/integration/create)
in the [Home Developer Console](https://console.home.google.com/projects),
use `0xFFF1` as your Vendor ID and `0x8001` as your Product ID.
* For an overview of the user interface and features, refer to
the [Google Home Sample App for Matter Guide](https://developers.home.google.com/samples/matter-app).
* To review code samples and start building, refer to
the [Build an Android App for Matter](https://developers.home.google.com/codelabs/matter-sample-app)
Codelab.

## Issues?

If you run into problems with the sample app, please submit an issue on the
[Issues page](https://github.com/google-home/sample-apps-for-matter-android/issues).

It is always greatly appreciated if you can try to reproduce the issue you encountered
from a clean state as described in document
["How to investigate issues with GHSAFM‐3p‐ecosystem"](https://github.com/google-home/sample-apps-for-matter-android/wiki/How-to-investigate-issues-with-GHSAFM%E2%80%903p%E2%80%90ecosystem).

## License

Google Home Sample App for Matter is licensed under
the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).

Only use the Google Home Sample App for Matter name and marks when accurately referencing this
software distribution. Do not use the marks in a way that suggests you are endorsed by or otherwise
affiliated with Nest, Google, or the Connectivity Standards Alliance (CSA).
166 changes: 166 additions & 0 deletions 3p-ecosystem/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.protobuf") version "0.9.1"
id("org.jetbrains.kotlin.kapt")
id("dagger.hilt.android.plugin")
id("androidx.navigation.safeargs")
id("com.google.dagger.hilt.android")
id("com.ncorti.ktfmt.gradle") version "0.12.0"
}

android {
namespace = "com.google.homesampleapp"
compileSdk = 33

defaultConfig {
// DeviceSharingClone: Change this value for the target commissioner cloned app
applicationId = "com.google.homesampleapp"
minSdk = 27
targetSdk = 33
versionCode = 15
versionName = "1.4.1"
testInstrumentationRunner = "com.google.homesampleapp.CustomTestRunner"
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
dataBinding = true
}
sourceSets {
getByName("main") {
jniLibs.srcDirs(listOf("third_party/connectedhomeip/libs/jniLibs"))
}
}
android.buildFeatures.viewBinding = true

// Specifies one flavor dimension.
flavorDimensions += "version"
productFlavors {
create("default") {
dimension = "version"
applicationIdSuffix = ".default"
versionNameSuffix = "-default"
}
create("targetcommissioner") {
dimension = "version"
applicationIdSuffix = ".targetcommissioner"
versionNameSuffix = "-targetcommissioner"
}
}
// Gradle will use the NDK that"s associated by default with its plugin.
// If it"s not available (from the SDK Manager), then stripping the .so"s will not happen
// (message: Unable to strip library...)
// See https://github.com/google-home/sample-app-for-matter-android/issues/82.
// https://developer.android.com/studio/projects/install-ndk
// If you want to use a specific NDK, then uncomment the statement below with the proper
// NDK version.
// ndkVersion = "25.2.9519653"
}

dependencies {
// Native libs
implementation(fileTree(mapOf("dir" to "third_party/connectedhomeip/libs", "include" to listOf("*.jar", "*.so"))))

// Connected Home
implementation("com.google.android.gms:play-services-base:18.2.0")
implementation("com.google.android.gms:play-services-home:16.0.0")

// AndroidX
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.databinding:databinding-runtime:8.0.2")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.preference:preference:1.2.0")

// Navigation
implementation("androidx.navigation:navigation-fragment-ktx:2.6.0")
implementation("androidx.navigation:navigation-ui-ktx:2.6.0")

// Lifecycle
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")

// Datastore
implementation("androidx.datastore:datastore:1.0.0")
implementation("androidx.datastore:datastore-core:1.0.0")
implementation("com.google.protobuf:protobuf-javalite:3.18.0")

// Hilt
// https://dagger.dev/hilt/gradle-setup
implementation("com.google.dagger:hilt-android:2.46.1")
kapt("com.google.dagger:hilt-compiler:2.46.1")
implementation("com.google.ar:core:1.38.0")


// Hilt For instrumentation tests
androidTestImplementation("com.google.dagger:hilt-android-testing:2.44.2")
kaptAndroidTest("com.google.dagger:hilt-compiler:2.46.1")

// Task.await()
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4")

// Other
implementation("com.google.android.material:material:1.9.0")
implementation("com.jakewharton.timber:timber:5.0.1")

// Test
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.5.1")
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.5.1")
androidTestImplementation("androidx.test:runner:1.5.2")
androidTestImplementation("androidx.test:rules:1.5.0")
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0")
}

// Issue with androidx.test.espresso:espresso-contrib:3.5.1
// https://github.com/android/android-test/issues/999
configurations.configureEach {
exclude(group = "com.google.protobuf", module = "protobuf-lite")
}

kapt {
correctErrorTypes = true
}

protobuf {
protoc {
// For Apple M1 Chip
val isMac = System.getProperty("os.name").toLowerCase().contains("mac")
val protocDepSuffix = if (isMac) ":osx-x86_64" else ""
artifact = "com.google.protobuf:protoc:3.14.0" + protocDepSuffix
}

// 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().forEach { task ->
task.builtins {
create("java") {
option("lite")
}
}
}
}
}
2 changes: 1 addition & 1 deletion app/proguard-rules.pro → 3p-ecosystem/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.homesampleapp">
xmlns:tools="http://schemas.android.com/tools">

<!-- BluetoothLE (BLE) -->
<!-- https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List%3Candroid.bluetooth.le.ScanFilter%3E,%20android.bluetooth.le.ScanSettings,%20android.bluetooth.le.ScanCallback) -->
Expand All @@ -44,7 +43,7 @@
<uses-permission android:name="android.permission.NFC" />

<application
android:name="com.google.homesampleapp.GHSAFMApplication"
android:name="com.google.homesampleapp.GHSAFM3pEcoApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import timber.log.Timber

/** Google Home Sample Application for Matter (GHSAFM) */
@HiltAndroidApp
class GHSAFMApplication : Application() {
class GHSAFM3pEcoApplication : Application() {
override fun onCreate() {
super.onCreate()

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-->

<resources>
<string name="app_name">GHSAFM</string>
<string name="app_name">GHSAFM-3p-ecosystem</string>

<!-- Device Types -->
<string name="device_type_unspecified" translatable="false">unspecified</string>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
-->

<resources>
<string name="app_name">GHSAFM-TC</string>
<string name="app_name">GHSAFM-3p-ecosystem-TC</string>
</resources>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory will contain .so files required by CHIPTool demo app for Android.
The .so files must be organized into folders by the name of the corresponding
Android architecture for which they are built, eg. arm64-v8a, x86, x86_64, etc.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit ee11802

Please sign in to comment.