Loading core/java/android/content/pm/PackageItemInfo.java +3 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,9 @@ public class PackageItemInfo { return loadSafeLabel(pm, DEFAULT_MAX_LABEL_SIZE_PX, SAFE_STRING_FLAG_TRIM | SAFE_STRING_FLAG_FIRST_LINE); } else { return loadUnsafeLabel(pm); // Trims the label string to the MAX_SAFE_LABEL_LENGTH. This is to prevent that the // system is overwhelmed by an enormous string returned by the application. return TextUtils.trimToSize(loadUnsafeLabel(pm), MAX_SAFE_LABEL_LENGTH); } } Loading packages/SettingsLib/src/com/android/settingslib/wifi/WifiUtils.java +55 −0 Original line number Diff line number Diff line Loading @@ -20,10 +20,13 @@ import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_ import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.getMaxNetworkSelectionDisableReason; import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiConfiguration.NetworkSelectionStatus; import android.net.wifi.WifiInfo; import android.os.Bundle; import android.os.SystemClock; import androidx.annotation.VisibleForTesting; Loading @@ -36,6 +39,23 @@ public class WifiUtils { private static final int INVALID_RSSI = -127; /** * The intent action shows network details settings to allow configuration of Wi-Fi. * <p> * In some cases, a matching Activity may not exist, so ensure you * safeguard against this. * <p> * Input: The calling package should put the chosen * com.android.wifitrackerlib.WifiEntry#getKey() to a string extra in the request bundle into * the {@link #KEY_CHOSEN_WIFIENTRY_KEY}. * <p> * Output: Nothing. */ public static final String ACTION_WIFI_DETAILS_SETTINGS = "android.settings.WIFI_DETAILS_SETTINGS"; public static final String KEY_CHOSEN_WIFIENTRY_KEY = "key_chosen_wifientry_key"; public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args"; static final int[] WIFI_PIE = { com.android.internal.R.drawable.ic_wifi_signal_0, com.android.internal.R.drawable.ic_wifi_signal_1, Loading Loading @@ -275,7 +295,42 @@ public class WifiUtils { return noInternet ? NO_INTERNET_WIFI_PIE[level] : WIFI_PIE[level]; } /** * Wrapper the {@link #getInternetIconResource} for testing compatibility. */ public static class InternetIconInjector { protected final Context mContext; public InternetIconInjector(Context context) { mContext = context; } /** * Returns the Internet icon for a given RSSI level. * * @param noInternet True if a connected Wi-Fi network cannot access the Internet * @param level The number of bars to show (0-4) */ public Drawable getIcon(boolean noInternet, int level) { return mContext.getDrawable(WifiUtils.getInternetIconResource(level, noInternet)); } } public static boolean isMeteredOverridden(WifiConfiguration config) { return config.meteredOverride != WifiConfiguration.METERED_OVERRIDE_NONE; } /** * Returns the Intent for Wi-Fi network details settings. * * @param key The Wi-Fi entry key */ public static Intent getWifiDetailsSettingsIntent(String key) { final Intent intent = new Intent(ACTION_WIFI_DETAILS_SETTINGS); final Bundle bundle = new Bundle(); bundle.putString(KEY_CHOSEN_WIFIENTRY_KEY, key); intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, bundle); return intent; } } packages/SettingsLib/tests/robotests/src/com/android/settingslib/wifi/WifiUtilsTest.java +32 −2 Original line number Diff line number Diff line Loading @@ -20,9 +20,12 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; import android.content.Intent; import android.net.NetworkKey; import android.net.RssiCurve; import android.net.ScoredNetwork; Loading @@ -36,6 +39,8 @@ import android.os.SystemClock; import android.text.format.DateUtils; import android.util.ArraySet; import androidx.test.core.app.ApplicationProvider; import com.android.settingslib.R; import org.junit.Before; Loading @@ -44,7 +49,6 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import java.util.ArrayList; import java.util.Set; Loading @@ -69,7 +73,7 @@ public class WifiUtilsTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; mContext = spy(ApplicationProvider.getApplicationContext()); } @Test Loading Loading @@ -148,6 +152,32 @@ public class WifiUtilsTest { assertThat(WifiUtils.isMeteredOverridden(mWifiConfig)).isTrue(); } @Test public void getWifiDetailsSettingsIntent_returnsCorrectValues() { final String key = "test_key"; final Intent intent = WifiUtils.getWifiDetailsSettingsIntent(key); assertThat(intent.getAction()).isEqualTo(WifiUtils.ACTION_WIFI_DETAILS_SETTINGS); final Bundle bundle = intent.getBundleExtra(WifiUtils.EXTRA_SHOW_FRAGMENT_ARGUMENTS); assertThat(bundle.getString(WifiUtils.KEY_CHOSEN_WIFIENTRY_KEY)).isEqualTo(key); } @Test public void testInternetIconInjector_getIcon_returnsCorrectValues() { WifiUtils.InternetIconInjector iconInjector = new WifiUtils.InternetIconInjector(mContext); for (int level = 0; level <= 4; level++) { iconInjector.getIcon(false /* noInternet */, level); verify(mContext).getDrawable( WifiUtils.getInternetIconResource(level, false /* noInternet */)); iconInjector.getIcon(true /* noInternet */, level); verify(mContext).getDrawable( WifiUtils.getInternetIconResource(level, true /* noInternet */)); } } private static ArrayList<ScanResult> buildScanResultCache() { ArrayList<ScanResult> scanResults = new ArrayList<>(); for (int i = 0; i < 5; i++) { Loading packages/SystemUI/res/anim/progress_indeterminate_horizontal_rect.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2021 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. --> <!-- Copy of progress_indeterminate_horizontal_rect2 in frameworks/base/core/res --> <set xmlns:android="http://schemas.android.com/apk/res/android" > <objectAnimator android:duration="2000" android:propertyXName="translateX" android:pathData="M -197.60001,0 c 14.28182,0 85.07782,0 135.54689,0 c 54.26191,0 90.42461,0 168.24331,0 c 144.72154,0 316.40982,0 316.40982,0 " android:interpolator="@interpolator/progress_indeterminate_horizontal_rect2_translatex_copy" android:repeatCount="infinite" /> </set> No newline at end of file packages/SystemUI/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml 0 → 100644 +23 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2021 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. --> <!-- Copy of progress_indeterminate_horizontal_material_trimmed in frameworks/base/core/res --> <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/vector_drawable_progress_indeterminate_horizontal_trimmed" > <target android:name="rect_grp" android:animation="@anim/progress_indeterminate_horizontal_rect" /> </animated-vector> No newline at end of file Loading
core/java/android/content/pm/PackageItemInfo.java +3 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,9 @@ public class PackageItemInfo { return loadSafeLabel(pm, DEFAULT_MAX_LABEL_SIZE_PX, SAFE_STRING_FLAG_TRIM | SAFE_STRING_FLAG_FIRST_LINE); } else { return loadUnsafeLabel(pm); // Trims the label string to the MAX_SAFE_LABEL_LENGTH. This is to prevent that the // system is overwhelmed by an enormous string returned by the application. return TextUtils.trimToSize(loadUnsafeLabel(pm), MAX_SAFE_LABEL_LENGTH); } } Loading
packages/SettingsLib/src/com/android/settingslib/wifi/WifiUtils.java +55 −0 Original line number Diff line number Diff line Loading @@ -20,10 +20,13 @@ import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_ import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.getMaxNetworkSelectionDisableReason; import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiConfiguration.NetworkSelectionStatus; import android.net.wifi.WifiInfo; import android.os.Bundle; import android.os.SystemClock; import androidx.annotation.VisibleForTesting; Loading @@ -36,6 +39,23 @@ public class WifiUtils { private static final int INVALID_RSSI = -127; /** * The intent action shows network details settings to allow configuration of Wi-Fi. * <p> * In some cases, a matching Activity may not exist, so ensure you * safeguard against this. * <p> * Input: The calling package should put the chosen * com.android.wifitrackerlib.WifiEntry#getKey() to a string extra in the request bundle into * the {@link #KEY_CHOSEN_WIFIENTRY_KEY}. * <p> * Output: Nothing. */ public static final String ACTION_WIFI_DETAILS_SETTINGS = "android.settings.WIFI_DETAILS_SETTINGS"; public static final String KEY_CHOSEN_WIFIENTRY_KEY = "key_chosen_wifientry_key"; public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args"; static final int[] WIFI_PIE = { com.android.internal.R.drawable.ic_wifi_signal_0, com.android.internal.R.drawable.ic_wifi_signal_1, Loading Loading @@ -275,7 +295,42 @@ public class WifiUtils { return noInternet ? NO_INTERNET_WIFI_PIE[level] : WIFI_PIE[level]; } /** * Wrapper the {@link #getInternetIconResource} for testing compatibility. */ public static class InternetIconInjector { protected final Context mContext; public InternetIconInjector(Context context) { mContext = context; } /** * Returns the Internet icon for a given RSSI level. * * @param noInternet True if a connected Wi-Fi network cannot access the Internet * @param level The number of bars to show (0-4) */ public Drawable getIcon(boolean noInternet, int level) { return mContext.getDrawable(WifiUtils.getInternetIconResource(level, noInternet)); } } public static boolean isMeteredOverridden(WifiConfiguration config) { return config.meteredOverride != WifiConfiguration.METERED_OVERRIDE_NONE; } /** * Returns the Intent for Wi-Fi network details settings. * * @param key The Wi-Fi entry key */ public static Intent getWifiDetailsSettingsIntent(String key) { final Intent intent = new Intent(ACTION_WIFI_DETAILS_SETTINGS); final Bundle bundle = new Bundle(); bundle.putString(KEY_CHOSEN_WIFIENTRY_KEY, key); intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, bundle); return intent; } }
packages/SettingsLib/tests/robotests/src/com/android/settingslib/wifi/WifiUtilsTest.java +32 −2 Original line number Diff line number Diff line Loading @@ -20,9 +20,12 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; import android.content.Intent; import android.net.NetworkKey; import android.net.RssiCurve; import android.net.ScoredNetwork; Loading @@ -36,6 +39,8 @@ import android.os.SystemClock; import android.text.format.DateUtils; import android.util.ArraySet; import androidx.test.core.app.ApplicationProvider; import com.android.settingslib.R; import org.junit.Before; Loading @@ -44,7 +49,6 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import java.util.ArrayList; import java.util.Set; Loading @@ -69,7 +73,7 @@ public class WifiUtilsTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; mContext = spy(ApplicationProvider.getApplicationContext()); } @Test Loading Loading @@ -148,6 +152,32 @@ public class WifiUtilsTest { assertThat(WifiUtils.isMeteredOverridden(mWifiConfig)).isTrue(); } @Test public void getWifiDetailsSettingsIntent_returnsCorrectValues() { final String key = "test_key"; final Intent intent = WifiUtils.getWifiDetailsSettingsIntent(key); assertThat(intent.getAction()).isEqualTo(WifiUtils.ACTION_WIFI_DETAILS_SETTINGS); final Bundle bundle = intent.getBundleExtra(WifiUtils.EXTRA_SHOW_FRAGMENT_ARGUMENTS); assertThat(bundle.getString(WifiUtils.KEY_CHOSEN_WIFIENTRY_KEY)).isEqualTo(key); } @Test public void testInternetIconInjector_getIcon_returnsCorrectValues() { WifiUtils.InternetIconInjector iconInjector = new WifiUtils.InternetIconInjector(mContext); for (int level = 0; level <= 4; level++) { iconInjector.getIcon(false /* noInternet */, level); verify(mContext).getDrawable( WifiUtils.getInternetIconResource(level, false /* noInternet */)); iconInjector.getIcon(true /* noInternet */, level); verify(mContext).getDrawable( WifiUtils.getInternetIconResource(level, true /* noInternet */)); } } private static ArrayList<ScanResult> buildScanResultCache() { ArrayList<ScanResult> scanResults = new ArrayList<>(); for (int i = 0; i < 5; i++) { Loading
packages/SystemUI/res/anim/progress_indeterminate_horizontal_rect.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2021 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. --> <!-- Copy of progress_indeterminate_horizontal_rect2 in frameworks/base/core/res --> <set xmlns:android="http://schemas.android.com/apk/res/android" > <objectAnimator android:duration="2000" android:propertyXName="translateX" android:pathData="M -197.60001,0 c 14.28182,0 85.07782,0 135.54689,0 c 54.26191,0 90.42461,0 168.24331,0 c 144.72154,0 316.40982,0 316.40982,0 " android:interpolator="@interpolator/progress_indeterminate_horizontal_rect2_translatex_copy" android:repeatCount="infinite" /> </set> No newline at end of file
packages/SystemUI/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml 0 → 100644 +23 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2021 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. --> <!-- Copy of progress_indeterminate_horizontal_material_trimmed in frameworks/base/core/res --> <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/vector_drawable_progress_indeterminate_horizontal_trimmed" > <target android:name="rect_grp" android:animation="@anim/progress_indeterminate_horizontal_rect" /> </animated-vector> No newline at end of file