Show greyed out icon when Wi-Fi network is restricted to configurate

- Use Drawable#setTintList() instead of Drawable#setTint() to show greyed out icon when the preference is disabled.

Bug: 233175849
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=WifiEntryPreferenceTest

Change-Id: I451106530bc19bc733fd58a57e8ac336b023e65e
diff --git a/src/com/android/settings/wifi/WifiEntryPreference.java b/src/com/android/settings/wifi/WifiEntryPreference.java
index e74f269..fedd9c9 100644
--- a/src/com/android/settings/wifi/WifiEntryPreference.java
+++ b/src/com/android/settings/wifi/WifiEntryPreference.java
@@ -201,7 +201,8 @@
         return accent ? android.R.attr.colorAccent : android.R.attr.colorControlNormal;
     }
 
-    private void updateIcon(boolean showX, int level) {
+    @VisibleForTesting
+    void updateIcon(boolean showX, int level) {
         if (level == -1) {
             setIcon(null);
             return;
@@ -209,7 +210,9 @@
 
         final Drawable drawable = mIconInjector.getIcon(showX, level);
         if (drawable != null) {
-            drawable.setTint(Utils.getColorAttrDefaultColor(getContext(), getIconColorAttr()));
+            // Must use Drawable#setTintList() instead of Drawable#setTint() to show the grey
+            // icon when the preference is disabled.
+            drawable.setTintList(Utils.getColorAttr(getContext(), getIconColorAttr()));
             setIcon(drawable);
         } else {
             setIcon(null);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiEntryPreferenceTest.java b/tests/robotests/src/com/android/settings/wifi/WifiEntryPreferenceTest.java
index b782a70..a5d63db 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiEntryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiEntryPreferenceTest.java
@@ -17,6 +17,8 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -252,4 +254,14 @@
 
         assertThat(view.findViewById(R.id.icon_button).getVisibility()).isEqualTo(View.GONE);
     }
+
+    @Test
+    public void updateIcon_ShouldSetTintListForDrawable() {
+        WifiEntryPreference pref =
+                new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector);
+
+        pref.updateIcon(false /* showX */, 4 /* level */);
+
+        verify(mMockDrawable4).setTintList(any());
+    }
 }