| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static void |
closeFileDescriptor(FileDescriptor descriptor) |
Disables a file descriptor in
MessageParcel. |
boolean |
containFileDescriptors() |
Checks whether this
MessageParcel object contains file descriptors. |
static MessageParcel |
create() |
Creates a
MessageParcel object. |
static MessageParcel |
create(long object) |
Creates a
MessageParcel object with a given pointer. |
IRemoteObject[] |
createRemoteObjectArray() |
Creates an array of
IRemoteObject objects. |
List<IRemoteObject> |
createRemoteObjectList() |
Creates a list of
IRemoteObject objects. |
static int |
detachFd(FileDescriptor fileDescriptor) |
Detaches the native fd from FileDescriptor.
|
static FileDescriptor |
dupFileDescriptor(FileDescriptor descriptor) |
Obtains a new file descriptor which is a duplication of an existing file 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 |
getDataVersion() |
return data version from the
MessageParcel object. |
static int |
getFd(FileDescriptor fileDescriptor) |
Reads an native fd from FileDescriptor
|
static FileDescriptor |
getFdFromDatagramSocket(DatagramSocket datagramSocket) |
Reads an FileDescriptor from DatagramSocket
|
int |
getRawDataCapacity() |
Obtains the maximum amount of raw data a
MessageParcel can hold. |
static MessageParcel |
obtain() |
Creates a
MessageParcel object. |
static MessageParcel |
obtain(long object) |
Obtains a
MessageParcel object with a given pointer. |
Ashmem |
readAshmem() |
Reads an
Ashmem object from this MessageParcel. |
void |
readException() |
Reads an exception from the
MessageParcel. |
FileDescriptor |
readFileDescriptor() |
Reads a file descriptor from
MessageParcel. |
String |
readInterfaceToken() |
Reads an interface token from
MessageParcel. |
byte[] |
readRawData(int size) |
Reads raw data from
MessageParcel. |
IRemoteObject |
readRemoteObject() |
Reads a remote object from
MessageParcel. |
void |
readRemoteObjectArray(IRemoteObject[] objects) |
Reads an array of
IRemoteObject objects from the MessageParcel. |
void |
readRemoteObjectList(List<IRemoteObject> objects) |
Reads a list of
IRemoteObject objects from the MessageParcel. |
void |
reclaim() |
Adds a
MessageParcel object to the cache pool. |
void |
updateDataVersion(IRemoteObject object) |
update a remote object data version to the
MessageParcel object. |
boolean |
writeAshmem(Ashmem ashmem) |
Writes a specified
Ashmem object to this MessageParcel. |
void |
writeException(Exception exception) |
Writes an exception to the
MessageParcel. |
boolean |
writeFileDescriptor(FileDescriptor descriptor) |
Serializes a file descriptor and writes it to
MessageParcel. |
boolean |
writeInterfaceToken(String token) |
Writes an interface token to the
MessageParcel object. |
void |
writeNoException() |
Writes no exception to the
MessageParcel. |
boolean |
writeRawData(byte[] rawData,
int size) |
Writes raw data to be sent to a remote process to a
MessageParcel object. |
boolean |
writeRemoteObject(IRemoteObject object) |
Serializes a remote object and writes it to the
MessageParcel object. |
boolean |
writeRemoteObjectArray(IRemoteObject[] objects) |
Writes an array of
IRemoteObject objects to the MessageParcel. |
boolean |
writeRemoteObjectList(List<IRemoteObject> objects) |
Writes a list of
IRemoteObject objects to the MessageParcel. |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddAppClassLoader, appendFrom, createSequenceable, createSequenceable, createSequenceableArray, flushBuffer, getBytes, getCapacity, getReadableBytes, getReadPosition, getSize, getWritableBytes, getWritePosition, readBoolean, readBooleanArray, readBooleanArray, readByte, readByteArray, readByteArray, readChar, readCharArray, readCharArray, readDouble, readDoubleArray, readDoubleArray, readFloat, readFloatArray, readFloatArray, readInt, readIntArray, readIntArray, readList, readLong, readLongArray, readLongArray, readMap, readPacMapEx, readParcelableEx, readPlainArray, readPlainBooleanArray, readSequenceable, readSequenceableArray, readSequenceableList, readSequenceableMap, readSerializable, readShort, readShortArray, readShortArray, readString, readStringArray, readStringArray, readStringList, readValue, rewindRead, rewindWrite, setCapacity, setSize, writeBoolean, writeBooleanArray, writeByte, writeByteArray, writeBytes, writeChar, writeCharArray, writeDouble, writeDoubleArray, writeFloat, writeFloatArray, writeInt, writeIntArray, writeList, writeLong, writeLongArray, writeMap, writeMap, writePacMapEx, writeParcelableEx, writePlainArray, writePlainBooleanArray, writeSequenceable, writeSequenceableArray, writeSequenceableList, writeSequenceableMap, writeSerializable, writeShort, writeShortArray, writeString, writeStringArray, writeStringList, writeTypedSequenceable, writeTypedSequenceableArray, writeValuepublic static final MessageParcel obtain()
MessageParcel object.MessageParcel object.public static final MessageParcel create()
MessageParcel object.MessageParcel object.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 在类中 ParcelThrowable - the Exception raised by this methodWeakReference,
PhantomReferencepublic static MessageParcel obtain(long object)
MessageParcel object with a given pointer.object - Indicates the address of a MessageParcel.MessageParcel object with the specified index if it is found in cache pool;
returns a new MessageParcel object with the specified index if not found.public static MessageParcel create(long object)
MessageParcel object with a given pointer.object - Indicates the address of a MessageParcel.MessageParcel object with the given pointer if it is found in cache pool;
returns a new MessageParcel object with the given pointer if not found.public final void reclaim()
MessageParcel object to the cache pool.
This method is used to clear a MessageParcel object that is no longer used.
public void updateDataVersion(IRemoteObject object)
MessageParcel object.object - Indicates the remote object and its data version written to MessageParcel.public int getDataVersion()
MessageParcel object.MessageParcel.public boolean writeRemoteObject(IRemoteObject object)
MessageParcel object.object - Indicates the remote object to be serialized and written to MessageParcel.true if the operation succeeds; returns false otherwise.public IRemoteObject readRemoteObject()
MessageParcel.
This method is used to deserialize a MessageParcel object to generate an IRemoteObject.
Remote objects are read in the sequence they were written to MessageParcel.
IRemoteObject.public boolean writeInterfaceToken(String token)
MessageParcel object.token - Indicates the interface token.true if the operation succeeds; returns false otherwise.public String readInterfaceToken()
MessageParcel.
Interface tokens are read in the sequence they were written to MessageParcel.
public boolean writeFileDescriptor(FileDescriptor descriptor)
MessageParcel.
In the current version, this method does not apply to cross-device communication.
descriptor - Indicates the file descriptor.true if the operation succeeds; returns false otherwise.public FileDescriptor readFileDescriptor()
MessageParcel.
File descriptors are read in the sequence they were written to MessageParcel.
In the current version, this method does not apply to cross-device communication.
public boolean writeRawData(byte[] rawData,
int size)
MessageParcel object.
If the remote process runs on the current device, the raw data is transmitted through the shared memory. If the remote process runs on the peer device, the raw data is transmitted through a cross-device channel such as a socket.
Only a group of raw data can be written to each MessageParcel. In cross-device case, raw data can
only be sent sequentially.
rawData - Indicates the raw data to be sent to the remote process. A maximum of 128 Mb raw data can be sent
through IPC, and the maximum is 128 Mb - 64byte in RPC case. If the data size is greater than maximum,
false will be returned. You must manage the lifecycle of data memory by yourself.size - Indicates the size of the raw data to be sent.true if the operation succeeds; returns false otherwise.public byte[] readRawData(int size)
MessageParcel.
The size of the raw data to be read must be the same as that of the raw data written to MessageParcel.
Raw data is read in the sequence it was written to MessageParcel.
size - Indicates the size of the raw data to be read.MessageParcel object.public int getRawDataCapacity()
MessageParcel can hold.MessageParcel can hold, that is, 128 Mb.public static void closeFileDescriptor(FileDescriptor descriptor)
MessageParcel.
In the current version, this method does not apply to cross-device communication.
descriptor - Indicates the file descriptor to be disabled.public static FileDescriptor dupFileDescriptor(FileDescriptor descriptor)
The status of the new file descriptor is the same as that of the existing one.
Calling this method does not close the input file descriptor. You are responsible for closing the returned new file descriptor.
In the current version, this method does not apply to cross-device communication.
descriptor - Indicates an existing file descriptor.public boolean containFileDescriptors()
MessageParcel object contains file descriptors.
After the writeFileDescriptor or writeRawData method is called,
the MessageParcel object will contain file descriptors.
true if this MessageParcel object contains file descriptors;
returns false otherwise.public IRemoteObject[] createRemoteObjectArray()
IRemoteObject objects.
This method is used to read IRemoteObject objects from the MessageParcel
and create an array of IRemoteObject objects.
IRemoteObject objects.
The lifecycle of the array is up to your application.public List<IRemoteObject> createRemoteObjectList()
IRemoteObject objects.
This method is used to read IRemoteObject objects from the MessageParcel
and create a list of IRemoteObject objects.
IRemoteObject objects. The lifecycle of the list is up to your application.public boolean writeRemoteObjectArray(IRemoteObject[] objects)
IRemoteObject objects to the MessageParcel.
You can use the createRemoteObjectArray() or readRemoteObjectArray(ohos.rpc.IRemoteObject[]) method to read the array of
IRemoteObject objects from the MessageParcel.
objects - Indicates the array of IRemoteObject objects to write to the MessageParcel.true if the array of IRemoteObject objects is successfully written to
the MessageParcel; returns false if objects is null or
the array fails to be written to the MessageParcel.public boolean writeRemoteObjectList(List<IRemoteObject> objects)
IRemoteObject objects to the MessageParcel.
You can use the createRemoteObjectList() or readRemoteObjectList(java.util.List<ohos.rpc.IRemoteObject>) method to read the list of
IRemoteObject objects from the MessageParcel.
objects - Indicates the list of IRemoteObject objects to write to the MessageParcel.true if the list of IRemoteObject objects is successfully written to
the MessageParcel; returns false if objects is null or the list fails to be
written to the MessageParcel.public void readRemoteObjectArray(IRemoteObject[] objects)
IRemoteObject objects from the MessageParcel.
When using this method, your application needs to pass the array of IRemoteObject objects
it wants to read from the MessageParcel.
objects - Indicates the array of IRemoteObject objects your application wants to read from
the MessageParcel. If the length of this array is not equal to the number of
IRemoteObject objects actually read from the MessageParcel, the array of
IRemoteObject objects passed by your application will be returned.public void readRemoteObjectList(List<IRemoteObject> objects)
IRemoteObject objects from the MessageParcel.
When using this method, your application needs to pass the list of IRemoteObject objects
it wants to read from the MessageParcel.
objects - Indicates the list of IRemoteObject objects your application wants to read from
the MessageParcel. No matter whether the length of this list is greater or less than the number of
IRemoteObject objects actually read from the MessageParcel, a list of
the IRemoteObject objects actually read from the MessageParcel will be returned.public void writeException(Exception exception)
MessageParcel.
Supported exceptions include SecurityException, IllegalArgumentException,
NullPointerException, IllegalStateException, UnsupportedOperationException,
IndexOutOfBoundsException, NegativeArraySizeException, ArrayStoreException,
ClassCastException, and RemoteException. If any other exception is written to
the MessageParcel, RuntimeException will be returned.
This method is typically used when responding to a received packet.
exception - Indicates the exception to write to the MessageParcel.public void writeNoException()
MessageParcel.public void readException()
MessageParcel.
The exception read will be thrown.
This method is typically used when reading a response packet.
Exception - Throws the exception read from the MessageParcel. The exception can be
SecurityException, IllegalArgumentException, NullPointerException,
IllegalStateException, UnsupportedOperationException, IndexOutOfBoundsException,
NegativeArraySizeException, ArrayStoreException, ClassCastException,
or RemoteException.public static FileDescriptor getFdFromDatagramSocket(DatagramSocket datagramSocket)
Creates a new file descriptor from the specified DatagramSocket.
The new file descriptor holds the duplication of the original file descriptor in the DatagramSocket,
so you are responsible for closing the returned new file descriptor.
datagramSocket - Indicates the DatagramSocket to get the FileDescriptor.FileDescriptor.public static int getFd(FileDescriptor fileDescriptor)
fileDescriptor - Indicates the FileDescriptor to get the fd.FileDescriptor if it is not null; otherwise returns -1.public static int detachFd(FileDescriptor fileDescriptor)
It is now your responsibility to turn off the native fd or fd leaks occur.
You cannot call the method when the original creator of the descriptor expects to
turn off the FileDescriptor itself.
fileDescriptor - FileDescriptor to detach fd.FileDescriptor; otherwise returns -1.public boolean writeAshmem(Ashmem ashmem)
Ashmem object to this MessageParcel.ashmem - Indicates the Ashmem object to write to this MessageParcel.true if the Ashmem object is successfully written to this MessageParcel;
returns false otherwise.public Ashmem readAshmem()
Ashmem object from this MessageParcel.Ashmem object.