Don't add SettingsLib to static_libs in Settings unit test.

Adding them results in duplicate classes and causes conflict for the R
classes and resource loading.

Meanwhile, correctly removing the SettingsLibSettingsSpinner resulted
in the test failing to find the getSelectedItem() method which is
unused inside Settings app. This is an inherent issue when unit
testing an optimized (and shrunk) app, and since there's no other way
for the test to get the current selected item, this change simply
changes the Settings code to invoke getSelectedItem() as well. This
has exactly the same effect because SettingsSpinnerPreference updates
its mPosition right before calling the OnItemSelectedListener in its
implementation.

Bug: 183340630
Bug: 177638625
Bug: 183342958
Test: atest SettingsSliderPreferenceControllerTest
Test: atest PrivateVolumeForgetTest
Change-Id: Ia26ca923369b41291614fb9bd50dfbd2aac2f0fa
diff --git a/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
index 03fddec..d6dcbf1 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
@@ -100,7 +100,8 @@
         if (mOnItemSelectedListener == null) {
             return;
         }
-        mOnItemSelectedListener.onItemSelected(mStorageAdapter.getItem(position));
+        mOnItemSelectedListener.onItemSelected(
+                (StorageEntry) mSpinnerPreference.getSelectedItem());
     }
 
     @Override
diff --git a/tests/unit/Android.bp b/tests/unit/Android.bp
index 5582ff4..249ce72 100644
--- a/tests/unit/Android.bp
+++ b/tests/unit/Android.bp
@@ -32,10 +32,8 @@
         "platform-test-annotations",
         "truth-prebuilt",
         "ub-uiautomator",
-        "SettingsLibSettingsSpinner",
-        "SettingsLibUsageProgressBarPreference",
-        "SettingsLibTwoTargetPreference",
-        "SettingsLibMainSwitchPreference",
+        // Don't add SettingsLib libraries here - you can use them directly as they are in the
+        // instrumented Settings app.
     ],
 
     // Include all test java files.