@Test public void testProxyConnectionStateForwardingWithDelay() { reset(mockAlarmManager, mockWifiMediator, mockCellMediator); when(mockProxyNetworkAgent.isProxyConnected()).thenReturn(false); mController.onProxyConnectionChange(false); verify(mockAlarmManager).cancel(mController.notifyProxyStatusChangeIntent); verify(mockAlarmManager).setWindow( anyInt(), anyLong(), anyLong(), eq(mController.notifyProxyStatusChangeIntent)); verifyNoMoreInteractions(mockWifiMediator); verifyNoMoreInteractions(mockCellMediator); reset(mockAlarmManager, mockWifiMediator, mockCellMediator); when(mockProxyNetworkAgent.isProxyConnected()).thenReturn(true); mController.onProxyConnectionChange(true); verify(mockAlarmManager).cancel(mController.notifyProxyStatusChangeIntent); verifyNoMoreInteractions(mockAlarmManager); verify(mockWifiMediator).updateProxyConnected(true); verify(mockCellMediator).updateProxyConnected(true); }
@Override public void onProxyConnectionChange(boolean proxyConnected) { mAlarmManager.cancel(notifyProxyStatusChangeIntent); if (proxyConnected || mBtStateChangeDelayMs <= 0) { notifyProxyStatusChange(); } else { mAlarmManager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + mBtStateChangeDelayMs, MAX_ACCEPTABLE_DELAY_MS, notifyProxyStatusChangeIntent); } }
WearConnectivityController implements
        ActivityModeTracker.Listener,
        WearNetworkObserver.Listener,
        WearProxyNetworkAgent.Listener { @Override public void onProxyConnectionChange(boolean proxyConnected) { mAlarmManager.cancel(notifyProxyStatusChangeIntent); if (proxyConnected || mBtStateChangeDelayMs <= 0) { notifyProxyStatusChange(); } else { mAlarmManager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + mBtStateChangeDelayMs, MAX_ACCEPTABLE_DELAY_MS, notifyProxyStatusChangeIntent); } } }
WearConnectivityController implements
        ActivityModeTracker.Listener,
        WearNetworkObserver.Listener,
        WearProxyNetworkAgent.Listener { @Override public void onProxyConnectionChange(boolean proxyConnected) { mAlarmManager.cancel(notifyProxyStatusChangeIntent); if (proxyConnected || mBtStateChangeDelayMs <= 0) { notifyProxyStatusChange(); } else { mAlarmManager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + mBtStateChangeDelayMs, MAX_ACCEPTABLE_DELAY_MS, notifyProxyStatusChangeIntent); } } WearConnectivityController(
            Context context,
            AlarmManager alarmManager,
            WearBluetoothMediator btMediator,
            WearWifiMediator wifiMediator,
            WearCellularMediator cellMediator,
            WearProxyNetworkAgent proxyNetworkAgent,
            ActivityModeTracker activityModeTracker,
            PowerTracker powerTracker); }
WearConnectivityController implements
        ActivityModeTracker.Listener,
        WearNetworkObserver.Listener,
        WearProxyNetworkAgent.Listener { @Override public void onProxyConnectionChange(boolean proxyConnected) { mAlarmManager.cancel(notifyProxyStatusChangeIntent); if (proxyConnected || mBtStateChangeDelayMs <= 0) { notifyProxyStatusChange(); } else { mAlarmManager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + mBtStateChangeDelayMs, MAX_ACCEPTABLE_DELAY_MS, notifyProxyStatusChangeIntent); } } WearConnectivityController(
            Context context,
            AlarmManager alarmManager,
            WearBluetoothMediator btMediator,
            WearWifiMediator wifiMediator,
            WearCellularMediator cellMediator,
            WearProxyNetworkAgent proxyNetworkAgent,
            ActivityModeTracker activityModeTracker,
            PowerTracker powerTracker); void onBootCompleted(); @Override void onProxyConnectionChange(boolean proxyConnected); @Override void onUnmeteredRequestsChanged(int numUnmeteredRequests); @Override void onHighBandwidthRequestsChanged(int numHighBandwidthRequests); @Override void onWifiRequestsChanged(int numWifiRequests); @Override void onCellularRequestsChanged(int numCellularRequests); @Override void onActivityModeChanged(boolean enabled); void dump(IndentingPrintWriter ipw); }
WearConnectivityController implements
        ActivityModeTracker.Listener,
        WearNetworkObserver.Listener,
        WearProxyNetworkAgent.Listener { @Override public void onProxyConnectionChange(boolean proxyConnected) { mAlarmManager.cancel(notifyProxyStatusChangeIntent); if (proxyConnected || mBtStateChangeDelayMs <= 0) { notifyProxyStatusChange(); } else { mAlarmManager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + mBtStateChangeDelayMs, MAX_ACCEPTABLE_DELAY_MS, notifyProxyStatusChangeIntent); } } WearConnectivityController(
            Context context,
            AlarmManager alarmManager,
            WearBluetoothMediator btMediator,
            WearWifiMediator wifiMediator,
            WearCellularMediator cellMediator,
            WearProxyNetworkAgent proxyNetworkAgent,
            ActivityModeTracker activityModeTracker,
            PowerTracker powerTracker); void onBootCompleted(); @Override void onProxyConnectionChange(boolean proxyConnected); @Override void onUnmeteredRequestsChanged(int numUnmeteredRequests); @Override void onHighBandwidthRequestsChanged(int numHighBandwidthRequests); @Override void onWifiRequestsChanged(int numWifiRequests); @Override void onCellularRequestsChanged(int numCellularRequests); @Override void onActivityModeChanged(boolean enabled); void dump(IndentingPrintWriter ipw);  }