Merge "[MS39.2] Remove the looper from NetworkStatsSubscriptionMonitor" am: 7d9470ca0b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1936490 Change-Id: I1458ab6ba83d4ab5fcc36c6fa7fb5ddfde8e04a7
This commit is contained in:
@@ -307,7 +307,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
||||
|
||||
@Override
|
||||
public NetworkStatsSubscriptionsMonitor makeSubscriptionsMonitor(
|
||||
@NonNull Context context, @NonNull Looper looper, @NonNull Executor executor,
|
||||
@NonNull Context context, @NonNull Executor executor,
|
||||
@NonNull NetworkStatsService service) {
|
||||
|
||||
return mNetworkStatsSubscriptionsMonitor;
|
||||
|
||||
@@ -35,7 +35,7 @@ import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.net.NetworkTemplate;
|
||||
import android.os.Build;
|
||||
import android.os.test.TestLooper;
|
||||
import android.os.Looper;
|
||||
import android.telephony.NetworkRegistrationInfo;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.ServiceState;
|
||||
@@ -79,19 +79,23 @@ public final class NetworkStatsSubscriptionsMonitorTest {
|
||||
|
||||
private final Executor mExecutor = Executors.newSingleThreadExecutor();
|
||||
private NetworkStatsSubscriptionsMonitor mMonitor;
|
||||
private TestLooper mTestLooper = new TestLooper();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
// TODO(b/213280079): Start a different thread and prepare the looper, create the monitor
|
||||
// on that thread instead of using the test main thread looper.
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
when(mContext.getSystemService(eq(Context.TELEPHONY_SUBSCRIPTION_SERVICE)))
|
||||
.thenReturn(mSubscriptionManager);
|
||||
when(mContext.getSystemService(eq(Context.TELEPHONY_SERVICE)))
|
||||
.thenReturn(mTelephonyManager);
|
||||
|
||||
mMonitor = new NetworkStatsSubscriptionsMonitor(mContext, mTestLooper.getLooper(),
|
||||
mExecutor, mDelegate);
|
||||
mMonitor = new NetworkStatsSubscriptionsMonitor(mContext, mExecutor, mDelegate);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user