Merge "Fix failing CarNavigationManager test" into nyc-dev
diff --git a/service/src/com/android/car/cluster/CarNavigationService.java b/service/src/com/android/car/cluster/CarNavigationService.java
index 597d10c..311b42a 100644
--- a/service/src/com/android/car/cluster/CarNavigationService.java
+++ b/service/src/com/android/car/cluster/CarNavigationService.java
@@ -51,7 +51,7 @@
     private final Context mContext;
     private final InstrumentClusterService mInstrumentClusterService;
 
-    private CarNavigationInstrumentCluster mInstrumentClusterInfo = null;
+    private volatile CarNavigationInstrumentCluster mInstrumentClusterInfo = null;
     private volatile NavigationRenderer mNavigationRenderer;
 
     public CarNavigationService(Context context, AppContextService appContextService,
@@ -64,8 +64,6 @@
     @Override
     public void init() {
         Log.d(TAG, "init");
-        // TODO: we need to obtain this infromation from CarInstrumentClusterService.
-        mInstrumentClusterInfo = CarNavigationInstrumentCluster.createCluster(1000);
         mInstrumentClusterService.registerListener(this);
     }
 
@@ -204,6 +202,9 @@
                 Looper.getMainLooper(),
                 mInstrumentClusterService.getNavigationRenderer());
 
+        // TODO: we need to obtain this information from InstrumentClusterRenderer.
+        mInstrumentClusterInfo = CarNavigationInstrumentCluster.createCluster(1000);
+
         if (isRendererAvailable()) {
             for (CarNavigationEventListener listener : mListeners) {
                 listener.onInstrumentClusterStart(mInstrumentClusterInfo);
diff --git a/tests/android_car_api_test/src/com/android/car/apitest/CarNavigationManagerTest.java b/tests/android_car_api_test/src/com/android/car/apitest/CarNavigationManagerTest.java
index 3f74a8f..a30136d 100644
--- a/tests/android_car_api_test/src/com/android/car/apitest/CarNavigationManagerTest.java
+++ b/tests/android_car_api_test/src/com/android/car/apitest/CarNavigationManagerTest.java
@@ -15,23 +15,24 @@
  */
 package com.android.car.apitest;
 
-import android.os.Looper;
 import android.car.Car;
 import android.car.CarAppContextManager;
 import android.car.CarAppContextManager.AppContextChangeListener;
 import android.car.navigation.CarNavigationInstrumentCluster;
-import android.car.CarNotConnectedException;
 import android.car.navigation.CarNavigationManager;
 import android.car.navigation.CarNavigationManager.CarNavigationListener;
+import android.util.Log;
 
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 /**
- * Unit tests for {@link android.support.car.navigation.CarNavigationStatusManager}
+ * Unit tests for {@link CarNavigationManager}
  */
 public class CarNavigationManagerTest extends CarApiTestBase {
 
+    private static final String TAG = CarNavigationManagerTest.class.getSimpleName();
+
     private CarNavigationManager mCarNavigationManager;
     private CarAppContextManager mCarAppContextManager;
 
@@ -47,6 +48,11 @@
     }
 
     public void testStart() throws Exception {
+        if (!mCarNavigationManager.isInstrumentClusterSupported()) {
+            Log.w(TAG, "Unable to run the test: instrument cluster is not supported");
+            return;
+        }
+
         final CountDownLatch onStartLatch = new CountDownLatch(1);
 
         mCarNavigationManager.registerListener(new CarNavigationListener() {