Loading framework/tests/bumble/src/android/bluetooth/LeAdvertisingTest.java +4 −20 Original line number Diff line number Diff line package android.bluetooth; import static android.bluetooth.Utils.factoryResetAndCreateNewChannel; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertisingSet; import android.bluetooth.le.AdvertisingSetCallback; Loading @@ -18,7 +20,6 @@ import com.google.protobuf.Empty; import io.grpc.Context.CancellableContext; import io.grpc.Deadline; import io.grpc.ManagedChannel; import io.grpc.okhttp.OkHttpChannelBuilder; import io.grpc.stub.StreamObserver; import java.util.concurrent.CompletableFuture; Loading Loading @@ -59,25 +60,8 @@ public class LeAdvertisingTest { @Before public void setUp() throws Exception { // FactorReset is killing the server and restart // all channel created before the server restarted // cannot be reused ManagedChannel channel = OkHttpChannelBuilder .forAddress("localhost", 7999) .usePlaintext() .build(); HostGrpc.HostBlockingStub stub = HostGrpc.newBlockingStub(channel); stub.factoryReset(Empty.getDefaultInstance()); // terminate the channel channel.shutdown().awaitTermination(1, TimeUnit.SECONDS); // Create a new channel for all successive grpc calls mChannel = OkHttpChannelBuilder .forAddress("localhost", 7999) .usePlaintext() .build(); // Cleanup previous channels and create a new channel for all successive grpc calls mChannel = factoryResetAndCreateNewChannel(); mHostBlockingStub = HostGrpc.newBlockingStub(mChannel); mHostStub = HostGrpc.newStub(mChannel); Loading framework/tests/bumble/src/android/bluetooth/LeScanningTest.java +5 −16 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.bluetooth; import static android.bluetooth.Utils.factoryResetAndCreateNewChannel; import static com.google.common.truth.Truth.assertThat; import android.bluetooth.le.BluetoothLeScanner; Loading Loading @@ -45,7 +47,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import io.grpc.ManagedChannel; import io.grpc.okhttp.OkHttpChannelBuilder; import io.grpc.stub.StreamObserver; import pandora.HostGrpc; Loading @@ -56,7 +57,7 @@ import pandora.HostProto.AdvertiseResponse; @RunWith(AndroidJUnit4.class) public class LeScanningTest { private static final String TAG = "LeScanningTest"; private static final int TIMEOUT_SCANNING_MS = 1000; private static final int TIMEOUT_SCANNING_MS = 2000; private static ManagedChannel mChannel; Loading @@ -75,20 +76,8 @@ public class LeScanningTest { @Before public void setUp() throws Exception { // FactorReset is killing the server and restart // all channel created before the server restarted // cannot be reused ManagedChannel channel = OkHttpChannelBuilder.forAddress("localhost", 7999).usePlaintext().build(); HostGrpc.HostBlockingStub stub = HostGrpc.newBlockingStub(channel); stub.factoryReset(Empty.getDefaultInstance()); // terminate the channel channel.shutdown().awaitTermination(1, TimeUnit.SECONDS); // Create a new channel for all successive grpc calls mChannel = OkHttpChannelBuilder.forAddress("localhost", 7999).usePlaintext().build(); // Cleanup previous channels and create a new channel for all successive grpc calls mChannel = factoryResetAndCreateNewChannel(); mHostBlockingStub = HostGrpc.newBlockingStub(mChannel); mHostStub = HostGrpc.newStub(mChannel); Loading framework/tests/bumble/src/android/bluetooth/Utils.java +25 −0 Original line number Diff line number Diff line package android.bluetooth; import com.google.protobuf.ByteString; import com.google.protobuf.Empty; import java.util.concurrent.TimeUnit; import io.grpc.ManagedChannel; import io.grpc.okhttp.OkHttpChannelBuilder; import pandora.HostGrpc; public final class Utils { public static String addressStringFromByteString(ByteString bs) { Loading @@ -13,4 +20,22 @@ public final class Utils { } return refAddrBuilder.toString(); } public static ManagedChannel factoryResetAndCreateNewChannel() throws InterruptedException { // FactoryReset is killing the server and restarting all channels created before the server // restarted that cannot be reused ManagedChannel channel = OkHttpChannelBuilder .forAddress("localhost", 7999) .usePlaintext() .build(); HostGrpc.HostBlockingStub stub = HostGrpc.newBlockingStub(channel); stub.factoryReset(Empty.getDefaultInstance()); // terminate the channel channel.shutdown().awaitTermination(1, TimeUnit.SECONDS); // return new channel for future use return OkHttpChannelBuilder.forAddress("localhost", 7999).usePlaintext().build(); } } Loading
framework/tests/bumble/src/android/bluetooth/LeAdvertisingTest.java +4 −20 Original line number Diff line number Diff line package android.bluetooth; import static android.bluetooth.Utils.factoryResetAndCreateNewChannel; import android.bluetooth.le.AdvertiseData; import android.bluetooth.le.AdvertisingSet; import android.bluetooth.le.AdvertisingSetCallback; Loading @@ -18,7 +20,6 @@ import com.google.protobuf.Empty; import io.grpc.Context.CancellableContext; import io.grpc.Deadline; import io.grpc.ManagedChannel; import io.grpc.okhttp.OkHttpChannelBuilder; import io.grpc.stub.StreamObserver; import java.util.concurrent.CompletableFuture; Loading Loading @@ -59,25 +60,8 @@ public class LeAdvertisingTest { @Before public void setUp() throws Exception { // FactorReset is killing the server and restart // all channel created before the server restarted // cannot be reused ManagedChannel channel = OkHttpChannelBuilder .forAddress("localhost", 7999) .usePlaintext() .build(); HostGrpc.HostBlockingStub stub = HostGrpc.newBlockingStub(channel); stub.factoryReset(Empty.getDefaultInstance()); // terminate the channel channel.shutdown().awaitTermination(1, TimeUnit.SECONDS); // Create a new channel for all successive grpc calls mChannel = OkHttpChannelBuilder .forAddress("localhost", 7999) .usePlaintext() .build(); // Cleanup previous channels and create a new channel for all successive grpc calls mChannel = factoryResetAndCreateNewChannel(); mHostBlockingStub = HostGrpc.newBlockingStub(mChannel); mHostStub = HostGrpc.newStub(mChannel); Loading
framework/tests/bumble/src/android/bluetooth/LeScanningTest.java +5 −16 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.bluetooth; import static android.bluetooth.Utils.factoryResetAndCreateNewChannel; import static com.google.common.truth.Truth.assertThat; import android.bluetooth.le.BluetoothLeScanner; Loading Loading @@ -45,7 +47,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import io.grpc.ManagedChannel; import io.grpc.okhttp.OkHttpChannelBuilder; import io.grpc.stub.StreamObserver; import pandora.HostGrpc; Loading @@ -56,7 +57,7 @@ import pandora.HostProto.AdvertiseResponse; @RunWith(AndroidJUnit4.class) public class LeScanningTest { private static final String TAG = "LeScanningTest"; private static final int TIMEOUT_SCANNING_MS = 1000; private static final int TIMEOUT_SCANNING_MS = 2000; private static ManagedChannel mChannel; Loading @@ -75,20 +76,8 @@ public class LeScanningTest { @Before public void setUp() throws Exception { // FactorReset is killing the server and restart // all channel created before the server restarted // cannot be reused ManagedChannel channel = OkHttpChannelBuilder.forAddress("localhost", 7999).usePlaintext().build(); HostGrpc.HostBlockingStub stub = HostGrpc.newBlockingStub(channel); stub.factoryReset(Empty.getDefaultInstance()); // terminate the channel channel.shutdown().awaitTermination(1, TimeUnit.SECONDS); // Create a new channel for all successive grpc calls mChannel = OkHttpChannelBuilder.forAddress("localhost", 7999).usePlaintext().build(); // Cleanup previous channels and create a new channel for all successive grpc calls mChannel = factoryResetAndCreateNewChannel(); mHostBlockingStub = HostGrpc.newBlockingStub(mChannel); mHostStub = HostGrpc.newStub(mChannel); Loading
framework/tests/bumble/src/android/bluetooth/Utils.java +25 −0 Original line number Diff line number Diff line package android.bluetooth; import com.google.protobuf.ByteString; import com.google.protobuf.Empty; import java.util.concurrent.TimeUnit; import io.grpc.ManagedChannel; import io.grpc.okhttp.OkHttpChannelBuilder; import pandora.HostGrpc; public final class Utils { public static String addressStringFromByteString(ByteString bs) { Loading @@ -13,4 +20,22 @@ public final class Utils { } return refAddrBuilder.toString(); } public static ManagedChannel factoryResetAndCreateNewChannel() throws InterruptedException { // FactoryReset is killing the server and restarting all channels created before the server // restarted that cannot be reused ManagedChannel channel = OkHttpChannelBuilder .forAddress("localhost", 7999) .usePlaintext() .build(); HostGrpc.HostBlockingStub stub = HostGrpc.newBlockingStub(channel); stub.factoryReset(Empty.getDefaultInstance()); // terminate the channel channel.shutdown().awaitTermination(1, TimeUnit.SECONDS); // return new channel for future use return OkHttpChannelBuilder.forAddress("localhost", 7999).usePlaintext().build(); } }