Search in sources :

Example 36 with DataUsageRequest

use of android.net.DataUsageRequest in project platform_frameworks_base by android.

the class NetworkStatsObserversTest method testUnregister_unknownRequest_noop.

public void testUnregister_unknownRequest_noop() throws Exception {
    DataUsageRequest unknownRequest = new DataUsageRequest(123456, /* id */
    sTemplateWifi, THRESHOLD_BYTES);
    mStatsObservers.unregister(unknownRequest, UID_RED);
}
Also used : DataUsageRequest(android.net.DataUsageRequest)

Example 37 with DataUsageRequest

use of android.net.DataUsageRequest in project platform_frameworks_base by android.

the class NetworkStatsObserversTest method testUnregister_knownRequest_releasesCaller.

public void testUnregister_knownRequest_releasesCaller() throws Exception {
    DataUsageRequest inputRequest = new DataUsageRequest(DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
    DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder, Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
    assertTrue(request.requestId > 0);
    assertTrue(Objects.equals(sTemplateImsi1, request.template));
    assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
    Mockito.verify(mockBinder).linkToDeath(any(IBinder.DeathRecipient.class), anyInt());
    mStatsObservers.unregister(request, Process.SYSTEM_UID);
    waitForObserverToIdle();
    Mockito.verify(mockBinder).unlinkToDeath(any(IBinder.DeathRecipient.class), anyInt());
}
Also used : DataUsageRequest(android.net.DataUsageRequest)

Example 38 with DataUsageRequest

use of android.net.DataUsageRequest in project platform_frameworks_base by android.

the class NetworkStatsObserversTest method testRegister_twoRequests_twoIds.

public void testRegister_twoRequests_twoIds() throws Exception {
    DataUsageRequest inputRequest = new DataUsageRequest(DataUsageRequest.REQUEST_ID_UNSET, sTemplateWifi, THRESHOLD_BYTES);
    DataUsageRequest request1 = mStatsObservers.register(inputRequest, mMessenger, mockBinder, Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
    assertTrue(request1.requestId > 0);
    assertTrue(Objects.equals(sTemplateWifi, request1.template));
    assertEquals(THRESHOLD_BYTES, request1.thresholdInBytes);
    DataUsageRequest request2 = mStatsObservers.register(inputRequest, mMessenger, mockBinder, Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
    assertTrue(request2.requestId > request1.requestId);
    assertTrue(Objects.equals(sTemplateWifi, request2.template));
    assertEquals(THRESHOLD_BYTES, request2.thresholdInBytes);
}
Also used : DataUsageRequest(android.net.DataUsageRequest)

Example 39 with DataUsageRequest

use of android.net.DataUsageRequest in project platform_frameworks_base by android.

the class NetworkStatsObserversTest method testRegister_highThreshold_accepted.

public void testRegister_highThreshold_accepted() throws Exception {
    long highThresholdBytes = 2 * THRESHOLD_BYTES;
    DataUsageRequest inputRequest = new DataUsageRequest(DataUsageRequest.REQUEST_ID_UNSET, sTemplateWifi, highThresholdBytes);
    DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder, Process.SYSTEM_UID, NetworkStatsAccess.Level.DEVICE);
    assertTrue(request.requestId > 0);
    assertTrue(Objects.equals(sTemplateWifi, request.template));
    assertEquals(highThresholdBytes, request.thresholdInBytes);
}
Also used : DataUsageRequest(android.net.DataUsageRequest)

Example 40 with DataUsageRequest

use of android.net.DataUsageRequest in project platform_frameworks_base by android.

the class NetworkStatsObserversTest method testUnregister_knownRequest_invalidUid_doesNotUnregister.

public void testUnregister_knownRequest_invalidUid_doesNotUnregister() throws Exception {
    DataUsageRequest inputRequest = new DataUsageRequest(DataUsageRequest.REQUEST_ID_UNSET, sTemplateImsi1, THRESHOLD_BYTES);
    DataUsageRequest request = mStatsObservers.register(inputRequest, mMessenger, mockBinder, UID_RED, NetworkStatsAccess.Level.DEVICE);
    assertTrue(request.requestId > 0);
    assertTrue(Objects.equals(sTemplateImsi1, request.template));
    assertEquals(THRESHOLD_BYTES, request.thresholdInBytes);
    Mockito.verify(mockBinder).linkToDeath(any(IBinder.DeathRecipient.class), anyInt());
    mStatsObservers.unregister(request, UID_BLUE);
    waitForObserverToIdle();
    Mockito.verifyZeroInteractions(mockBinder);
}
Also used : DataUsageRequest(android.net.DataUsageRequest)

Aggregations

DataUsageRequest (android.net.DataUsageRequest)75 NetworkStats (android.net.NetworkStats)32 NetworkIdentity (android.net.NetworkIdentity)28 Messenger (android.os.Messenger)9 NetworkTemplate (android.net.NetworkTemplate)5 Binder (android.os.Binder)5 Looper (android.os.Looper)5 RemoteException (android.os.RemoteException)5 ConditionVariable (android.os.ConditionVariable)4 IBinder (android.os.IBinder)3 Test (org.junit.Test)2