[automerger skipped] Update SUW Lib with OEM customizable boolean for immersive mode am: 9983a290a9 -s ours

am skip reason: skipped by user sandraalfaro

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/car/setupwizard/+/11843104

Change-Id: I7a934d2dfb62251d49e296e7d3da68d8493dfe6a
diff --git a/OWNERS b/OWNERS
index 422989e..30c6f6a 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,6 +1,7 @@
 # People who can approve changes for submission.
+jdsouza@google.com
 jinjian@google.com
-kevinjm@google.com
+sandraalfaro@google.com
 
 # TLs
 rlagos@google.com
diff --git a/library/main/Android.bp b/library/main/Android.bp
index af4f995..b7cc78f 100644
--- a/library/main/Android.bp
+++ b/library/main/Android.bp
@@ -17,8 +17,8 @@
     name: "car-setup-wizard-lib",
     srcs: ["src/**/*.java"],
     resource_dirs: ["res"],
-    libs: ["android.car"],
-    static_libs: ["androidx.car_car"],
+    libs: ["android.car-system-stubs"],
+    static_libs: ["androidx.car_car-resources-partially-dejetified"],
     optimize: {
         enabled: false,
     },
diff --git a/library/main/src/com/android/car/setupwizardlib/BaseSetupWizardActivity.java b/library/main/src/com/android/car/setupwizardlib/BaseSetupWizardActivity.java
index 0fa8b01..3da7df6 100644
--- a/library/main/src/com/android/car/setupwizardlib/BaseSetupWizardActivity.java
+++ b/library/main/src/com/android/car/setupwizardlib/BaseSetupWizardActivity.java
@@ -485,7 +485,7 @@
                 CarWizardManagerHelper.getNextIntent(getIntent(), mResultCode, mResultData);
         if (forResult) {
             startActivityForResult(nextIntent, REQUEST_CODE_NEXT);
-        } else  {
+        } else {
             startActivity(nextIntent);
         }
     }
diff --git a/library/main/src/com/android/car/setupwizardlib/CarSetupWizardBaseLayout.java b/library/main/src/com/android/car/setupwizardlib/CarSetupWizardBaseLayout.java
index 526a5ca..7a7808d 100644
--- a/library/main/src/com/android/car/setupwizardlib/CarSetupWizardBaseLayout.java
+++ b/library/main/src/com/android/car/setupwizardlib/CarSetupWizardBaseLayout.java
@@ -20,7 +20,6 @@
 import android.content.Context;
 import android.content.res.ColorStateList;
 import android.content.res.TypedArray;
-import android.graphics.PorterDuff;
 import android.graphics.Rect;
 import android.graphics.Typeface;
 import android.graphics.drawable.Drawable;
@@ -578,9 +577,10 @@
     /** Sets button text color using partner overlay if exists */
     @VisibleForTesting
     void setButtonTextColor(TextView button, PartnerConfig config) {
-        int color = mPartnerConfigHelper.getColor(getContext(), config);
-        if (color != 0) {
-            button.setTextColor(color);
+        ColorStateList colorStateList =
+                mPartnerConfigHelper.getColorStateList(getContext(), config);
+        if (colorStateList != null) {
+            button.setTextColor(colorStateList);
         }
     }
 
@@ -605,12 +605,9 @@
     /** Sets button background color using partner overlay if exists */
     @VisibleForTesting
     void setBackgroundColor(View button, PartnerConfig config) {
-        int color = mPartnerConfigHelper.getColor(getContext(), config);
-        if (color != 0) {
-            Drawable background = button.getBackground();
-            if (background != null) {
-                background.mutate().setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
-            }
+        ColorStateList color = mPartnerConfigHelper.getColorStateList(getContext(), config);
+        if (color != null) {
+            button.setBackgroundTintList(color);
         }
     }
 
diff --git a/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfigHelper.java b/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfigHelper.java
index 2f367a8..dfb134f 100644
--- a/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfigHelper.java
+++ b/library/main/src/com/android/car/setupwizardlib/partner/PartnerConfigHelper.java
@@ -19,6 +19,7 @@
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.pm.PackageManager;
+import android.content.res.ColorStateList;
 import android.content.res.Resources;
 import android.content.res.Resources.NotFoundException;
 import android.graphics.drawable.Drawable;
@@ -78,7 +79,10 @@
         }
 
         if (mPartnerResourceCache.containsKey(partnerConfig)) {
-            return (int) mPartnerResourceCache.get(partnerConfig);
+            Object cacheValue = mPartnerResourceCache.get(partnerConfig);
+            if (cacheValue instanceof Integer) {
+                return (int) cacheValue;
+            }
         }
 
         int result = 0;
@@ -100,6 +104,53 @@
     }
 
     /**
+     * Returns the {@link android.content.res.ColorStateList} of given {@link PartnerConfig}, or
+     * {@code null} if the given {@code partnerConfig} is not found. If the {@code ResourceType} of
+     * the given {@link PartnerConfig} is not a color, IllegalArgumentException will be thrown.
+     *
+     * @param context The context of client activity
+     * @param partnerConfig The {@link PartnerConfig} of target resource
+     */
+    @Nullable
+    public ColorStateList getColorStateList(@NonNull Context context, PartnerConfig partnerConfig) {
+        if (partnerConfig.getResourceType() != PartnerConfig.ResourceType.COLOR) {
+            throw new IllegalArgumentException("Not a color resource");
+        }
+
+        if (mPartnerResourceCache.containsKey(partnerConfig)) {
+            Object cacheValue = mPartnerResourceCache.get(partnerConfig);
+            if (cacheValue instanceof ColorStateList) {
+                return (ColorStateList) cacheValue;
+            }
+        }
+
+        ColorStateList result = null;
+        try {
+            String resourceName = partnerConfig.getResourceName();
+            ResourceEntry resourceEntry = getResourceEntryFromKey(resourceName);
+            if (resourceEntry == null) {
+                Log.w(TAG, "Resource not found: " + resourceName);
+                return null;
+            }
+
+            Resources resource = getResourcesByPackageName(context, resourceEntry.getPackageName());
+
+            // In case the resource is {@code null} it's simply returned as it is.
+            TypedValue outValue = new TypedValue();
+            resource.getValue(resourceEntry.getResourceId(), outValue, true);
+            if (outValue.type == TypedValue.TYPE_REFERENCE && outValue.data == 0) {
+                return result;
+            }
+
+            result = resource.getColorStateList(resourceEntry.getResourceId(), null);
+            mPartnerResourceCache.put(partnerConfig, result);
+        } catch (PackageManager.NameNotFoundException exception) {
+            Log.e(TAG, exception.getMessage());
+        }
+        return result;
+    }
+
+    /**
      * Returns the {@code Drawable} of given {@code partnerConfig}, or {@code null} if the given
      * {@code partnerConfig} is not found. If the {@code ResourceType} of the given {@code
      * resourceConfig} is not drawable, IllegalArgumentException will be thrown.
diff --git a/library/main/src/com/android/car/setupwizardlib/summary/PartnerSummaryActionsCollector.java b/library/main/src/com/android/car/setupwizardlib/summary/PartnerSummaryActionsCollector.java
index f0cc786..ed556cd 100644
--- a/library/main/src/com/android/car/setupwizardlib/summary/PartnerSummaryActionsCollector.java
+++ b/library/main/src/com/android/car/setupwizardlib/summary/PartnerSummaryActionsCollector.java
@@ -75,13 +75,13 @@
 
     // Extra used as a key for the action id passed in to query summary action state.
     private static final String EXTRA_ACTION_ID = "action_id";
-    private static PartnerSummaryActionsCollector sPartnerSummaryActionsCollector;
-    private final Context mContext;
+    private static PartnerSummaryActionsCollector partnerSummaryActionsCollector;
+    private final Context context;
     private Uri mContentProviderUri;
 
     /** private constructor, should use getter. */
     private PartnerSummaryActionsCollector(Context context) {
-        mContext = context;
+        this.context = context;
         ResolveInfo resolveInfo = getSummaryContentProviderResolveInfo(context.getPackageManager());
 
         if (resolveInfo == null) {
@@ -98,10 +98,10 @@
 
     /** Gets the current instance of the {@link PartnerSummaryActionsCollector}. */
     public static PartnerSummaryActionsCollector get(Context context) {
-        if (sPartnerSummaryActionsCollector == null) {
-            sPartnerSummaryActionsCollector = new PartnerSummaryActionsCollector(context);
+        if (partnerSummaryActionsCollector == null) {
+            partnerSummaryActionsCollector = new PartnerSummaryActionsCollector(context);
         }
-        return sPartnerSummaryActionsCollector;
+        return partnerSummaryActionsCollector;
     }
 
     /**
@@ -330,7 +330,7 @@
      *                                  properly.
      */
     private ArrayList<String> getPartnerSummaryActionsFromContentProvider(Uri contentProviderUri) {
-        Bundle result = mContext.getContentResolver().call(
+        Bundle result = context.getContentResolver().call(
                 contentProviderUri,
                 METHOD_GET_SUMMARY_ACTIONS,
                 /* arg= */ null,
@@ -358,7 +358,7 @@
             String actionId, Uri contentProviderUri) {
         Bundle completionStateArgs = new Bundle();
         completionStateArgs.putString(EXTRA_ACTION_ID, actionId);
-        Bundle result = mContext.getContentResolver().call(
+        Bundle result = context.getContentResolver().call(
                 contentProviderUri,
                 METHOD_GET_ACTION_COMPLETION_STATE,
                 /* arg= */ null,
@@ -374,7 +374,7 @@
             Uri contentProviderUri) {
         Bundle summaryStateArgs = new Bundle();
         summaryStateArgs.putString(EXTRA_ACTION_ID, actionId);
-        Bundle result = mContext.getContentResolver().call(
+        Bundle result = context.getContentResolver().call(
                 contentProviderUri,
                 METHOD_GET_ACTION_SUMMARY_STATE,
                 /* arg= */ null,
@@ -392,7 +392,7 @@
         deferredStateArgs.putString(EXTRA_ACTION_ID, actionId);
         Bundle result;
         try {
-            result = mContext.getContentResolver().call(
+            result = context.getContentResolver().call(
                     contentProviderUri,
                     METHOD_GET_DEFERRED_ACTION_STATE,
                     /* arg= */ null,
diff --git a/library/main/src/com/android/car/setupwizardlib/util/CarDrivingStateMonitor.java b/library/main/src/com/android/car/setupwizardlib/util/CarDrivingStateMonitor.java
index ee6c8db..759dd81 100644
--- a/library/main/src/com/android/car/setupwizardlib/util/CarDrivingStateMonitor.java
+++ b/library/main/src/com/android/car/setupwizardlib/util/CarDrivingStateMonitor.java
@@ -18,12 +18,8 @@
 
 import android.car.Car;
 import android.car.CarNotConnectedException;
-import android.car.VehicleAreaType;
-import android.car.VehiclePropertyIds;
 import android.car.drivingstate.CarUxRestrictions;
 import android.car.drivingstate.CarUxRestrictionsManager;
-import android.car.hardware.CarPropertyValue;
-import android.car.hardware.property.CarPropertyManager;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -47,17 +43,11 @@
     public static final String EXIT_BROADCAST_ACTION =
             "com.android.car.setupwizardlib.driving_exit";
 
-    public static final String INTENT_EXTRA_REASON = "reason";
-    public static final String REASON_GEAR_REVERSAL = "gear_reversal";
-
     private static final String TAG = "CarDrivingStateMonitor";
     private static final long DISCONNECT_DELAY_MS = 700;
 
-    private static final int GEAR_REVERSE = 2;
-
     private Car mCar;
     private CarUxRestrictionsManager mRestrictionsManager;
-    private CarPropertyManager mCarPropertyManager;
     // Need to track the number of times the monitor is started so a single stopMonitor call does
     // not override them all.
     private int mMonitorStartedCount;
@@ -71,25 +61,6 @@
     @VisibleForTesting
     final Runnable mDisconnectRunnable = this::disconnectCarMonitor;
 
-    private final CarPropertyManager.CarPropertyEventCallback mGearChangeCallback =
-            new CarPropertyManager.CarPropertyEventCallback() {
-        @SuppressWarnings("rawtypes")
-        @Override
-        public void onChangeEvent(CarPropertyValue value) {
-            switch (value.getPropertyId()) {
-                case VehiclePropertyIds.GEAR_SELECTION:
-                    if ((Integer) value.getValue() == GEAR_REVERSE) {
-                        Log.v(TAG, "Gear has reversed, exiting SetupWizard.");
-                        broadcastGearReversal();
-                    }
-                    break;
-            }
-        }
-
-        @Override
-        public void onErrorEvent(int propertyId, int zone) {}
-    };
-
     private CarDrivingStateMonitor(Context context) {
         mContext = context.getApplicationContext();
     }
@@ -137,9 +108,18 @@
             @Override
             public void onServiceConnected(ComponentName name, IBinder service) {
                 try {
-                    registerPropertyManager();
-                    registerRestrictionsManager();
-
+                    mRestrictionsManager = (CarUxRestrictionsManager)
+                            mCar.getCarManager(Car.CAR_UX_RESTRICTION_SERVICE);
+                    if (mRestrictionsManager == null) {
+                        Log.e(TAG, "Unable to get CarUxRestrictionsManager");
+                        return;
+                    }
+                    onUxRestrictionsChanged(mRestrictionsManager.getCurrentCarUxRestrictions());
+                    mRestrictionsManager.registerListener(CarDrivingStateMonitor.this);
+                    if (mStopMonitorAfterUxCheck) {
+                        mStopMonitorAfterUxCheck = false;
+                        stopMonitor();
+                    }
                 } catch (CarNotConnectedException e) {
                     Log.e(TAG, "Car not connected", e);
                 }
@@ -200,10 +180,6 @@
                 mRestrictionsManager.unregisterListener();
                 mRestrictionsManager = null;
             }
-            if (mCarPropertyManager != null) {
-                mCarPropertyManager.unregisterCallback(mGearChangeCallback);
-                mCarPropertyManager = null;
-            }
         } catch (CarNotConnectedException e) {
             Log.e(TAG, "Car not connected for unregistering listener", e);
         }
@@ -293,49 +269,9 @@
                 CarDrivingStateMonitor.class, new CarDrivingStateMonitor(context));
     }
 
-    private void registerRestrictionsManager() {
-        mRestrictionsManager = (CarUxRestrictionsManager)
-                mCar.getCarManager(Car.CAR_UX_RESTRICTION_SERVICE);
-        if (mRestrictionsManager == null) {
-            Log.e(TAG, "Unable to get CarUxRestrictionsManager");
-            return;
-        }
-        onUxRestrictionsChanged(mRestrictionsManager.getCurrentCarUxRestrictions());
-        mRestrictionsManager.registerListener(CarDrivingStateMonitor.this);
-        if (mStopMonitorAfterUxCheck) {
-            mStopMonitorAfterUxCheck = false;
-            stopMonitor();
-        }
+    /** Testing only */
+    @VisibleForTesting
+    public static void replace(Context context, CarDrivingStateMonitor monitor) {
+        CarHelperRegistry.getRegistry(context).putHelper(CarDrivingStateMonitor.class, monitor);
     }
-
-    private void registerPropertyManager() {
-        mCarPropertyManager = (CarPropertyManager) mCar.getCarManager(Car.PROPERTY_SERVICE);
-        if (mCarPropertyManager == null) {
-            Log.e(TAG, "Unable to get CarPropertyManager");
-            return;
-        }
-        mCarPropertyManager.registerCallback(
-                mGearChangeCallback, VehiclePropertyIds.GEAR_SELECTION,
-                CarPropertyManager.SENSOR_RATE_ONCHANGE);
-        CarPropertyValue<Integer> gearSelection =
-                mCarPropertyManager.getProperty(Integer.class, VehiclePropertyIds.GEAR_SELECTION,
-                    VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL);
-        if (gearSelection != null
-                && gearSelection.getStatus() == CarPropertyValue.STATUS_AVAILABLE) {
-            if (gearSelection.getValue() == GEAR_REVERSE) {
-                Log.v(TAG, "SetupWizard started when gear is in reverse, exiting.");
-                broadcastGearReversal();
-            }
-        } else {
-            Log.e(TAG, "GEAR_SELECTION is not available.");
-        }
-    }
-
-    private void broadcastGearReversal() {
-        Intent intent = new Intent();
-        intent.setAction(EXIT_BROADCAST_ACTION);
-        intent.putExtra(INTENT_EXTRA_REASON, REASON_GEAR_REVERSAL);
-        mContext.sendBroadcast(intent);
-    }
-
 }
diff --git a/library/main/tests/robotests/Android.bp b/library/main/tests/robotests/Android.bp
new file mode 100644
index 0000000..13335f3
--- /dev/null
+++ b/library/main/tests/robotests/Android.bp
@@ -0,0 +1,33 @@
+//##############################################################
+// CarSetupWizardLib app just for Robolectric test target.     #
+//##############################################################
+android_app {
+    name: "CarSetupWizardLib",
+
+    resource_dirs: ["res"],
+
+    platform_apis: true,
+
+    privileged: true,
+
+    libs: ["android.car"],
+
+    static_libs: ["car-setup-wizard-lib"],
+}
+
+//##############################################################
+// CarSetupWizardLib Robolectric test target.                  #
+//##############################################################
+android_robolectric_test {
+    name: "CarSetupWizardLibRoboTests",
+
+    srcs: ["src/**/*.java"],
+
+    java_resource_dirs: ["config"],
+
+    libs: [
+        "android.car",
+    ],
+
+    instrumentation_for: "CarSetupWizardLib",
+}
diff --git a/library/main/tests/robotests/Android.mk b/library/main/tests/robotests/Android.mk
deleted file mode 100644
index 1d62740..0000000
--- a/library/main/tests/robotests/Android.mk
+++ /dev/null
@@ -1,75 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-###############################################################
-# CarSetupWizardLib app just for Robolectric test target.     #
-###############################################################
-include $(CLEAR_VARS)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_PACKAGE_NAME := CarSetupWizardLib
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_USE_AAPT2 := true
-
-LOCAL_PRIVILEGED_MODULE := true
-
-LOCAL_JAVA_LIBRARIES := android.car
-
-LOCAL_STATIC_ANDROID_LIBRARIES += car-setup-wizard-lib
-
-include $(BUILD_PACKAGE)
-
-###############################################################
-# CarSetupWizardLib Robolectric test target.                  #
-###############################################################
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := CarSetupWizardLibRoboTests
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_JAVA_RESOURCE_DIRS := config
-
-LOCAL_JAVA_LIBRARIES := \
-    android.car \
-    robolectric_android-all-stub \
-    Robolectric_all-target \
-    mockito-robolectric-prebuilt \
-    truth-prebuilt
-
-LOCAL_INSTRUMENTATION_FOR := CarSetupWizardLib
-
-LOCAL_MODULE_TAGS := optional
-
-# Generate test_config.properties
-include external/robolectric-shadows/gen_test_config.mk
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-###############################################################
-# CarSetupWizardLib runner target to run the previous target. #
-###############################################################
-include $(CLEAR_VARS)
-LOCAL_MODULE := RunCarSetupWizardLibRoboTests
-
-LOCAL_JAVA_LIBRARIES := \
-    android.car \
-    CarSetupWizardLibRoboTests \
-    robolectric_android-all-stub \
-    Robolectric_all-target \
-    mockito-robolectric-prebuilt \
-    truth-prebuilt
-
-LOCAL_TEST_PACKAGE := CarSetupWizardLib
-
-LOCAL_ROBOTEST_FILES := $(filter-out %/BaseRobolectricTest.java,\
-    $(call find-files-in-subdirs,$(LOCAL_PATH)/src,*Test.java,.))
-
-LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))../src
-
-include external/robolectric-shadows/run_robotests.mk
diff --git a/library/main/tests/robotests/res/values/styles.xml b/library/main/tests/robotests/res/values/styles.xml
new file mode 100644
index 0000000..7b867c7
--- /dev/null
+++ b/library/main/tests/robotests/res/values/styles.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2020 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<resources>
+    <style name="NavAndStatusBarTestTheme" parent="Theme.AppCompat">
+        <item name="android:statusBarColor">#00000001</item>
+        <item name="android:navigationBarColor">#00000002</item>
+    </style>
+</resources>
diff --git a/library/main/tests/robotests/src/com/android/car/setupwizardlib/partner/ExternalResources.java b/library/main/tests/robotests/src/com/android/car/setupwizardlib/partner/ExternalResources.java
index fec2290..3892266 100644
--- a/library/main/tests/robotests/src/com/android/car/setupwizardlib/partner/ExternalResources.java
+++ b/library/main/tests/robotests/src/com/android/car/setupwizardlib/partner/ExternalResources.java
@@ -22,6 +22,7 @@
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.res.AssetManager;
+import android.content.res.ColorStateList;
 import android.content.res.Configuration;
 import android.graphics.drawable.Drawable;
 import android.util.DisplayMetrics;
@@ -162,6 +163,24 @@
             return (Drawable) get(id, ResType.DRAWABLE);
         }
 
+        @NonNull
+        @Override
+        public ColorStateList getColorStateList(int id) throws NotFoundException {
+            return (ColorStateList) get(id, ResType.COLOR_STATE_LIST);
+        }
+
+        @NonNull
+        @Override
+        public ColorStateList getColorStateList(int id, @Nullable Theme theme) {
+            return (ColorStateList) get(id, ResType.COLOR_STATE_LIST);
+        }
+
+        public void putColorStateList(String name, ColorStateList value) {
+            put(
+                    ResName.qualifyResName(name, mPackageName, "color"),
+                    new TypedResource<>(value, ResType.COLOR_STATE_LIST, null));
+        }
+
         public void putDrawable(String name, Drawable value) {
             put(
                     ResName.qualifyResName(name, mPackageName, "drawable"),
@@ -229,8 +248,13 @@
 
         private Object get(@AnyRes int id, ResType type) {
             TypedResource<?> override = mOverrideResources.get(id);
-            if (override != null && override.getResType() == type) {
-                return override.getData();
+            if (override != null) {
+                if (override.getResType() == type) {
+                    return override.getData();
+                } else if (type == ResType.COLOR_STATE_LIST
+                        && override.getResType() == ResType.COLOR) {
+                    return ColorStateList.valueOf((Integer) override.getData());
+                }
             }
             throw new NotFoundException();
         }
diff --git a/library/main/tests/robotests/src/com/android/car/setupwizardlib/partner/PartnerConfigHelperTest.java b/library/main/tests/robotests/src/com/android/car/setupwizardlib/partner/PartnerConfigHelperTest.java
index 081bb22..9969f08 100644
--- a/library/main/tests/robotests/src/com/android/car/setupwizardlib/partner/PartnerConfigHelperTest.java
+++ b/library/main/tests/robotests/src/com/android/car/setupwizardlib/partner/PartnerConfigHelperTest.java
@@ -20,6 +20,7 @@
 
 import static org.robolectric.RuntimeEnvironment.application;
 
+import android.content.res.ColorStateList;
 import android.graphics.drawable.Drawable;
 
 
@@ -88,17 +89,81 @@
 
     @Test
     public void getColor_shouldReturnExpectedColor() {
+        // Making this a global variable makes the VM crash when tests run.
+        ColorStateList grayColorStateList = ColorStateList.valueOf(android.R.color.darker_gray);
+
         PartnerConfigHelper helper = PartnerConfigHelper.get(application);
         assertThat(helper.mPartnerResourceCache).doesNotContainKey(TEST_COLOR_RESOURCE_NAME);
 
-        int result = helper.getColor(application, TEST_COLOR_RESOURCE_NAME);
-        assertThat(result).isEqualTo(android.R.color.darker_gray);
+        int color = helper.getColor(application, TEST_COLOR_RESOURCE_NAME);
+        assertThat(color).isEqualTo(android.R.color.darker_gray);
         assertThat(helper.mPartnerResourceCache).containsKey(TEST_COLOR_RESOURCE_NAME);
         assertThat(helper.mPartnerResourceCache.get(TEST_COLOR_RESOURCE_NAME))
                 .isEqualTo(android.R.color.darker_gray);
     }
 
     @Test
+    public void getColor_whenCacheHasColorStateList_shouldReturnExpectedColor() {
+        // Making this a global variable makes the VM crash when tests run.
+        ColorStateList grayColorStateList = ColorStateList.valueOf(android.R.color.darker_gray);
+
+        PartnerConfigHelper helper = PartnerConfigHelper.get(application);
+        assertThat(helper.mPartnerResourceCache).doesNotContainKey(TEST_COLOR_RESOURCE_NAME);
+
+        // Filling up cache with gray color state list.
+        helper.getColorStateList(application, TEST_COLOR_RESOURCE_NAME);
+
+        // Trying to retrieve the color should return the color state list default darker_gray.
+        int color = helper.getColor(application, TEST_COLOR_RESOURCE_NAME);
+        assertThat(color).isEqualTo(android.R.color.darker_gray);
+        assertThat(helper.mPartnerResourceCache).containsKey(TEST_COLOR_RESOURCE_NAME);
+        assertThat(helper.mPartnerResourceCache.get(TEST_COLOR_RESOURCE_NAME))
+                .isEqualTo(android.R.color.darker_gray);
+    }
+
+    @Test
+    public void getColorStateList_shouldReturnExpectedColorStateList() {
+        // Making this a global variable makes the VM crash when tests run.
+        ColorStateList grayColorStateList = ColorStateList.valueOf(android.R.color.darker_gray);
+
+        PartnerConfigHelper helper = PartnerConfigHelper.get(application);
+        assertThat(helper.mPartnerResourceCache)
+                .doesNotContainKey(TEST_COLOR_RESOURCE_NAME);
+
+        ColorStateList colorStateList = helper.getColorStateList(
+                application, TEST_COLOR_RESOURCE_NAME);
+        assertThat(colorStateList)
+                .isEqualTo(grayColorStateList);
+        assertThat(helper.mPartnerResourceCache)
+                .containsKey(TEST_COLOR_RESOURCE_NAME);
+        assertThat(helper.mPartnerResourceCache.get(TEST_COLOR_RESOURCE_NAME))
+                .isEqualTo(grayColorStateList);
+    }
+
+    @Test
+    public void getColorStateList_whenCacheHasColorValue_shouldReturnExpectedColorStateList() {
+        // Making this a global variable makes the VM crash when tests run.
+        ColorStateList grayColorStateList = ColorStateList.valueOf(android.R.color.darker_gray);
+
+        PartnerConfigHelper helper = PartnerConfigHelper.get(application);
+        assertThat(helper.mPartnerResourceCache)
+                .doesNotContainKey(TEST_COLOR_RESOURCE_NAME);
+
+        // Filling up cache with gray color.
+        helper.getColor(application, TEST_COLOR_RESOURCE_NAME);
+
+        // Trying to retrieve the color state list should return it with a single value.
+        ColorStateList colorStateList = helper.getColorStateList(
+                application, TEST_COLOR_RESOURCE_NAME);
+        assertThat(colorStateList)
+                .isEqualTo(grayColorStateList);
+        assertThat(helper.mPartnerResourceCache)
+                .containsKey(TEST_COLOR_RESOURCE_NAME);
+        assertThat(helper.mPartnerResourceCache.get(TEST_COLOR_RESOURCE_NAME))
+                .isEqualTo(grayColorStateList);
+    }
+
+    @Test
     public void getString_shouldReturnExpectedString() {
         PartnerConfigHelper helper = PartnerConfigHelper.get(application);
         assertThat(helper.mPartnerResourceCache).doesNotContainKey(TEST_STRING_RESOURCE_NAME);
diff --git a/library/main/tests/robotests/src/com/android/car/setupwizardlib/util/CarSetupWizardUiUtilsTest.java b/library/main/tests/robotests/src/com/android/car/setupwizardlib/util/CarSetupWizardUiUtilsTest.java
index 8ba08f3..5933bd4 100644
--- a/library/main/tests/robotests/src/com/android/car/setupwizardlib/util/CarSetupWizardUiUtilsTest.java
+++ b/library/main/tests/robotests/src/com/android/car/setupwizardlib/util/CarSetupWizardUiUtilsTest.java
@@ -24,7 +24,6 @@
 import android.view.Window;
 
 import com.android.car.setupwizardlib.robotests.R;
-import com.android.internal.util.XmlUtils;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -57,8 +56,8 @@
 
     // Note that these colors are defined in the test theme
     private static final int TEST_THEME = R.style.NavAndStatusBarTestTheme;
-    private static final int EXPECTED_COLOR_STATUS_BAR = XmlUtils.convertValueToInt("#001", -1);
-    private static final int EXPECTED_COLOR_NAVIGATION_BAR = XmlUtils.convertValueToInt("#002", -1);
+    private static final int EXPECTED_COLOR_STATUS_BAR = Color.getHtmlColor("#001");
+    private static final int EXPECTED_COLOR_NAVIGATION_BAR = Color.getHtmlColor("#002");
 
     private Activity mActivity;
     private Window mWindow;
diff --git a/library/utils/Android.bp b/library/utils/Android.bp
index f8cb4c7..7cd7c0b 100644
--- a/library/utils/Android.bp
+++ b/library/utils/Android.bp
@@ -15,15 +15,9 @@
 
 android_library {
     name: "car-setup-wizard-lib-utils",
-    srcs: [
-        "src/**/*.java",
-        "src/com/android/car/setupwizardlib/IInitialLockSetupService.aidl",
-        "src/com/android/car/setupwizardlib/InitialLockListener.java",
-        "src/com/android/car/setupwizardlib/InitialLockSetupClient.java",
-        "src/com/android/car/setupwizardlib/InitialLockSetupConstants.java",
-        "src/com/android/car/setupwizardlib/InitialLockSetupHelper.java",
-    ],
-    libs: ["android.car"],
+    srcs: ["src/**/*.java",
+            "src/**/*.aidl"],
+    libs: ["android.car-system-stubs"],
     optimize: {
         enabled: false,
     },
diff --git a/library/utils/src/com/android/car/setupwizardlib/IInitialLockSetupService.aidl b/library/utils/src/com/android/car/setupwizardlib/IInitialLockSetupService.aidl
index 1940ccb..305195b 100644
--- a/library/utils/src/com/android/car/setupwizardlib/IInitialLockSetupService.aidl
+++ b/library/utils/src/com/android/car/setupwizardlib/IInitialLockSetupService.aidl
@@ -16,7 +16,7 @@
 
 package com.android.car.setupwizardlib;
 
-import src.com.android.car.setupwizardlib.LockConfig;
+import com.android.car.setupwizardlib.LockConfig;
 
 interface IInitialLockSetupService {