IRemoteObjectInstallerCallback, LocalRemoteObject, NfcController.ReaderModeCallbackStub, OnPermissionChangedCallbackpublic class RemoteObject extends Object implements IRemoteObject
Service providers must inherit this class.
If RemoteObject is defined as an anonymous, local, or member class
but not a static singleton class, potential leaks may occur.
IRemoteObject.DeathRecipientDUMP_TRANSACTION, INTERFACE_TRANSACTION, MAX_TRANSACTION_ID, MIN_TRANSACTION_ID, PING_TRANSACTION| 构造器 | 说明 |
|---|---|
RemoteObject(String descriptor) |
A constructor used to create a
RemoteObject instance using the default interface descriptor. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
addDeathRecipient(IRemoteObject.DeathRecipient recipient,
int flags) |
Registers a callback used to receive death notifications of a remote proxy.
|
void |
attachLocalInterface(IRemoteBroker localInterface,
String descriptor) |
Modifies the description of the current
RemoteObject. |
protected void |
dump(FileDescriptor fd,
PrintWriter pw,
String[] args) |
Dumps the status of the current interface to a file with a specific descriptor.
|
void |
dump(FileDescriptor fd,
String[] args) |
Dumps the status of the current interface to a file with a specific descriptor.
|
protected void |
finalize() |
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
int |
getCallingPid() |
Obtains the PID of the
RemoteProxy object. |
int |
getCallingUid() |
Obtains the UID of the
RemoteProxy object. |
String |
getInterfaceDescriptor() |
Queries an interface descriptor.
|
boolean |
isObjectDead() |
Checks whether a
RemoteObject is dead. |
boolean |
onRemoteRequest(int code,
MessageParcel data,
MessageParcel reply,
MessageOption option) |
Sets an entry for receiving requests.
|
IRemoteBroker |
queryLocalInterface(String descriptor) |
Queries a remote object using an interface descriptor.
|
boolean |
removeDeathRecipient(IRemoteObject.DeathRecipient recipient,
int flags) |
Deregisters a callback used to receive death notifications of a remote proxy.
|
boolean |
sendRequest(int code,
MessageParcel data,
MessageParcel reply,
MessageOption option) |
Sends a request to the peer object.
|
protected void |
slowPathDump(FileDescriptor fd,
PrintWriter pw,
String[] args) |
Asynchronously dumps data to a specified file using the given
PrintWriter object. |
void |
slowPathDump(FileDescriptor fd,
String[] args) |
Asynchronously dumps data to a specified file.
|
public RemoteObject(String descriptor)
RemoteObject instance using the default interface descriptor.descriptor - Indicates the interface descriptor used to create the RemoteObject instance.public IRemoteBroker queryLocalInterface(String descriptor)
queryLocalInterface 在接口中 IRemoteObjectdescriptor - Indicates the interface descriptor used to query the remote object.public boolean addDeathRecipient(IRemoteObject.DeathRecipient recipient, int flags)
addDeathRecipient 在接口中 IRemoteObjectrecipient - Indicates the callback to be registered.flags - Indicates the flag of the death notification.false because this callback is not required.public boolean removeDeathRecipient(IRemoteObject.DeathRecipient recipient, int flags)
removeDeathRecipient 在接口中 IRemoteObjectrecipient - Indicates the callback to be deregistered.flags - Indicates the flag of the death notification.false because this callback is not required.public String getInterfaceDescriptor()
getInterfaceDescriptor 在接口中 IRemoteObjectpublic boolean onRemoteRequest(int code,
MessageParcel data,
MessageParcel reply,
MessageOption option)
throws RemoteException
This method is implemented by the remote service provider. You need to override this method with your own service logic when you are using IPC.
code - Indicates the service request code sent from the peer end.data - Indicates the MessageParcel object sent from the peer end.reply - Indicates the response message object sent from the remote service.
The local service writes the response data to the MessageParcel object.option - Indicates whether the operation is synchronous or asynchronous.true if the operation succeeds; returns false otherwise.RemoteException - Throws this exception if a remote service error occurs.public boolean sendRequest(int code,
MessageParcel data,
MessageParcel reply,
MessageOption option)
throws RemoteException
If the peer object and RemoteObject are on the same device, the request is sent by the IPC driver.
If they are on different devices, the request is sent by the socket driver.
sendRequest 在接口中 IRemoteObjectcode - Indicates the message code of the request.data - Indicates the MessageParcel object storing the data to be sent.reply - Indicates the MessageParcel object receiving the response data.option - Indicates a synchronous (default) or asynchronous request.true if the operation succeeds; returns false otherwise.RemoteException - Throws this exception if a remote service error occurs.public int getCallingPid()
RemoteProxy object.RemoteProxy object.public int getCallingUid()
RemoteProxy object.RemoteProxy object.protected void dump(FileDescriptor fd, PrintWriter pw, String[] args)
fd - Indicates the descriptor of the target file.pw - Prints a formatted representation of the object to the output stream.args - Indicates parameters of this method in character string format.RemoteException - Throws this exception if an error occurs when FileOutputStream is opened or
data is written to FileOutputStream.protected void slowPathDump(FileDescriptor fd, PrintWriter pw, String[] args)
PrintWriter object.
This method applies only to data dump on the same device.
You need to override this method to define the data to dump to the file. After the dump is complete, you need to close the file descriptor.
fd - Indicates the file descriptor of the target file.pw - Indicates the PrintWriter object used to dump data to the target file,
with automatic flushing disabled.args - Indicates the arguments (an array of strings) to dump.public void dump(FileDescriptor fd, String[] args) throws RemoteException
dump 在接口中 IRemoteObjectfd - Indicates the descriptor of the target file.args - Indicates parameters of this method in character string format.RemoteException - Throws this exception if an error occurs when FileOutputStream is opened or
data is written to FileOutputStream.public void slowPathDump(FileDescriptor fd, String[] args) throws RemoteException
This method applies only to data dump on the same device.
Alternatively, you can override the slowPathDump(java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[]) method to
define the data to dump to the file. After the dump is complete, you need to close the file descriptor.
slowPathDump 在接口中 IRemoteObjectfd - Indicates the file descriptor of the target file.args - Indicates the arguments (an array of strings) to dump.RemoteException - Throws this exception if the dump command fails to be sent or
an error occurs during the dump.protected void finalize()
throws Throwable
Objectfinalize method to dispose of
system resources or to perform other cleanup.
The general contract of finalize is that it is invoked
if and when the Java™ virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize method may take any action, including
making this object available again to other threads; the usual purpose
of finalize, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize method of class Object performs no
special action; it simply returns normally. Subclasses of
Object may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize method causes
the finalization of this object to be halted, but is otherwise
ignored.
finalize 在类中 ObjectThrowable - the Exception raised by this methodWeakReference,
PhantomReferencepublic boolean isObjectDead()
RemoteObject is dead.isObjectDead 在接口中 IRemoteObjectfalse by default.public void attachLocalInterface(IRemoteBroker localInterface, String descriptor)
RemoteObject.
This method is used to change the default descriptor specified during the creation of RemoteObject.
localInterface - Indicates the RemoteObject whose descriptor is to be changed.descriptor - Indicates the new descriptor of the RemoteObject.