Loading packages/SettingsLib/src/com/android/settingslib/Utils.java +2 −7 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ public class Utils { private static String sServicesSystemSharedLibPackageName; private static String sSharedSystemSharedLibPackageName; public static final int[] WIFI_PIE_FOR_BADGING = { static final int[] WIFI_PIE_FOR_BADGING = { com.android.internal.R.drawable.ic_signal_wifi_badged_0_bars, com.android.internal.R.drawable.ic_signal_wifi_badged_1_bar, com.android.internal.R.drawable.ic_signal_wifi_badged_2_bars, Loading Loading @@ -294,12 +294,7 @@ public class Utils { }); } /** * Returns the resource id for the given badge or {@link View.NO_ID} if no badge is to be shown. * * @throws IllegalArgumentException if the given badge value is not supported. */ public static int getWifiBadgeResource(int badge) { private static int getWifiBadgeResource(int badge) { switch (badge) { case NetworkBadging.BADGING_NONE: return View.NO_ID; Loading packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java +9 −27 Original line number Diff line number Diff line Loading @@ -12,17 +12,13 @@ package com.android.settingslib.wifi; import android.content.Intent; import android.net.NetworkInfo; import android.net.NetworkKey; import android.net.WifiKey; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.util.Log; import java.util.List; public class WifiStatusTracker { private static final String TAG = "WifiStatusTracker"; private final WifiManager mWifiManager; public boolean enabled; Loading @@ -32,7 +28,6 @@ public class WifiStatusTracker { public String ssid; public int rssi; public int level; public NetworkKey networkKey; public WifiStatusTracker(WifiManager wifiManager) { mWifiManager = wifiManager; Loading @@ -54,32 +49,19 @@ public class WifiStatusTracker { connecting = networkInfo != null && !networkInfo.isConnected() && networkInfo.isConnectedOrConnecting(); connected = networkInfo != null && networkInfo.isConnected(); // If Connected grab the signal strength and ssid. if (connected) { // try getting it out of the intent first WifiInfo info = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO) != null ? (WifiInfo) intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO) : mWifiManager.getConnectionInfo(); // If Connected grab the signal strength and ssid. if (connected && info != null) { if (info != null) { ssid = getSsid(info); String bssid = info.getBSSID(); if ((ssid != null) && (bssid != null)) { // Reuse existing network key object if possible. if ((networkKey == null) || !networkKey.wifiKey.ssid.equals(ssid) || !networkKey.wifiKey.bssid.equals(bssid)) { try { networkKey = new NetworkKey( new WifiKey(ssid, bssid)); } catch (IllegalArgumentException e) { Log.e(TAG, "Cannot create NetworkKey", e); } } } else { networkKey = null; ssid = null; } } else { } else if (!connected) { ssid = null; networkKey = null; } } else if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) { // Default to -200 as its below WifiManager.MIN_RSSI. Loading packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java +3 −48 Original line number Diff line number Diff line Loading @@ -16,19 +16,15 @@ package com.android.systemui.statusbar; import android.annotation.ColorInt; import android.annotation.DrawableRes; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.Rect; import android.graphics.drawable.Animatable; import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.net.NetworkBadging; import android.telephony.SubscriptionInfo; import android.util.ArraySet; import android.util.AttributeSet; Loading Loading @@ -80,10 +76,8 @@ public class SignalClusterView extends LinearLayout implements NetworkController private boolean mEthernetVisible = false; private int mEthernetIconId = 0; private int mLastEthernetIconId = -1; private int mWifiBadgeId = -1; private boolean mWifiVisible = false; private int mWifiStrengthId = 0; private int mLastWifiBadgeId = -1; private int mLastWifiStrengthId = -1; private boolean mWifiIn; private boolean mWifiOut; Loading Loading @@ -291,7 +285,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController boolean activityIn, boolean activityOut, String description, boolean isTransient) { mWifiVisible = statusIcon.visible && !mBlockWifi; mWifiStrengthId = statusIcon.icon; mWifiBadgeId = statusIcon.iconOverlay; mWifiDescription = statusIcon.contentDescription; mWifiIn = activityIn && mActivityEnabled && mWifiVisible; mWifiOut = activityOut && mActivityEnabled && mWifiVisible; Loading Loading @@ -428,7 +421,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController mWifi.setImageDrawable(null); mWifiDark.setImageDrawable(null); mLastWifiStrengthId = -1; mLastWifiBadgeId = -1; } for (PhoneState state : mPhoneStates) { Loading Loading @@ -484,16 +476,10 @@ public class SignalClusterView extends LinearLayout implements NetworkController (mEthernetVisible ? "VISIBLE" : "GONE"))); if (mWifiVisible) { if (mWifiStrengthId != mLastWifiStrengthId || mWifiBadgeId != mLastWifiBadgeId) { if (mWifiBadgeId == -1) { if (mWifiStrengthId != mLastWifiStrengthId) { setIconForView(mWifi, mWifiStrengthId); setIconForView(mWifiDark, mWifiStrengthId); } else { setBadgedWifiIconForView(mWifi, mWifiStrengthId, mWifiBadgeId); setBadgedWifiIconForView(mWifiDark, mWifiStrengthId, mWifiBadgeId); } mLastWifiStrengthId = mWifiStrengthId; mLastWifiBadgeId = mWifiBadgeId; } mWifiGroup.setContentDescription(mWifiDescription); mWifiGroup.setVisibility(View.VISIBLE); Loading Loading @@ -558,10 +544,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController // Using the imageView's context to retrieve the Drawable so that theme is preserved. Drawable icon = imageView.getContext().getDrawable(iconId); setScaledIcon(imageView, icon); } private void setScaledIcon(ImageView imageView, Drawable icon) { if (mIconScaleFactor == 1.f) { imageView.setImageDrawable(icon); } else { Loading @@ -569,33 +551,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController } } /** * Creates and sets a LayerDrawable from the given ids on the given view. * * <p>This method will also scale the icon by {@link #mIconScaleFactor} if appropriate. */ private void setBadgedWifiIconForView(ImageView imageView, @DrawableRes int wifiPieId, @DrawableRes int badgeId) { // TODO(sghuman): Delete this method and revert to N badging logic // Using the imageView's context to retrieve the Drawable so that theme is preserved.; LayerDrawable icon = new LayerDrawable(new Drawable[] { imageView.getContext().getDrawable(wifiPieId), imageView.getContext().getDrawable(NetworkBadging.BADGING_NONE)}); // The LayerDrawable shares an underlying state so we must mutate the object to change the // color between the light and dark themes. icon.mutate().setTint(getColorAttr(imageView.getContext(), R.attr.singleToneColor)); setScaledIcon(imageView, icon); } /** Returns the given color attribute value, or white if not defined. */ @ColorInt private static int getColorAttr(Context context, int attr) { TypedArray ta = context.obtainStyledAttributes(new int[] {attr}); @ColorInt int colorAccent = ta.getColor(0, Color.WHITE); ta.recycle(); return colorAccent; } @Override public void onDarkChanged(Rect tintArea, float darkIntensity, int tint) { Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java +1 −15 Original line number Diff line number Diff line Loading @@ -67,29 +67,15 @@ public interface NetworkController extends CallbackController<SignalCallback>, D public static class IconState { public final boolean visible; public final int icon; /** * Optional iconOverlay resource id. * * <p>Set to -1 if not present. */ public final int iconOverlay; public final String contentDescription; public IconState(boolean visible, int icon, int iconOverlay, String contentDescription) { public IconState(boolean visible, int icon, String contentDescription) { this.visible = visible; this.icon = icon; this.iconOverlay = iconOverlay; this.contentDescription = contentDescription; } public IconState(boolean visible, int icon, String contentDescription) { this(visible, icon, -1 /* iconOverlay */, contentDescription); } public IconState(boolean visible, int icon, int contentDescription, Context context) { this(visible, icon, context.getString(contentDescription)); Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java +4 −14 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.net.ConnectivityManager; import android.net.NetworkCapabilities; import android.net.NetworkScoreManager; import android.net.wifi.WifiManager; import android.os.AsyncTask; import android.os.Bundle; Loading Loading @@ -92,7 +91,6 @@ public class NetworkControllerImpl extends BroadcastReceiver private final DataSaverController mDataSaverController; private final CurrentUserTracker mUserTracker; private Config mConfig; private final NetworkScoreManager mNetworkScoreManager; // Subcontrollers. @VisibleForTesting Loading Loading @@ -149,12 +147,9 @@ public class NetworkControllerImpl extends BroadcastReceiver public NetworkControllerImpl(Context context, Looper bgLooper, DeviceProvisionedController deviceProvisionedController) { this(context, (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE), context.getSystemService(NetworkScoreManager.class), (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE), (WifiManager) context.getSystemService(Context.WIFI_SERVICE), SubscriptionManager.from(context), Config.readConfig(context), bgLooper, SubscriptionManager.from(context), Config.readConfig(context), bgLooper, new CallbackHandler(), new AccessPointControllerImpl(context, bgLooper), new DataUsageController(context), Loading @@ -165,12 +160,8 @@ public class NetworkControllerImpl extends BroadcastReceiver @VisibleForTesting NetworkControllerImpl(Context context, ConnectivityManager connectivityManager, NetworkScoreManager networkScoreManager, TelephonyManager telephonyManager, WifiManager wifiManager, SubscriptionManager subManager, Config config, Looper bgLooper, TelephonyManager telephonyManager, WifiManager wifiManager, SubscriptionManager subManager, Config config, Looper bgLooper, CallbackHandler callbackHandler, AccessPointControllerImpl accessPointController, DataUsageController dataUsageController, Loading @@ -193,7 +184,6 @@ public class NetworkControllerImpl extends BroadcastReceiver // wifi mWifiManager = wifiManager; mNetworkScoreManager = networkScoreManager; mLocale = mContext.getResources().getConfiguration().locale; mAccessPoints = accessPointController; Loading @@ -207,7 +197,7 @@ public class NetworkControllerImpl extends BroadcastReceiver } }); mWifiSignalController = new WifiSignalController(mContext, mHasMobileDataFeature, mCallbackHandler, this, mNetworkScoreManager); mCallbackHandler, this); mEthernetSignalController = new EthernetSignalController(mContext, mCallbackHandler, this); Loading Loading
packages/SettingsLib/src/com/android/settingslib/Utils.java +2 −7 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ public class Utils { private static String sServicesSystemSharedLibPackageName; private static String sSharedSystemSharedLibPackageName; public static final int[] WIFI_PIE_FOR_BADGING = { static final int[] WIFI_PIE_FOR_BADGING = { com.android.internal.R.drawable.ic_signal_wifi_badged_0_bars, com.android.internal.R.drawable.ic_signal_wifi_badged_1_bar, com.android.internal.R.drawable.ic_signal_wifi_badged_2_bars, Loading Loading @@ -294,12 +294,7 @@ public class Utils { }); } /** * Returns the resource id for the given badge or {@link View.NO_ID} if no badge is to be shown. * * @throws IllegalArgumentException if the given badge value is not supported. */ public static int getWifiBadgeResource(int badge) { private static int getWifiBadgeResource(int badge) { switch (badge) { case NetworkBadging.BADGING_NONE: return View.NO_ID; Loading
packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java +9 −27 Original line number Diff line number Diff line Loading @@ -12,17 +12,13 @@ package com.android.settingslib.wifi; import android.content.Intent; import android.net.NetworkInfo; import android.net.NetworkKey; import android.net.WifiKey; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.util.Log; import java.util.List; public class WifiStatusTracker { private static final String TAG = "WifiStatusTracker"; private final WifiManager mWifiManager; public boolean enabled; Loading @@ -32,7 +28,6 @@ public class WifiStatusTracker { public String ssid; public int rssi; public int level; public NetworkKey networkKey; public WifiStatusTracker(WifiManager wifiManager) { mWifiManager = wifiManager; Loading @@ -54,32 +49,19 @@ public class WifiStatusTracker { connecting = networkInfo != null && !networkInfo.isConnected() && networkInfo.isConnectedOrConnecting(); connected = networkInfo != null && networkInfo.isConnected(); // If Connected grab the signal strength and ssid. if (connected) { // try getting it out of the intent first WifiInfo info = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO) != null ? (WifiInfo) intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO) : mWifiManager.getConnectionInfo(); // If Connected grab the signal strength and ssid. if (connected && info != null) { if (info != null) { ssid = getSsid(info); String bssid = info.getBSSID(); if ((ssid != null) && (bssid != null)) { // Reuse existing network key object if possible. if ((networkKey == null) || !networkKey.wifiKey.ssid.equals(ssid) || !networkKey.wifiKey.bssid.equals(bssid)) { try { networkKey = new NetworkKey( new WifiKey(ssid, bssid)); } catch (IllegalArgumentException e) { Log.e(TAG, "Cannot create NetworkKey", e); } } } else { networkKey = null; ssid = null; } } else { } else if (!connected) { ssid = null; networkKey = null; } } else if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) { // Default to -200 as its below WifiManager.MIN_RSSI. Loading
packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java +3 −48 Original line number Diff line number Diff line Loading @@ -16,19 +16,15 @@ package com.android.systemui.statusbar; import android.annotation.ColorInt; import android.annotation.DrawableRes; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.Rect; import android.graphics.drawable.Animatable; import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.net.NetworkBadging; import android.telephony.SubscriptionInfo; import android.util.ArraySet; import android.util.AttributeSet; Loading Loading @@ -80,10 +76,8 @@ public class SignalClusterView extends LinearLayout implements NetworkController private boolean mEthernetVisible = false; private int mEthernetIconId = 0; private int mLastEthernetIconId = -1; private int mWifiBadgeId = -1; private boolean mWifiVisible = false; private int mWifiStrengthId = 0; private int mLastWifiBadgeId = -1; private int mLastWifiStrengthId = -1; private boolean mWifiIn; private boolean mWifiOut; Loading Loading @@ -291,7 +285,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController boolean activityIn, boolean activityOut, String description, boolean isTransient) { mWifiVisible = statusIcon.visible && !mBlockWifi; mWifiStrengthId = statusIcon.icon; mWifiBadgeId = statusIcon.iconOverlay; mWifiDescription = statusIcon.contentDescription; mWifiIn = activityIn && mActivityEnabled && mWifiVisible; mWifiOut = activityOut && mActivityEnabled && mWifiVisible; Loading Loading @@ -428,7 +421,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController mWifi.setImageDrawable(null); mWifiDark.setImageDrawable(null); mLastWifiStrengthId = -1; mLastWifiBadgeId = -1; } for (PhoneState state : mPhoneStates) { Loading Loading @@ -484,16 +476,10 @@ public class SignalClusterView extends LinearLayout implements NetworkController (mEthernetVisible ? "VISIBLE" : "GONE"))); if (mWifiVisible) { if (mWifiStrengthId != mLastWifiStrengthId || mWifiBadgeId != mLastWifiBadgeId) { if (mWifiBadgeId == -1) { if (mWifiStrengthId != mLastWifiStrengthId) { setIconForView(mWifi, mWifiStrengthId); setIconForView(mWifiDark, mWifiStrengthId); } else { setBadgedWifiIconForView(mWifi, mWifiStrengthId, mWifiBadgeId); setBadgedWifiIconForView(mWifiDark, mWifiStrengthId, mWifiBadgeId); } mLastWifiStrengthId = mWifiStrengthId; mLastWifiBadgeId = mWifiBadgeId; } mWifiGroup.setContentDescription(mWifiDescription); mWifiGroup.setVisibility(View.VISIBLE); Loading Loading @@ -558,10 +544,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController // Using the imageView's context to retrieve the Drawable so that theme is preserved. Drawable icon = imageView.getContext().getDrawable(iconId); setScaledIcon(imageView, icon); } private void setScaledIcon(ImageView imageView, Drawable icon) { if (mIconScaleFactor == 1.f) { imageView.setImageDrawable(icon); } else { Loading @@ -569,33 +551,6 @@ public class SignalClusterView extends LinearLayout implements NetworkController } } /** * Creates and sets a LayerDrawable from the given ids on the given view. * * <p>This method will also scale the icon by {@link #mIconScaleFactor} if appropriate. */ private void setBadgedWifiIconForView(ImageView imageView, @DrawableRes int wifiPieId, @DrawableRes int badgeId) { // TODO(sghuman): Delete this method and revert to N badging logic // Using the imageView's context to retrieve the Drawable so that theme is preserved.; LayerDrawable icon = new LayerDrawable(new Drawable[] { imageView.getContext().getDrawable(wifiPieId), imageView.getContext().getDrawable(NetworkBadging.BADGING_NONE)}); // The LayerDrawable shares an underlying state so we must mutate the object to change the // color between the light and dark themes. icon.mutate().setTint(getColorAttr(imageView.getContext(), R.attr.singleToneColor)); setScaledIcon(imageView, icon); } /** Returns the given color attribute value, or white if not defined. */ @ColorInt private static int getColorAttr(Context context, int attr) { TypedArray ta = context.obtainStyledAttributes(new int[] {attr}); @ColorInt int colorAccent = ta.getColor(0, Color.WHITE); ta.recycle(); return colorAccent; } @Override public void onDarkChanged(Rect tintArea, float darkIntensity, int tint) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java +1 −15 Original line number Diff line number Diff line Loading @@ -67,29 +67,15 @@ public interface NetworkController extends CallbackController<SignalCallback>, D public static class IconState { public final boolean visible; public final int icon; /** * Optional iconOverlay resource id. * * <p>Set to -1 if not present. */ public final int iconOverlay; public final String contentDescription; public IconState(boolean visible, int icon, int iconOverlay, String contentDescription) { public IconState(boolean visible, int icon, String contentDescription) { this.visible = visible; this.icon = icon; this.iconOverlay = iconOverlay; this.contentDescription = contentDescription; } public IconState(boolean visible, int icon, String contentDescription) { this(visible, icon, -1 /* iconOverlay */, contentDescription); } public IconState(boolean visible, int icon, int contentDescription, Context context) { this(visible, icon, context.getString(contentDescription)); Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java +4 −14 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.net.ConnectivityManager; import android.net.NetworkCapabilities; import android.net.NetworkScoreManager; import android.net.wifi.WifiManager; import android.os.AsyncTask; import android.os.Bundle; Loading Loading @@ -92,7 +91,6 @@ public class NetworkControllerImpl extends BroadcastReceiver private final DataSaverController mDataSaverController; private final CurrentUserTracker mUserTracker; private Config mConfig; private final NetworkScoreManager mNetworkScoreManager; // Subcontrollers. @VisibleForTesting Loading Loading @@ -149,12 +147,9 @@ public class NetworkControllerImpl extends BroadcastReceiver public NetworkControllerImpl(Context context, Looper bgLooper, DeviceProvisionedController deviceProvisionedController) { this(context, (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE), context.getSystemService(NetworkScoreManager.class), (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE), (WifiManager) context.getSystemService(Context.WIFI_SERVICE), SubscriptionManager.from(context), Config.readConfig(context), bgLooper, SubscriptionManager.from(context), Config.readConfig(context), bgLooper, new CallbackHandler(), new AccessPointControllerImpl(context, bgLooper), new DataUsageController(context), Loading @@ -165,12 +160,8 @@ public class NetworkControllerImpl extends BroadcastReceiver @VisibleForTesting NetworkControllerImpl(Context context, ConnectivityManager connectivityManager, NetworkScoreManager networkScoreManager, TelephonyManager telephonyManager, WifiManager wifiManager, SubscriptionManager subManager, Config config, Looper bgLooper, TelephonyManager telephonyManager, WifiManager wifiManager, SubscriptionManager subManager, Config config, Looper bgLooper, CallbackHandler callbackHandler, AccessPointControllerImpl accessPointController, DataUsageController dataUsageController, Loading @@ -193,7 +184,6 @@ public class NetworkControllerImpl extends BroadcastReceiver // wifi mWifiManager = wifiManager; mNetworkScoreManager = networkScoreManager; mLocale = mContext.getResources().getConfiguration().locale; mAccessPoints = accessPointController; Loading @@ -207,7 +197,7 @@ public class NetworkControllerImpl extends BroadcastReceiver } }); mWifiSignalController = new WifiSignalController(mContext, mHasMobileDataFeature, mCallbackHandler, this, mNetworkScoreManager); mCallbackHandler, this); mEthernetSignalController = new EthernetSignalController(mContext, mCallbackHandler, this); Loading