NetworkStatsServiceTest.java revision b09540f33a6cabe50edec0ef32d0b1d0b0d96fff
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server;
18
19import static android.content.Intent.ACTION_UID_REMOVED;
20import static android.content.Intent.EXTRA_UID;
21import static android.net.ConnectivityManager.CONNECTIVITY_ACTION;
22import static android.net.ConnectivityManager.TYPE_MOBILE;
23import static android.net.ConnectivityManager.TYPE_WIFI;
24import static android.net.NetworkStats.TAG_NONE;
25import static android.net.NetworkStats.UID_ALL;
26import static android.net.NetworkTemplate.MATCH_MOBILE_ALL;
27import static android.net.NetworkTemplate.MATCH_WIFI;
28import static android.net.TrafficStats.UID_REMOVED;
29import static android.text.format.DateUtils.DAY_IN_MILLIS;
30import static android.text.format.DateUtils.HOUR_IN_MILLIS;
31import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
32import static android.text.format.DateUtils.WEEK_IN_MILLIS;
33import static com.android.server.net.NetworkStatsService.ACTION_NETWORK_STATS_POLL;
34import static org.easymock.EasyMock.anyLong;
35import static org.easymock.EasyMock.createMock;
36import static org.easymock.EasyMock.eq;
37import static org.easymock.EasyMock.expect;
38import static org.easymock.EasyMock.expectLastCall;
39import static org.easymock.EasyMock.isA;
40
41import android.app.AlarmManager;
42import android.app.IAlarmManager;
43import android.app.PendingIntent;
44import android.content.Intent;
45import android.net.IConnectivityManager;
46import android.net.LinkProperties;
47import android.net.NetworkInfo;
48import android.net.NetworkInfo.DetailedState;
49import android.net.NetworkState;
50import android.net.NetworkStats;
51import android.net.NetworkStatsHistory;
52import android.net.NetworkTemplate;
53import android.os.INetworkManagementService;
54import android.telephony.TelephonyManager;
55import android.test.AndroidTestCase;
56import android.test.suitebuilder.annotation.LargeTest;
57import android.util.TrustedTime;
58
59import com.android.server.net.NetworkStatsService;
60import com.android.server.net.NetworkStatsService.NetworkStatsSettings;
61
62import org.easymock.EasyMock;
63
64import java.io.File;
65
66/**
67 * Tests for {@link NetworkStatsService}.
68 */
69@LargeTest
70public class NetworkStatsServiceTest extends AndroidTestCase {
71    private static final String TAG = "NetworkStatsServiceTest";
72
73    private static final String TEST_IFACE = "test0";
74    private static final long TEST_START = 1194220800000L;
75
76    private static final String IMSI_1 = "310004";
77    private static final String IMSI_2 = "310260";
78
79    private static NetworkTemplate sTemplateWifi = new NetworkTemplate(MATCH_WIFI, null);
80    private static NetworkTemplate sTemplateImsi1 = new NetworkTemplate(MATCH_MOBILE_ALL, IMSI_1);
81    private static NetworkTemplate sTemplateImsi2 = new NetworkTemplate(MATCH_MOBILE_ALL, IMSI_2);
82
83    private static final int TEST_UID_RED = 1001;
84    private static final int TEST_UID_BLUE = 1002;
85    private static final int TEST_UID_GREEN = 1003;
86
87    private BroadcastInterceptingContext mServiceContext;
88    private File mStatsDir;
89
90    private INetworkManagementService mNetManager;
91    private IAlarmManager mAlarmManager;
92    private TrustedTime mTime;
93    private NetworkStatsSettings mSettings;
94    private IConnectivityManager mConnManager;
95
96    private NetworkStatsService mService;
97
98    @Override
99    public void setUp() throws Exception {
100        super.setUp();
101
102        mServiceContext = new BroadcastInterceptingContext(getContext());
103        mStatsDir = getContext().getFilesDir();
104
105        mNetManager = createMock(INetworkManagementService.class);
106        mAlarmManager = createMock(IAlarmManager.class);
107        mTime = createMock(TrustedTime.class);
108        mSettings = createMock(NetworkStatsSettings.class);
109        mConnManager = createMock(IConnectivityManager.class);
110
111        mService = new NetworkStatsService(
112                mServiceContext, mNetManager, mAlarmManager, mTime, mStatsDir, mSettings);
113        mService.bindConnectivityManager(mConnManager);
114
115        expectDefaultSettings();
116        expectSystemReady();
117
118        replay();
119        mService.systemReady();
120        verifyAndReset();
121
122    }
123
124    @Override
125    public void tearDown() throws Exception {
126        for (File file : mStatsDir.listFiles()) {
127            file.delete();
128        }
129
130        mServiceContext = null;
131        mStatsDir = null;
132
133        mNetManager = null;
134        mAlarmManager = null;
135        mTime = null;
136        mSettings = null;
137        mConnManager = null;
138
139        mService = null;
140
141        super.tearDown();
142    }
143
144    public void testNetworkStatsWifi() throws Exception {
145        long elapsedRealtime = 0;
146
147        // pretend that wifi network comes online; service should ask about full
148        // network state, and poll any existing interfaces before updating.
149        expectTime(TEST_START + elapsedRealtime);
150        expectDefaultSettings();
151        expectNetworkState(buildWifiState());
152        expectNetworkStatsSummary(buildEmptyStats(elapsedRealtime));
153
154        replay();
155        mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION));
156
157        // verify service has empty history for wifi
158        assertNetworkTotal(sTemplateWifi, 0L, 0L);
159        verifyAndReset();
160
161        // modify some number on wifi, and trigger poll event
162        elapsedRealtime += HOUR_IN_MILLIS;
163        expectTime(TEST_START + elapsedRealtime);
164        expectDefaultSettings();
165        expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1)
166                .addEntry(TEST_IFACE, UID_ALL, TAG_NONE, 1024L, 2048L));
167        expectNetworkStatsDetail(buildEmptyStats(elapsedRealtime));
168
169        replay();
170        mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL));
171
172        // verify service recorded history
173        assertNetworkTotal(sTemplateWifi, 1024L, 2048L);
174        verifyAndReset();
175
176        // and bump forward again, with counters going higher. this is
177        // important, since polling should correctly subtract last snapshot.
178        elapsedRealtime += DAY_IN_MILLIS;
179        expectTime(TEST_START + elapsedRealtime);
180        expectDefaultSettings();
181        expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1)
182                .addEntry(TEST_IFACE, UID_ALL, TAG_NONE, 4096L, 8192L));
183        expectNetworkStatsDetail(buildEmptyStats(elapsedRealtime));
184
185        replay();
186        mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL));
187
188        // verify service recorded history
189        assertNetworkTotal(sTemplateWifi, 4096L, 8192L);
190        verifyAndReset();
191
192    }
193
194    public void testStatsRebootPersist() throws Exception {
195        long elapsedRealtime = 0;
196        assertStatsFilesExist(false);
197
198        // pretend that wifi network comes online; service should ask about full
199        // network state, and poll any existing interfaces before updating.
200        expectTime(TEST_START + elapsedRealtime);
201        expectDefaultSettings();
202        expectNetworkState(buildWifiState());
203        expectNetworkStatsSummary(buildEmptyStats(elapsedRealtime));
204
205        replay();
206        mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION));
207
208        // verify service has empty history for wifi
209        assertNetworkTotal(sTemplateWifi, 0L, 0L);
210        verifyAndReset();
211
212        // modify some number on wifi, and trigger poll event
213        elapsedRealtime += HOUR_IN_MILLIS;
214        expectTime(TEST_START + elapsedRealtime);
215        expectDefaultSettings();
216        expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1)
217                .addEntry(TEST_IFACE, UID_ALL, TAG_NONE, 1024L, 2048L));
218        expectNetworkStatsDetail(new NetworkStats(elapsedRealtime, 2)
219                .addEntry(TEST_IFACE, TEST_UID_RED, TAG_NONE, 512L, 256L)
220                .addEntry(TEST_IFACE, TEST_UID_BLUE, TAG_NONE, 128L, 128L));
221
222        replay();
223        mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL));
224
225        // verify service recorded history
226        assertNetworkTotal(sTemplateWifi, 1024L, 2048L);
227        assertUidTotal(sTemplateWifi, TEST_UID_RED, 512L, 256L);
228        assertUidTotal(sTemplateWifi, TEST_UID_BLUE, 128L, 128L);
229        verifyAndReset();
230
231        // graceful shutdown system, which should trigger persist of stats, and
232        // clear any values in memory.
233        mServiceContext.sendBroadcast(new Intent(Intent.ACTION_SHUTDOWN));
234
235        // talk with zombie service to assert stats have gone; and assert that
236        // we persisted them to file.
237        expectDefaultSettings();
238        replay();
239        assertNetworkTotal(sTemplateWifi, 0L, 0L);
240        verifyAndReset();
241
242        assertStatsFilesExist(true);
243
244        // boot through serviceReady() again
245        expectDefaultSettings();
246        expectSystemReady();
247
248        replay();
249        mService.systemReady();
250
251        // after systemReady(), we should have historical stats loaded again
252        assertNetworkTotal(sTemplateWifi, 1024L, 2048L);
253        assertUidTotal(sTemplateWifi, TEST_UID_RED, 512L, 256L);
254        assertUidTotal(sTemplateWifi, TEST_UID_BLUE, 128L, 128L);
255        verifyAndReset();
256
257    }
258
259    public void testStatsBucketResize() throws Exception {
260        long elapsedRealtime = 0;
261        NetworkStatsHistory history = null;
262        long[] total = null;
263
264        assertStatsFilesExist(false);
265
266        // pretend that wifi network comes online; service should ask about full
267        // network state, and poll any existing interfaces before updating.
268        expectTime(TEST_START + elapsedRealtime);
269        expectSettings(0L, HOUR_IN_MILLIS, WEEK_IN_MILLIS);
270        expectNetworkState(buildWifiState());
271        expectNetworkStatsSummary(buildEmptyStats(elapsedRealtime));
272
273        replay();
274        mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION));
275        verifyAndReset();
276
277        // modify some number on wifi, and trigger poll event
278        elapsedRealtime += 2 * HOUR_IN_MILLIS;
279        expectTime(TEST_START + elapsedRealtime);
280        expectSettings(0L, HOUR_IN_MILLIS, WEEK_IN_MILLIS);
281        expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1)
282                .addEntry(TEST_IFACE, UID_ALL, TAG_NONE, 512L, 512L));
283        expectNetworkStatsDetail(buildEmptyStats(elapsedRealtime));
284
285        replay();
286        mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL));
287
288        // verify service recorded history
289        history = mService.getHistoryForNetwork(new NetworkTemplate(MATCH_WIFI, null));
290        total = history.getTotalData(Long.MIN_VALUE, Long.MAX_VALUE, null);
291        assertEquals(512L, total[0]);
292        assertEquals(512L, total[1]);
293        assertEquals(HOUR_IN_MILLIS, history.bucketDuration);
294        assertEquals(2, history.bucketCount);
295        verifyAndReset();
296
297        // now change bucket duration setting and trigger another poll with
298        // exact same values, which should resize existing buckets.
299        expectTime(TEST_START + elapsedRealtime);
300        expectSettings(0L, 30 * MINUTE_IN_MILLIS, WEEK_IN_MILLIS);
301        expectNetworkStatsSummary(buildEmptyStats(elapsedRealtime));
302        expectNetworkStatsDetail(buildEmptyStats(elapsedRealtime));
303
304        replay();
305        mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL));
306
307        // verify identical stats, but spread across 4 buckets now
308        history = mService.getHistoryForNetwork(new NetworkTemplate(MATCH_WIFI, null));
309        total = history.getTotalData(Long.MIN_VALUE, Long.MAX_VALUE, null);
310        assertEquals(512L, total[0]);
311        assertEquals(512L, total[1]);
312        assertEquals(30 * MINUTE_IN_MILLIS, history.bucketDuration);
313        assertEquals(4, history.bucketCount);
314        verifyAndReset();
315
316    }
317
318    public void testUidStatsAcrossNetworks() throws Exception {
319        long elapsedRealtime = 0;
320
321        // pretend first mobile network comes online
322        expectTime(TEST_START + elapsedRealtime);
323        expectDefaultSettings();
324        expectNetworkState(buildMobile3gState(IMSI_1));
325        expectNetworkStatsSummary(buildEmptyStats(elapsedRealtime));
326
327        replay();
328        mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION));
329        verifyAndReset();
330
331        // create some traffic on first network
332        elapsedRealtime += HOUR_IN_MILLIS;
333        expectTime(TEST_START + elapsedRealtime);
334        expectDefaultSettings();
335        expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1)
336                .addEntry(TEST_IFACE, UID_ALL, TAG_NONE, 2048L, 512L));
337        expectNetworkStatsDetail(new NetworkStats(elapsedRealtime, 3)
338                .addEntry(TEST_IFACE, TEST_UID_RED, TAG_NONE, 1024L, 0L)
339                .addEntry(TEST_IFACE, TEST_UID_RED, 0xF00D, 512L, 512L)
340                .addEntry(TEST_IFACE, TEST_UID_BLUE, TAG_NONE, 512L, 0L));
341
342        replay();
343        mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL));
344
345        // verify service recorded history
346        assertNetworkTotal(sTemplateImsi1, 2048L, 512L);
347        assertNetworkTotal(sTemplateWifi, 0L, 0L);
348        assertUidTotal(sTemplateImsi1, TEST_UID_RED, 1536L, 512L);
349        assertUidTotal(sTemplateImsi1, TEST_UID_BLUE, 512L, 0L);
350        verifyAndReset();
351
352        // now switch networks; this also tests that we're okay with interfaces
353        // disappearing, to verify we don't count backwards.
354        elapsedRealtime += HOUR_IN_MILLIS;
355        expectTime(TEST_START + elapsedRealtime);
356        expectDefaultSettings();
357        expectNetworkState(buildMobile3gState(IMSI_2));
358        expectNetworkStatsSummary(buildEmptyStats(elapsedRealtime));
359        expectNetworkStatsDetail(buildEmptyStats(elapsedRealtime));
360
361        replay();
362        mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION));
363        mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL));
364        verifyAndReset();
365
366        // create traffic on second network
367        elapsedRealtime += HOUR_IN_MILLIS;
368        expectTime(TEST_START + elapsedRealtime);
369        expectDefaultSettings();
370        expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1)
371                .addEntry(TEST_IFACE, UID_ALL, TAG_NONE, 128L, 1024L));
372        expectNetworkStatsDetail(new NetworkStats(elapsedRealtime, 1)
373                .addEntry(TEST_IFACE, TEST_UID_BLUE, TAG_NONE, 128L, 1024L));
374
375        replay();
376        mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL));
377
378        // verify original history still intact
379        assertNetworkTotal(sTemplateImsi1, 2048L, 512L);
380        assertUidTotal(sTemplateImsi1, TEST_UID_RED, 1536L, 512L);
381        assertUidTotal(sTemplateImsi1, TEST_UID_BLUE, 512L, 0L);
382
383        // and verify new history also recorded under different template, which
384        // verifies that we didn't cross the streams.
385        assertNetworkTotal(sTemplateImsi2, 128L, 1024L);
386        assertNetworkTotal(sTemplateWifi, 0L, 0L);
387        assertUidTotal(sTemplateImsi2, TEST_UID_BLUE, 128L, 1024L);
388        verifyAndReset();
389
390    }
391
392    public void testUidRemovedIsMoved() throws Exception {
393        long elapsedRealtime = 0;
394
395        // pretend that network comes online
396        expectTime(TEST_START + elapsedRealtime);
397        expectDefaultSettings();
398        expectNetworkState(buildWifiState());
399        expectNetworkStatsSummary(buildEmptyStats(elapsedRealtime));
400
401        replay();
402        mServiceContext.sendBroadcast(new Intent(CONNECTIVITY_ACTION));
403        verifyAndReset();
404
405        // create some traffic
406        elapsedRealtime += HOUR_IN_MILLIS;
407        expectTime(TEST_START + elapsedRealtime);
408        expectDefaultSettings();
409        expectNetworkStatsSummary(new NetworkStats(elapsedRealtime, 1)
410                .addEntry(TEST_IFACE, UID_ALL, TAG_NONE, 4128L, 544L));
411        expectNetworkStatsDetail(new NetworkStats(elapsedRealtime, 1)
412                .addEntry(TEST_IFACE, TEST_UID_RED, TAG_NONE, 16L, 16L)
413                .addEntry(TEST_IFACE, TEST_UID_BLUE, TAG_NONE, 4096L, 512L)
414                .addEntry(TEST_IFACE, TEST_UID_GREEN, TAG_NONE, 16L, 16L));
415
416        replay();
417        mServiceContext.sendBroadcast(new Intent(ACTION_NETWORK_STATS_POLL));
418
419        // verify service recorded history
420        assertNetworkTotal(sTemplateWifi, 4128L, 544L);
421        assertUidTotal(sTemplateWifi, TEST_UID_RED, 16L, 16L);
422        assertUidTotal(sTemplateWifi, TEST_UID_BLUE, 4096L, 512L);
423        assertUidTotal(sTemplateWifi, TEST_UID_GREEN, 16L, 16L);
424        verifyAndReset();
425
426        // now pretend two UIDs are uninstalled, which should migrate stats to
427        // special "removed" bucket.
428        expectDefaultSettings();
429        replay();
430        final Intent intent = new Intent(ACTION_UID_REMOVED);
431        intent.putExtra(EXTRA_UID, TEST_UID_BLUE);
432        mServiceContext.sendBroadcast(intent);
433        intent.putExtra(EXTRA_UID, TEST_UID_RED);
434        mServiceContext.sendBroadcast(intent);
435
436        // existing uid and total should remain unchanged; but removed UID
437        // should be gone completely.
438        assertNetworkTotal(sTemplateWifi, 4128L, 544L);
439        assertUidTotal(sTemplateWifi, TEST_UID_RED, 0L, 0L);
440        assertUidTotal(sTemplateWifi, TEST_UID_BLUE, 0L, 0L);
441        assertUidTotal(sTemplateWifi, TEST_UID_GREEN, 16L, 16L);
442        assertUidTotal(sTemplateWifi, UID_REMOVED, 4112L, 528L);
443        verifyAndReset();
444
445    }
446
447    private void assertNetworkTotal(NetworkTemplate template, long rx, long tx) {
448        final NetworkStatsHistory history = mService.getHistoryForNetwork(template);
449        final long[] total = history.getTotalData(Long.MIN_VALUE, Long.MAX_VALUE, null);
450        assertEquals(rx, total[0]);
451        assertEquals(tx, total[1]);
452    }
453
454    private void assertUidTotal(NetworkTemplate template, int uid, long rx, long tx) {
455        final NetworkStatsHistory history = mService.getHistoryForUid(template, uid);
456        final long[] total = history.getTotalData(Long.MIN_VALUE, Long.MAX_VALUE, null);
457        assertEquals(rx, total[0]);
458        assertEquals(tx, total[1]);
459    }
460
461    private void expectSystemReady() throws Exception {
462        mAlarmManager.remove(isA(PendingIntent.class));
463        expectLastCall().anyTimes();
464
465        mAlarmManager.setInexactRepeating(
466                eq(AlarmManager.ELAPSED_REALTIME), anyLong(), anyLong(), isA(PendingIntent.class));
467        expectLastCall().atLeastOnce();
468    }
469
470    private void expectNetworkState(NetworkState... state) throws Exception {
471        expect(mConnManager.getAllNetworkState()).andReturn(state).atLeastOnce();
472    }
473
474    private void expectNetworkStatsSummary(NetworkStats summary) throws Exception {
475        expect(mNetManager.getNetworkStatsSummary()).andReturn(summary).atLeastOnce();
476    }
477
478    private void expectNetworkStatsDetail(NetworkStats detail) throws Exception {
479        expect(mNetManager.getNetworkStatsDetail()).andReturn(detail).atLeastOnce();
480    }
481
482    private void expectDefaultSettings() throws Exception {
483        expectSettings(0L, HOUR_IN_MILLIS, WEEK_IN_MILLIS);
484    }
485
486    private void expectSettings(long persistThreshold, long bucketDuration, long maxHistory)
487            throws Exception {
488        expect(mSettings.getPollInterval()).andReturn(HOUR_IN_MILLIS).anyTimes();
489        expect(mSettings.getPersistThreshold()).andReturn(persistThreshold).anyTimes();
490        expect(mSettings.getNetworkBucketDuration()).andReturn(bucketDuration).anyTimes();
491        expect(mSettings.getNetworkMaxHistory()).andReturn(maxHistory).anyTimes();
492        expect(mSettings.getUidBucketDuration()).andReturn(bucketDuration).anyTimes();
493        expect(mSettings.getUidMaxHistory()).andReturn(maxHistory).anyTimes();
494        expect(mSettings.getTimeCacheMaxAge()).andReturn(DAY_IN_MILLIS).anyTimes();
495    }
496
497    private void expectTime(long currentTime) throws Exception {
498        expect(mTime.forceRefresh()).andReturn(false).anyTimes();
499        expect(mTime.hasCache()).andReturn(true).anyTimes();
500        expect(mTime.currentTimeMillis()).andReturn(currentTime).anyTimes();
501        expect(mTime.getCacheAge()).andReturn(0L).anyTimes();
502        expect(mTime.getCacheCertainty()).andReturn(0L).anyTimes();
503    }
504
505    private void assertStatsFilesExist(boolean exist) {
506        final File networkFile = new File(mStatsDir, "netstats.bin");
507        final File uidFile = new File(mStatsDir, "netstats_uid.bin");
508        if (exist) {
509            assertTrue(networkFile.exists());
510            assertTrue(uidFile.exists());
511        } else {
512            assertFalse(networkFile.exists());
513            assertFalse(uidFile.exists());
514        }
515    }
516
517    private static NetworkState buildWifiState() {
518        final NetworkInfo info = new NetworkInfo(TYPE_WIFI, 0, null, null);
519        info.setDetailedState(DetailedState.CONNECTED, null, null);
520        final LinkProperties prop = new LinkProperties();
521        prop.setInterfaceName(TEST_IFACE);
522        return new NetworkState(info, prop, null);
523    }
524
525    private static NetworkState buildMobile3gState(String subscriberId) {
526        final NetworkInfo info = new NetworkInfo(
527                TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UMTS, null, null);
528        info.setDetailedState(DetailedState.CONNECTED, null, null);
529        final LinkProperties prop = new LinkProperties();
530        prop.setInterfaceName(TEST_IFACE);
531        return new NetworkState(info, prop, null, subscriberId);
532    }
533
534    private static NetworkStats buildEmptyStats(long elapsedRealtime) {
535        return new NetworkStats(elapsedRealtime, 0);
536    }
537
538    private void replay() {
539        EasyMock.replay(mNetManager, mAlarmManager, mTime, mSettings, mConnManager);
540    }
541
542    private void verifyAndReset() {
543        EasyMock.verify(mNetManager, mAlarmManager, mTime, mSettings, mConnManager);
544        EasyMock.reset(mNetManager, mAlarmManager, mTime, mSettings, mConnManager);
545    }
546}
547