6#include <android/sensor.h>
7#include <android_native_app_glue.h>
11#include "tools/SO3Util.h"
12#include <scolPlugin.h>
16int getAndroidOrientation()
20 struct android_app *androidApp = (
struct android_app *) SCgetExtra(
"this_inst");
25 ANativeActivity *nativeActivity = androidApp->activity;
26 nativeActivity->vm->AttachCurrentThread(&env, NULL);
35 jclass cContext = env->FindClass(
"android/content/Context");
36 jobject oContext = nativeActivity->clazz;
38 jfieldID fidWindowService = env->GetStaticFieldID(cContext,
"WINDOW_SERVICE",
"Ljava/lang/String;");
39 jstring sWindowService = (jstring) env->GetStaticObjectField(cContext, fidWindowService);
41 jclass cWinManager = env->FindClass(
"android/view/WindowManager");
42 jmethodID midgetsys = env->GetMethodID(cContext,
"getSystemService",
"(Ljava/lang/String;)Ljava/lang/Object;");
43 jobject oWindowService = env->CallObjectMethod(oContext, midgetsys, sWindowService);
47 jmethodID midGetDisplay = env->GetMethodID(cWinManager,
"getDefaultDisplay",
"()Landroid/view/Display;");
48 jclass cDisplay = env->FindClass(
"android/view/Display");
49 jobject oDisplay = env->CallObjectMethod(oWindowService, midGetDisplay);
53 jmethodID midgetRot = env->GetMethodID(cDisplay,
"getRotation",
"()I");
54 orient = (int) env->CallIntMethod(oDisplay, midgetRot);
55 env->DeleteLocalRef(oDisplay);
57 env->DeleteLocalRef(cDisplay);
58 env->DeleteLocalRef(oWindowService);
61 env->DeleteLocalRef(cWinManager);
62 env->DeleteLocalRef(sWindowService);
63 env->DeleteLocalRef(cContext);
66 nativeActivity->vm->DetachCurrentThread();
71Vector3d getDeviceOrientationCorrection(DeviceOrientation orientation,
Vector3d vec)
74 if (orientation == ROTATION_90)
80 else if (orientation == ROTATION_180)
86 else if (orientation == ROTATION_270)
102SASensor::SASensor() :
SSensor()
107SASensor::SASensor(SSensorType type) :
SSensor(type)
127ASensor* SASensor::GetASensor()
132void SASensor::SetASensor(ASensor* aSensor)
141 mGravity.x = alpha * mGravity.x + (1 - alpha) * acc.x;
142 mGravity.y = alpha * mGravity.y + (1 - alpha) * acc.y;
143 mGravity.z = alpha * mGravity.z + (1 - alpha) * acc.z;
152 mSensorList = std::set<SSensor*>();
153 mASensorManager = ASensorManager_getInstance();
154 mASensorEventQueue = 0;
155 mScreenOrientation = getAndroidOrientation();
157 ASensorList aSensorList;
159 int nbSensor = ASensorManager_getSensorList(mASensorManager, &aSensorList);
160 MMechostr(MSKDEBUG,
"SSensorManager() : %d sensors has been found", nbSensor);
161 for (
int i = 0; i < nbSensor; i++)
163 const ASensor* aSensor = aSensorList[i];
166 if (aSensor == ASensorManager_getDefaultSensor(mASensorManager,ASensor_getType(aSensor)))
168 switch (ASensor_getType(aSensor))
170 case ASENSOR_TYPE_ACCELEROMETER:
172 MMechostr(MSKDEBUG,
"SSensorManager() : an accelerometer has been found (%d)", i);
173 SASensor* sensor =
new SASensor(SSensorType::SSENSOR_TYPE_ACCELEROMETER);
174 sensor->SetASensor((ASensor*) aSensor);
175 mSensorList.insert(sensor);
178 case ASENSOR_TYPE_MAGNETIC_FIELD:
180 MMechostr(MSKDEBUG,
"SSensorManager() : a magnetometer has been found (%d)", i);
181 SASensor* sensor =
new SASensor(SSensorType::SSENSOR_TYPE_MAGNETIC_FIELD);
182 sensor->SetASensor((ASensor*) aSensor);
183 mSensorList.insert(sensor);
186 case ASENSOR_TYPE_GYROSCOPE:
188 MMechostr(MSKDEBUG,
"SSensorManager() : a gyrometer has been found (%d)", i);
189 SASensor* sensor =
new SASensor(SSensorType::SSENSOR_TYPE_GYROSCOPE);
190 sensor->SetASensor((ASensor*) aSensor);
191 mSensorList.insert(sensor);
194 case ASENSOR_TYPE_LIGHT:
196 MMechostr(MSKDEBUG,
"SSensorManager() : a light sensor has been found (%d)", i);
197 SASensor* sensor =
new SASensor(SSensorType::SSENSOR_TYPE_LIGHT);
198 sensor->SetASensor((ASensor*) aSensor);
199 mSensorList.insert(sensor);
202 case ASENSOR_TYPE_PROXIMITY:
204 MMechostr(MSKDEBUG,
"SSensorManager() : a proximity sensor has been found (%d)", i);
205 SASensor* sensor =
new SASensor(SSensorType::SSENSOR_TYPE_PROXIMITY);
206 sensor->SetASensor((ASensor*) aSensor);
207 mSensorList.insert(sensor);
215 MMechostr(MSKDEBUG,
"SSensorManager() : an unknown sensor has been found (%d)", i);
223 MMechostr(MSKDEBUG,
"SSensorManager() : a secondary (non default) sensor has been found (%d)", i);
228 mThread = boost::thread(boost::bind(&SASensorManager::UpdateThread,
this));
231DeviceOrientation SASensorManager::GetScreenOrientation()
233 return (DeviceOrientation)mScreenOrientation;
236void SASensorManager::UpdateThread()
240 if (mASensorEventQueue == 0)
242 ALooper* looper = ALooper_forThread();
244 looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
247 mASensorEventQueue = ASensorManager_createEventQueue(mASensorManager, looper, ALOOPER_POLL_CALLBACK, SASensorManager::UpdateSensorData,
this);
251 struct android_poll_source* source;
253 ALooper_pollAll(0, NULL, &events, (
void**)&source);
255 boost::this_thread::sleep_for(boost::chrono::milliseconds(5));
258 if (mASensorEventQueue)
260 ASensorManager_destroyEventQueue(mASensorManager, mASensorEventQueue);
261 mASensorEventQueue = 0;
265int SASensorManager::UpdateSensorData(
int fd,
int events,
void* data)
267 boost::upgrade_lock< boost::shared_mutex > lock(mGlobalMutex);
268 SASensorManager* manager = (SASensorManager*)data;
271 while (ASensorEventQueue_getEvents(manager->GetASensorEventQueue(), &event, 1) > 0)
273 std::set<SSensor*> sensorList = manager->GetSensorList();
274 for (std::set<SSensor*>::iterator it = sensorList.begin(); it != sensorList.end(); ++it)
276 SASensor* csensor = (SASensor*)*it;
277 if (ASensor_getType(csensor->GetASensor()) == event.type)
279 if (csensor->IsEnabled())
282 memset(&formatedData, 0,
sizeof(formatedData));
283 formatedData.delta = csensor->GetElapsedTime(event.timestamp);
287 case ASENSOR_TYPE_ACCELEROMETER:
289 Vector3d vec(event.acceleration.x, event.acceleration.y, event.acceleration.z);
290 formatedData.vec3 = getDeviceOrientationCorrection((DeviceOrientation)manager->GetScreenOrientation(), vec);
292 csensor->CallSensorCb(formatedData);
294 if (manager->IsEnabled(SSENSOR_TYPE_ORIENTATION))
298 vec *= ASENSOR_STANDARD_GRAVITY;
299 orientationTracker->processAcceleration(vec, event.timestamp);
304 case ASENSOR_TYPE_GYROSCOPE:
306 Vector3d vec(event.vector.x, event.vector.y, event.vector.z);
307 formatedData.vec3 = getDeviceOrientationCorrection((DeviceOrientation)manager->GetScreenOrientation(), vec);
309 csensor->CallSensorCb(formatedData);
311 if (manager->IsEnabled(SSENSOR_TYPE_ORIENTATION))
315 orientationTracker->processGyro(vec, event.timestamp);
320 case ASENSOR_TYPE_MAGNETIC_FIELD:
322 formatedData.vec3.x =
event.magnetic.x;
323 formatedData.vec3.y =
event.magnetic.y;
324 formatedData.vec3.z =
event.magnetic.z;
326 csensor->CallSensorCb(formatedData);
328 if (manager->IsEnabled(SSENSOR_TYPE_ORIENTATION) && manager->IsEnabled(SSENSOR_TYPE_MAGNETIC_FIELD))
332 orientationTracker->processMag(formatedData.vec3, event.timestamp);
337 case ASENSOR_TYPE_LIGHT:
339 formatedData.fval =
event.light;
341 csensor->CallSensorCb(formatedData);
345 case ASENSOR_TYPE_PROXIMITY:
347 formatedData.fval =
event.distance;
349 csensor->CallSensorCb(formatedData);
360 csensor->SetData(formatedData);
368SASensorManager::~SASensorManager()
373 for (std::set<SSensor*>::iterator it = mSensorList.begin(); it != mSensorList.end(); ++it)
375 SASensor* sensor = (SASensor*) (*it);
379 mSingletonInstance = NULL;
382 struct android_app* androidApp = (
struct android_app*)SCgetExtra(
"this_inst");
383 if (androidApp != NULL)
385 if (androidApp->activity->vm->GetEnv((
void**)&env, JNI_VERSION_1_6) != JNI_EDETACHED)
386 androidApp->activity->vm->DetachCurrentThread();
390ASensorEventQueue* SASensorManager::GetASensorEventQueue()
392 return mASensorEventQueue;
395int SASensorManager::SetSensorEnable(SSensorType sensorType,
bool state)
397 boost::shared_lock< boost::shared_mutex > lock(mGlobalMutex);
400 while (mASensorEventQueue == 0)
401 boost::this_thread::sleep_for(boost::chrono::milliseconds(5));
404 if (sensorType == SSENSOR_TYPE_ORIENTATION && IsAvailable(SSENSOR_TYPE_ORIENTATION))
408 GetOrientationTracker()->startTracking(GetScreenOrientation());
411 GetOrientationTracker()->stopTracking();
415 return SetSensorEnable(SSENSOR_TYPE_ACCELEROMETER, state) + SetSensorEnable(SSENSOR_TYPE_GYROSCOPE, state);
420 SSensor* sensor = GetSensorByType(sensorType);
423 ASensor* aSensor = ((SASensor*) sensor)->GetASensor();
426 sensor->SetEnabled(state);
429 ASensorEventQueue_enableSensor(mASensorEventQueue, aSensor);
430 ASensorEventQueue_setEventRate(mASensorEventQueue, aSensor, (1000L / 200) * 1000);
434 ASensorEventQueue_disableSensor(mASensorEventQueue, aSensor);
452void SASensorManager::Vibrate(
long millis)
454 struct android_app* androidApp = (
struct android_app*)SCgetExtra(
"this_inst");
458 ANativeActivity* nativeActivity = androidApp->activity;
459 if (nativeActivity->vm->GetEnv((
void**)&env, JNI_VERSION_1_6) != JNI_OK)
460 nativeActivity->vm->AttachCurrentThread(&env, NULL);
462 jobject oContext = nativeActivity->clazz;
463 jclass cContext = env->GetObjectClass(oContext);
465 jmethodID fidSystemService = env->GetMethodID(cContext,
"getSystemService",
"(Ljava/lang/String;)Ljava/lang/Object;");
466 jstring svibrator = env->NewStringUTF(
"vibrator");
467 jobject oVibratorService = env->CallObjectMethod(oContext, fidSystemService, svibrator);
469 if (oVibratorService)
471 jclass cVibrator = env->GetObjectClass(oVibratorService);
472 jmethodID midHasVibrator = env->GetMethodID(cVibrator,
"hasVibrator",
"()Z");
475 if (env->ExceptionCheck())
478 env->ExceptionClear();
479 MMechostr(MSKRUNTIME,
"Could not get hasVibrator method");
483 isavaible = (int)env->CallBooleanMethod(oVibratorService, midHasVibrator);
488 jmethodID midVibrate = env->GetMethodID(cVibrator,
"vibrate",
"(J)V");
489 env->CallVoidMethod(oVibratorService, midVibrate, (jlong)millis);
492 env->DeleteLocalRef(svibrator);
493 env->DeleteLocalRef(oVibratorService);
494 env->DeleteLocalRef(cContext);
498void SASensorManager::StartVibration()
500 struct android_app* androidApp = (
struct android_app*)SCgetExtra(
"this_inst");
504 ANativeActivity* nativeActivity = androidApp->activity;
505 if (nativeActivity->vm->GetEnv((
void**)&env, JNI_VERSION_1_6) != JNI_OK)
506 nativeActivity->vm->AttachCurrentThread(&env, NULL);
508 jobject oContext = nativeActivity->clazz;
509 jclass cContext = env->GetObjectClass(oContext);
511 jmethodID fidSystemService = env->GetMethodID(cContext,
"getSystemService",
"(Ljava/lang/String;)Ljava/lang/Object;");
512 jstring svibrator = env->NewStringUTF(
"vibrator");
513 jobject oVibratorService = env->CallObjectMethod(oContext, fidSystemService, svibrator);
515 if (oVibratorService)
517 jclass cVibrator = env->GetObjectClass(oVibratorService);
518 jmethodID midHasVibrator = env->GetMethodID(cVibrator,
"hasVibrator",
"()Z");
521 if (env->ExceptionCheck())
524 env->ExceptionClear();
525 MMechostr(MSKRUNTIME,
"Could not get hasVibrator method");
529 isavaible = (int)env->CallBooleanMethod(oVibratorService, midHasVibrator);
534 jmethodID midVibrate = env->GetMethodID(cVibrator,
"vibrate",
"([JI)V");
536 jlongArray pattern = env->NewLongArray(2);
540 env->SetLongArrayRegion(pattern, 0, 2, t);
543 env->CallVoidMethod(oVibratorService, midVibrate, pattern, 0);
544 env->DeleteLocalRef(pattern);
547 env->DeleteLocalRef(svibrator);
548 env->DeleteLocalRef(oVibratorService);
549 env->DeleteLocalRef(cContext);
553void SASensorManager::VibratePattern(std::vector<int> pattern,
bool loop)
555 struct android_app* androidApp = (
struct android_app*)SCgetExtra(
"this_inst");
559 ANativeActivity* nativeActivity = androidApp->activity;
560 if (nativeActivity->vm->GetEnv((
void**)&env, JNI_VERSION_1_6) != JNI_OK)
561 nativeActivity->vm->AttachCurrentThread(&env, NULL);
563 jobject oContext = nativeActivity->clazz;
564 jclass cContext = env->GetObjectClass(oContext);
566 jmethodID fidSystemService = env->GetMethodID(cContext,
"getSystemService",
"(Ljava/lang/String;)Ljava/lang/Object;");
567 jstring svibrator = env->NewStringUTF(
"vibrator");
568 jobject oVibratorService = env->CallObjectMethod(oContext, fidSystemService, svibrator);
570 if (oVibratorService)
572 jclass cVibrator = env->GetObjectClass(oVibratorService);
573 jmethodID midHasVibrator = env->GetMethodID(cVibrator,
"hasVibrator",
"()Z");
576 if (env->ExceptionCheck())
579 env->ExceptionClear();
580 MMechostr(MSKRUNTIME,
"Could not get hasVibrator method");
584 isavaible = (int)env->CallBooleanMethod(oVibratorService, midHasVibrator);
589 jmethodID midVibrate = env->GetMethodID(cVibrator,
"vibrate",
"([JI)V");
591 jlongArray jpattern = env->NewLongArray(pattern.size());
592 jlong t[pattern.size()];
593 for (
unsigned int i = 0; i < pattern.size(); i++)
594 t[i] = (jlong)pattern[i];
596 env->SetLongArrayRegion(jpattern, 0, pattern.size(), t);
599 jint jloop = (loop ==
true) ? 0 : -1;
600 env->CallVoidMethod(oVibratorService, midVibrate, jpattern, jloop);
601 env->DeleteLocalRef(jpattern);
604 env->DeleteLocalRef(svibrator);
605 env->DeleteLocalRef(oVibratorService);
606 env->DeleteLocalRef(cContext);
611void SASensorManager::StopVibration()
613 struct android_app* androidApp = (
struct android_app*)SCgetExtra(
"this_inst");
617 ANativeActivity* nativeActivity = androidApp->activity;
618 if (nativeActivity->vm->GetEnv((
void**)&env, JNI_VERSION_1_6) != JNI_OK)
619 nativeActivity->vm->AttachCurrentThread(&env, NULL);
621 jobject oContext = nativeActivity->clazz;
622 jclass cContext = env->GetObjectClass(oContext);
624 jmethodID fidSystemService = env->GetMethodID(cContext,
"getSystemService",
"(Ljava/lang/String;)Ljava/lang/Object;");
625 jstring svibrator = env->NewStringUTF(
"vibrator");
626 jobject oVibratorService = env->CallObjectMethod(oContext, fidSystemService, svibrator);
628 if (oVibratorService)
630 jclass cVibrator = env->GetObjectClass(oVibratorService);
631 jmethodID midHasVibrator = env->GetMethodID(cVibrator,
"hasVibrator",
"()Z");
634 if (env->ExceptionCheck())
637 env->ExceptionClear();
638 MMechostr(MSKRUNTIME,
"Could not get hasVibrator method");
642 isavaible = (int)env->CallBooleanMethod(oVibratorService, midHasVibrator);
647 jmethodID midVibrate = env->GetMethodID(cVibrator,
"cancel",
"()V");
648 env->CallVoidMethod(oVibratorService, midVibrate);
651 env->DeleteLocalRef(svibrator);
652 env->DeleteLocalRef(oVibratorService);
653 env->DeleteLocalRef(cContext);
658void SASensorManager::StartLocationService()
660 struct android_app* androidApp = (
struct android_app*)SCgetExtra(
"this_inst");
664 ANativeActivity* nativeActivity = androidApp->activity;
665 if (nativeActivity->vm->GetEnv((
void**)&env, JNI_VERSION_1_6) != JNI_OK)
666 nativeActivity->vm->AttachCurrentThread(&env, NULL);
669 jobject oActivity = nativeActivity->clazz;
670 jclass cActivity = env->GetObjectClass(oActivity);
673 jobject scolexternal_object = 0;
674 jclass scolexternal_clazz = 0;
675 jmethodID jStartLocationService = 0;
677 jfieldID scolexternal_fieldID = env->GetFieldID(cActivity,
"mScolExternal",
"Lorg/imaginer/scol/ScolExternal;");
678 if (scolexternal_fieldID)
679 scolexternal_object = env->GetObjectField(oActivity, scolexternal_fieldID);
680 if (scolexternal_object)
681 scolexternal_clazz = env->GetObjectClass(scolexternal_object);
682 if (scolexternal_clazz)
683 jStartLocationService = env->GetMethodID(scolexternal_clazz,
"startLocationService",
"()V");
685 if (env->ExceptionCheck())
686 env->ExceptionClear();
688 if (!jStartLocationService)
690 env->DeleteLocalRef(scolexternal_clazz);
691 env->DeleteLocalRef(scolexternal_object);
692 env->DeleteLocalRef(cActivity);
695 env->CallVoidMethod(scolexternal_object, jStartLocationService);
698 env->DeleteLocalRef(scolexternal_clazz);
699 env->DeleteLocalRef(scolexternal_object);
701 if (env->ExceptionCheck())
703 env->ExceptionClear();
704 MMechostr(MSKRUNTIME,
"Android location exception : Check android.permission.FINE_LOCATION\n");
707 env->DeleteLocalRef(cActivity);
709 androidApp->activity->vm->DetachCurrentThread();
713void SASensorManager::StopLocationService()
715 struct android_app* androidApp = (
struct android_app*)SCgetExtra(
"this_inst");
719 ANativeActivity* nativeActivity = androidApp->activity;
720 if (nativeActivity->vm->GetEnv((
void**)&env, JNI_VERSION_1_6) != JNI_OK)
721 nativeActivity->vm->AttachCurrentThread(&env, NULL);
724 jobject oActivity = nativeActivity->clazz;
725 jclass cActivity = env->GetObjectClass(oActivity);
728 jobject scolexternal_object = 0;
729 jclass scolexternal_clazz = 0;
730 jmethodID jStopLocationService = 0;
732 jfieldID scolexternal_fieldID = env->GetFieldID(cActivity,
"mScolExternal",
"Lorg/imaginer/scol/ScolExternal;");
733 if (scolexternal_fieldID)
734 scolexternal_object = env->GetObjectField(oActivity, scolexternal_fieldID);
735 if (scolexternal_object)
736 scolexternal_clazz = env->GetObjectClass(scolexternal_object);
737 if (scolexternal_clazz)
738 jStopLocationService = env->GetMethodID(scolexternal_clazz,
"stopLocationService",
"()V");
740 if (env->ExceptionCheck())
741 env->ExceptionClear();
743 if (!jStopLocationService)
745 env->DeleteLocalRef(scolexternal_clazz);
746 env->DeleteLocalRef(scolexternal_object);
747 env->DeleteLocalRef(cActivity);
750 env->CallVoidMethod(scolexternal_object, jStopLocationService);
752 if (env->ExceptionCheck())
754 env->ExceptionClear();
755 MMechostr(MSKRUNTIME,
"Android location exception : Check android.permission.FINE_LOCATION\n");
759 env->DeleteLocalRef(scolexternal_clazz);
760 env->DeleteLocalRef(scolexternal_object);
761 env->DeleteLocalRef(cActivity);
763 androidApp->activity->vm->DetachCurrentThread();
767bool SASensorManager::GetLocation(
float &longitude,
float &latitude,
float &altitude)
773 struct android_app* androidApp = (
struct android_app*)SCgetExtra(
"this_inst");
777 ANativeActivity* nativeActivity = androidApp->activity;
778 if (nativeActivity->vm->GetEnv((
void**)&env, JNI_VERSION_1_6) != JNI_OK)
779 nativeActivity->vm->AttachCurrentThread(&env, NULL);
782 jobject oActivity = nativeActivity->clazz;
783 jclass cActivity = env->GetObjectClass(oActivity);
786 jobject scolexternal_object = 0;
787 jclass scolexternal_clazz = 0;
788 jmethodID jGetLocationLongitude = 0;
789 jmethodID jGetLocationLatitude = 0;
790 jmethodID jGetLocationAltitude = 0;
792 jfieldID scolexternal_fieldID = env->GetFieldID(cActivity,
"mScolExternal",
"Lorg/imaginer/scol/ScolExternal;");
793 if (scolexternal_fieldID)
794 scolexternal_object = env->GetObjectField(oActivity, scolexternal_fieldID);
795 if (scolexternal_object)
796 scolexternal_clazz = env->GetObjectClass(scolexternal_object);
797 if (scolexternal_clazz)
798 jGetLocationLongitude = env->GetMethodID(scolexternal_clazz,
"getLocationLongitude",
"()F");
800 if (env->ExceptionCheck())
801 env->ExceptionClear();
803 if (!jGetLocationLongitude)
805 env->DeleteLocalRef(scolexternal_clazz);
806 env->DeleteLocalRef(scolexternal_object);
807 env->DeleteLocalRef(cActivity);
810 longitude = (float) env->CallFloatMethod(scolexternal_object, jGetLocationLongitude);
812 if (env->ExceptionCheck())
814 env->ExceptionClear();
815 MMechostr(MSKRUNTIME,
"Android location exception : Check android.permission.FINE_LOCATION\n");
817 env->DeleteLocalRef(scolexternal_clazz);
818 env->DeleteLocalRef(scolexternal_object);
819 env->DeleteLocalRef(cActivity);
823 jGetLocationLatitude = env->GetMethodID(scolexternal_clazz,
"getLocationLatitude",
"()F");
825 if (env->ExceptionCheck())
826 env->ExceptionClear();
828 if (!jGetLocationLongitude)
830 env->DeleteLocalRef(scolexternal_clazz);
831 env->DeleteLocalRef(scolexternal_object);
832 env->DeleteLocalRef(cActivity);
835 latitude = (float)env->CallFloatMethod(scolexternal_object, jGetLocationLatitude);
837 if (env->ExceptionCheck())
839 env->ExceptionClear();
840 MMechostr(MSKRUNTIME,
"Android location exception : Check android.permission.FINE_LOCATION\n");
842 env->DeleteLocalRef(scolexternal_clazz);
843 env->DeleteLocalRef(scolexternal_object);
844 env->DeleteLocalRef(cActivity);
848 jGetLocationAltitude = env->GetMethodID(scolexternal_clazz,
"getLocationAltitude",
"()F");
850 if (env->ExceptionCheck())
851 env->ExceptionClear();
853 if (!jGetLocationAltitude)
855 env->DeleteLocalRef(scolexternal_clazz);
856 env->DeleteLocalRef(scolexternal_object);
857 env->DeleteLocalRef(cActivity);
860 altitude = (float)env->CallFloatMethod(scolexternal_object, jGetLocationAltitude);
862 if (env->ExceptionCheck())
864 env->ExceptionClear();
865 MMechostr(MSKRUNTIME,
"Android location exception : Check android.permission.FINE_LOCATION\n");
867 env->DeleteLocalRef(scolexternal_clazz);
868 env->DeleteLocalRef(scolexternal_object);
869 env->DeleteLocalRef(cActivity);
874 env->DeleteLocalRef(scolexternal_clazz);
875 env->DeleteLocalRef(scolexternal_object);
876 env->DeleteLocalRef(cActivity);