summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 14:04:24 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 14:04:24 -0800
commit076357b8567458d4b6dfdcf839ef751634cd2bfb (patch)
treeefbb2fd6f1dc67d2d606382fc3b82983e7cb2e1f /core/jni
parent3dec7d563a2f3e1eb967ce2054a00b6620e3558c (diff)
downloadframeworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.zip
frameworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.tar.gz
frameworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.tar.bz2
auto import from //depot/cupcake/@132589
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_database_SQLiteDatabase.cpp8
-rw-r--r--core/jni/android_hardware_Camera.cpp286
-rw-r--r--core/jni/android_media_AudioTrack.cpp34
-rw-r--r--core/jni/android_os_ParcelFileDescriptor.cpp30
-rw-r--r--core/jni/android_server_BluetoothEventLoop.cpp9
-rw-r--r--core/jni/android_util_Binder.cpp1
-rw-r--r--core/jni/server/com_android_server_AlarmManagerService.cpp7
7 files changed, 143 insertions, 232 deletions
diff --git a/core/jni/android_database_SQLiteDatabase.cpp b/core/jni/android_database_SQLiteDatabase.cpp
index 66858f9..66f0118 100644
--- a/core/jni/android_database_SQLiteDatabase.cpp
+++ b/core/jni/android_database_SQLiteDatabase.cpp
@@ -45,8 +45,6 @@
#define INVALID_VERSION -1
#define SQLITE_SOFT_HEAP_LIMIT (4 * 1024 * 1024)
#define ANDROID_TABLE "android_metadata"
-/* uncomment the next line to force-enable logging of all statements */
-// #define DB_LOG_STATEMENTS
namespace android {
@@ -199,11 +197,7 @@ static void native_execSQL(JNIEnv* env, jobject object, jstring sqlString)
env->ReleaseStringUTFChars(sqlString, sql8);
}
- } else
-#ifndef DB_LOG_STATEMENTS
- IF_LOGV()
-#endif
- {
+ } else IF_LOGV() {
char const * sql8 = env->GetStringUTFChars(sqlString, NULL);
LOGV("Success on %p when executing '%s'\n", handle, sql8);
env->ReleaseStringUTFChars(sqlString, sql8);
diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp
index f6cd211..2f1f9b8 100644
--- a/core/jni/android_hardware_Camera.cpp
+++ b/core/jni/android_hardware_Camera.cpp
@@ -15,9 +15,7 @@
** limitations under the License.
*/
-//#define LOG_NDEBUG 0
#define LOG_TAG "Camera-JNI"
-#include <utils/Log.h>
#include "jni.h"
#include "JNIHelp.h"
@@ -47,43 +45,38 @@ enum CameraError {
struct fields_t {
jfieldID context;
jfieldID surface;
+ jfieldID listener_context;
jmethodID post_event;
};
static fields_t fields;
static Mutex sLock;
+static jclass sCameraClass;
-struct camera_context_t {
- jobject mCameraJObjectWeak; // weak reference to java object
- jclass mCameraJClass; // strong reference to java class
- sp<Camera> mCamera; // strong reference to native object
+struct callback_cookie {
+ jobject camera_ref;
};
-sp<Camera> get_native_camera(JNIEnv *env, jobject thiz, camera_context_t** pContext)
+sp<Camera> get_native_camera(JNIEnv *env, jobject thiz)
{
- sp<Camera> camera;
Mutex::Autolock _l(sLock);
- camera_context_t* context = reinterpret_cast<camera_context_t*>(env->GetIntField(thiz, fields.context));
- if (context != NULL) {
- camera = context->mCamera;
- }
- LOGV("get_native_camera: context=%p, camera=%p", context, camera.get());
- if (camera == 0) {
+ sp<Camera> c = reinterpret_cast<Camera*>(env->GetIntField(thiz, fields.context));
+ if (c == 0)
jniThrowException(env, "java/lang/RuntimeException", "Method called after release()");
- }
- if (pContext != NULL) *pContext = context;
- return camera;
+ return c;
}
static void err_callback(status_t err, void *cookie)
{
- camera_context_t* context = reinterpret_cast<camera_context_t*>(cookie);
- if ((context == NULL) || (context->mCamera == 0)) return;
-
- LOGV("err_callback: context=%p, camera=%p", context, context->mCamera.get());
-
+ JNIEnv *env = AndroidRuntime::getJNIEnv();
+ if (env == NULL) {
+ LOGE("err_callback on dead VM");
+ return;
+ }
+ callback_cookie *c = (callback_cookie *)cookie;
int error;
+
switch (err) {
case DEAD_OBJECT:
error = kCameraErrorMediaServer;
@@ -92,32 +85,29 @@ static void err_callback(status_t err, void *cookie)
error = kCameraErrorUnknown;
break;
}
+ LOGV("err_callback: camera_ref=%x, cookie=%x", (int)c->camera_ref, (int)cookie);
- JNIEnv *env = AndroidRuntime::getJNIEnv();
- if (env == NULL) {
- LOGE("err_callback on dead VM");
- return;
- }
- env->CallStaticVoidMethod(context->mCameraJClass, fields.post_event,
- context->mCameraJObjectWeak, kErrorCallback, error, 0, NULL);
+ env->CallStaticVoidMethod(sCameraClass, fields.post_event,
+ c->camera_ref, kErrorCallback, error, 0, NULL);
}
// connect to camera service
static void android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz, jobject weak_this)
{
- sp<Camera> camera = Camera::connect();
+ sp<Camera> c = Camera::connect();
- if (camera == NULL) {
+ if (c == NULL) {
jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
return;
}
// make sure camera hardware is alive
- if (camera->getStatus() != NO_ERROR) {
+ if (c->getStatus() != NO_ERROR) {
jniThrowException(env, "java/io/IOException", "Camera initialization failed");
return;
}
+ callback_cookie *cookie = new callback_cookie;
jclass clazz = env->GetObjectClass(thiz);
if (clazz == NULL) {
LOGE("Can't find android/hardware/Camera");
@@ -128,84 +118,71 @@ static void android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz, jobj
// We use a weak reference so the Camera object can be garbage collected.
// The reference is only used as a proxy for callbacks.
- camera_context_t* context = new camera_context_t;
- context->mCameraJObjectWeak = env->NewGlobalRef(weak_this);
- context->mCameraJClass = (jclass)env->NewGlobalRef(clazz);
- context->mCamera = camera;
+ cookie->camera_ref = env->NewGlobalRef(weak_this);
+ env->SetIntField(thiz, fields.listener_context, (int)cookie);
+
+ LOGV("native_setup: camera_ref=%x, camera_obj=%x, cookie=%x", (int)cookie->camera_ref, (int)thiz, (int)cookie);
- // save context in opaque field
- env->SetIntField(thiz, fields.context, (int)context);
+ // save camera object in opaque field
+ env->SetIntField(thiz, fields.context, reinterpret_cast<int>(c.get()));
- LOGV("native_setup: mCameraJObjectWeak=%x, camera_obj=%x, context=%p",
- (int)context->mCameraJObjectWeak, (int)thiz, context);
+ c->setErrorCallback(err_callback, cookie);
- // set error callback
- camera->setErrorCallback(err_callback, context);
+ // hold a strong reference so the camera doesn't go away while the app is still running
+ c->incStrong(thiz);
}
// disconnect from camera service
-// It's okay to call this when the native camera context is already null.
-// This handles the case where the user has called release() and the
-// finalizer is invoked later.
static void android_hardware_Camera_release(JNIEnv *env, jobject thiz)
{
- camera_context_t* context = NULL;
- sp<Camera> camera;
- {
- Mutex::Autolock _l(sLock);
- context = reinterpret_cast<camera_context_t*>(env->GetIntField(thiz, fields.context));
-
- // Make sure we do not attempt to callback on a deleted Java object.
+ Mutex::Autolock _l(sLock);
+ sp<Camera> c = reinterpret_cast<Camera*>(env->GetIntField(thiz, fields.context));
+ // It's okay to call this when the native camera context is already null.
+ // This handles the case where the user has called release() and the
+ // finalizer is invoked later.
+ if (c != 0) {
+ // Make sure that we do not attempt to deliver an eror callback on a deleted
+ // Java object.
+ c->setErrorCallback(NULL, NULL);
+ c->disconnect();
+
+ // remove our strong reference created in native setup
+ c->decStrong(thiz);
env->SetIntField(thiz, fields.context, 0);
- }
- // clean up if release has not been called before
- if (context != NULL) {
- camera = context->mCamera;
- context->mCamera.clear();
- LOGV("native_release: context=%p camera=%p", context, camera.get());
-
- // clear callbacks
- if (camera != NULL) {
- camera->setPreviewCallback(NULL, NULL, FRAME_CALLBACK_FLAG_NOOP);
- camera->setErrorCallback(NULL, NULL);
- camera->disconnect();
- env->DeleteGlobalRef(context->mCameraJObjectWeak);
- env->DeleteGlobalRef(context->mCameraJClass);
- }
+ callback_cookie *cookie = (callback_cookie *)env->GetIntField(thiz, fields.listener_context);
+
+ LOGV("release: camera_ref=%x, camera_obj=%x, cookie=%x", (int)cookie->camera_ref, (int)thiz, (int)cookie);
- // remove context to prevent further Java access
- delete context;
+ if (cookie) {
+ env->DeleteGlobalRef(cookie->camera_ref);
+ delete cookie;
+ env->SetIntField(thiz, fields.listener_context, 0);
+ }
}
}
-static void android_hardware_Camera_setPreviewDisplay(JNIEnv *env, jobject thiz, jobject jSurface)
+static void android_hardware_Camera_setPreviewDisplay(JNIEnv *env, jobject thiz, jobject surface)
{
- LOGV("setPreviewDisplay");
- sp<Camera> camera = get_native_camera(env, thiz, NULL);
- if (camera == 0) return;
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return;
- sp<Surface> surface = reinterpret_cast<Surface*>(env->GetIntField(jSurface, fields.surface));
- if (camera->setPreviewDisplay(surface) != NO_ERROR) {
+ sp<Surface> s = (Surface *)env->GetIntField(surface, fields.surface);
+ if (c->setPreviewDisplay(s) != NO_ERROR) {
jniThrowException(env, "java/io/IOException", "setPreviewDisplay failed");
+ return;
}
}
static void preview_callback(const sp<IMemory>& mem, void *cookie)
{
- LOGV("preview_callback");
JNIEnv *env = AndroidRuntime::getJNIEnv();
if (env == NULL) {
LOGE("preview_callback on dead VM");
return;
}
- camera_context_t* context = reinterpret_cast<camera_context_t*>(cookie);
- if ((context == NULL) || (context->mCamera == 0)) {
- LOGW("context or camera is NULL in preview_callback");
- return;
- }
- LOGV("native_release: context=%p camera=%p", context, context->mCamera.get());
-
+ callback_cookie *c = (callback_cookie *)cookie;
int arg1 = 0, arg2 = 0;
jobject obj = NULL;
@@ -228,18 +205,18 @@ static void preview_callback(const sp<IMemory>& mem, void *cookie)
obj = array;
- env->CallStaticVoidMethod(context->mCameraJClass, fields.post_event,
- context->mCameraJObjectWeak, kPreviewCallback, arg1, arg2, obj);
+ env->CallStaticVoidMethod(sCameraClass, fields.post_event,
+ c->camera_ref, kPreviewCallback, arg1, arg2, obj);
env->DeleteLocalRef(array);
}
static void android_hardware_Camera_startPreview(JNIEnv *env, jobject thiz)
{
- LOGV("startPreview");
- sp<Camera> camera = get_native_camera(env, thiz, NULL);
- if (camera == 0) return;
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return;
- if (camera->startPreview() != NO_ERROR) {
+ if (c->startPreview() != NO_ERROR) {
jniThrowException(env, "java/io/IOException", "startPreview failed");
return;
}
@@ -247,30 +224,32 @@ static void android_hardware_Camera_startPreview(JNIEnv *env, jobject thiz)
static void android_hardware_Camera_stopPreview(JNIEnv *env, jobject thiz)
{
- LOGV("stopPreview");
- sp<Camera> c = get_native_camera(env, thiz, NULL);
- if (c == 0) return;
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return;
c->stopPreview();
}
static bool android_hardware_Camera_previewEnabled(JNIEnv *env, jobject thiz)
{
- LOGV("previewEnabled");
- sp<Camera> c = get_native_camera(env, thiz, NULL);
- if (c == 0) return false;
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return false;
return c->previewEnabled();
}
static void android_hardware_Camera_setHasPreviewCallback(JNIEnv *env, jobject thiz, jboolean installed, jboolean oneshot)
{
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return;
+
// Important: Only install preview_callback if the Java code has called
// setPreviewCallback() with a non-null value, otherwise we'd pay to memcpy
// each preview frame for nothing.
- camera_context_t* context;
- sp<Camera> camera = get_native_camera(env, thiz, &context);
- if (camera == 0) return;
+ callback_cookie *cookie = (callback_cookie *)env->GetIntField(thiz, fields.listener_context);
int callback_flag;
if (installed) {
@@ -278,31 +257,29 @@ static void android_hardware_Camera_setHasPreviewCallback(JNIEnv *env, jobject t
} else {
callback_flag = FRAME_CALLBACK_FLAG_NOOP;
}
- camera->setPreviewCallback(installed ? preview_callback : NULL, context, callback_flag);
+ c->setPreviewCallback(installed ? preview_callback : NULL, cookie, callback_flag);
}
static void autofocus_callback_impl(bool success, void *cookie)
{
- LOGV("autoFocusCallback");
- camera_context_t* context = reinterpret_cast<camera_context_t*>(cookie);
-
JNIEnv *env = AndroidRuntime::getJNIEnv();
if (env == NULL) {
LOGE("autofocus_callback on dead VM");
return;
}
- env->CallStaticVoidMethod(context->mCameraJClass, fields.post_event,
- context->mCameraJObjectWeak, kAutoFocusCallback, success, 0, NULL);
+ callback_cookie *c = (callback_cookie *)cookie;
+ env->CallStaticVoidMethod(sCameraClass, fields.post_event,
+ c->camera_ref, kAutoFocusCallback,
+ success, 0, NULL);
}
static void android_hardware_Camera_autoFocus(JNIEnv *env, jobject thiz)
{
- LOGV("autoFocus");
- camera_context_t* context;
- sp<Camera> c = get_native_camera(env, thiz, &context);
- if (c == 0) return;
-
- c->setAutoFocusCallback(autofocus_callback_impl, context);
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return;
+ callback_cookie *cookie = (callback_cookie *)env->GetIntField(thiz, fields.listener_context);
+ c->setAutoFocusCallback(autofocus_callback_impl, cookie);
if (c->autoFocus() != NO_ERROR) {
jniThrowException(env, "java/io/IOException", "autoFocus failed");
}
@@ -310,20 +287,18 @@ static void android_hardware_Camera_autoFocus(JNIEnv *env, jobject thiz)
static void jpeg_callback(const sp<IMemory>& mem, void *cookie)
{
- LOGV("jpegCallback");
- camera_context_t* context = reinterpret_cast<camera_context_t*>(cookie);
-
JNIEnv *env = AndroidRuntime::getJNIEnv();
if (env == NULL) {
LOGE("jpeg`_callback on dead VM");
return;
}
+ callback_cookie *c = (callback_cookie *)cookie;
int arg1 = 0, arg2 = 0;
jobject obj = NULL;
if (mem == NULL) {
- env->CallStaticVoidMethod(context->mCameraJClass, fields.post_event,
- context->mCameraJObjectWeak, kJpegCallback, arg1, arg2, NULL);
+ env->CallStaticVoidMethod(sCameraClass, fields.post_event,
+ c->camera_ref, kJpegCallback, arg1, arg2, NULL);
return;
}
ssize_t offset;
@@ -352,51 +327,48 @@ static void jpeg_callback(const sp<IMemory>& mem, void *cookie)
obj = array;
- env->CallStaticVoidMethod(context->mCameraJClass, fields.post_event,
- context->mCameraJObjectWeak, kJpegCallback, arg1, arg2, obj);
+ env->CallStaticVoidMethod(sCameraClass, fields.post_event,
+ c->camera_ref, kJpegCallback, arg1, arg2, obj);
env->DeleteLocalRef(array);
}
static void shutter_callback_impl(void *cookie)
{
- LOGV("shutterCallback");
- camera_context_t* context = reinterpret_cast<camera_context_t*>(cookie);
-
JNIEnv *env = AndroidRuntime::getJNIEnv();
if (env == NULL) {
LOGE("shutter_callback on dead VM");
return;
}
- env->CallStaticVoidMethod(context->mCameraJClass, fields.post_event,
- context->mCameraJObjectWeak, kShutterCallback, 0, 0, NULL);
+ callback_cookie *c = (callback_cookie *)cookie;
+ env->CallStaticVoidMethod(sCameraClass, fields.post_event,
+ c->camera_ref, kShutterCallback, 0, 0, NULL);
}
static void raw_callback(const sp<IMemory>& mem __attribute__((unused)),
void *cookie)
{
- LOGV("rawCallback");
- camera_context_t* context = reinterpret_cast<camera_context_t*>(cookie);
-
JNIEnv *env = AndroidRuntime::getJNIEnv();
if (env == NULL) {
LOGE("raw_callback on dead VM");
return;
}
- env->CallStaticVoidMethod(context->mCameraJClass, fields.post_event,
- context->mCameraJObjectWeak, kRawCallback, 0, 0, NULL);
+ callback_cookie *c = (callback_cookie *)cookie;
+ env->CallStaticVoidMethod(sCameraClass, fields.post_event,
+ c->camera_ref, kRawCallback, 0, 0, NULL);
}
static void android_hardware_Camera_takePicture(JNIEnv *env, jobject thiz)
{
- LOGV("takePicture");
- camera_context_t* context;
- sp<Camera> camera = get_native_camera(env, thiz, &context);
- if (camera == 0) return;
-
- camera->setShutterCallback(shutter_callback_impl, context);
- camera->setRawCallback(raw_callback, context);
- camera->setJpegCallback(jpeg_callback, context);
- if (camera->takePicture() != NO_ERROR) {
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return;
+
+ callback_cookie *cookie =
+ (callback_cookie *)env->GetIntField(thiz, fields.listener_context);
+ c->setShutterCallback(shutter_callback_impl, cookie);
+ c->setRawCallback(raw_callback, cookie);
+ c->setJpegCallback(jpeg_callback, cookie);
+ if (c->takePicture() != NO_ERROR) {
jniThrowException(env, "java/io/IOException", "takePicture failed");
return;
}
@@ -406,9 +378,9 @@ static void android_hardware_Camera_takePicture(JNIEnv *env, jobject thiz)
static void android_hardware_Camera_setParameters(JNIEnv *env, jobject thiz, jstring params)
{
- LOGV("setParameters");
- sp<Camera> camera = get_native_camera(env, thiz, NULL);
- if (camera == 0) return;
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return;
const jchar* str = env->GetStringCritical(params, 0);
String8 params8;
@@ -416,7 +388,7 @@ static void android_hardware_Camera_setParameters(JNIEnv *env, jobject thiz, jst
params8 = String8(str, env->GetStringLength(params));
env->ReleaseStringCritical(params, str);
}
- if (camera->setParameters(params8) != NO_ERROR) {
+ if (c->setParameters(params8) != NO_ERROR) {
jniThrowException(env, "java/lang/IllegalArgumentException", "setParameters failed");
return;
}
@@ -424,20 +396,20 @@ static void android_hardware_Camera_setParameters(JNIEnv *env, jobject thiz, jst
static jstring android_hardware_Camera_getParameters(JNIEnv *env, jobject thiz)
{
- LOGV("getParameters");
- sp<Camera> camera = get_native_camera(env, thiz, NULL);
- if (camera == 0) return 0;
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return 0;
- return env->NewStringUTF(camera->getParameters().string());
+ return env->NewStringUTF(c->getParameters().string());
}
static void android_hardware_Camera_reconnect(JNIEnv *env, jobject thiz)
{
- LOGV("reconnect");
- sp<Camera> camera = get_native_camera(env, thiz, NULL);
- if (camera == 0) return;
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return;
- if (camera->reconnect() != NO_ERROR) {
+ if (c->reconnect() != NO_ERROR) {
jniThrowException(env, "java/io/IOException", "reconnect failed");
return;
}
@@ -445,18 +417,18 @@ static void android_hardware_Camera_reconnect(JNIEnv *env, jobject thiz)
static jint android_hardware_Camera_lock(JNIEnv *env, jobject thiz)
{
- LOGV("lock");
- sp<Camera> camera = get_native_camera(env, thiz, NULL);
- if (camera == 0) return INVALID_OPERATION;
- return (jint) camera->lock();
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return INVALID_OPERATION;
+ return (jint) c->lock();
}
static jint android_hardware_Camera_unlock(JNIEnv *env, jobject thiz)
{
- LOGV("unlock");
- sp<Camera> camera = get_native_camera(env, thiz, NULL);
- if (camera == 0) return INVALID_OPERATION;
- return (jint) camera->unlock();
+ sp<Camera> c = get_native_camera(env, thiz);
+ if (c == 0)
+ return INVALID_OPERATION;
+ return (jint) c->unlock();
}
//-------------------------------------------------
@@ -540,6 +512,7 @@ int register_android_hardware_Camera(JNIEnv *env)
{
field fields_to_find[] = {
{ "android/hardware/Camera", "mNativeContext", "I", &fields.context },
+ { "android/hardware/Camera", "mListenerContext", "I", &fields.listener_context },
{ "android/view/Surface", "mSurface", "I", &fields.surface }
};
@@ -547,6 +520,7 @@ int register_android_hardware_Camera(JNIEnv *env)
return -1;
jclass clazz = env->FindClass("android/hardware/Camera");
+ sCameraClass = (jclass)env->NewGlobalRef(clazz);
fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative",
"(Ljava/lang/Object;IIILjava/lang/Object;)V");
if (fields.post_event == NULL) {
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index f625ffb..d9effee 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -688,33 +688,15 @@ static jint android_media_AudioTrack_reload(JNIEnv *env, jobject thiz) {
// ----------------------------------------------------------------------------
-static jint android_media_AudioTrack_get_output_sample_rate(JNIEnv *env, jobject thiz,
- jint javaStreamType) {
- int afSamplingRate;
- // convert the stream type from Java to native value
- // FIXME: code duplication with android_media_AudioTrack_native_setup()
- AudioSystem::stream_type nativeStreamType;
- if (javaStreamType == javaAudioTrackFields.STREAM_VOICE_CALL) {
- nativeStreamType = AudioSystem::VOICE_CALL;
- } else if (javaStreamType == javaAudioTrackFields.STREAM_SYSTEM) {
- nativeStreamType = AudioSystem::SYSTEM;
- } else if (javaStreamType == javaAudioTrackFields.STREAM_RING) {
- nativeStreamType = AudioSystem::RING;
- } else if (javaStreamType == javaAudioTrackFields.STREAM_MUSIC) {
- nativeStreamType = AudioSystem::MUSIC;
- } else if (javaStreamType == javaAudioTrackFields.STREAM_ALARM) {
- nativeStreamType = AudioSystem::ALARM;
- } else if (javaStreamType == javaAudioTrackFields.STREAM_NOTIFICATION) {
- nativeStreamType = AudioSystem::NOTIFICATION;
- } else if (javaStreamType == javaAudioTrackFields.STREAM_BLUETOOTH_SCO) {
- nativeStreamType = AudioSystem::BLUETOOTH_SCO;
- } else {
- nativeStreamType = AudioSystem::DEFAULT;
+static jint android_media_AudioTrack_get_output_sample_rate(JNIEnv *env, jobject thiz) {
+ int afSamplingRate;
+ AudioTrackJniStorage* lpJniStorage = (AudioTrackJniStorage *)env->GetIntField(
+ thiz, javaAudioTrackFields.jniData);
+ if (lpJniStorage == NULL) {
+ return DEFAULT_OUTPUT_SAMPLE_RATE;
}
- if (AudioSystem::getOutputSamplingRate(&afSamplingRate, nativeStreamType) != NO_ERROR) {
- LOGE("AudioSystem::getOutputSamplingRate() for stream type %d failed in AudioTrack JNI",
- nativeStreamType);
+ if (AudioSystem::getOutputSamplingRate(&afSamplingRate, lpJniStorage->mStreamType) != NO_ERROR) {
return DEFAULT_OUTPUT_SAMPLE_RATE;
} else {
return afSamplingRate;
@@ -784,7 +766,7 @@ static JNINativeMethod gMethods[] = {
{"native_set_loop", "(III)I", (void *)android_media_AudioTrack_set_loop},
{"native_reload_static", "()I", (void *)android_media_AudioTrack_reload},
{"native_get_output_sample_rate",
- "(I)I", (void *)android_media_AudioTrack_get_output_sample_rate},
+ "()I", (void *)android_media_AudioTrack_get_output_sample_rate},
{"native_get_min_buff_size",
"(III)I", (void *)android_media_AudioTrack_get_min_buff_size},
};
diff --git a/core/jni/android_os_ParcelFileDescriptor.cpp b/core/jni/android_os_ParcelFileDescriptor.cpp
index 1429f58..465e233 100644
--- a/core/jni/android_os_ParcelFileDescriptor.cpp
+++ b/core/jni/android_os_ParcelFileDescriptor.cpp
@@ -60,37 +60,9 @@ static jobject android_os_ParcelFileDescriptor_getFileDescriptorFromSocket(JNIEn
return fileDescriptorClone;
}
-static jlong android_os_ParcelFileDescriptor_getStatSize(JNIEnv* env,
- jobject clazz)
-{
- jint fd = env->GetIntField(clazz, gFileDescriptorOffsets.mDescriptor);
-
- struct stat st;
- if (fstat(fd, &st) != 0) {
- return -1;
- }
-
- if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
- return st.st_size;
- }
-
- return -1;
-}
-
-static jlong android_os_ParcelFileDescriptor_seekTo(JNIEnv* env,
- jobject clazz, jlong pos)
-{
- jint fd = env->GetIntField(clazz, gFileDescriptorOffsets.mDescriptor);
- return lseek(fd, pos, SEEK_SET);
-}
-
static const JNINativeMethod gParcelFileDescriptorMethods[] = {
{"getFileDescriptorFromSocket", "(Ljava/net/Socket;)Ljava/io/FileDescriptor;",
- (void*)android_os_ParcelFileDescriptor_getFileDescriptorFromSocket},
- {"getStatSize", "()J",
- (void*)android_os_ParcelFileDescriptor_getStatSize},
- {"seekTo", "(J)J",
- (void*)android_os_ParcelFileDescriptor_seekTo}
+ (void*)android_os_ParcelFileDescriptor_getFileDescriptorFromSocket}
};
const char* const kParcelFileDescriptorPathName = "android/os/ParcelFileDescriptor";
diff --git a/core/jni/android_server_BluetoothEventLoop.cpp b/core/jni/android_server_BluetoothEventLoop.cpp
index adfd912..9100e81 100644
--- a/core/jni/android_server_BluetoothEventLoop.cpp
+++ b/core/jni/android_server_BluetoothEventLoop.cpp
@@ -721,7 +721,6 @@ static jboolean waitForAndDispatchEventNative(JNIEnv *env, jobject object,
#define BOND_RESULT_AUTH_REJECTED 2
#define BOND_RESULT_AUTH_CANCELED 3
#define BOND_RESULT_REMOTE_DEVICE_DOWN 4
-#define BOND_RESULT_DISCOVERY_IN_PROGRESS 5
void onCreateBondingResult(DBusMessage *msg, void *user) {
LOGV(__FUNCTION__);
@@ -756,14 +755,10 @@ void onCreateBondingResult(DBusMessage *msg, void *user) {
// already bonded
LOGV("... error = %s (%s)\n", err.name, err.message);
result = BOND_RESULT_SUCCESS;
- } else if (!strcmp(err.name, BLUEZ_DBUS_BASE_IFC ".Error.InProgress") &&
- !strcmp(err.message, "Bonding in progress")) {
+ } else if (!strcmp(err.name, BLUEZ_DBUS_BASE_IFC ".Error.InProgress")) {
+ // don't make the java callback
LOGV("... error = %s (%s)\n", err.name, err.message);
goto done;
- } else if (!strcmp(err.name, BLUEZ_DBUS_BASE_IFC ".Error.InProgress") &&
- !strcmp(err.message, "Discover in progress")) {
- LOGV("... error = %s (%s)\n", err.name, err.message);
- result = BOND_RESULT_DISCOVERY_IN_PROGRESS;
} else {
LOGE("%s: D-Bus error: %s (%s)\n", __FUNCTION__, err.name, err.message);
result = BOND_RESULT_ERROR;
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index 7325432..24404a8 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -1223,7 +1223,6 @@ static jobject android_os_Parcel_openFileDescriptor(JNIEnv* env, jobject clazz,
if (mode&0x08000000) flags |= O_CREAT;
if (mode&0x04000000) flags |= O_TRUNC;
- if (mode&0x02000000) flags |= O_APPEND;
int realMode = S_IRWXU|S_IRWXG;
if (mode&0x00000001) realMode |= S_IROTH;
diff --git a/core/jni/server/com_android_server_AlarmManagerService.cpp b/core/jni/server/com_android_server_AlarmManagerService.cpp
index 1d66fb1..0f37921 100644
--- a/core/jni/server/com_android_server_AlarmManagerService.cpp
+++ b/core/jni/server/com_android_server_AlarmManagerService.cpp
@@ -52,17 +52,12 @@ static jint android_server_AlarmManagerService_setKernelTimezone(JNIEnv* env, jo
tz.tz_minuteswest = minswest;
tz.tz_dsttime = 0;
- int result = settimeofday(NULL, &tz);
+ int result = ioctl(fd, ANDROID_ALARM_SET_TIMEZONE, &tz);
if (result < 0) {
LOGE("Unable to set kernel timezone to %d: %s\n", minswest, strerror(errno));
return -1;
- } else {
- LOGD("Kernel timezone updated to %d minutes west of GMT\n", minswest);
}
-
return 0;
-#else
- return -ENOSYS;
#endif
}