blob: 5d27966f491a6c5fff1926cd9ffddfd6ff113b63 [file] [log] [blame]
James Dongf3997522011-03-11 12:02:12 -08001/*
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002**
3** Copyright 2007, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
James Dongf3997522011-03-11 12:02:12 -080018//#define LOG_NDEBUG 0
19#define LOG_TAG "MediaScannerJNI"
20#include <utils/Log.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021#include <utils/threads.h>
James Dongf3997522011-03-11 12:02:12 -080022#include <media/mediascanner.h>
23#include <media/stagefright/StagefrightMediaScanner.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024
25#include "jni.h"
26#include "JNIHelp.h"
27#include "android_runtime/AndroidRuntime.h"
28
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029using namespace android;
30
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031
James Dongf3997522011-03-11 12:02:12 -080032static const char* const kClassMediaScannerClient =
33 "android/media/MediaScannerClient";
34
35static const char* const kClassMediaScanner =
36 "android/media/MediaScanner";
37
38static const char* const kRunTimeException =
39 "java/lang/RuntimeException";
40
41static const char* const kIllegalArgumentException =
42 "java/lang/IllegalArgumentException";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043
James Dong133cf8b2011-03-11 15:18:40 -080044struct fields_t {
45 jfieldID context;
46};
47static fields_t fields;
James Dong133cf8b2011-03-11 15:18:40 -080048
Jeff Brown2c70d4a2011-07-20 16:38:43 -070049static status_t checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) {
50 if (env->ExceptionCheck()) {
Steve Blockc6aacce2012-01-06 19:20:56 +000051 ALOGE("An exception was thrown by callback '%s'.", methodName);
Jeff Brown2c70d4a2011-07-20 16:38:43 -070052 LOGE_EX(env);
53 env->ExceptionClear();
54 return UNKNOWN_ERROR;
55 }
56 return OK;
57}
58
Marco Nelissenf51f1bd2011-11-02 10:49:50 -070059// stolen from dalvik/vm/checkJni.cpp
60static bool isValidUtf8(const char* bytes) {
61 while (*bytes != '\0') {
62 unsigned char utf8 = *(bytes++);
63 // Switch on the high four bits.
64 switch (utf8 >> 4) {
65 case 0x00:
66 case 0x01:
67 case 0x02:
68 case 0x03:
69 case 0x04:
70 case 0x05:
71 case 0x06:
72 case 0x07:
73 // Bit pattern 0xxx. No need for any extra bytes.
74 break;
75 case 0x08:
76 case 0x09:
77 case 0x0a:
78 case 0x0b:
79 case 0x0f:
80 /*
81 * Bit pattern 10xx or 1111, which are illegal start bytes.
82 * Note: 1111 is valid for normal UTF-8, but not the
83 * modified UTF-8 used here.
84 */
85 return false;
86 case 0x0e:
87 // Bit pattern 1110, so there are two additional bytes.
88 utf8 = *(bytes++);
89 if ((utf8 & 0xc0) != 0x80) {
90 return false;
91 }
92 // Fall through to take care of the final byte.
93 case 0x0c:
94 case 0x0d:
95 // Bit pattern 110x, so there is one additional byte.
96 utf8 = *(bytes++);
97 if ((utf8 & 0xc0) != 0x80) {
98 return false;
99 }
100 break;
101 }
102 }
103 return true;
104}
105
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106class MyMediaScannerClient : public MediaScannerClient
107{
108public:
109 MyMediaScannerClient(JNIEnv *env, jobject client)
110 : mEnv(env),
111 mClient(env->NewGlobalRef(client)),
112 mScanFileMethodID(0),
113 mHandleStringTagMethodID(0),
114 mSetMimeTypeMethodID(0)
115 {
Steve Block06ade6a2011-10-20 11:56:00 +0100116 ALOGV("MyMediaScannerClient constructor");
James Dongf3997522011-03-11 12:02:12 -0800117 jclass mediaScannerClientInterface =
118 env->FindClass(kClassMediaScannerClient);
119
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800120 if (mediaScannerClientInterface == NULL) {
Steve Blockc6aacce2012-01-06 19:20:56 +0000121 ALOGE("Class %s not found", kClassMediaScannerClient);
James Dongf3997522011-03-11 12:02:12 -0800122 } else {
123 mScanFileMethodID = env->GetMethodID(
124 mediaScannerClientInterface,
125 "scanFile",
Mike Lockwood997354e2011-04-24 11:15:09 -0700126 "(Ljava/lang/String;JJZZ)V");
James Dongf3997522011-03-11 12:02:12 -0800127
128 mHandleStringTagMethodID = env->GetMethodID(
129 mediaScannerClientInterface,
130 "handleStringTag",
131 "(Ljava/lang/String;Ljava/lang/String;)V");
132
133 mSetMimeTypeMethodID = env->GetMethodID(
134 mediaScannerClientInterface,
135 "setMimeType",
136 "(Ljava/lang/String;)V");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800137 }
138 }
James Dongf3997522011-03-11 12:02:12 -0800139
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800140 virtual ~MyMediaScannerClient()
141 {
Steve Block06ade6a2011-10-20 11:56:00 +0100142 ALOGV("MyMediaScannerClient destructor");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800143 mEnv->DeleteGlobalRef(mClient);
144 }
James Dongf3997522011-03-11 12:02:12 -0800145
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700146 virtual status_t scanFile(const char* path, long long lastModified,
Mike Lockwood997354e2011-04-24 11:15:09 -0700147 long long fileSize, bool isDirectory, bool noMedia)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800148 {
Steve Block06ade6a2011-10-20 11:56:00 +0100149 ALOGV("scanFile: path(%s), time(%lld), size(%lld) and isDir(%d)",
James Dongf3997522011-03-11 12:02:12 -0800150 path, lastModified, fileSize, isDirectory);
151
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800152 jstring pathStr;
James Dongf3997522011-03-11 12:02:12 -0800153 if ((pathStr = mEnv->NewStringUTF(path)) == NULL) {
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700154 mEnv->ExceptionClear();
155 return NO_MEMORY;
James Dongf3997522011-03-11 12:02:12 -0800156 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800157
Mike Lockwood076e05b2010-12-16 12:54:24 -0800158 mEnv->CallVoidMethod(mClient, mScanFileMethodID, pathStr, lastModified,
Mike Lockwood997354e2011-04-24 11:15:09 -0700159 fileSize, isDirectory, noMedia);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800160
161 mEnv->DeleteLocalRef(pathStr);
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700162 return checkAndClearExceptionFromCallback(mEnv, "scanFile");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800163 }
164
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700165 virtual status_t handleStringTag(const char* name, const char* value)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800166 {
Steve Block06ade6a2011-10-20 11:56:00 +0100167 ALOGV("handleStringTag: name(%s) and value(%s)", name, value);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800168 jstring nameStr, valueStr;
James Dongf3997522011-03-11 12:02:12 -0800169 if ((nameStr = mEnv->NewStringUTF(name)) == NULL) {
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700170 mEnv->ExceptionClear();
171 return NO_MEMORY;
James Dongf3997522011-03-11 12:02:12 -0800172 }
Marco Nelissenf51f1bd2011-11-02 10:49:50 -0700173 char *cleaned = NULL;
174 if (!isValidUtf8(value)) {
175 cleaned = strdup(value);
176 char *chp = cleaned;
177 char ch;
178 while ((ch = *chp)) {
179 if (ch & 0x80) {
180 *chp = '?';
181 }
182 chp++;
183 }
184 value = cleaned;
185 }
186 valueStr = mEnv->NewStringUTF(value);
187 free(cleaned);
188 if (valueStr == NULL) {
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700189 mEnv->DeleteLocalRef(nameStr);
190 mEnv->ExceptionClear();
191 return NO_MEMORY;
James Dongf3997522011-03-11 12:02:12 -0800192 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193
James Dongf3997522011-03-11 12:02:12 -0800194 mEnv->CallVoidMethod(
195 mClient, mHandleStringTagMethodID, nameStr, valueStr);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800196
197 mEnv->DeleteLocalRef(nameStr);
198 mEnv->DeleteLocalRef(valueStr);
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700199 return checkAndClearExceptionFromCallback(mEnv, "handleStringTag");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800200 }
201
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700202 virtual status_t setMimeType(const char* mimeType)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800203 {
Steve Block06ade6a2011-10-20 11:56:00 +0100204 ALOGV("setMimeType: %s", mimeType);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 jstring mimeTypeStr;
James Dongf3997522011-03-11 12:02:12 -0800206 if ((mimeTypeStr = mEnv->NewStringUTF(mimeType)) == NULL) {
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700207 mEnv->ExceptionClear();
208 return NO_MEMORY;
James Dongf3997522011-03-11 12:02:12 -0800209 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800210
211 mEnv->CallVoidMethod(mClient, mSetMimeTypeMethodID, mimeTypeStr);
212
213 mEnv->DeleteLocalRef(mimeTypeStr);
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700214 return checkAndClearExceptionFromCallback(mEnv, "setMimeType");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800215 }
216
217private:
218 JNIEnv *mEnv;
219 jobject mClient;
James Dongf3997522011-03-11 12:02:12 -0800220 jmethodID mScanFileMethodID;
221 jmethodID mHandleStringTagMethodID;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800222 jmethodID mSetMimeTypeMethodID;
223};
224
225
James Dong133cf8b2011-03-11 15:18:40 -0800226static MediaScanner *getNativeScanner_l(JNIEnv* env, jobject thiz)
227{
228 return (MediaScanner *) env->GetIntField(thiz, fields.context);
229}
230
James Dong133cf8b2011-03-11 15:18:40 -0800231static void setNativeScanner_l(JNIEnv* env, jobject thiz, MediaScanner *s)
232{
233 env->SetIntField(thiz, fields.context, (int)s);
234}
235
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800236static void
James Dongf3997522011-03-11 12:02:12 -0800237android_media_MediaScanner_processDirectory(
238 JNIEnv *env, jobject thiz, jstring path, jobject client)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800239{
Steve Block06ade6a2011-10-20 11:56:00 +0100240 ALOGV("processDirectory");
James Dong133cf8b2011-03-11 15:18:40 -0800241 MediaScanner *mp = getNativeScanner_l(env, thiz);
242 if (mp == NULL) {
243 jniThrowException(env, kRunTimeException, "No scanner available");
244 return;
245 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800246
247 if (path == NULL) {
James Dongf3997522011-03-11 12:02:12 -0800248 jniThrowException(env, kIllegalArgumentException, NULL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800249 return;
250 }
Mike Lockwoodc37255d2010-09-10 14:47:36 -0400251
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800252 const char *pathStr = env->GetStringUTFChars(path, NULL);
253 if (pathStr == NULL) { // Out of memory
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800254 return;
255 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800256
257 MyMediaScannerClient myClient(env, client);
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700258 MediaScanResult result = mp->processDirectory(pathStr, myClient);
259 if (result == MEDIA_SCAN_RESULT_ERROR) {
Steve Blockc6aacce2012-01-06 19:20:56 +0000260 ALOGE("An error occurred while scanning directory '%s'.", pathStr);
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700261 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800262 env->ReleaseStringUTFChars(path, pathStr);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800263}
264
265static void
James Dongf3997522011-03-11 12:02:12 -0800266android_media_MediaScanner_processFile(
267 JNIEnv *env, jobject thiz, jstring path,
268 jstring mimeType, jobject client)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800269{
Steve Block06ade6a2011-10-20 11:56:00 +0100270 ALOGV("processFile");
James Dong133cf8b2011-03-11 15:18:40 -0800271
272 // Lock already hold by processDirectory
273 MediaScanner *mp = getNativeScanner_l(env, thiz);
274 if (mp == NULL) {
275 jniThrowException(env, kRunTimeException, "No scanner available");
276 return;
277 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800278
279 if (path == NULL) {
James Dongf3997522011-03-11 12:02:12 -0800280 jniThrowException(env, kIllegalArgumentException, NULL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800281 return;
282 }
James Dongf3997522011-03-11 12:02:12 -0800283
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800284 const char *pathStr = env->GetStringUTFChars(path, NULL);
285 if (pathStr == NULL) { // Out of memory
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800286 return;
287 }
James Dongf3997522011-03-11 12:02:12 -0800288
289 const char *mimeTypeStr =
290 (mimeType ? env->GetStringUTFChars(mimeType, NULL) : NULL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800291 if (mimeType && mimeTypeStr == NULL) { // Out of memory
James Dongc371a022011-04-06 12:16:07 -0700292 // ReleaseStringUTFChars can be called with an exception pending.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293 env->ReleaseStringUTFChars(path, pathStr);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800294 return;
295 }
296
297 MyMediaScannerClient myClient(env, client);
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700298 MediaScanResult result = mp->processFile(pathStr, mimeTypeStr, myClient);
299 if (result == MEDIA_SCAN_RESULT_ERROR) {
Steve Blockc6aacce2012-01-06 19:20:56 +0000300 ALOGE("An error occurred while scanning file '%s'.", pathStr);
Jeff Brown2c70d4a2011-07-20 16:38:43 -0700301 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800302 env->ReleaseStringUTFChars(path, pathStr);
303 if (mimeType) {
304 env->ReleaseStringUTFChars(mimeType, mimeTypeStr);
305 }
306}
307
308static void
James Dongf3997522011-03-11 12:02:12 -0800309android_media_MediaScanner_setLocale(
310 JNIEnv *env, jobject thiz, jstring locale)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800311{
Steve Block06ade6a2011-10-20 11:56:00 +0100312 ALOGV("setLocale");
James Dong133cf8b2011-03-11 15:18:40 -0800313 MediaScanner *mp = getNativeScanner_l(env, thiz);
314 if (mp == NULL) {
315 jniThrowException(env, kRunTimeException, "No scanner available");
316 return;
317 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800318
319 if (locale == NULL) {
James Dongf3997522011-03-11 12:02:12 -0800320 jniThrowException(env, kIllegalArgumentException, NULL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321 return;
322 }
323 const char *localeStr = env->GetStringUTFChars(locale, NULL);
324 if (localeStr == NULL) { // Out of memory
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800325 return;
326 }
327 mp->setLocale(localeStr);
328
329 env->ReleaseStringUTFChars(locale, localeStr);
330}
331
332static jbyteArray
James Dongf3997522011-03-11 12:02:12 -0800333android_media_MediaScanner_extractAlbumArt(
334 JNIEnv *env, jobject thiz, jobject fileDescriptor)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800335{
Steve Block06ade6a2011-10-20 11:56:00 +0100336 ALOGV("extractAlbumArt");
James Dong133cf8b2011-03-11 15:18:40 -0800337 MediaScanner *mp = getNativeScanner_l(env, thiz);
338 if (mp == NULL) {
339 jniThrowException(env, kRunTimeException, "No scanner available");
340 return NULL;
341 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342
343 if (fileDescriptor == NULL) {
James Dongf3997522011-03-11 12:02:12 -0800344 jniThrowException(env, kIllegalArgumentException, NULL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800345 return NULL;
346 }
347
Elliott Hughesa3804cf2011-04-11 16:50:19 -0700348 int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800349 char* data = mp->extractAlbumArt(fd);
350 if (!data) {
351 return NULL;
352 }
353 long len = *((long*)data);
James Dongf3997522011-03-11 12:02:12 -0800354
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800355 jbyteArray array = env->NewByteArray(len);
356 if (array != NULL) {
357 jbyte* bytes = env->GetByteArrayElements(array, NULL);
358 memcpy(bytes, data + 4, len);
359 env->ReleaseByteArrayElements(array, bytes, 0);
360 }
James Dongf3997522011-03-11 12:02:12 -0800361
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800362done:
363 free(data);
364 // if NewByteArray() returned NULL, an out-of-memory
365 // exception will have been raised. I just want to
366 // return null in that case.
367 env->ExceptionClear();
368 return array;
369}
370
Marco Nelissen4935d052009-08-03 11:12:58 -0700371// This function gets a field ID, which in turn causes class initialization.
372// It is called from a static block in MediaScanner, which won't run until the
373// first time an instance of this class is used.
374static void
375android_media_MediaScanner_native_init(JNIEnv *env)
376{
Steve Block06ade6a2011-10-20 11:56:00 +0100377 ALOGV("native_init");
James Dongf3997522011-03-11 12:02:12 -0800378 jclass clazz = env->FindClass(kClassMediaScanner);
Marco Nelissen4935d052009-08-03 11:12:58 -0700379 if (clazz == NULL) {
Marco Nelissen4935d052009-08-03 11:12:58 -0700380 return;
381 }
382
383 fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
384 if (fields.context == NULL) {
Marco Nelissen4935d052009-08-03 11:12:58 -0700385 return;
386 }
387}
388
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800389static void
390android_media_MediaScanner_native_setup(JNIEnv *env, jobject thiz)
391{
Steve Block06ade6a2011-10-20 11:56:00 +0100392 ALOGV("native_setup");
Andreas Huber8d65dd22010-06-23 16:40:57 -0700393 MediaScanner *mp = new StagefrightMediaScanner;
Andreas Huberbfb9fb12009-12-03 11:31:19 -0800394
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800395 if (mp == NULL) {
James Dongf3997522011-03-11 12:02:12 -0800396 jniThrowException(env, kRunTimeException, "Out of memory");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800397 return;
398 }
399
400 env->SetIntField(thiz, fields.context, (int)mp);
401}
402
403static void
404android_media_MediaScanner_native_finalize(JNIEnv *env, jobject thiz)
405{
Steve Block06ade6a2011-10-20 11:56:00 +0100406 ALOGV("native_finalize");
James Dong133cf8b2011-03-11 15:18:40 -0800407 MediaScanner *mp = getNativeScanner_l(env, thiz);
James Dongf3997522011-03-11 12:02:12 -0800408 if (mp == 0) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800409 return;
James Dongf3997522011-03-11 12:02:12 -0800410 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800411 delete mp;
James Dong133cf8b2011-03-11 15:18:40 -0800412 setNativeScanner_l(env, thiz, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800413}
414
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800415static JNINativeMethod gMethods[] = {
James Dongf3997522011-03-11 12:02:12 -0800416 {
417 "processDirectory",
418 "(Ljava/lang/String;Landroid/media/MediaScannerClient;)V",
419 (void *)android_media_MediaScanner_processDirectory
420 },
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800421
James Dongf3997522011-03-11 12:02:12 -0800422 {
423 "processFile",
424 "(Ljava/lang/String;Ljava/lang/String;Landroid/media/MediaScannerClient;)V",
425 (void *)android_media_MediaScanner_processFile
426 },
427
428 {
429 "setLocale",
430 "(Ljava/lang/String;)V",
431 (void *)android_media_MediaScanner_setLocale
432 },
433
434 {
435 "extractAlbumArt",
436 "(Ljava/io/FileDescriptor;)[B",
437 (void *)android_media_MediaScanner_extractAlbumArt
438 },
439
440 {
441 "native_init",
442 "()V",
443 (void *)android_media_MediaScanner_native_init
444 },
445
446 {
447 "native_setup",
448 "()V",
449 (void *)android_media_MediaScanner_native_setup
450 },
451
452 {
453 "native_finalize",
454 "()V",
455 (void *)android_media_MediaScanner_native_finalize
456 },
457};
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800458
Marco Nelissen4935d052009-08-03 11:12:58 -0700459// This function only registers the native methods, and is called from
460// JNI_OnLoad in android_media_MediaPlayer.cpp
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800461int register_android_media_MediaScanner(JNIEnv *env)
462{
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800463 return AndroidRuntime::registerNativeMethods(env,
James Dongf3997522011-03-11 12:02:12 -0800464 kClassMediaScanner, gMethods, NELEM(gMethods));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800465}