Add periodically pulling data from StatsD
- Use a provided Handler to schedule periodic
pulling reports from StatsD.
- The period is currently hard-coded, but
it can be simply refactored into config
in the future.
- Add FakeHandlerWrapper to simplify working
with Handler and running delayed callbacks.
Bug: 189143813
Test: atest CarServiceUnitTest:StatsPublisherTest
Change-Id: Ib3d342fff3b6e10e8ce1e4fc0aac46a3a8ffe1ac
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/databroker/DataBrokerUnitTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/databroker/DataBrokerUnitTest.java
index 02166ea..73a36d2 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/databroker/DataBrokerUnitTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/databroker/DataBrokerUnitTest.java
@@ -30,6 +30,7 @@
import android.car.hardware.CarPropertyConfig;
import android.content.Context;
import android.content.ServiceConnection;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -43,6 +44,7 @@
import com.android.car.telemetry.ResultStore;
import com.android.car.telemetry.TelemetryProto;
import com.android.car.telemetry.publisher.PublisherFactory;
+import com.android.car.telemetry.publisher.StatsManagerProxy;
import org.junit.Before;
import org.junit.Test;
@@ -97,6 +99,10 @@
@Mock
private CarPropertyService mMockCarPropertyService;
@Mock
+ private StatsManagerProxy mMockStatsManager;
+ @Mock
+ private SharedPreferences mMockSharedPreferences;
+ @Mock
private IBinder mMockScriptExecutorBinder;
@Mock
private ResultStore mMockResultStore;
@@ -110,7 +116,8 @@
.thenReturn(Collections.singletonList(PROP_CONFIG));
// bind service should return true, otherwise broker is disabled
when(mMockContext.bindServiceAsUser(any(), any(), anyInt(), any())).thenReturn(true);
- PublisherFactory factory = new PublisherFactory(mMockCarPropertyService);
+ PublisherFactory factory = new PublisherFactory(
+ mMockCarPropertyService, mMockStatsManager, mMockSharedPreferences);
mDataBroker = new DataBrokerImpl(mMockContext, factory, mMockResultStore);
mHandler = mDataBroker.getWorkerHandler();