Skip to content

Commit

Permalink
Add unsigned resources for Car Info RHMI
Browse files Browse the repository at this point in the history
  • Loading branch information
hufman committed Jul 29, 2024
1 parent 4b4e58a commit bff7755
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 4 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
/build
/captures
/external
/app/src/main/assets/carapplications
/app/src/test/resources/*.xml
.externalNativeBuild
sentry.properties
Expand Down
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ android {
// enable async RHMI data updates
// big performance improvement, and seemingly doesn't even cause bugs!
buildConfigField "boolean", "ASYNC_RHMI_APPLICATION", "true"

// with custom hackery, the car HMI can accept unsigned resources
// if your car has this, set this option to attempt to send these unsigned resources
buildConfigField "boolean", "SEND_UNSIGNED_RESOURCES", (System.env.AndroidAutoIdrive_SendUnsignedResources ? System.env.AndroidAutoIdrive_SendUnsignedResources : AndroidAutoIdrive_SendUnsignedResources)
}

signingConfigs {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

basecoreOnlineServices
bmwone
calendar
cdsbaseapp
multimedia
news
smartthings
spotify
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class NotificationAppService: CarAppService() {
// using a handler to automatically handle shutting down during init
val carappReadout = ReadoutApp(iDriveConnectionStatus, securityAccess,
CarAppAssetResources(applicationContext, "news"),
CarAppAssetResources(applicationContext, "carinfo_unsigned"),
handler, applicationContext.resources, AppSettingsViewer())
carappNotifications?.readoutInteractions?.readoutController = carappReadout.readoutController
this.carappReadout = carappReadout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import io.bimmergestalt.idriveconnectkit.rhmi.*
import io.bimmergestalt.idriveconnectkit.rhmi.deserialization.loadFromXML
import kotlinx.coroutines.android.asCoroutineDispatcher
import me.hufman.androidautoidrive.AppSettings
import me.hufman.androidautoidrive.BuildConfig
import me.hufman.androidautoidrive.CarInformation
import me.hufman.androidautoidrive.R
import me.hufman.androidautoidrive.carapp.*
Expand All @@ -28,7 +29,7 @@ import me.hufman.androidautoidrive.carapp.carinfo.views.CategoryView
import me.hufman.androidautoidrive.cds.*
import me.hufman.androidautoidrive.utils.Utils

class ReadoutApp(val iDriveConnectionStatus: IDriveConnectionStatus, val securityAccess: SecurityAccess, val carAppAssets: CarAppResources, val handler: Handler, val resources: Resources, val appSettings: AppSettings) {
class ReadoutApp(val iDriveConnectionStatus: IDriveConnectionStatus, val securityAccess: SecurityAccess, val carAppAssets: CarAppResources, val unsignedCarAppAssets: CarAppResources, val handler: Handler, val resources: Resources, val appSettings: AppSettings) {
private val coroutineContext = handler.asCoroutineDispatcher()
val carConnection: BMWRemotingServer
var rhmiHandle: Int = -1
Expand Down Expand Up @@ -98,7 +99,17 @@ class ReadoutApp(val iDriveConnectionStatus: IDriveConnectionStatus, val securit
rhmiHandle = carConnection.rhmi_create(null, BMWRemoting.RHMIMetaData("me.hufman.androidautoidrive.notification.readout", BMWRemoting.VersionInfo(0, 1, 0),
"me.hufman.androidautoidrive.notification.readout", "me.hufman"))
carConnection.rhmi_setResourceCached(rhmiHandle, BMWRemoting.RHMIResourceType.DESCRIPTION, carAppAssets.getUiDescription())
// no icons or text, so sneaky
if (BuildConfig.SEND_UNSIGNED_RESOURCES) {
try {
carConnection.rhmi_setResourceCached(rhmiHandle, BMWRemoting.RHMIResourceType.TEXTDB, unsignedCarAppAssets.getTextsDB(iDriveConnectionStatus.brand ?: "common"))
carConnection.rhmi_setResourceCached(rhmiHandle, BMWRemoting.RHMIResourceType.IMAGEDB, unsignedCarAppAssets.getImagesDB(iDriveConnectionStatus.brand ?: "common"))
} catch (e: Exception) {
Log.w(TAG, "Unsigned resources were not accepted by car")
}
} else {
// no icons or text, so sneaky
}

carConnection.rhmi_initialize(rhmiHandle)
carConnection.rhmi_addActionEventHandler(rhmiHandle, "me.hufman.androidautoidrive.notification.readout", -1)
carConnection.rhmi_addHmiEventHandler(rhmiHandle, "me.hufman.androidautoidrive.notification.readout", -1, -1)
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ AndroidAutoIdrive_GmapsApiKey=unset
AndroidAutoIdrive_MapboxAccessToken=unset
AndroidAutoIdrive_MapboxDownloadToken=unset
AndroidAutoIdrive_SentryDsn=unset
AndroidAutoIdrive_SpotifyApiKey=invalid
AndroidAutoIdrive_SpotifyApiKey=invalid
AndroidAutoIdrive_SendUnsignedResources=false

0 comments on commit bff7755

Please sign in to comment.