aboutsummaryrefslogtreecommitdiff
path: root/car-lib/src/android/car/navigation
diff options
context:
space:
mode:
authorPavel Maltsev <pavelm@google.com>2017-07-05 19:09:07 -0700
committerPavel Maltsev <pavelm@google.com>2017-07-07 15:22:01 -0700
commit1fd2ff63ed701ccc8d2f86d6285e09410eedb411 (patch)
treed47a12e01096e78a10e906668a222e39a35be206 /car-lib/src/android/car/navigation
parentf91b5eaf2231a61689127d2b887894cde21f6110 (diff)
downloadCar-1fd2ff63ed701ccc8d2f86d6285e09410eedb411.tar.gz
Allow to pass custom bundle in Car Nav Manager
Fix: b/63148533 Test: added API test, verified bundle is received in logging renderer Change-Id: Ieb230c02a89251520fce058f082bc63cc522aad8
Diffstat (limited to 'car-lib/src/android/car/navigation')
-rw-r--r--car-lib/src/android/car/navigation/CarNavigationInstrumentCluster.java34
-rw-r--r--car-lib/src/android/car/navigation/CarNavigationStatusManager.java36
2 files changed, 57 insertions, 13 deletions
diff --git a/car-lib/src/android/car/navigation/CarNavigationInstrumentCluster.java b/car-lib/src/android/car/navigation/CarNavigationInstrumentCluster.java
index fe48504274..cfa05f8037 100644
--- a/car-lib/src/android/car/navigation/CarNavigationInstrumentCluster.java
+++ b/car-lib/src/android/car/navigation/CarNavigationInstrumentCluster.java
@@ -17,9 +17,9 @@ package android.car.navigation;
import android.annotation.IntDef;
import android.annotation.SystemApi;
+import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
-
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -46,13 +46,15 @@ public class CarNavigationInstrumentCluster implements Parcelable {
private int mMinIntervalMillis;
@ClusterType
- private int mType;
+ private final int mType;
+
+ private final int mImageWidth;
- private int mImageWidth;
+ private final int mImageHeight;
- private int mImageHeight;
+ private final int mImageColorDepthBits;
- private int mImageColorDepthBits;
+ private final Bundle mExtra;
public static final Parcelable.Creator<CarNavigationInstrumentCluster> CREATOR
= new Parcelable.Creator<CarNavigationInstrumentCluster>() {
@@ -102,6 +104,12 @@ public class CarNavigationInstrumentCluster implements Parcelable {
}
/**
+ * Contains extra information about instrument cluster.
+ * @hide
+ */
+ public Bundle getExtra() { return mExtra; }
+
+ /**
* If instrument cluster is image, number of bits of colour depth it supports (8, 16, or 32).
*/
public int getImageColorDepthBits() {
@@ -130,11 +138,12 @@ public class CarNavigationInstrumentCluster implements Parcelable {
int imageWidth,
int imageHeight,
int imageColorDepthBits) {
- this.mMinIntervalMillis = minIntervalMillis;
- this.mType = type;
- this.mImageWidth = imageWidth;
- this.mImageHeight = imageHeight;
- this.mImageColorDepthBits = imageColorDepthBits;
+ mMinIntervalMillis = minIntervalMillis;
+ mType = type;
+ mImageWidth = imageWidth;
+ mImageHeight = imageHeight;
+ mImageColorDepthBits = imageColorDepthBits;
+ mExtra = new Bundle();
}
@Override
@@ -149,6 +158,7 @@ public class CarNavigationInstrumentCluster implements Parcelable {
dest.writeInt(mImageWidth);
dest.writeInt(mImageHeight);
dest.writeInt(mImageColorDepthBits);
+ dest.writeBundle(mExtra);
}
private CarNavigationInstrumentCluster(Parcel in) {
@@ -157,6 +167,7 @@ public class CarNavigationInstrumentCluster implements Parcelable {
mImageWidth = in.readInt();
mImageHeight = in.readInt();
mImageColorDepthBits = in.readInt();
+ mExtra = in.readBundle(getClass().getClassLoader());
}
/** Converts to string for debug purpose */
@@ -167,6 +178,7 @@ public class CarNavigationInstrumentCluster implements Parcelable {
"type: " + mType + ", " +
"imageWidth: " + mImageWidth + ", " +
"imageHeight: " + mImageHeight + ", " +
- "imageColourDepthBits: " + mImageColorDepthBits + " }";
+ "imageColourDepthBits: " + mImageColorDepthBits +
+ "extra: " + mExtra + " }";
}
}
diff --git a/car-lib/src/android/car/navigation/CarNavigationStatusManager.java b/car-lib/src/android/car/navigation/CarNavigationStatusManager.java
index f24ff30773..9a83219858 100644
--- a/car-lib/src/android/car/navigation/CarNavigationStatusManager.java
+++ b/car-lib/src/android/car/navigation/CarNavigationStatusManager.java
@@ -22,10 +22,10 @@ import android.car.CarManagerBase;
import android.car.CarNotConnectedException;
import android.car.cluster.renderer.IInstrumentClusterNavigation;
import android.graphics.Bitmap;
+import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
-
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -114,6 +114,13 @@ public final class CarNavigationStatusManager implements CarManagerBase {
@Retention(RetentionPolicy.SOURCE)
public @interface TurnEvent {}
+ /** Event type that holds information about next maneuver. */
+ public static final int EVENT_TYPE_NEXT_MANEUVER_INFO = 1;
+ /** Event type that holds information regarding distance/time to the next maneuver. */
+ public static final int EVENT_TYPE_NEXT_MANEUVER_COUNTDOWN = 2;
+ /** All custom (vendor-specific) event types should be equal or greater than this constant. */
+ public static final int EVENT_TYPE_VENDOR_FIRST = 1024;
+
/* Turn Side */
/** Turn is on the left side of the vehicle. */
public static final int TURN_SIDE_LEFT = 1;
@@ -198,7 +205,7 @@ public final class CarNavigationStatusManager implements CarManagerBase {
* drives on the left-hand side of the road, such as Australia; anti-clockwise for roads where
* the car drives on the right, such as the USA).
*
- * @param event event type ({@link #TURN_TURN}, {@link #TURN_U_TURN},
+ * @param turnEvent turn event like ({@link #TURN_TURN}, {@link #TURN_U_TURN},
* {@link #TURN_ROUNDABOUT_ENTER_AND_EXIT}, etc).
* @param eventName Name of the turn event like road name to turn. For example "Charleston road"
* in "Turn right to Charleston road"
@@ -212,6 +219,7 @@ public final class CarNavigationStatusManager implements CarManagerBase {
* {@link #TURN_SIDE_UNSPECIFIED}).
* @throws CarNotConnectedException if the connection to the car service has been lost.
*
+ * @deprecated Use {@link #sendEvent(int, Bundle)} instead.
*/
public void sendNavigationTurnEvent(@TurnEvent int turnEvent, CharSequence eventName,
int turnAngle, int turnNumber, Bitmap image, @TurnSide int turnSide)
@@ -238,6 +246,8 @@ public final class CarNavigationStatusManager implements CarManagerBase {
* @param displayDistanceUnit units for {@param displayDistanceMillis} param.
* See {@link DistanceUnit} for acceptable values.
* @throws CarNotConnectedException if the connection to the car service has been lost.
+ *
+ * @deprecated Use {@link #sendEvent(int, Bundle)} instead.
*/
public void sendNavigationTurnDistanceEvent(int distanceMeters, int timeSeconds,
int displayDistanceMillis, @DistanceUnit int displayDistanceUnit)
@@ -252,6 +262,28 @@ public final class CarNavigationStatusManager implements CarManagerBase {
}
}
+ /**
+ * Sends events from navigation app to instrument cluster.
+ *
+ * @param eventType event type
+ * @param bundle object that holds data about the event
+ * @throws CarNotConnectedException if the connection to the car service has been lost.
+ *
+ * @see #EVENT_TYPE_NEXT_MANEUVER_INFO
+ * @see #EVENT_TYPE_NEXT_MANEUVER_COUNTDOWN
+ *
+ * @hide
+ */
+ public void sendEvent(int eventType, Bundle bundle) throws CarNotConnectedException {
+ try {
+ mService.onEvent(eventType, bundle);
+ } catch (IllegalStateException e) {
+ CarApiUtil.checkCarNotConnectedExceptionFromCarService(e);
+ } catch (RemoteException e) {
+ handleCarServiceRemoteExceptionAndThrow(e);
+ }
+ }
+
@Override
public void onCarDisconnected() {
Log.d(TAG, "onCarDisconnected");