Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//THIS IS STUB!!!!
package android.os;
import java.io.FileDescriptor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Container for a message (data and object references) that can
* be sent through an IBinder. A Parcel can contain both flattened data
* that will be unflattened on the other side of the IPC (using the various
* methods here for writing specific types, or the general {@link Parcelable} interface), and
* references to live {@link IBinder} objects that will result in the other side receiving a proxy
* IBinder
* connected with the original IBinder in the Parcel.
*
* Parcel is not a general-purpose serialization mechanism. This class (and the
* corresponding {@link Parcelable} API for placing arbitrary objects into a Parcel) is designed as
* a high-performance IPC transport. As such, it is not appropriate to place any Parcel data in to
* persistent storage: changes in the underlying implementation of any of the data in the Parcel can
* render older data unreadable.
*
*
* The bulk of the Parcel API revolves around reading and writing data of various types. There are
* six major classes of such functions available.
*
*
Primitives
*
* The most basic data functions are for writing and reading primitive data types:
* {@link #writeByte}, {@link #readByte}, {@link #writeDouble}, {@link #readDouble},
* {@link #writeFloat}, {@link #readFloat}, {@link #writeInt}, {@link #readInt}, {@link #writeLong},
* {@link #readLong}, {@link #writeString}, {@link #readString}. Most other data operations are
* built on top of these. The given data is written and read using the endianess of the host CPU.
*
*
Primitive Arrays
*
* There are a variety of methods for reading and writing raw arrays of primitive objects, which
* generally result in writing a 4-byte length followed by the primitive data items. The methods for
* reading can either read the data into an existing array, or create and return a new array. These
* available types are:
*
* The {@link Parcelable} protocol provides an extremely efficient (but low-level) protocol for
* objects to write and read themselves from Parcels. You can use the direct methods
* {@link #writeParcelable(Parcelable, int)} and {@link #readParcelable(ClassLoader)} or
* {@link #writeParcelableArray} and {@link #readParcelableArray(ClassLoader)} to write or read.
* These methods write both the class type and its data to the Parcel, allowing that class to be
* reconstructed from the appropriate class loader when later reading.
*
*
* There are also some methods that provide a more efficient way to work with Parcelables:
* {@link #writeTypedArray}, {@link #writeTypedList(List)}, {@link #readTypedArray} and
* {@link #readTypedList}. These methods do not write the class information of the original object:
* instead, the caller of the read function must know what type to expect and pass in the
* appropriate {@link Parcelable.Creator Parcelable.Creator} instead to properly construct the new
* object and read its data. (To more efficient write and read a single Parceable object, you can
* directly call {@link Parcelable#writeToParcel Parcelable.writeToParcel} and
* {@link Parcelable.Creator#createFromParcel Parcelable.Creator.createFromParcel} yourself.)
*
*
Bundles
*
* A special type-safe container, called {@link Bundle}, is available for key/value maps of
* heterogeneous values. This has many optimizations for improved performance when reading and
* writing data, and its type-safe API avoids difficult to debug type errors when finally
* marshalling the data contents into a Parcel. The methods to use are {@link #writeBundle(Bundle)},
* {@link #readBundle()}, and {@link #readBundle(ClassLoader)}.
*
Active Objects
*
* An unusual feature of Parcel is the ability to read and write active objects. For these objects
* the actual contents of the object is not written, rather a special token referencing the object
* is written. When reading the object back from the Parcel, you do not get a new instance of the
* object, but rather a handle that operates on the exact same object that was originally written.
* There are two forms of active objects available.
*
*
* {@link Binder} objects are a core facility of Android's general cross-process communication
* system. The {@link IBinder} interface describes an abstract protocol with a Binder object. Any
* such interface can be written in to a Parcel, and upon reading you will receive either the
* original object implementing that interface or a special proxy implementation that communicates
* calls back to the original object. The methods to use are {@link #writeStrongBinder(IBinder)},
* {@link #writeStrongInterface(IInterface)}, {@link #readStrongBinder()},
* {@link #writeBinderArray(IBinder[])}, {@link #readBinderArray(IBinder[])},
* {@link #createBinderArray()}, {@link #writeBinderList(List)}, {@link #readBinderList(List)},
* {@link #createBinderArrayList()}.
*
*
* FileDescriptor objects, representing raw Linux file descriptor identifiers, can be written and
* {@link ParcelFileDescriptor} objects returned to operate on the original file descriptor. The
* returned file descriptor is a dup of the original file descriptor: the object and fd is
* different, but operating on the same underlying file stream, with the same position, etc. The
* methods to use are {@link #writeFileDescriptor(FileDescriptor)}, {@link #readFileDescriptor()}.
*
Untyped Containers
*
* A final class of methods are for writing and reading standard Java containers of arbitrary types.
* These all revolve around the {@link #writeValue(Object)} and {@link #readValue(ClassLoader)}
* methods which define the types of objects allowed. The container methods are
* {@link #writeArray(Object[])}, {@link #readArray(ClassLoader)}, {@link #writeList(List)},
* {@link #readList(List, ClassLoader)}, {@link #readArrayList(ClassLoader)}, {@link #writeMap(Map)}, {@link #readMap(Map, ClassLoader)}, {@link #writeSparseArray(SparseArray)},
* {@link #readSparseArray(ClassLoader)}.
*/
public abstract class Parcel {
public final static Parcelable.Creator STRING_CREATOR = new Parcelable.Creator() {
@Override
public String createFromParcel(Parcel source) {
return source.readString();
}
@Override
public String[] newArray(int size) {
return new String[size];
}
};
/**
* Put a Parcel object back into the pool. You must not touch
* the object after this call.
*/
public abstract void recycle();
/**
* Returns the total amount of data contained in the parcel.
*/
public abstract int dataSize();
/**
* Returns the amount of data remaining to be read from the
* parcel. That is, {@link #dataSize}-{@link #dataPosition}.
*/
public abstract int dataAvail();
/**
* Returns the current position in the parcel data. Never
* more than {@link #dataSize}.
*/
public abstract int dataPosition();
/**
* Returns the total amount of space in the parcel. This is always
* >= {@link #dataSize}. The difference between it and dataSize() is the
* amount of room left until the parcel needs to re-allocate its
* data buffer.
*/
public abstract int dataCapacity();
/**
* Change the amount of data in the parcel. Can be either smaller or
* larger than the current size. If larger than the current capacity,
* more memory will be allocated.
* @param size The new number of bytes in the Parcel.
*/
public abstract void setDataSize(int size);
/**
* Move the current read/write position in the parcel.
* @param pos New offset in the parcel; must be between 0 and {@link #dataSize}.
*/
public abstract void setDataPosition(int pos);
/**
* Change the capacity (current available space) of the parcel.
* @param size The new capacity of the parcel, in bytes. Can not be
* less than {@link #dataSize} -- that is, you can not drop existing data
* with this method.
*/
public abstract void setDataCapacity(int size);
/** @hide */
public abstract boolean pushAllowFds(boolean allowFds);
/** @hide */
public abstract void restoreAllowFds(boolean lastValue);
/**
* Returns the raw bytes of the parcel.
*
* The data you retrieve here must not be placed in any kind of persistent
* storage (on local disk, across a network, etc). For that, you should use standard serialization
* or another kind of general serialization mechanism. The Parcel marshalled representation is
* highly optimized for local IPC, and as such does not attempt to maintain compatibility with
* data created in different versions of the platform.
*/
public abstract byte[] marshall();
/**
* Set the bytes in data to be the raw bytes of this Parcel.
*/
public abstract void unmarshall(byte[] data, int offset, int length);
public abstract void appendFrom(Parcel parcel, int offset, int length);
/**
* Report whether the parcel contains any marshalled file descriptors.
*/
public abstract boolean hasFileDescriptors();
/**
* Store or read an IBinder interface token in the parcel at the current {@link #dataPosition}.
* This is used to validate that the marshalled
* transaction is intended for the target interface.
*/
public abstract void writeInterfaceToken(String interfaceName);
public abstract void enforceInterface(String interfaceName);
/**
* Write a byte array into the parcel at the current {@link #dataPosition},
* growing {@link #dataCapacity} if needed.
* @param b Bytes to place into the parcel.
*/
public abstract void writeByteArray(byte[] b);
/**
* Write a byte array into the parcel at the current {@link #dataPosition},
* growing {@link #dataCapacity} if needed.
* @param b Bytes to place into the parcel.
* @param offset Index of first byte to be written.
* @param len Number of bytes to write.
*/
public abstract void writeByteArray(byte[] b, int offset, int len);
/**
* Write a blob of data into the parcel at the current {@link #dataPosition},
* growing {@link #dataCapacity} if needed.
* @param b Bytes to place into the parcel. {@hide} {@SystemApi}
*/
public abstract void writeBlob(byte[] b);
/**
* Write an integer value into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
public abstract void writeInt(int val);
/**
* Write a long integer value into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
public abstract void writeLong(long val);
/**
* Write a floating point value into the parcel at the current
* dataPosition(), growing dataCapacity() if needed.
*/
public abstract void writeFloat(float val);
/**
* Write a double precision floating point value into the parcel at the
* current dataPosition(), growing dataCapacity() if needed.
*/
public abstract void writeDouble(double val);
/**
* Write a string value into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
public abstract void writeString(String val);
/**
* Write a CharSequence value into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
* @hide
*/
public abstract void writeCharSequence(CharSequence val);
/**
* Write an object into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
public abstract void writeStrongBinder(IBinder val);
/**
* Write an object into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
public abstract void writeStrongInterface(IInterface val);
/**
* Write a FileDescriptor into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*
* The file descriptor will not be closed, which may result in file descriptor leaks when objects
* are returned from Binder calls. Use {@link ParcelFileDescriptor#writeToParcel} instead, which
* accepts contextual flags and will close the original file descriptor if
* {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE} is set.
*
*/
public abstract void writeFileDescriptor(FileDescriptor val);
/**
* Write a byte value into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
public abstract void writeByte(byte val);
/**
* Please use {@link #writeBundle} instead. Flattens a Map into the parcel
* at the current dataPosition(),
* growing dataCapacity() if needed. The Map keys must be String objects.
* The Map values are written using {@link #writeValue} and must follow
* the specification there.
*
* It is strongly recommended to use {@link #writeBundle} instead of this method, since the Bundle
* class provides a type-safe API that allows you to avoid mysterious type errors at the point of
* marshalling.
*/
public abstract void writeMap(Map val);
/**
* @hide For testing only.
*/
public abstract void writeArrayMap(Object val);
/**
* Flatten a Bundle into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
public abstract void writeBundle(Bundle val);
/**
* Flatten a PersistableBundle into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
public abstract void writePersistableBundle(PersistableBundle val);
/**
* Flatten a Size into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
public abstract void writeSize(Size val);
/**
* Flatten a SizeF into the parcel at the current dataPosition(),
* growing dataCapacity() if needed.
*/
public abstract void writeSizeF(SizeF val);
/**
* Flatten a List into the parcel at the current dataPosition(), growing
* dataCapacity() if needed. The List values are written using {@link #writeValue} and must follow
* the specification there.
*/
public abstract void writeList(List val);
/**
* Flatten an Object array into the parcel at the current dataPosition(),
* growing dataCapacity() if needed. The array values are written using {@link #writeValue} and
* must follow the specification there.
*/
public abstract void writeArray(Object[] val);
/**
* Flatten a generic SparseArray into the parcel at the current
* dataPosition(), growing dataCapacity() if needed. The SparseArray
* values are written using {@link #writeValue} and must follow the
* specification there.
*/
public abstract void writeSparseArray(SparseArray