Skip to content

Commit 74c3ca2

Browse files
committed
Add required AOSP headers and libraries
1 parent 73e8902 commit 74c3ca2

File tree

245 files changed

+37711
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+37711
-0
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*
2+
* Copyright (C) 2010 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
#ifndef ANDROID_ASSET_MANAGER_H
19+
#define ANDROID_ASSET_MANAGER_H
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
struct AAssetManager;
26+
typedef struct AAssetManager AAssetManager;
27+
28+
struct AAssetDir;
29+
typedef struct AAssetDir AAssetDir;
30+
31+
struct AAsset;
32+
typedef struct AAsset AAsset;
33+
34+
/* Available modes for opening assets */
35+
enum {
36+
AASSET_MODE_UNKNOWN = 0,
37+
AASSET_MODE_RANDOM = 1,
38+
AASSET_MODE_STREAMING = 2,
39+
AASSET_MODE_BUFFER = 3
40+
};
41+
42+
43+
/**
44+
* Open the named directory within the asset hierarchy. The directory can then
45+
* be inspected with the AAssetDir functions. To open the top-level directory,
46+
* pass in "" as the dirName.
47+
*
48+
* The object returned here should be freed by calling AAssetDir_close().
49+
*/
50+
AAssetDir* AAssetManager_openDir(AAssetManager* mgr, const char* dirName);
51+
52+
/**
53+
* Open an asset.
54+
*
55+
* The object returned here should be freed by calling AAsset_close().
56+
*/
57+
AAsset* AAssetManager_open(AAssetManager* mgr, const char* filename, int mode);
58+
59+
/**
60+
* Iterate over the files in an asset directory. A NULL string is returned
61+
* when all the file names have been returned.
62+
*
63+
* The returned file name is suitable for passing to AAssetManager_open().
64+
*
65+
* The string returned here is owned by the AssetDir implementation and is not
66+
* guaranteed to remain valid if any other calls are made on this AAssetDir
67+
* instance.
68+
*/
69+
const char* AAssetDir_getNextFileName(AAssetDir* assetDir);
70+
71+
/**
72+
* Reset the iteration state of AAssetDir_getNextFileName() to the beginning.
73+
*/
74+
void AAssetDir_rewind(AAssetDir* assetDir);
75+
76+
/**
77+
* Close an opened AAssetDir, freeing any related resources.
78+
*/
79+
void AAssetDir_close(AAssetDir* assetDir);
80+
81+
/**
82+
* Attempt to read 'count' bytes of data from the current offset.
83+
*
84+
* Returns the number of bytes read, zero on EOF, or < 0 on error.
85+
*/
86+
int AAsset_read(AAsset* asset, void* buf, size_t count);
87+
88+
/**
89+
* Seek to the specified offset within the asset data. 'whence' uses the
90+
* same constants as lseek()/fseek().
91+
*
92+
* Returns the new position on success, or (off_t) -1 on error.
93+
*/
94+
off_t AAsset_seek(AAsset* asset, off_t offset, int whence);
95+
96+
/**
97+
* Seek to the specified offset within the asset data. 'whence' uses the
98+
* same constants as lseek()/fseek().
99+
*
100+
* Uses 64-bit data type for large files as opposed to the 32-bit type used
101+
* by AAsset_seek.
102+
*
103+
* Returns the new position on success, or (off64_t) -1 on error.
104+
*/
105+
off64_t AAsset_seek64(AAsset* asset, off64_t offset, int whence);
106+
107+
/**
108+
* Close the asset, freeing all associated resources.
109+
*/
110+
void AAsset_close(AAsset* asset);
111+
112+
/**
113+
* Get a pointer to a buffer holding the entire contents of the assset.
114+
*
115+
* Returns NULL on failure.
116+
*/
117+
const void* AAsset_getBuffer(AAsset* asset);
118+
119+
/**
120+
* Report the total size of the asset data.
121+
*/
122+
off_t AAsset_getLength(AAsset* asset);
123+
124+
/**
125+
* Report the total size of the asset data. Reports the size using a 64-bit
126+
* number insted of 32-bit as AAsset_getLength.
127+
*/
128+
off64_t AAsset_getLength64(AAsset* asset);
129+
130+
/**
131+
* Report the total amount of asset data that can be read from the current position.
132+
*/
133+
off_t AAsset_getRemainingLength(AAsset* asset);
134+
135+
/**
136+
* Report the total amount of asset data that can be read from the current position.
137+
*
138+
* Uses a 64-bit number instead of a 32-bit number as AAsset_getRemainingLength does.
139+
*/
140+
off64_t AAsset_getRemainingLength64(AAsset* asset);
141+
142+
/**
143+
* Open a new file descriptor that can be used to read the asset data. If the
144+
* start or length cannot be represented by a 32-bit number, it will be
145+
* truncated. If the file is large, use AAsset_openFileDescriptor64 instead.
146+
*
147+
* Returns < 0 if direct fd access is not possible (for example, if the asset is
148+
* compressed).
149+
*/
150+
int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength);
151+
152+
/**
153+
* Open a new file descriptor that can be used to read the asset data.
154+
*
155+
* Uses a 64-bit number for the offset and length instead of 32-bit instead of
156+
* as AAsset_openFileDescriptor does.
157+
*
158+
* Returns < 0 if direct fd access is not possible (for example, if the asset is
159+
* compressed).
160+
*/
161+
int AAsset_openFileDescriptor64(AAsset* asset, off64_t* outStart, off64_t* outLength);
162+
163+
/**
164+
* Returns whether this asset's internal buffer is allocated in ordinary RAM (i.e. not
165+
* mmapped).
166+
*/
167+
int AAsset_isAllocated(AAsset* asset);
168+
169+
170+
171+
#ifdef __cplusplus
172+
};
173+
#endif
174+
175+
#endif // ANDROID_ASSET_MANAGER_H
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) 2010 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
#ifndef ANDROID_ASSET_MANAGER_JNI_H
19+
#define ANDROID_ASSET_MANAGER_JNI_H
20+
21+
#include <android/asset_manager.h>
22+
#include <jni.h>
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
/**
29+
* Given a Dalvik AssetManager object, obtain the corresponding native AAssetManager
30+
* object. Note that the caller is responsible for obtaining and holding a VM reference
31+
* to the jobject to prevent its being garbage collected while the native object is
32+
* in use.
33+
*/
34+
AAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager);
35+
36+
#ifdef __cplusplus
37+
};
38+
#endif
39+
40+
#endif // ANDROID_ASSET_MANAGER_JNI_H
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (C) 2009 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef ANDROID_BITMAP_H
18+
#define ANDROID_BITMAP_H
19+
20+
#include <stdint.h>
21+
#include <jni.h>
22+
23+
#ifdef __cplusplus
24+
extern "C" {
25+
#endif
26+
27+
#define ANDROID_BITMAP_RESULT_SUCCESS 0
28+
#define ANDROID_BITMAP_RESULT_BAD_PARAMETER -1
29+
#define ANDROID_BITMAP_RESULT_JNI_EXCEPTION -2
30+
#define ANDROID_BITMAP_RESULT_ALLOCATION_FAILED -3
31+
32+
/* Backward compatibility: this macro used to be misspelled. */
33+
#define ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS
34+
35+
enum AndroidBitmapFormat {
36+
ANDROID_BITMAP_FORMAT_NONE = 0,
37+
ANDROID_BITMAP_FORMAT_RGBA_8888 = 1,
38+
ANDROID_BITMAP_FORMAT_RGB_565 = 4,
39+
ANDROID_BITMAP_FORMAT_RGBA_4444 = 7,
40+
ANDROID_BITMAP_FORMAT_A_8 = 8,
41+
};
42+
43+
typedef struct {
44+
uint32_t width;
45+
uint32_t height;
46+
uint32_t stride;
47+
int32_t format;
48+
uint32_t flags; // 0 for now
49+
} AndroidBitmapInfo;
50+
51+
/**
52+
* Given a java bitmap object, fill out the AndroidBitmap struct for it.
53+
* If the call fails, the info parameter will be ignored
54+
*/
55+
int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap,
56+
AndroidBitmapInfo* info);
57+
58+
/**
59+
* Given a java bitmap object, attempt to lock the pixel address.
60+
* Locking will ensure that the memory for the pixels will not move
61+
* until the unlockPixels call, and ensure that, if the pixels had been
62+
* previously purged, they will have been restored.
63+
*
64+
* If this call succeeds, it must be balanced by a call to
65+
* AndroidBitmap_unlockPixels, after which time the address of the pixels should
66+
* no longer be used.
67+
*
68+
* If this succeeds, *addrPtr will be set to the pixel address. If the call
69+
* fails, addrPtr will be ignored.
70+
*/
71+
int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr);
72+
73+
/**
74+
* Call this to balanace a successful call to AndroidBitmap_lockPixels
75+
*/
76+
int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap);
77+
78+
#ifdef __cplusplus
79+
}
80+
#endif
81+
82+
#endif

0 commit comments

Comments
 (0)