use of com.inceptai.dobby.eventbus.DobbyEvent in project dobby-android by InceptAi.
the class WifiAnalyzer method updateWifiStatsDetailedState.
protected void updateWifiStatsDetailedState(NetworkInfo.DetailedState detailedState) {
@WifiState.WifiLinkMode int oldProblemMode = wifiState.getWifiProblemMode();
@WifiState.WifiLinkMode int newProblemMode = wifiState.updateDetailedWifiStateInfo(detailedState, System.currentTimeMillis());
if (oldProblemMode != newProblemMode) {
@DobbyEvent.EventType int eventTypeToBroadcast = convertWifiStateProblemToDobbyEventType(newProblemMode);
if (eventTypeToBroadcast != DobbyEvent.EventType.WIFI_STATE_UNKNOWN) {
eventBus.postEvent(new DobbyEvent(eventTypeToBroadcast));
}
}
//Utils.PercentileStats stats = wifiState.getStatsForDetailedState(detailedState, GAP_FOR_GETTING_DETAILED_NETWORK_STATE_STATS_MS);
//DobbyLog.v("updateDetailedWifiStateInfo State: " + detailedState.name() + " stats: " + stats.toString());
}
use of com.inceptai.dobby.eventbus.DobbyEvent in project dobby-android by InceptAi.
the class FakeWifiAnalyzer method updateWifiStatsDetailedState.
@Override
protected void updateWifiStatsDetailedState(NetworkInfo.DetailedState detailedState) {
@WifiState.WifiLinkMode int problemMode = FAKE_WIFI_SCAN_CONFIG.fakeWifiProblemMode;
wifiState.setCurrentWifiProblemMode(problemMode);
@DobbyEvent.EventType int eventTypeToBroadcast = convertWifiStateProblemToDobbyEventType(problemMode);
if (eventTypeToBroadcast != DobbyEvent.EventType.WIFI_STATE_UNKNOWN) {
eventBus.postEvent(new DobbyEvent(eventTypeToBroadcast));
}
}
use of com.inceptai.dobby.eventbus.DobbyEvent in project dobby-android by InceptAi.
the class ConnectivityAnalyzer method updateWifiConnectivityMode.
private synchronized void updateWifiConnectivityMode(final int scheduleCount) {
@WifiConnectivityMode int currentWifiMode = WifiConnectivityMode.UNKNOWN;
if (isWifiOnline()) {
DobbyLog.v("CA In updateWifiConnectivityMode with scheduleCount " + scheduleCount + " but returning since already Online");
return;
}
DobbyLog.v("Update wifi connectivity mode, scheduleCount =" + scheduleCount);
final NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
// Reschedule network check if requested to do so and we have a null NetworkInfo.
if (scheduleCount > 0 && activeNetwork == null) {
rescheduleConnectivityTest(scheduleCount - 1);
return;
}
DobbyLog.v("active network is not null, activeNetwork:" + activeNetwork.toString());
try {
currentWifiMode = performConnectivityAndPortalTest(activeNetwork);
} catch (IllegalStateException e) {
DobbyLog.v("Exception while checking connectivity: " + e);
}
//Set the wifiConnectivityMode
if (currentWifiMode != WifiConnectivityMode.UNKNOWN) {
wifiConnectivityMode = currentWifiMode;
}
if (isWifiOnline()) {
eventBus.postEvent(new DobbyEvent(DobbyEvent.EventType.WIFI_INTERNET_CONNECTIVITY_ONLINE));
} else if (isWifiInCaptivePortal()) {
eventBus.postEvent(new DobbyEvent(DobbyEvent.EventType.WIFI_INTERNET_CONNECTIVITY_CAPTIVE_PORTAL));
} else if (isWifiDisconnected()) {
} else {
eventBus.postEvent(new DobbyEvent(DobbyEvent.EventType.WIFI_INTERNET_CONNECTIVITY_OFFLINE));
}
//TODO: Move this to the end.
if (scheduleCount > 0 && !isWifiOnline()) {
// Try once more before quitting.
rescheduleConnectivityTest(0);
}
}
use of com.inceptai.dobby.eventbus.DobbyEvent in project dobby-android by InceptAi.
the class FakePingAnalyzer method scheduleEssentialPingTestsAsync.
@Override
protected ListenableFuture<HashMap<String, PingStats>> scheduleEssentialPingTestsAsync(int maxAgeToReTriggerPingMs) throws IllegalStateException {
eventBus.postEvent(new DobbyEvent(DobbyEvent.EventType.PING_STARTED));
if (ipLayerInfo == null) {
//Try to get new iplayerInfo
eventBus.postEvent(new DobbyEvent(DobbyEvent.EventType.PING_FAILED));
throw new IllegalStateException("Cannot schedule pings when iplayerInfo is null or own IP is 0.0.0.0");
}
fakePingResultsFuture = dobbyThreadpool.getListeningScheduledExecutorService().schedule(new Callable<HashMap<String, PingStats>>() {
@Override
public HashMap<String, PingStats> call() {
HashMap<String, PingStats> pingStatsHashMap = generateFakePingStats();
ipLayerPingStats = pingStatsHashMap;
DobbyLog.v("FAKE IP Layer Ping Stats " + ipLayerPingStats.toString());
eventBus.postEvent(new DobbyEvent(DobbyEvent.EventType.PING_INFO_AVAILABLE));
return pingStatsHashMap;
}
}, PING_LATENCY_MS, TimeUnit.MILLISECONDS);
return fakePingResultsFuture;
}
use of com.inceptai.dobby.eventbus.DobbyEvent in project dobby-android by InceptAi.
the class WifiAnalyzer method postToEventBus.
private void postToEventBus(@DobbyEvent.EventType int eventType) {
eventBus.postEvent(new DobbyEvent(eventType));
publishedWifiState = true;
}
Aggregations