Commit 13b5e5b7 authored by Martin Storsjö's avatar Martin Storsjö

Update the honeycomb frameworks/base headers

The honeycomb history hasn't been published with branches and tags,
but nowadays there is a tag "android-3.2.4_r1" in frameworks/base,
allowing picking headers much closer to what honeycomb devices
actually used than the previous random guess.

This is necessary for working IOMX direct rendering on honeycomb,
where the GraphicsBuffer class ABI is slightly different from what
it was in the previously guessed (randomly picked) honeycomb header
checkout.
Signed-off-by: Martin Storsjö's avatarMartin Storsjö <martin@martin.st>
parent f3c0ce85
......@@ -31,50 +31,43 @@
namespace android {
class CursorWindow;
class AndroidRuntime
{
public:
AndroidRuntime();
virtual ~AndroidRuntime();
enum StartMode {
Zygote,
SystemServer,
Application,
Tool,
};
/**
* Register a set of methods in the specified class.
*/
static int registerNativeMethods(JNIEnv* env,
const char* className, const JNINativeMethod* gMethods, int numMethods);
/**
* Call a static Java function that takes no arguments and returns void.
*/
status_t callStatic(const char* className, const char* methodName);
/**
* Call a class's static main method with the given arguments,
*/
status_t callMain(const char* className, jclass clazz, int argc,
const char* const argv[]);
status_t callMain(const char* className, int argc, const char* const argv[]);
/**
* Find a class, with the input either of the form
* Find a class, with the input either of the form
* "package/class" or "package.class".
*/
static jclass findClass(JNIEnv* env, const char* className);
int addVmArguments(int argc, const char* const argv[]);
void start(const char *classname, const char* options);
void start(const char *classname, const bool startSystemServer);
void start(); // start in android.util.RuntimeInit
static AndroidRuntime* getRuntime();
/**
* This gets called after the VM has been created, but before we
* run any code. Override it to make any FindClass calls that need
* to use CLASSPATH.
*/
virtual void onVmCreated(JNIEnv* env);
/**
* This gets called after the JavaVM has initialized. Override it
* with the system's native entry point.
......@@ -105,9 +98,6 @@ public:
/** return a pointer to the JNIEnv pointer for this thread */
static JNIEnv* getJNIEnv();
/** return a new string corresponding to 'className' with all '.'s replaced by '/'s. */
static char* toSlashClassName(const char* className);
private:
static int startReg(JNIEnv* env);
void parseExtraOpts(char* extraOptsBuf);
......@@ -122,7 +112,7 @@ private:
* Thread creation helpers.
*/
static int javaCreateThreadEtc(
android_thread_func_t entryFunction,
android_thread_func_t entryFunction,
void* userData,
const char* threadName,
int32_t threadPriority,
......@@ -131,6 +121,11 @@ private:
static int javaThreadShell(void* args);
};
// Returns the Unix file descriptor for a ParcelFileDescriptor object
extern int getParcelFileDescriptorFD(JNIEnv* env, jobject object);
extern CursorWindow * get_window_from_object(JNIEnv * env, jobject javaWindow);
}
#endif
......@@ -23,14 +23,8 @@
namespace android {
class SurfaceTexture;
extern sp<ANativeWindow> android_SurfaceTexture_getNativeWindow(
JNIEnv* env, jobject thiz);
extern bool android_SurfaceTexture_isInstanceOf(JNIEnv* env, jobject thiz);
/* Gets the underlying SurfaceTexture from a SurfaceTexture Java object. */
extern sp<SurfaceTexture> SurfaceTexture_getSurfaceTexture(JNIEnv* env, jobject thiz);
} // namespace android
......
......@@ -23,14 +23,8 @@
namespace android {
class Surface;
extern sp<ANativeWindow> android_Surface_getNativeWindow(
JNIEnv* env, jobject clazz);
extern bool android_Surface_isInstanceOf(JNIEnv* env, jobject obj);
/* Gets the underlying Surface from a Surface Java object. */
extern sp<Surface> Surface_getSurface(JNIEnv* env, jobject thiz);
} // namespace android
......
......@@ -21,8 +21,18 @@
#include <stddef.h>
#include <stdint.h>
#include <binder/Parcel.h>
#include <utils/String8.h>
#include <binder/IMemory.h>
#include <utils/RefBase.h>
#define DEFAULT_WINDOW_SIZE 4096
#define WINDOW_ALLOCATION_SIZE 4096
#define ROW_SLOT_CHUNK_NUM_ROWS 16
// Row slots are allocated in chunks of ROW_SLOT_CHUNK_NUM_ROWS,
// with an offset after the rows that points to the next chunk
#define ROW_SLOT_CHUNK_SIZE ((ROW_SLOT_CHUNK_NUM_ROWS * sizeof(row_slot_t)) + sizeof(uint32_t))
#if LOG_NDEBUG
......@@ -36,157 +46,152 @@
#endif
// When defined to true strings are stored as UTF8, otherwise they're UTF16
#define WINDOW_STORAGE_UTF8 1
// When defined to true numberic values are stored inline in the field_slot_t, otherwise they're allocated in the window
#define WINDOW_STORAGE_INLINE_NUMERICS 1
namespace android {
typedef struct
{
uint32_t numRows;
uint32_t numColumns;
} window_header_t;
typedef struct
{
uint32_t offset;
} row_slot_t;
typedef struct
{
uint8_t type;
union {
double d;
int64_t l;
struct {
uint32_t offset;
uint32_t size;
} buffer;
} data;
} __attribute__((packed)) field_slot_t;
#define FIELD_TYPE_NULL 0
#define FIELD_TYPE_INTEGER 1
#define FIELD_TYPE_FLOAT 2
#define FIELD_TYPE_STRING 3
#define FIELD_TYPE_BLOB 4
/**
* This class stores a set of rows from a database in a buffer. The begining of the
* window has first chunk of RowSlots, which are offsets to the row directory, followed by
* an offset to the next chunk in a linked-list of additional chunk of RowSlots in case
* window has first chunk of row_slot_ts, which are offsets to the row directory, followed by
* an offset to the next chunk in a linked-list of additional chunk of row_slot_ts in case
* the pre-allocated chunk isn't big enough to refer to all rows. Each row directory has a
* FieldSlot per column, which has the size, offset, and type of the data for that field.
* field_slot_t per column, which has the size, offset, and type of the data for that field.
* Note that the data types come from sqlite3.h.
*
* Strings are stored in UTF-8.
*/
class CursorWindow {
CursorWindow(const String8& name, int ashmemFd,
void* data, size_t size, bool readOnly);
class CursorWindow
{
public:
/* Field types. */
enum {
FIELD_TYPE_NULL = 0,
FIELD_TYPE_INTEGER = 1,
FIELD_TYPE_FLOAT = 2,
FIELD_TYPE_STRING = 3,
FIELD_TYPE_BLOB = 4,
};
/* Opaque type that describes a field slot. */
struct FieldSlot {
private:
int32_t type;
union {
double d;
int64_t l;
struct {
uint32_t offset;
uint32_t size;
} buffer;
} data;
friend class CursorWindow;
} __attribute((packed));
~CursorWindow();
static status_t create(const String8& name, size_t size, bool localOnly,
CursorWindow** outCursorWindow);
static status_t createFromParcel(Parcel* parcel, CursorWindow** outCursorWindow);
status_t writeToParcel(Parcel* parcel);
inline String8 name() { return mName; }
inline size_t size() { return mSize; }
inline size_t freeSpace() { return mSize - mHeader->freeOffset; }
inline uint32_t getNumRows() { return mHeader->numRows; }
inline uint32_t getNumColumns() { return mHeader->numColumns; }
status_t clear();
status_t setNumColumns(uint32_t numColumns);
/**
* Allocate a row slot and its directory.
* The row is initialized will null entries for each field.
*/
status_t allocRow();
status_t freeLastRow();
status_t putBlob(uint32_t row, uint32_t column, const void* value, size_t size);
status_t putString(uint32_t row, uint32_t column, const char* value, size_t sizeIncludingNull);
status_t putLong(uint32_t row, uint32_t column, int64_t value);
status_t putDouble(uint32_t row, uint32_t column, double value);
status_t putNull(uint32_t row, uint32_t column);
/**
* Gets the field slot at the specified row and column.
* Returns null if the requested row or column is not in the window.
*/
FieldSlot* getFieldSlot(uint32_t row, uint32_t column);
inline int32_t getFieldSlotType(FieldSlot* fieldSlot) {
return fieldSlot->type;
}
inline int64_t getFieldSlotValueLong(FieldSlot* fieldSlot) {
return fieldSlot->data.l;
}
inline double getFieldSlotValueDouble(FieldSlot* fieldSlot) {
return fieldSlot->data.d;
}
inline const char* getFieldSlotValueString(FieldSlot* fieldSlot,
size_t* outSizeIncludingNull) {
*outSizeIncludingNull = fieldSlot->data.buffer.size;
return static_cast<char*>(offsetToPtr(fieldSlot->data.buffer.offset));
}
inline const void* getFieldSlotValueBlob(FieldSlot* fieldSlot, size_t* outSize) {
*outSize = fieldSlot->data.buffer.size;
return offsetToPtr(fieldSlot->data.buffer.offset);
}
CursorWindow(size_t maxSize);
CursorWindow(){}
bool setMemory(const sp<IMemory>&);
~CursorWindow();
bool initBuffer(bool localOnly);
sp<IMemory> getMemory() {return mMemory;}
size_t size() {return mSize;}
uint8_t * data() {return mData;}
uint32_t getNumRows() {return mHeader->numRows;}
uint32_t getNumColumns() {return mHeader->numColumns;}
void freeLastRow() {
if (mHeader->numRows > 0) {
mHeader->numRows--;
}
}
bool setNumColumns(uint32_t numColumns)
{
uint32_t cur = mHeader->numColumns;
if (cur > 0 && cur != numColumns) {
LOGE("Trying to go from %d columns to %d", cur, numColumns);
return false;
}
mHeader->numColumns = numColumns;
return true;
}
int32_t freeSpace();
void clear();
/**
* Allocate a row slot and its directory. The returned
* pointer points to the begining of the row's directory
* or NULL if there wasn't room. The directory is
* initialied with NULL entries for each field.
*/
field_slot_t * allocRow();
/**
* Allocate a portion of the window. Returns the offset
* of the allocation, or 0 if there isn't enough space.
* If aligned is true, the allocation gets 4 byte alignment.
*/
uint32_t alloc(size_t size, bool aligned = false);
uint32_t read_field_slot(int row, int column, field_slot_t * slot);
/**
* Copy data into the window at the given offset.
*/
void copyIn(uint32_t offset, uint8_t const * data, size_t size);
void copyIn(uint32_t offset, int64_t data);
void copyIn(uint32_t offset, double data);
void copyOut(uint32_t offset, uint8_t * data, size_t size);
int64_t copyOutLong(uint32_t offset);
double copyOutDouble(uint32_t offset);
bool putLong(unsigned int row, unsigned int col, int64_t value);
bool putDouble(unsigned int row, unsigned int col, double value);
bool putNull(unsigned int row, unsigned int col);
bool getLong(unsigned int row, unsigned int col, int64_t * valueOut);
bool getDouble(unsigned int row, unsigned int col, double * valueOut);
bool getNull(unsigned int row, unsigned int col, bool * valueOut);
uint8_t * offsetToPtr(uint32_t offset) {return mData + offset;}
row_slot_t * allocRowSlot();
row_slot_t * getRowSlot(int row);
/**
* return NULL if Failed to find rowSlot or
* Invalid rowSlot
*/
field_slot_t * getFieldSlotWithCheck(int row, int column);
field_slot_t * getFieldSlot(int row, int column)
{
int fieldDirOffset = getRowSlot(row)->offset;
return ((field_slot_t *)offsetToPtr(fieldDirOffset)) + column;
}
private:
static const size_t ROW_SLOT_CHUNK_NUM_ROWS = 100;
struct Header {
// Offset of the lowest unused byte in the window.
uint32_t freeOffset;
// Offset of the first row slot chunk.
uint32_t firstChunkOffset;
uint32_t numRows;
uint32_t numColumns;
};
struct RowSlot {
uint32_t offset;
};
struct RowSlotChunk {
RowSlot slots[ROW_SLOT_CHUNK_NUM_ROWS];
uint32_t nextChunkOffset;
};
String8 mName;
int mAshmemFd;
void* mData;
uint8_t * mData;
size_t mSize;
bool mReadOnly;
Header* mHeader;
inline void* offsetToPtr(uint32_t offset) {
return static_cast<uint8_t*>(mData) + offset;
}
inline uint32_t offsetFromPtr(void* ptr) {
return static_cast<uint8_t*>(ptr) - static_cast<uint8_t*>(mData);
}
size_t mMaxSize;
window_header_t * mHeader;
sp<IMemory> mMemory;
/**
* Allocate a portion of the window. Returns the offset
* of the allocation, or 0 if there isn't enough space.
* If aligned is true, the allocation gets 4 byte alignment.
* Offset of the lowest unused data byte in the array.
*/
uint32_t alloc(size_t size, bool aligned = false);
RowSlot* getRowSlot(uint32_t row);
RowSlot* allocRowSlot();
status_t putBlobOrString(uint32_t row, uint32_t column,
const void* value, size_t size, int32_t type);
uint32_t mFreeOffset;
};
}; // namespace android
......
......@@ -43,7 +43,6 @@ public:
virtual void* getBase() const = 0;
virtual size_t getSize() const = 0;
virtual uint32_t getFlags() const = 0;
virtual uint32_t getOffset() const = 0;
// these are there just for backward source compatibility
int32_t heapID() const { return getHeapID(); }
......
......@@ -27,7 +27,7 @@ namespace android {
// ---------------------------------------------------------------------------
class MemoryHeapBase : public virtual BnMemoryHeap
class MemoryHeapBase : public virtual BnMemoryHeap
{
public:
enum {
......@@ -38,12 +38,12 @@ public:
NO_CACHING = 0x00000200
};
/*
/*
* maps the memory referenced by fd. but DOESN'T take ownership
* of the filedescriptor (it makes a copy with dup()
*/
MemoryHeapBase(int fd, size_t size, uint32_t flags = 0, uint32_t offset = 0);
/*
* maps memory from the given device
*/
......@@ -61,10 +61,9 @@ public:
virtual void* getBase() const;
virtual size_t getSize() const;
virtual uint32_t getFlags() const;
virtual uint32_t getOffset() const;
const char* getDevice() const;
/* this closes this heap -- use carefully */
void dispose();
......@@ -75,12 +74,12 @@ public:
mDevice = device;
return mDevice ? NO_ERROR : ALREADY_EXISTS;
}
protected:
MemoryHeapBase();
// init() takes ownership of fd
status_t init(int fd, void *base, int size,
int flags = 0, const char* device = NULL);
int flags = 0, const char* device = NULL);
private:
status_t mapfd(int fd, size_t size, uint32_t offset = 0);
......@@ -91,7 +90,6 @@ private:
uint32_t mFlags;
const char* mDevice;
bool mNeedUnmap;
uint32_t mOffset;
};
// ---------------------------------------------------------------------------
......
......@@ -38,9 +38,6 @@ struct flat_binder_object; // defined in support_p/binder_module.h
class Parcel
{
public:
class ReadableBlob;
class WritableBlob;
Parcel();
~Parcel();
......@@ -49,18 +46,14 @@ public:
size_t dataAvail() const;
size_t dataPosition() const;
size_t dataCapacity() const;
status_t setDataSize(size_t size);
void setDataPosition(size_t pos) const;
status_t setDataCapacity(size_t size);
status_t setData(const uint8_t* buffer, size_t len);
status_t appendFrom(const Parcel *parcel,
size_t start, size_t len);
bool pushAllowFds(bool allowFds);
void restoreAllowFds(bool lastValue);
status_t appendFrom(Parcel *parcel, size_t start, size_t len);
bool hasFileDescriptors() const;
......@@ -115,13 +108,7 @@ public:
// Place a file descriptor into the parcel. A dup of the fd is made, which
// will be closed once the parcel is destroyed.
status_t writeDupFileDescriptor(int fd);
// Writes a blob to the parcel.