Find a file
dimitri bf5a983be2
TLS Client Authentication Support (#2526)
* Rebasing First TLS Client (MTLS) implemention onto upstream's master

* Removed commented code

* First Client TLS implementation rebased with upstream's masster

* Removed redundant semicolon

* Added try/catch to key import, added import feedback to enduser

* ktlint fixes

* Rely on the device Credential store

* Tweaked and cleaned the strings related to the TLS Client Auth message

* Removed commented code

* Attempt to remember the key alias and load it as soon as the app starts

* Cleaned rebase and tidying up code

* Added handler for HTTP error (when a certificate is not provided)

* When no certificate is availble, do the request to get an HTTP error back (for error handling)

* Pleased the linter

* Pleased the linter

* Switched to constructor injection

* Attempt to load the key in a non-blocking fashion.

* Do not loop around the blocking code

* onReceivedClientCertRequest now runs non blocking and the KCAC callback is used instead of polling.

* Wait until the executor task actually completes.

* Cleaned the code

* Removed unused import

* Wait for the executor to finishes executing its task

* During onboarding, if TLS Client Auth is enabled but no certificate is available, correctly report to the user

* Use a safe call on errorResponse

* Do not block anymore

* Removed unused return types

* Removed unused return types and the executor

* Removed unused imports

* Code cleanup

* Improved synchronization

* Added a string for certificate expiration

* Added a function to clear the alias and removed blocking code

* Added a function to clear the alias

* Display an error message if the user certificate is not valid plus minor refactoring

* Check the validity of the selected certificate

* Added an error message if the client certificate is not valid

* Resolved warnings and linting issues

* Fixed broken branch when testing for error condition

* Removed unused imports

Co-authored-by: Mirco Boschi <mircoboschi@gmail.com>
2022-06-30 21:55:23 -04:00
.github Bump actions/setup-java from 3.3.0 to 3.4.0 (#2632) 2022-06-26 18:36:17 +00:00
app TLS Client Authentication Support (#2526) 2022-06-30 21:55:23 -04:00
common TLS Client Authentication Support (#2526) 2022-06-30 21:55:23 -04:00
gradle/wrapper Dependency bumps. (#2556) 2022-05-30 15:40:54 -04:00
wear Bump iconics-compose from 5.3.3 to 5.3.4 (#2643) 2022-06-26 15:41:23 -04:00
.gitignore Wear os authentication (#1691) 2021-09-30 20:41:22 -04:00
build.gradle.kts Bump google-services from 4.3.10 to 4.3.12 (#2641) 2022-06-26 15:40:53 -04:00
CLA.md Add required documents 2019-04-01 22:52:24 -07:00
CODE_OF_CONDUCT.md Update Code of Conduct to 2.0 (#603) 2020-05-26 09:10:31 +02:00
gradle.properties Update distribution plugin. (#1079) 2020-10-20 09:34:45 -04:00
gradlew Update to Gradle 7.2 (#1726) 2021-09-30 20:37:51 -04:00
gradlew.bat Remove redundant buildscript declaration (#1029) 2020-10-11 13:38:46 -04:00
LICENSE.md Add required documents 2019-04-01 22:52:24 -07:00
README.md Fix typo in readme (#2258) 2022-02-12 19:46:26 -05:00
settings.gradle.kts Update to Gradle 7.2 (#1726) 2021-09-30 20:37:51 -04:00

📱 Home Assistant Companion for Android Beta Deploy

Documentation

If you are looking for documentation around the companion applications check out the Home Assistant Companion Documentation. This will provide you instructions on using the applications.

Setup App Development Environment

  1. Download and install Android Studio

  2. Download / clone this repository to a folder on your computer

  3. Create a Firebase project at Firebase Console

  4. Create four Android apps, with following package names

  • io.homeassistant.companion.android
  • io.homeassistant.companion.android.debug
  • io.homeassistant.companion.android.minimal
  • io.homeassistant.companion.android.minimal.debug
  1. Now download the google-services.json file and put it in the home-assistant-Android/app folder. This file contains the configuration of the whole project (all four applications). (You can also use the mock services file instead of generating your own. The file should contain client IDs for all packages listed above for debugging to work properly. If you do not generate your own file FCM push notification will never work, only websocket notifications will)
  2. Start Android Studio, open your source code folder and check if the Gradle build will be successful using Build/Make Module "App". You might have to install the right Android SDK via Tools/SDK Manager first.
  3. Run gradlew assembleDebug to build all debug versions, this might take a while.
  4. If the build is successful, you can run the app by doing the following: click Run -> Run 'app'.
  5. Connect your phone or create a new virtual device following on screen instruction
  6. 🎉

If you get stuck while setting up your own environment, you can ask questions in the #devs_mobile_apps channel on Discord.

Push Notifications

If you want to work on push notifications or use a development build with push notifications, please go the server side code HERE and deploy it to your firebase project. Once you have your androidV1 URL to the deployed service, set it in to your ${GRADLE_USER_HOME}/gradle.properties file, e.g.:

homeAssistantAndroidPushUrl=https://mydomain.cloudfunctions.net/androidV1

You can also define the rate limit function URL, e.g.:

homeAssistantAndroidRateLimitUrl=https://mydomain.cloudfunctions.net/checkRateLimits

App Flavors

The Android app has both a full flavor that uses Google Play Services to offer features like location tracking and notifications. There is also a minimal flavor that does not require Google Play Services and can be found in the releases section. The minimal flavor does not have location tracking or notifications.

Building for publishing

To build the app for publishing, you will need to sign the app. To do this, do the following:

  1. Create keystore containing keypair for debug application signing. In Android Studio: Menu/Build/Generate signed APK, then use a button to create new keystore. Remember the passwords and key alias. Default, the keystore must be named release_keystore.keystore and should be placed in the home-assistant-Android/app and home-assistant-Android/wear folder.
  2. Set environmental variables used in app/build.gradle.kts:
  • KEYSTORE_PASSWORD
  • KEYSTORE_ALIAS
  • KEYSTORE_ALIAS_PASSWORD
  • KEYSTORE_PATH (if your keystore is located differently than stated above)
  1. Run gradlew build
  2. The signed APK is located in your build folder

Testing Dev Releases

We are using Github Actions to perform continuous integration both by unit testing, deploying dev releases to Play Store Beta and final releases to the Play Store when we release. To help test out a specific feature/fixes users can find the APK on the Actions page for each pull request, this debug APK can be installed side-by-side the production or beta builds.

Quality

We are using ktlint as our linter. You can run a check locally on your machine with:

./gradlew ktlintCheck

This commands runs on our CI to check if your PR passes all tests. So we strongly recommend running it before committing.

To run a check with an auto-format:

./gradlew ktlintFormat

Translating

The project currently uses lokalise to translate the application. If you are interested in helping translate go to the link and click start translating!

Generating a release to production

  • Create a new release with the name and tag in the {MAJOR}.{MINOR}.{PATCH} format
  • Steal the release notes from the latest beta build
  • This will cause a tag to be added to the project and the Production Deploy Workflow will handle the rest
  • Note: Only the first 500 characters of the release notes get set in the Google Play release