[automerger skipped] DO NOT MERGE: Add support for lane guidance transparency am: 16dca10dab am: d602116153 am: 7884f95e2c
am: 2b742134d4 -s ours
am skip reason: subject contains skip directive

Change-Id: Ib062358833af0bbe44074f16d0f04be656041a4e
diff --git a/Android.mk b/Android.mk
index 8da51c3..ef92d7e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -36,8 +36,7 @@
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    android.car.cluster.navigation \
-    androidx.car_car-cluster
+    android.car.cluster.navigation
 
 LOCAL_JAVA_LIBRARIES += android.car
 LOCAL_STATIC_ANDROID_LIBRARIES += \
diff --git a/src/android/car/cluster/ClusterRenderingService.java b/src/android/car/cluster/ClusterRenderingService.java
index 5770773..f27b036 100644
--- a/src/android/car/cluster/ClusterRenderingService.java
+++ b/src/android/car/cluster/ClusterRenderingService.java
@@ -40,8 +40,6 @@
 import android.view.InputDevice;
 import android.view.KeyEvent;
 
-import androidx.versionedparcelable.ParcelUtils;
-
 import com.google.protobuf.InvalidProtocolBufferException;
 
 import java.io.FileDescriptor;
@@ -190,39 +188,27 @@
             }
 
             @Override
-            public void onEvent(int eventType, Bundle bundle) {
+            public void onNavigationStateChanged(Bundle bundle) {
                 StringBuilder bundleSummary = new StringBuilder();
-                if (eventType == NAV_STATE_EVENT_ID) {
-                    // Required to prevent backwards compatibility crash with old map providers
-                    // sending androidx.versionedparcelables
-                    bundle.setClassLoader(ParcelUtils.class.getClassLoader());
-                    
-                    // Attempt to read proto byte array
-                    byte[] protoBytes = bundle.getByteArray(NAV_STATE_PROTO_BUNDLE_KEY);
-                    if (protoBytes != null) {
-                        try {
-                            NavigationStateProto navState = NavigationStateProto.parseFrom(
-                                    protoBytes);
-                            bundleSummary.append(navState.toString());
 
-                            // Update clients
-                            broadcastClientEvent(
-                                    client -> client.onNavigationStateChange(navState));
-                        } catch (InvalidProtocolBufferException e) {
-                            Log.e(TAG, "Error parsing navigation state proto", e);
-                        }
-                    } else {
-                        Log.e(TAG, "Received nav state byte array is null");
+                // Attempt to read proto byte array
+                byte[] protoBytes = bundle.getByteArray(NAV_STATE_PROTO_BUNDLE_KEY);
+                if (protoBytes != null) {
+                    try {
+                        NavigationStateProto navState = NavigationStateProto.parseFrom(
+                                protoBytes);
+                        bundleSummary.append(navState.toString());
+
+                        // Update clients
+                        broadcastClientEvent(
+                                client -> client.onNavigationStateChange(navState));
+                    } catch (InvalidProtocolBufferException e) {
+                        Log.e(TAG, "Error parsing navigation state proto", e);
                     }
                 } else {
-                    for (String key : bundle.keySet()) {
-                        bundleSummary.append(key);
-                        bundleSummary.append("=");
-                        bundleSummary.append(bundle.get(key));
-                        bundleSummary.append(" ");
-                    }
+                    Log.e(TAG, "Received nav state byte array is null");
                 }
-                Log.d(TAG, "onEvent(" + eventType + ", " + bundleSummary + ")");
+                Log.d(TAG, "onNavigationStateChanged(" + bundleSummary + ")");
             }
         };
 
diff --git a/src/android/car/cluster/ImageResolver.java b/src/android/car/cluster/ImageResolver.java
index 2e1ada9..5053d67 100644
--- a/src/android/car/cluster/ImageResolver.java
+++ b/src/android/car/cluster/ImageResolver.java
@@ -44,12 +44,7 @@
         /**
          * Returns a {@link Bitmap} given a request Uri and dimensions
          */
-        Bitmap getBitmap(Uri uri, int width, int height);
-
-        /**
-         * Returns a {@link Bitmap} given a request Uri, dimensions, and offLanesAlpha value
-         */
-        Bitmap getBitmap(Uri uri, int width, int height, float offLanesAlpha);
+        Bitmap getBitmap(Uri uri, int width, int height) throws IllegalArgumentException;
     }
 
     /**
@@ -69,22 +64,6 @@
      */
     @NonNull
     public CompletableFuture<Bitmap> getBitmap(@NonNull ImageReference img, int width, int height) {
-        return getBitmap(img, width, height, 1f);
-    }
-
-    /**
-     * Returns a {@link CompletableFuture} that provides a bitmap from a {@link ImageReference}.
-     * This image would fit inside the provided size. Either width, height or both should be greater
-     * than 0.
-     *
-     * @param width         required width, or 0 if width is flexible based on height.
-     * @param height        required height, or 0 if height is flexible based on width.
-     * @param offLanesAlpha opacity value for off lane guidance images. Only applies to lane
-     *                      guidance images. 0 (transparent) <= offLanesAlpha <= 1 (opaque).
-     */
-    @NonNull
-    public CompletableFuture<Bitmap> getBitmap(@NonNull ImageReference img, int width, int height,
-            float offLanesAlpha) {
         if (Log.isLoggable(TAG, Log.DEBUG)) {
             Log.d(TAG, String.format("Requesting image %s (width: %d, height: %d)",
                     img.getContentUri(), width, height));
@@ -101,9 +80,9 @@
             Uri uri = Uri.parse(img.getContentUri());
             Bitmap bitmap = null;
             try {
-                bitmap = mFetcher.getBitmap(uri, adjusted.x, adjusted.y, offLanesAlpha);
+                bitmap = mFetcher.getBitmap(uri, adjusted.x, adjusted.y);
             } catch (IllegalArgumentException e) {
-                Log.e(TAG, e.getMessage());
+                Log.e(TAG, "Bitmap must have positive width and height");
             }
             if (bitmap == null) {
                 if (Log.isLoggable(TAG, Log.DEBUG)) {
@@ -131,28 +110,12 @@
     @NonNull
     public CompletableFuture<Map<ImageReference, Bitmap>> getBitmaps(
             @NonNull List<ImageReference> imgs, int width, int height) {
-        return getBitmaps(imgs, width, height, 1f);
-    }
-
-    /**
-     * Same as {@link #getBitmap(ImageReference, int, int)} but it works on a list of images. The
-     * returning {@link CompletableFuture} will contain a map from each {@link ImageReference} to
-     * its bitmap. If any image fails to be fetched, the whole future completes exceptionally.
-     *
-     * @param width         required width, or 0 if width is flexible based on height.
-     * @param height        required height, or 0 if height is flexible based on width.
-     * @param offLanesAlpha opacity value for off lane guidance images. Only applies to lane
-     *                      guidance images. 0 (transparent) <= offLanesAlpha <= 1 (opaque).
-     */
-    @NonNull
-    public CompletableFuture<Map<ImageReference, Bitmap>> getBitmaps(
-            @NonNull List<ImageReference> imgs, int width, int height, float offLanesAlpha) {
         CompletableFuture<Map<ImageReference, Bitmap>> future = new CompletableFuture<>();
 
         Map<ImageReference, CompletableFuture<Bitmap>> bitmapFutures = imgs.stream().collect(
                 Collectors.toMap(
                         img -> img,
-                        img -> getBitmap(img, width, height, offLanesAlpha)));
+                        img -> getBitmap(img, width, height)));
 
         CompletableFuture.allOf(bitmapFutures.values().toArray(new CompletableFuture[0]))
                 .thenAccept(v -> {
diff --git a/src/android/car/cluster/LoggingClusterRenderingService.java b/src/android/car/cluster/LoggingClusterRenderingService.java
index 89990f9..dfed06c 100644
--- a/src/android/car/cluster/LoggingClusterRenderingService.java
+++ b/src/android/car/cluster/LoggingClusterRenderingService.java
@@ -15,6 +15,7 @@
  */
 package android.car.cluster;
 
+import android.car.cluster.navigation.NavigationState.NavigationStateProto;
 import android.car.cluster.renderer.InstrumentClusterRenderingService;
 import android.car.cluster.renderer.NavigationRenderer;
 import android.car.navigation.CarNavigationInstrumentCluster;
@@ -32,7 +33,6 @@
 public class LoggingClusterRenderingService extends InstrumentClusterRenderingService {
     private static final String TAG = LoggingClusterRenderingService.class.getSimpleName();
     private static final String NAV_STATE_PROTO_BUNDLE_KEY = "navstate2";
-    private static final int NAV_STATE_EVENT_ID = 1;
 
     @Override
     public NavigationRenderer getNavigationRenderer() {
@@ -48,39 +48,29 @@
             }
 
             @Override
-            public void onEvent(int eventType, Bundle bundle) {
+            public void onNavigationStateChanged(Bundle bundle) {
                 StringBuilder bundleSummary = new StringBuilder();
-                if (eventType == NAV_STATE_EVENT_ID) {
-                    // Attempt to read proto byte array
-                    byte[] protoBytes = bundle.getByteArray(NAV_STATE_PROTO_BUNDLE_KEY);
-                    if (protoBytes != null) {
-                        try {
-                            android.car.cluster.navigation.NavigationState.NavigationStateProto
-                                    navState =
-                                    android.car.cluster.navigation.NavigationState.NavigationStateProto.parseFrom(
-                                            protoBytes);
-                            bundleSummary.append(navState.toString());
 
-                            // Sending broadcast for testing.
-                            Intent intent = new Intent(
-                                    "android.car.cluster.NAVIGATION_STATE_UPDATE");
-                            intent.putExtra(NAV_STATE_PROTO_BUNDLE_KEY, bundle);
-                            sendBroadcastAsUser(intent, UserHandle.ALL);
-                        } catch (InvalidProtocolBufferException e) {
-                            Log.e(TAG, "Error parsing navigation state proto", e);
-                        }
-                    } else {
-                        Log.e(TAG, "Received nav state byte array is null");
+                // Attempt to read proto byte array
+                byte[] protoBytes = bundle.getByteArray(NAV_STATE_PROTO_BUNDLE_KEY);
+                if (protoBytes != null) {
+                    try {
+                        NavigationStateProto navState = NavigationStateProto.parseFrom(protoBytes);
+                        bundleSummary.append(navState.toString());
+
+                        // Sending broadcast for testing.
+                        Intent intent = new Intent(
+                                "android.car.cluster.NAVIGATION_STATE_UPDATE");
+                        intent.putExtra(NAV_STATE_PROTO_BUNDLE_KEY, bundle);
+                        sendBroadcastAsUser(intent, UserHandle.ALL);
+                    } catch (InvalidProtocolBufferException e) {
+                        Log.e(TAG, "Error parsing navigation state proto", e);
                     }
                 } else {
-                    for (String key : bundle.keySet()) {
-                        bundleSummary.append(key);
-                        bundleSummary.append("=");
-                        bundleSummary.append(bundle.get(key));
-                        bundleSummary.append(" ");
-                    }
+                    Log.e(TAG, "Received nav state byte array is null");
                 }
-                Log.i(TAG, "onEvent(" + eventType + ", " + bundleSummary + ")");
+
+                Log.i(TAG, "onEvent(" + bundleSummary + ")");
             }
         };
 
diff --git a/src/android/car/cluster/NetworkedVirtualDisplay.java b/src/android/car/cluster/NetworkedVirtualDisplay.java
index 56121d0..831f61e 100644
--- a/src/android/car/cluster/NetworkedVirtualDisplay.java
+++ b/src/android/car/cluster/NetworkedVirtualDisplay.java
@@ -380,7 +380,7 @@
                 }
                 return new PipeThread(mHandler, pipe);
             } catch (IOException e) {
-                Log.e(TAG, "Failed to establish pipe connection", e);
+                Log.w(TAG, "Failed to establish pipe connection", e);
                 return null;
             }
         }
@@ -401,7 +401,7 @@
 
                 return new SocketThread(mHandler, serverSocket, inputStream, outputStream);
             } catch (IOException e) {
-                Log.e(TAG, "Failed to establish network connection", e);
+                Log.w(TAG, "Failed to establish network connection", e);
                 return null;
             }
         }
diff --git a/tests/robotests/src/android/car/cluster/ImageResolverTest.java b/tests/robotests/src/android/car/cluster/ImageResolverTest.java
index 9b39659..0c05390 100644
--- a/tests/robotests/src/android/car/cluster/ImageResolverTest.java
+++ b/tests/robotests/src/android/car/cluster/ImageResolverTest.java
@@ -17,9 +17,7 @@
 
 import static org.junit.Assert.assertEquals;
 
-import android.graphics.Bitmap;
 import android.graphics.Point;
-import android.net.Uri;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -34,17 +32,7 @@
 
     @Before
     public void setup() {
-        mImageResolver = new ImageResolver(new ImageResolver.BitmapFetcher() {
-            @Override
-            public Bitmap getBitmap(Uri uri, int width, int height) {
-                return null;
-            }
-
-            @Override
-            public Bitmap getBitmap(Uri uri, int width, int height, float offLanesAlpha) {
-                return null;
-            }
-        });
+        mImageResolver = new ImageResolver((uri, w, h) -> null);
     }
 
     @Test