-
- All Implemented Interfaces:
-
java.io.Serializable
public final class AndroidComponentAddress extends SocketAddress
The target of an Android android.app.Service binding.
Consists of an explicit Intent that identifies an android.os.IBinder returned by some Service's onBind method. You can specify that Service by ComponentName or let Android resolve it using the Intent's other fields (package, action, data URI, type and category set). See Bound Services Overviewand Intents and Intent Filters for more.
For convenience in the common case where a android.app.Service exposes just one IPC interface, we provide default values for the binding Intent fields, namely, an action of ACTION_BIND, an empty category set and null type and data URI.
Optionally contains a UserHandle that must be considered wherever the Intent is evaluated.
equals uses filterEquals semantics to compare Intents.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
AndroidComponentAddress.Builder
Fluently builds instances of AndroidComponentAddress.
-
Field Summary
Fields Modifier and Type Field Description private final UserHandle
targetUser
-
Method Summary
Modifier and Type Method Description UserHandle
getTargetUser()
Identifies the Android user in which the bind Intent will be evaluated. static AndroidComponentAddress
forContext(Context context)
Creates an address for the given android.app.Service instance with the default binding Intent. static AndroidComponentAddress
forLocalComponent(Context context, Class<out Object> cls)
Creates an address referencing a android.app.Service hosted by this application andusing the default binding Intent. static AndroidComponentAddress
forRemoteComponent(String applicationPackage, String serviceClassName)
Creates an address referencing a android.app.Service in another application and usingthe default binding Intent. static AndroidComponentAddress
forBindIntent(Intent intent)
Creates a new address that uses the "filter matching" fields of intent
as thebinding Intent.static AndroidComponentAddress
forComponent(ComponentName component)
Creates an address referencing the specified android.app.Service component and usingthe default binding Intent. String
getAuthority()
Returns the Authority which is the package name of the target app. String
getPackage()
Returns the package target of the wrapped Intent, either from its package restrictionor, if not present, its fully qualified ComponentName. ComponentName
getComponent()
Returns the ComponentName of this binding Intent, or null if one isn't set. Intent
asBindIntent()
Returns this address as an explicit Intent suitable for passing to . String
asAndroidAppUri()
Returns this address as an "android-app://" uri. int
hashCode()
boolean
equals(Object obj)
String
toString()
static AndroidComponentAddress.Builder
newBuilder()
-
-
Method Detail
-
getTargetUser
@ExperimentalApi(value = https://github.com/grpc/grpc-java/issues/10173)@Nullable() UserHandle getTargetUser()
Identifies the Android user in which the bind Intent will be evaluated.
Returns the UserHandle, or null which means that the Android user hosting thecurrent process will be used.
-
forContext
static AndroidComponentAddress forContext(Context context)
Creates an address for the given android.app.Service instance with the default binding Intent.
-
forLocalComponent
static AndroidComponentAddress forLocalComponent(Context context, Class<out Object> cls)
Creates an address referencing a android.app.Service hosted by this application andusing the default binding Intent.
-
forRemoteComponent
static AndroidComponentAddress forRemoteComponent(String applicationPackage, String serviceClassName)
Creates an address referencing a android.app.Service in another application and usingthe default binding Intent.
- Parameters:
applicationPackage
- The package name of the application containing the server.serviceClassName
- The full class name of the Android Service to bind to.
-
forBindIntent
static AndroidComponentAddress forBindIntent(Intent intent)
Creates a new address that uses the "filter matching" fields of
intent
as thebinding Intent.intent
must be "explicit", i.e. having either a target component () or package restriction (getPackage). See Intents and IntentFilters for more.A multi-tenant android.app.Service can call this from its method to locate an appropriate io.grpc.Server bylistening address.
-
forComponent
static AndroidComponentAddress forComponent(ComponentName component)
Creates an address referencing the specified android.app.Service component and usingthe default binding Intent.
-
getAuthority
String getAuthority()
Returns the Authority which is the package name of the target app.
See android.content.ComponentName and getPackage.
-
getPackage
String getPackage()
Returns the package target of the wrapped Intent, either from its package restrictionor, if not present, its fully qualified ComponentName.
-
getComponent
@Nullable() ComponentName getComponent()
Returns the ComponentName of this binding Intent, or null if one isn't set.
-
asBindIntent
Intent asBindIntent()
Returns this address as an explicit Intent suitable for passing to .
NB: The returned Intent does not specify a target Android user. If getTargetUser is non-null, bindServiceAsUser should be called instead.
-
asAndroidAppUri
String asAndroidAppUri()
Returns this address as an "android-app://" uri.
See URI_ANDROID_APP_SCHEME for details.
-
hashCode
int hashCode()
-
newBuilder
static AndroidComponentAddress.Builder newBuilder()
-
-
-
-