Merge "Import translations. DO NOT MERGE" into qt-dev
diff --git a/car-lib/src/android/car/navigation/navigation_state.proto b/car-lib/src/android/car/navigation/navigation_state.proto
index d786ad3..f6161e0 100644
--- a/car-lib/src/android/car/navigation/navigation_state.proto
+++ b/car-lib/src/android/car/navigation/navigation_state.proto
@@ -106,6 +106,8 @@
// Information about a maneuver that the driver will be required to perform.
message Maneuver {
+
+ // Next ID: 57
enum Type {
// Maneuver type is unknown, no maneuver information should be displayed.
UNKNOWN = 0;
@@ -168,6 +170,7 @@
// Current road joins another (e.g. "Merge left/right onto Main St.").
MERGE_LEFT = 27;
MERGE_RIGHT = 28;
+ MERGE_SIDE_UNSPECIFIED = 54;
// Roundabout entrance on which the current road ends (e.g. "Enter the
// roundabout").
@@ -183,6 +186,7 @@
// (sharp right, vs. normal left, etc. - see the definitions for
// TURN_SHARP_LEFT, TURN_SLIGHT_RIGHT, etc., for a definition of what "sharp"
// vs. "normal" vs. "slight" is.
+ ROUNDABOUT_ENTER_AND_EXIT_CW = 55;
ROUNDABOUT_ENTER_AND_EXIT_CW_SHARP_RIGHT = 31;
ROUNDABOUT_ENTER_AND_EXIT_CW_NORMAL_RIGHT = 32;
ROUNDABOUT_ENTER_AND_EXIT_CW_SLIGHT_RIGHT = 33;
@@ -198,6 +202,7 @@
// amount (sharp right, vs. normal left, etc. - see the definitions for
// TURN_SHARP_LEFT, TURN_SLIGHT_RIGHT, etc., for a definition of what "sharp"
// vs. "normal" vs. "slight" is.
+ ROUNDABOUT_ENTER_AND_EXIT_CCW = 56;
ROUNDABOUT_ENTER_AND_EXIT_CCW_SHARP_RIGHT = 39;
ROUNDABOUT_ENTER_AND_EXIT_CCW_NORMAL_RIGHT = 40;
ROUNDABOUT_ENTER_AND_EXIT_CCW_SLIGHT_RIGHT = 41;
diff --git a/tests/EmbeddedKitchenSinkApp/Android.mk b/tests/EmbeddedKitchenSinkApp/Android.mk
index 386044c..f00a14b 100644
--- a/tests/EmbeddedKitchenSinkApp/Android.mk
+++ b/tests/EmbeddedKitchenSinkApp/Android.mk
@@ -50,7 +50,8 @@
vehicle-hal-support-lib \
com.android.car.keventreader-client \
guava \
- kitchensink-gson
+ kitchensink-gson \
+ android.car.cluster.navigation
LOCAL_JAVA_LIBRARIES += android.car
diff --git a/tests/EmbeddedKitchenSinkApp/res/raw/nav_state_data.json b/tests/EmbeddedKitchenSinkApp/res/raw/nav_state_data.json
deleted file mode 100644
index 414cc2d..0000000
--- a/tests/EmbeddedKitchenSinkApp/res/raw/nav_state_data.json
+++ /dev/null
@@ -1,143 +0,0 @@
-[
- {
- "mSteps": [
- {
- "mDistance": {
- "mMeters": 200,
- "mDisplayValue": "0.2",
- "mDisplayUnit": { "mValues": [ "KILOMETERS" ] }
- },
- "mManeuver": {
- "mType": { "mValues": [ "DEPART" ] }
- },
- "mCue":{
- "mElements": [
- {
- "mText": "Stay on"
- },
- {
- "mText": "US 101",
- "mImage": {
- "mContentUri": "content://com.google.android.car.kitchensink.cluster.clustercontentprovider/img/US_101.png",
- "mOriginalWidth": 60,
- "mOriginalHeight": 52
- }
- },
- {
- "mText": "East"
- }
- ]
- },
- "mLanes": [
- {
- "mDirections": [
- {
- "mShape": { "mValues": [ "SLIGHT_LEFT" ] },
- "mHighlighted": false
- }
- ]
- },
- {
- "mDirections": [
- {
- "mShape": { "mValues": [ "STRAIGHT" ] },
- "mHighlighted": false
- }
- ]
- },
- {
- "mDirections": [
- {
- "mShape": { "mValues": [ "STRAIGHT" ] },
- "mHighlighted": false
- }
- ]
- },
- {
- "mDirections": [
- {
- "mShape": { "mValues": [ "STRAIGHT" ] },
- "mHighlighted": false
- }
- ]
- },
- {
- "mDirections": [
- {
- "mShape": { "mValues": [ "STRAIGHT" ] },
- "mHighlighted": false
- }
- ]
- },
- {
- "mDirections": [
- {
- "mShape": { "mValues": [ "STRAIGHT" ] },
- "mHighlighted": false
- },
- {
- "mShape": { "mValues": [ "SLIGHT_RIGHT" ] },
- "mHighlighted": true
- }
- ]
- },
- {
- "mDirections": [
- {
- "mShape": { "mValues": [ "SLIGHT_RIGHT" ] },
- "mHighlighted": false
- }
- ]
- }
- ]
- }
- ],
- "mCurrentSegment": {
- "mName": "On Something Really Long St"
- },
- "mDestinations": [
- {
- "mTitle": "Home",
- "mAddress": "123 Main st",
- "mDistance": {
- "mMeters": 2000,
- "mDisplayValue": "2",
- "mDisplayUnit": { "mValues": [ "KILOMETERS" ] }
- },
- "mEta": {
- "mSecondsSinceEpoch": 1551314762,
- "mZoneId": "America/Los_Angeles"
- },
- "mTraffic": { "mValues": [ "MEDIUM" ] }
- }
- ]
- },
- {
- "mSteps": [
- {
- "mDistance": {
- "mMeters": 91,
- "mDisplayValue": "300",
- "mDisplayUnit": { "mValues": [ "FEET" ] }
- },
- "mManeuver": {
- "mType": { "mValues": [ "TURN_NORMAL_LEFT" ] }
- }
- }
- ]
- },
- {
- "mSteps": [
- {
- "mDistance": {
- "mMeters": 3218,
- "mDisplayValue": "2",
- "mDisplayUnit": { "mValues": [ "MILES" ] }
- },
- "mManeuver": {
- "mType": { "mValues": [ "TURN_NORMAL_RIGHT" ] }
- }
- }
- ]
- }
-]
\ No newline at end of file
diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/cluster/InstrumentClusterFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/cluster/InstrumentClusterFragment.java
index 2c0e715..7657c38 100644
--- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/cluster/InstrumentClusterFragment.java
+++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/cluster/InstrumentClusterFragment.java
@@ -18,6 +18,20 @@
import android.annotation.Nullable;
import android.car.Car;
import android.car.CarAppFocusManager;
+import android.car.CarNotConnectedException;
+import android.car.cluster.navigation.NavigationState;
+import android.car.cluster.navigation.NavigationState.Cue;
+import android.car.cluster.navigation.NavigationState.Cue.CueElement;
+import android.car.cluster.navigation.NavigationState.Destination;
+import android.car.cluster.navigation.NavigationState.Destination.Traffic;
+import android.car.cluster.navigation.NavigationState.Distance;
+import android.car.cluster.navigation.NavigationState.Lane;
+import android.car.cluster.navigation.NavigationState.Lane.LaneDirection;
+import android.car.cluster.navigation.NavigationState.Maneuver;
+import android.car.cluster.navigation.NavigationState.NavigationStateProto;
+import android.car.cluster.navigation.NavigationState.Road;
+import android.car.cluster.navigation.NavigationState.Step;
+import android.car.cluster.navigation.NavigationState.Timestamp;
import android.car.navigation.CarNavigationStatusManager;
import android.content.ComponentName;
import android.content.ServiceConnection;
@@ -33,12 +47,9 @@
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
-import androidx.car.cluster.navigation.NavigationState;
import androidx.fragment.app.Fragment;
import com.google.android.car.kitchensink.R;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
import java.io.BufferedReader;
import java.io.IOException;
@@ -59,7 +70,7 @@
private CarAppFocusManager mCarAppFocusManager;
private Car mCarApi;
private Timer mTimer;
- private NavigationState[] mNavStateData;
+ private NavigationStateProto[] mNavStateData;
private Button mTurnByTurnButton;
private ServiceConnection mCarServiceConnection = new ServiceConnection() {
@@ -80,22 +91,23 @@
private final CarAppFocusManager.OnAppFocusOwnershipCallback mFocusCallback =
new CarAppFocusManager.OnAppFocusOwnershipCallback() {
- @Override
- public void onAppFocusOwnershipLost(@CarAppFocusManager.AppFocusType int appType) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "onAppFocusOwnershipLost, appType: " + appType);
- }
- Toast.makeText(getContext(), getText(R.string.cluster_nav_app_context_loss),
- Toast.LENGTH_LONG).show();
- }
+ @Override
+ public void onAppFocusOwnershipLost(@CarAppFocusManager.AppFocusType int appType) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "onAppFocusOwnershipLost, appType: " + appType);
+ }
+ Toast.makeText(getContext(), getText(R.string.cluster_nav_app_context_loss),
+ Toast.LENGTH_LONG).show();
+ }
- @Override
- public void onAppFocusOwnershipGranted(@CarAppFocusManager.AppFocusType int appType) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "onAppFocusOwnershipGranted, appType: " + appType);
- }
- }
- };
+ @Override
+ public void onAppFocusOwnershipGranted(
+ @CarAppFocusManager.AppFocusType int appType) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "onAppFocusOwnershipGranted, appType: " + appType);
+ }
+ }
+ };
private CarAppFocusManager.OnAppFocusChangedListener mOnAppFocusChangedListener =
(appType, active) -> {
if (Log.isLoggable(TAG, Log.DEBUG)) {
@@ -114,21 +126,68 @@
mCarApi.connect();
}
- /**
- * Loads sample navigation data from the "nav_state_data.json" file.
- */
@NonNull
- private NavigationState[] getNavStateData() {
- try {
- Gson gson = new GsonBuilder().create();
- String navStateData = getRawResourceAsString(R.raw.nav_state_data);
- NavigationState[] navigationState = gson.fromJson(navStateData,
- NavigationState[].class);
- return navigationState;
- } catch (IOException ex) {
- Log.e(TAG, "Unable to read navigation state data", ex);
- return new NavigationState[0];
- }
+ private NavigationStateProto[] getNavStateData() {
+ NavigationStateProto[] navigationStateArray = new NavigationStateProto[1];
+
+ navigationStateArray[0] = NavigationStateProto.newBuilder()
+ .addSteps(Step.newBuilder()
+ .setManeuver(Maneuver.newBuilder()
+ .setType(Maneuver.Type.DEPART)
+ .build())
+ .setDistance(Distance.newBuilder()
+ .setMeters(300)
+ .setDisplayUnits(Distance.Unit.FEET)
+ .setDisplayValue("0.5")
+ .build())
+ .setCue(Cue.newBuilder()
+ .addElements(CueElement.newBuilder()
+ .setText("Stay on ")
+ .build())
+ .addElements(CueElement.newBuilder()
+ .setText("US 101 ")
+ .setImage(NavigationState.ImageReference.newBuilder()
+ .setAspectRatio(1.153846)
+ .setContentUri(
+ "content://com.google.android.car"
+ + ".kitchensink.cluster"
+ + ".clustercontentprovider/img"
+ + "/US_101.png")
+ .build())
+ .build())
+ .build())
+ .addLanes(Lane.newBuilder()
+ .addLaneDirections(LaneDirection.newBuilder()
+ .setShape(LaneDirection.Shape.SLIGHT_LEFT)
+ .setIsHighlighted(false)
+ .build())
+ .addLaneDirections(LaneDirection.newBuilder()
+ .setShape(LaneDirection.Shape.STRAIGHT)
+ .setIsHighlighted(true)
+ .build())
+ .build())
+ .build())
+ .setCurrentRoad(Road.newBuilder()
+ .setName("On something really long st")
+ .build())
+ .addDestinations(Destination.newBuilder()
+ .setTitle("Home")
+ .setAddress("123 Main st")
+ .setDistance(Distance.newBuilder()
+ .setMeters(2000)
+ .setDisplayValue("2")
+ .setDisplayUnits(Distance.Unit.KILOMETERS)
+ .build())
+ .setEstimatedTimeAtArrival(Timestamp.newBuilder()
+ .setSeconds(1592610807)
+ .build())
+ .setFormattedDurationUntilArrival("45 min")
+ .setZoneId("America/Los_Angeles")
+ .setTraffic(Traffic.HIGH)
+ .build())
+ .build();
+
+ return navigationStateArray;
}
/**
@@ -216,11 +275,15 @@
/**
* Sends one update of the navigation state through the {@link CarNavigationStatusManager}
*/
- private void sendTurn(@NonNull NavigationState state) {
- Bundle bundle = new Bundle();
- bundle.putParcelable("navstate", state.toParcelable());
- mCarNavigationStatusManager.sendEvent(1, bundle);
- Log.i(TAG, "Sending nav state: " + state);
+ private void sendTurn(@NonNull NavigationStateProto state) {
+ try {
+ Bundle bundle = new Bundle();
+ bundle.putByteArray("navstate2", state.toByteArray());
+ mCarNavigationStatusManager.sendEvent(1, bundle);
+ Log.i(TAG, "Sending nav state: " + state);
+ } catch (CarNotConnectedException e) {
+ Log.e(TAG, "Failed to send turn information.", e);
+ }
}
private void initCluster() {
@@ -260,7 +323,7 @@
!= PackageManager.PERMISSION_GRANTED) {
Log.i(TAG, "Requesting: " + android.car.Car.PERMISSION_CAR_DISPLAY_IN_CLUSTER);
- requestPermissions(new String[] {android.car.Car.PERMISSION_CAR_DISPLAY_IN_CLUSTER},
+ requestPermissions(new String[]{android.car.Car.PERMISSION_CAR_DISPLAY_IN_CLUSTER},
DISPLAY_IN_CLUSTER_PERMISSION_REQUEST);
} else {
Log.i(TAG, "All required permissions granted");