Skip to content

Commit

Permalink
Move vehicle service to main to allow for minimal Automotive build (#…
Browse files Browse the repository at this point in the history
…3570)

* Move vehicle service to minimal to allow for minimal Automotive build

 - Move the vehicle package from full to main so it is included in the minimal build as well, to allow for a minimal Automotive build
 - Adjust dependencies from full to any version (checked: the androidx.car dependency does not have a dependency on any GMS libraries)
 - Move Automotive CarAppActivity + service + metadata to main manifest; not moved in app module because it is only used for Android Auto there
 - Adjust GitHub Actions to include minimal Automotive APK

* Cleanup duplicate Play Services coroutines dependency

* Cleanup duplicate <uses-feature> for camera

* Missed one GMS dependency
  • Loading branch information
jpelgrom committed Jun 19, 2023
1 parent b285c95 commit e8fae5d
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 46 deletions.
1 change: 1 addition & 0 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
./app/build/outputs/apk/minimal/release/app-minimal-release.apk
./wear/build/outputs/apk/release/wear-release.apk
./automotive/build/outputs/apk/full/release/automotive-full-release.apk
./automotive/build/outputs/apk/minimal/release/automotive-minimal-release.apk
- name: Deploy to Firebase
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
./app/build/outputs/apk/minimal/release/app-minimal-release.apk
./wear/build/outputs/apk/release/wear-release.apk
./automotive/build/outputs/apk/full/release/automotive-full-release.apk
./automotive/build/outputs/apk/minimal/release/automotive-minimal-release.apk
./app/build/outputs/version_code.txt
- name: Deploy to Firebase
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If you are looking for documentation around the companion applications check out
- `io.homeassistant.companion.android.minimal`
- `io.homeassistant.companion.android.minimal.debug`

5. Now download the `google-services.json` file and put it in the _home-assistant-Android/app_ and _home-assistant-Android/wear_ 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](/.github/mock-google-services.json). 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**)
5. Now download the `google-services.json` file and put it in the project's _/app_, _/automotive_ and _/wear_ folders. 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](/.github/mock-google-services.json). 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**)
6. 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.
7. Run `gradlew assembleDebug` to build all debug versions, this might take a while.
8. If the build is successful, you can run the app by doing the following: click **Run** -> **Run 'app'**.
Expand Down
3 changes: 1 addition & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ dependencies {
"fullImplementation"(platform("com.google.firebase:firebase-bom:32.1.0"))
"fullImplementation"("com.google.firebase:firebase-messaging")
"fullImplementation"("io.sentry:sentry-android:6.21.0")
"fullImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.7.1")
"fullImplementation"("com.google.android.gms:play-services-wearable:18.0.0")
"fullImplementation"("androidx.wear:wear-remote-interactions:1.0.0")

Expand Down Expand Up @@ -210,7 +209,7 @@ dependencies {
"fullImplementation"("org.burnoutcrew.composereorderable:reorderable:0.9.6")
implementation("com.github.AppDevNext:ChangeLog:3.4")

"fullImplementation"("androidx.car.app:app:1.3.0-rc01")
implementation("androidx.car.app:app:1.3.0-rc01")
}

// Disable to fix memory leak and be compatible with the configuration cache.
Expand Down
46 changes: 32 additions & 14 deletions automotive/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,32 @@ android {
sourceSets {
getByName("main") {
java {
srcDirs("../app/src/main/java", "../app/src/full/java")
srcDirs("../app/src/main/java")
}
res {
srcDirs("../app/src/main/res", "../app/src/full/res")
srcDirs("../app/src/main/res")
}
}
create("full") {
java {
srcDirs("../app/src/full/java")
}
res {
srcDirs("../app/src/full/res")
}
}
create("minimal") {
java {
srcDirs("../app/src/minimal/java")
}
res {
srcDirs("../app/src/minimal/res")
}
}
getByName("debug") {
res {
srcDirs("../app/src/debug/res")
}
manifest.srcFile("src/main/AndroidManifest.xml")
}
}

Expand Down Expand Up @@ -169,28 +189,26 @@ dependencies {
implementation("com.google.android.material:material:1.9.0")
implementation("androidx.fragment:fragment-ktx:1.5.7")

implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.5")
implementation("com.squareup.okhttp3:okhttp:4.11.0")
implementation("com.squareup.picasso:picasso:2.8")

implementation("com.google.android.gms:play-services-location:21.0.1")
implementation("com.google.android.gms:play-services-home:16.0.0")
implementation("com.google.android.gms:play-services-threadnetwork:16.0.0")
implementation(platform("com.google.firebase:firebase-bom:32.1.0"))
implementation("com.google.firebase:firebase-messaging")
implementation("io.sentry:sentry-android:6.21.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.7.1")
implementation("com.google.android.gms:play-services-wearable:18.0.0")
implementation("androidx.wear:wear-remote-interactions:1.0.0")
"fullImplementation"("com.google.android.gms:play-services-location:21.0.1")
"fullImplementation"("com.google.android.gms:play-services-home:16.0.0")
"fullImplementation"("com.google.android.gms:play-services-threadnetwork:16.0.0")
"fullImplementation"(platform("com.google.firebase:firebase-bom:32.1.0"))
"fullImplementation"("com.google.firebase:firebase-messaging")
"fullImplementation"("io.sentry:sentry-android:6.21.0")
"fullImplementation"("com.google.android.gms:play-services-wearable:18.0.0")
"fullImplementation"("androidx.wear:wear-remote-interactions:1.0.0")

implementation("androidx.biometric:biometric:1.1.0")
implementation("androidx.webkit:webkit:1.7.0")

implementation("com.google.android.exoplayer:exoplayer-core:2.18.7")
implementation("com.google.android.exoplayer:exoplayer-hls:2.18.7")
implementation("com.google.android.exoplayer:exoplayer-ui:2.18.7")
implementation("com.google.android.exoplayer:extension-cronet:2.18.7")
"fullImplementation"("com.google.android.exoplayer:extension-cronet:2.18.7")
"minimalImplementation"("com.google.android.exoplayer:extension-cronet:2.18.7") {
exclude(group = "com.google.android.gms", module = "play-services-cronet")
}
Expand Down
28 changes: 0 additions & 28 deletions automotive/src/full/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,6 @@
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorPrimary" />

<meta-data
android:name="androidx.car.app.minCarApiLevel"
android:value="1"/>
<meta-data
android:name="com.android.automotive"
android:resource="@xml/automotive_app_desc"/>
<service
android:name=".vehicle.HaCarAppService"
android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService" />
<category android:name="androidx.car.app.category.IOT"/>
</intent-filter>
</service>
<activity
android:name="androidx.car.app.activity.CarAppActivity"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:exported="true"
android:launchMode="singleTask"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="distractionOptimized" android:value="true"/>
</activity>

</application>

</manifest>
30 changes: 29 additions & 1 deletion automotive/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-feature android:name="android.hardware.screen.portrait" android:required="false" />
<uses-feature android:name="android.hardware.screen.landscape" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<application
android:name="io.homeassistant.companion.android.HomeAssistantApplication"
android:allowBackup="true"
Expand Down Expand Up @@ -379,6 +378,35 @@
</intent-filter>
</activity>

<meta-data
android:name="androidx.car.app.minCarApiLevel"
android:value="1"/>
<meta-data
android:name="com.android.automotive"
android:resource="@xml/automotive_app_desc"/>
<service
android:name=".vehicle.HaCarAppService"
android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService" />
<category android:name="androidx.car.app.category.IOT"/>
</intent-filter>
</service>
<activity
android:name="androidx.car.app.activity.CarAppActivity"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:exported="true"
android:launchMode="singleTask"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="distractionOptimized" android:value="true"/>
</activity>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
Expand Down

0 comments on commit e8fae5d

Please sign in to comment.