forked from w3c/automotive-viss2
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upstream initial android application that leverage gRPC/VISS API
Application supports following features - Collect & Vistualize vehicle datasets to enable 'Pay-as-you drive' usecase - Visualization of Safety score caluculation based on datasets - Curve logging visualization Application comply following VISS - gRPC APIs for Subscribing Vehicle datasets - Use Access Grant Token server(AGT) to authenticate/authorize client - Use Access Token(AT) server to validate the access Limitations - Doesn't use TLS as application assume that AGT, AT & VISS server runs on local host to simply the demo
- Loading branch information
1 parent
74b99f5
commit 6d3e3c2
Showing
88 changed files
with
20,361 additions
and
0 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,85 @@ | ||
plugins { | ||
alias(libs.plugins.androidApplication) | ||
alias(libs.plugins.jetbrainsKotlinAndroid) | ||
} | ||
|
||
android { | ||
namespace = "com.vissr.safetyscore" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "com.vissr.safetyscore" | ||
minSdk = 24 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.1" | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.lifecycle.runtime.ktx) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(platform(libs.androidx.compose.bom)) | ||
implementation(libs.androidx.ui) | ||
implementation(libs.androidx.ui.graphics) | ||
implementation(libs.androidx.ui.tooling.preview) | ||
implementation(libs.androidx.material3) | ||
testImplementation(libs.junit) | ||
androidTestImplementation(libs.androidx.junit) | ||
androidTestImplementation(libs.androidx.espresso.core) | ||
androidTestImplementation(platform(libs.androidx.compose.bom)) | ||
androidTestImplementation(libs.androidx.ui.test.junit4) | ||
debugImplementation(libs.androidx.ui.tooling) | ||
debugImplementation(libs.androidx.ui.test.manifest) | ||
|
||
// Koin | ||
implementation("io.insert-koin:koin-android:3.1.2") | ||
|
||
// gRPC dependencies | ||
implementation("io.grpc:grpc-okhttp:1.47.0") | ||
implementation("io.grpc:grpc-protobuf-lite:1.47.0") | ||
implementation("io.grpc:grpc-stub:1.46.0") | ||
implementation("io.grpc:grpc-kotlin-stub:1.3.0") | ||
implementation("com.google.protobuf:protobuf-kotlin-lite:3.21.2") | ||
|
||
// Retrofit | ||
implementation(libs.squareup.retrofit) | ||
implementation(libs.squareup.retrofit.converter.gson) | ||
implementation(libs.squareup.retrofit.converter.scalars) | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
client/android/covesa-vissr-app-demo/app/proguard-rules.pro
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 |
197 changes: 197 additions & 0 deletions
197
client/android/covesa-vissr-app-demo/app/proto/VISSv2.proto
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,197 @@ | ||
/** | ||
* (C) 2023 Ford Motor Company | ||
* (C) 2021 Geotab | ||
* | ||
* All files and artifacts in the repository at https://github.com/w3c/automotive-viss2 | ||
* are licensed under the provisions of the license provided by the LICENSE file in this repository. | ||
* | ||
**/ | ||
|
||
syntax = "proto3"; | ||
package grpcProtobufMessages; | ||
|
||
//import "google/protobuf/timestamp.proto"; | ||
option go_package = "./"; | ||
|
||
enum ResponseStatus { | ||
SUCCESS = 0; | ||
ERROR = 1; | ||
} | ||
|
||
enum SubscribeResponseType { | ||
RESPONSE = 0; | ||
EVENT = 1; | ||
} | ||
|
||
service VISSv2 { | ||
rpc GetRequest (GetRequestMessage) returns (GetResponseMessage); | ||
|
||
rpc SetRequest (SetRequestMessage) returns (SetResponseMessage); | ||
|
||
rpc SubscribeRequest (SubscribeRequestMessage) returns (stream SubscribeStreamMessage); | ||
|
||
rpc UnsubscribeRequest (UnsubscribeRequestMessage) returns (UnsubscribeResponseMessage); | ||
} | ||
|
||
message ErrorResponseMessage { | ||
string Number = 1; | ||
optional string Reason = 2; | ||
optional string Message = 3; | ||
} | ||
|
||
message FilterExpressions { | ||
message FilterExpression { | ||
enum FilterType { | ||
PATHS = 0; | ||
TIMEBASED = 1; | ||
RANGE = 2; | ||
CHANGE = 3; | ||
CURVELOG = 4; | ||
HISTORY = 5; | ||
STATIC_METADATA = 6; | ||
DYNAMIC_METADATA = 7; | ||
} | ||
FilterType FType = 1; | ||
|
||
message FilterValue { | ||
message PathsValue { | ||
repeated string RelativePath = 1; | ||
} | ||
optional PathsValue ValuePaths = 1; | ||
|
||
message TimebasedValue { | ||
string Period = 1; | ||
} | ||
optional TimebasedValue ValueTimebased = 2; | ||
|
||
message RangeValue { | ||
string LogicOperator = 1; | ||
string Boundary = 2; | ||
} | ||
repeated RangeValue ValueRange = 3; | ||
|
||
message ChangeValue { | ||
string LogicOperator = 1; | ||
string Diff = 2; | ||
} | ||
optional ChangeValue ValueChange = 4; | ||
|
||
message CurvelogValue { | ||
string MaxErr = 1; | ||
string BufSize = 2; | ||
} | ||
optional CurvelogValue ValueCurvelog = 5; | ||
|
||
message HistoryValue { | ||
string TimePeriod = 1; //ISO8601 period expression | ||
} | ||
optional HistoryValue ValueHistory = 6; | ||
|
||
message StaticMetadataValue { | ||
string Tree = 1; | ||
} | ||
optional StaticMetadataValue ValueStaticMetadata = 7; | ||
|
||
message DynamicMetadataValue { | ||
string MetadataDomain = 1; | ||
} | ||
optional DynamicMetadataValue ValueDynamicMetadata = 8; | ||
} | ||
FilterValue Value = 2; | ||
} | ||
repeated FilterExpression FilterExp = 1; | ||
} | ||
|
||
message DataPackages { | ||
message DataPackage { | ||
optional string Path = 1; | ||
optional int32 PathC = 2; | ||
|
||
message DataPoint { | ||
string Value = 1; | ||
optional string Ts = 2; | ||
optional int32 TsC = 3; | ||
} | ||
repeated DataPoint Dp = 3; | ||
} | ||
repeated DataPackage Data = 1; | ||
} | ||
|
||
message GetRequestMessage { | ||
string Path = 1; | ||
optional FilterExpressions Filter = 2; | ||
optional string Authorization = 3; | ||
optional string RequestId = 4; | ||
} | ||
|
||
message GetResponseMessage { | ||
ResponseStatus Status = 1; | ||
message SuccessResponseMessage { | ||
optional DataPackages DataPack = 1; | ||
optional string Metadata = 2; // replaces DataPack in static metadata and one dynamic metadata variant | ||
} | ||
optional SuccessResponseMessage SuccessResponse = 2; | ||
optional ErrorResponseMessage ErrorResponse = 3; | ||
optional string RequestId = 4; | ||
optional string Ts = 5; | ||
optional int32 TsC = 6; | ||
} | ||
|
||
message SetRequestMessage { | ||
string Path = 1; | ||
string Value = 2; | ||
optional string Authorization = 3; | ||
optional string RequestId = 4; | ||
} | ||
|
||
message SetResponseMessage { | ||
ResponseStatus Status = 1; | ||
optional ErrorResponseMessage ErrorResponse = 2; | ||
optional string RequestId = 3; | ||
string Ts = 4; | ||
} | ||
|
||
message SubscribeRequestMessage { | ||
string Path = 1; | ||
optional FilterExpressions Filter = 2; | ||
optional string Authorization = 3; | ||
string RequestId = 4; | ||
} | ||
|
||
message SubscribeStreamMessage { | ||
SubscribeResponseType MType = 1; | ||
ResponseStatus Status = 2; | ||
|
||
message SubscribeResponseMessage { | ||
optional ErrorResponseMessage ErrorResponse = 1; | ||
string SubscriptionId = 2; | ||
string RequestId = 3; | ||
string Ts = 4; | ||
} | ||
optional SubscribeResponseMessage Response = 3; | ||
|
||
message SubscribeEventMessage { | ||
string SubscriptionId = 1; | ||
message SuccessResponseMessage { | ||
DataPackages DataPack = 1; | ||
} | ||
optional SuccessResponseMessage SuccessResponse = 2; | ||
optional ErrorResponseMessage ErrorResponse = 3; | ||
optional string Ts = 4; | ||
optional int32 TsC = 5; | ||
} | ||
optional SubscribeEventMessage Event = 4; | ||
} | ||
|
||
message UnsubscribeRequestMessage { | ||
string SubscriptionId = 1; | ||
optional string RequestId = 2; | ||
} | ||
|
||
message UnsubscribeResponseMessage { | ||
string SubscriptionId = 1; | ||
ResponseStatus Status = 2; | ||
optional ErrorResponseMessage ErrorResponse = 3; | ||
optional string RequestId = 4; | ||
string Ts = 5; | ||
} |
Binary file added
BIN
+13.6 MB
client/android/covesa-vissr-app-demo/app/proto/protoc-gen-grpc-kotlin-1.3.0-jdk8.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
client/android/covesa-vissr-app-demo/app/proto/protoc-gen-grpc-kotlin.sh
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,4 @@ | ||
#!/usr/bin/env sh | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
java -jar $DIR/protoc-gen-grpc-kotlin-1.3.0-jdk8.jar |
24 changes: 24 additions & 0 deletions
24
...-vissr-app-demo/app/src/androidTest/java/com/vissr/safetyscore/ExampleInstrumentedTest.kt
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 @@ | ||
package com.vissr.safetyscore | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.volvo.carapi", appContext.packageName) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
client/android/covesa-vissr-app-demo/app/src/main/AndroidManifest.xml
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,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.vissr.safetyscore"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
||
<application | ||
android:name="com.vissr.safetyscore.VissApiGrpcDemoApplication" | ||
android:networkSecurityConfig="@xml/network_security_config" | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.VissApiGrpcDemo" | ||
tools:targetApi="31"> | ||
|
||
<activity | ||
android:name="com.vissr.safetyscore.ui.MainActivity" | ||
android:exported="true" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme.VissApiGrpcDemo"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Oops, something went wrong.