2323
2424import android .content .Context ;
2525import android .content .Intent ;
26+ import android .net .Uri ;
2627import android .os .Parcel ;
2728import android .os .Parcelable ;
2829import androidx .test .core .app .ApplicationProvider ;
3940import io .grpc .ManagedChannel ;
4041import io .grpc .Metadata ;
4142import io .grpc .MethodDescriptor ;
42- import io .grpc .NameResolverRegistry ;
4343import io .grpc .ServerCall ;
4444import io .grpc .ServerCall .Listener ;
4545import io .grpc .ServerCallHandler ;
4949import io .grpc .Status .Code ;
5050import io .grpc .StatusRuntimeException ;
5151import io .grpc .internal .GrpcUtil ;
52- import io .grpc .internal .testing .FakeNameResolverProvider ;
5352import io .grpc .stub .ClientCalls ;
5453import io .grpc .stub .MetadataUtils ;
5554import io .grpc .stub .ServerCalls ;
@@ -77,7 +76,6 @@ public final class BinderChannelSmokeTest {
7776
7877 private static final int SLIGHTLY_MORE_THAN_ONE_BLOCK = 16 * 1024 + 100 ;
7978 private static final String MSG = "Some text which will be repeated many many times" ;
80- private static final String SERVER_TARGET_URI = "fake://server" ;
8179 private static final Metadata .Key <PoisonParcelable > POISON_KEY =
8280 ParcelableUtils .metadataKey ("poison-bin" , PoisonParcelable .CREATOR );
8381
@@ -99,7 +97,6 @@ public final class BinderChannelSmokeTest {
9997 .setType (MethodDescriptor .MethodType .BIDI_STREAMING )
10098 .build ();
10199
102- FakeNameResolverProvider fakeNameResolverProvider ;
103100 ManagedChannel channel ;
104101 AtomicReference <Metadata > headersCapture = new AtomicReference <>();
105102 AtomicReference <PeerUid > clientUidCapture = new AtomicReference <>();
@@ -138,8 +135,6 @@ public void setUp() throws Exception {
138135 PeerUids .newPeerIdentifyingServerInterceptor ());
139136
140137 AndroidComponentAddress serverAddress = HostServices .allocateService (appContext );
141- fakeNameResolverProvider = new FakeNameResolverProvider (SERVER_TARGET_URI , serverAddress );
142- NameResolverRegistry .getDefaultRegistry ().register (fakeNameResolverProvider );
143138 HostServices .configureService (
144139 serverAddress ,
145140 HostServices .serviceParamsBuilder ()
@@ -166,7 +161,6 @@ public void setUp() throws Exception {
166161 @ After
167162 public void tearDown () throws Exception {
168163 channel .shutdownNow ();
169- NameResolverRegistry .getDefaultRegistry ().deregister (fakeNameResolverProvider );
170164 HostServices .awaitServiceShutdown ();
171165 }
172166
@@ -235,7 +229,11 @@ public void testStreamingCallOptionHeaders() throws Exception {
235229
236230 @ Test
237231 public void testConnectViaTargetUri () throws Exception {
238- channel = BinderChannelBuilder .forTarget (SERVER_TARGET_URI , appContext ).build ();
232+ // Compare with the <intent-filter> mapping in AndroidManifest.xml.
233+ channel =
234+ BinderChannelBuilder .forTarget (
235+ "intent://authority/path#Intent;action=action1;scheme=scheme;end;" , appContext )
236+ .build ();
239237 assertThat (doCall ("Hello" ).get ()).isEqualTo ("Hello" );
240238 }
241239
@@ -245,7 +243,10 @@ public void testConnectViaIntentFilter() throws Exception {
245243 channel =
246244 BinderChannelBuilder .forAddress (
247245 AndroidComponentAddress .forBindIntent (
248- new Intent ().setAction ("action1" ).setPackage (appContext .getPackageName ())),
246+ new Intent ()
247+ .setAction ("action1" )
248+ .setData (Uri .parse ("scheme://authority/path" ))
249+ .setPackage (appContext .getPackageName ())),
249250 appContext )
250251 .build ();
251252 assertThat (doCall ("Hello" ).get ()).isEqualTo ("Hello" );
0 commit comments