From 983893dda058bd02a861e732a5e00bec7a414ee8 Mon Sep 17 00:00:00 2001 From: d34d Date: Mon, 22 Feb 2016 09:38:09 -0800 Subject: HotSpot: Store # of connected clients in receiver Get the number of connected clients in onReceive and cache the value to be used in handleUpdateState Change-Id: I011a13e186c1fa9976df58a4ad1603e6c0cd6bbb --- .../SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'packages/SystemUI/src') diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java index 71a3f95..25a7fb7 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java @@ -51,6 +51,7 @@ public class HotspotTile extends QSTile { private final UsageTracker mUsageTracker; private final ConnectivityManager mConnectivityManager; private boolean mListening; + private int mNumConnectedClients = 0; public HotspotTile(Host host) { super(host); @@ -131,10 +132,9 @@ public class HotspotTile extends QSTile { state.value = mController.isHotspotEnabled(); } if (state.visible && state.value) { - final List clients = mConnectivityManager.getTetherConnectedSta(); - final int count = clients != null ? clients.size() : 0; state.label = mContext.getResources().getQuantityString( - R.plurals.wifi_hotspot_connected_clients_label, count, count); + R.plurals.wifi_hotspot_connected_clients_label, mNumConnectedClients, + mNumConnectedClients); } else { state.label = mContext.getString(R.string.quick_settings_hotspot_label); } @@ -163,6 +163,8 @@ public class HotspotTile extends QSTile { private BroadcastReceiver mTetherConnectStateChangedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { + final List clients = mConnectivityManager.getTetherConnectedSta(); + mNumConnectedClients = clients != null ? clients.size() : 0; refreshState(); } }; -- cgit v1.1