@Test public void testGetWifiSSID() { ConnectivityManager connectivityManager = (ConnectivityManager) RuntimeEnvironment.application.getSystemService(Context.CONNECTIVITY_SERVICE); ShadowConnectivityManager shadowConnectivityManager = (ShadowConnectivityManager) ShadowExtractor.extract(connectivityManager); ShadowNetworkInfo shadowOfActiveNetworkInfo = (ShadowNetworkInfo) ShadowExtractor.extract(connectivityManager.getActiveNetworkInfo()); shadowOfActiveNetworkInfo.setConnectionType(ConnectivityManager.TYPE_WIFI); shadowConnectivityManager.setNetworkInfo(ConnectivityManager.TYPE_WIFI, connectivityManager.getActiveNetworkInfo()); PersistentStatsHandler persistentStatsHandler = new PersistentStatsHandler(RuntimeEnvironment.application); Assert.assertTrue(persistentStatsHandler.getWifiSSID() != 0); }
@VisibleForTesting int getWifiSSID() { WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); if (wifiInfo != null) { String ssid = wifiInfo.getSSID(); if (!TextUtils.isEmpty(ssid)) { return ssid.hashCode(); } } return -1; }
PersistentStatsHandler implements NetworkRequestStatsHandler { @VisibleForTesting int getWifiSSID() { WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); if (wifiInfo != null) { String ssid = wifiInfo.getSSID(); if (!TextUtils.isEmpty(ssid)) { return ssid.hashCode(); } } return -1; } }
PersistentStatsHandler implements NetworkRequestStatsHandler { @VisibleForTesting int getWifiSSID() { WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); if (wifiInfo != null) { String ssid = wifiInfo.getSSID(); if (!TextUtils.isEmpty(ssid)) { return ssid.hashCode(); } } return -1; } PersistentStatsHandler(Context context); @VisibleForTesting  PersistentStatsHandler(Context context, PreferenceManager preferenceManager); }
PersistentStatsHandler implements NetworkRequestStatsHandler { @VisibleForTesting int getWifiSSID() { WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); if (wifiInfo != null) { String ssid = wifiInfo.getSSID(); if (!TextUtils.isEmpty(ssid)) { return ssid.hashCode(); } } return -1; } PersistentStatsHandler(Context context); @VisibleForTesting  PersistentStatsHandler(Context context, PreferenceManager preferenceManager); NetworkInfo getActiveNetworkInfo(); void addListener(OnResponseListener onResponseListener); void removeListener(OnResponseListener onResponseListener); void setMaxSizeForPersistence(int size); float getAverageNetworkSpeed(); ConnectionQuality getConnectionQuality(); @Override void onResponseReceived(final RequestStats requestStats); @Override void onHttpExchangeError(RequestStats requestStats, IOException e); @Override void onResponseInputStreamError(RequestStats requestStats, Exception e); }
PersistentStatsHandler implements NetworkRequestStatsHandler { @VisibleForTesting int getWifiSSID() { WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); if (wifiInfo != null) { String ssid = wifiInfo.getSSID(); if (!TextUtils.isEmpty(ssid)) { return ssid.hashCode(); } } return -1; } PersistentStatsHandler(Context context); @VisibleForTesting  PersistentStatsHandler(Context context, PreferenceManager preferenceManager); NetworkInfo getActiveNetworkInfo(); void addListener(OnResponseListener onResponseListener); void removeListener(OnResponseListener onResponseListener); void setMaxSizeForPersistence(int size); float getAverageNetworkSpeed(); ConnectionQuality getConnectionQuality(); @Override void onResponseReceived(final RequestStats requestStats); @Override void onHttpExchangeError(RequestStats requestStats, IOException e); @Override void onResponseInputStreamError(RequestStats requestStats, Exception e);  }