… | |
… | |
36 | #include "types.h" |
36 | #include "types.h" |
37 | #include "search.h" |
37 | #include "search.h" |
38 | #include "start_real.h" |
38 | #include "start_real.h" |
39 | #include "route.h" |
39 | #include "route.h" |
40 | #include "file.h" |
40 | #include "file.h" |
|
|
41 | #include "navit_nls.h" |
41 | |
42 | |
42 | // #include "layout.h" |
43 | // #include "layout.h" |
43 | |
44 | |
44 | JNIEnv *jnienv; |
45 | JNIEnv *jnienv; |
45 | jobject *android_activity; |
46 | jobject *android_activity; |
… | |
… | |
402 | //DBG // dbg(0,"l meth %p\n", *ret); |
403 | //DBG // dbg(0,"l meth %p\n", *ret); |
403 | return 1; |
404 | return 1; |
404 | } |
405 | } |
405 | |
406 | |
406 | JNIEXPORT void JNICALL |
407 | JNIEXPORT void JNICALL |
407 | Java_com_zoffcc_applications_zanavi_Navit_NavitMain(JNIEnv* env, jobject thiz, jobject activity, jobject lang, int version, jobject display_density_string) |
408 | Java_com_zoffcc_applications_zanavi_Navit_NavitMain(JNIEnv* env, jobject thiz, jobject activity, jobject lang, int version, jobject display_density_string, jobject n_datadir, jobject n_sharedir) |
408 | { |
409 | { |
409 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
410 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
410 | // dbg(0,"+#+:enter\n"); |
411 | // dbg(0,"+#+:enter\n"); |
411 | #endif |
412 | #endif |
412 | |
413 | |
413 | #ifdef DEBUG_GLIB_MEM_FUNCTIONS |
414 | #ifdef DEBUG_GLIB_MEM_FUNCTIONS |
414 | // GLIB debugging |
415 | // GLIB debugging |
415 | // GLIB debugging |
416 | // GLIB debugging |
416 | // GLIB debugging |
417 | // GLIB debugging |
|
|
418 | /* |
417 | dbg(0,"GLIB debugging ----------------------"); |
419 | dbg(0,"GLIB debugging ----------------------"); |
418 | dbg(0,"GLIB debugging ----------------------"); |
420 | dbg(0,"GLIB debugging ----------------------"); |
419 | dbg(0,"GLIB debugging ----------------------"); |
421 | dbg(0,"GLIB debugging ----------------------"); |
420 | dbg(0,"GLIB debugging ----------------------"); |
422 | dbg(0,"GLIB debugging ----------------------"); |
421 | dbg(0,"GLIB debugging ----------------------"); |
423 | dbg(0,"GLIB debugging ----------------------"); |
422 | dbg(0,"GLIB debugging ----------------------"); |
424 | dbg(0,"GLIB debugging ----------------------"); |
423 | dbg(0,"GLIB debugging ----------------------"); |
425 | dbg(0,"GLIB debugging ----------------------"); |
424 | dbg(0,"GLIB debugging ----------------------"); |
426 | dbg(0,"GLIB debugging ----------------------"); |
425 | dbg(0,"GLIB debugging 1 --------------------"); |
427 | dbg(0,"GLIB debugging 1 --------------------"); |
|
|
428 | */ |
426 | g_mem_set_vtable(glib_mem_profiler_table); |
429 | //*******???******** g_mem_set_vtable(glib_mem_profiler_table); |
427 | //char *dummy_997; |
430 | //char *dummy_997; |
428 | //dummy_997 = g_malloc(1024*1024*10); // 10 MByte |
431 | //dummy_997 = g_malloc(1024*1024*10); // 10 MByte |
429 | //g_free(dummy_997); |
432 | //g_free(dummy_997); |
430 | //dummy_997 = NULL; |
433 | //dummy_997 = NULL; |
431 | //g_mem_profile(); |
434 | //g_mem_profile(); |
|
|
435 | /* |
432 | dbg(0,"GLIB debugging 2 --------------------"); |
436 | dbg(0,"GLIB debugging 2 --------------------"); |
433 | dbg(0,"GLIB debugging ----------------------"); |
437 | dbg(0,"GLIB debugging ----------------------"); |
434 | dbg(0,"GLIB debugging ----------------------"); |
438 | dbg(0,"GLIB debugging ----------------------"); |
435 | dbg(0,"GLIB debugging ----------------------"); |
439 | dbg(0,"GLIB debugging ----------------------"); |
436 | dbg(0,"GLIB debugging ----------------------"); |
440 | dbg(0,"GLIB debugging ----------------------"); |
437 | dbg(0,"GLIB debugging ----------------------"); |
441 | dbg(0,"GLIB debugging ----------------------"); |
438 | dbg(0,"GLIB debugging ----------------------"); |
442 | dbg(0,"GLIB debugging ----------------------"); |
439 | dbg(0,"GLIB debugging ----------------------"); |
443 | dbg(0,"GLIB debugging ----------------------"); |
440 | dbg(0,"GLIB debugging ----------------------"); |
444 | dbg(0,"GLIB debugging ----------------------"); |
|
|
445 | */ |
441 | // GLIB debugging |
446 | // GLIB debugging |
442 | // GLIB debugging |
447 | // GLIB debugging |
443 | // GLIB debugging |
448 | // GLIB debugging |
444 | #endif |
449 | #endif |
445 | |
450 | |
… | |
… | |
447 | // dbg(0, "THREAD ID=%d\n", thread_id); |
452 | // dbg(0, "THREAD ID=%d\n", thread_id); |
448 | |
453 | |
449 | char *strings[] = { "/data/data/com.zoffcc.applications.zanavi/bin/navit", NULL }; |
454 | char *strings[] = { "/data/data/com.zoffcc.applications.zanavi/bin/navit", NULL }; |
450 | const char *langstr; |
455 | const char *langstr; |
451 | const char *displaydensitystr; |
456 | const char *displaydensitystr; |
|
|
457 | const char *s; |
452 | android_version = version; |
458 | android_version = version; |
453 | //__android_log_print(ANDROID_LOG_ERROR,"test","called"); |
459 | //__android_log_print(ANDROID_LOG_ERROR,"test","called"); |
454 | android_activity_cbl = callback_list_new(); |
460 | android_activity_cbl = callback_list_new(); |
455 | |
461 | |
456 | // SET GLOBAL JNIENV here, this is bad!! |
462 | // SET GLOBAL JNIENV here, this is bad!! |
… | |
… | |
473 | //DBG // dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, activity, langstr, version); |
479 | //DBG // dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, activity, langstr, version); |
474 | //DBG // dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, android_activity, langstr, version); |
480 | //DBG // dbg(0, "enter env=%p thiz=%p activity=%p lang=%s version=%d\n", env, thiz, android_activity, langstr, version); |
475 | setenv("LANG", langstr, 1); |
481 | setenv("LANG", langstr, 1); |
476 | (*env)->ReleaseStringUTFChars(env, lang, langstr); |
482 | (*env)->ReleaseStringUTFChars(env, lang, langstr); |
477 | |
483 | |
|
|
484 | s = (*env)->GetStringUTFChars(env, n_datadir, NULL); |
|
|
485 | navit_data_dir = g_strdup(s); |
|
|
486 | (*env)->ReleaseStringUTFChars(env, n_datadir, s); |
|
|
487 | |
|
|
488 | s = (*env)->GetStringUTFChars(env, n_sharedir, NULL); |
|
|
489 | navit_share_dir = g_strdup(s); |
|
|
490 | (*env)->ReleaseStringUTFChars(env, n_sharedir, s); |
|
|
491 | |
|
|
492 | |
478 | displaydensitystr = (*env)->GetStringUTFChars(env, display_density_string, NULL); |
493 | displaydensitystr = (*env)->GetStringUTFChars(env, display_density_string, NULL); |
479 | //DBG // dbg(0, "*****displaydensity=%s\n", displaydensitystr); |
494 | dbg(0, "*****displaydensity=%s\n", displaydensitystr); |
480 | setenv("ANDROID_DENSITY", displaydensitystr, 1); |
495 | setenv("ANDROID_DENSITY", displaydensitystr, 1); |
|
|
496 | |
|
|
497 | // calc DPI value |
|
|
498 | global_have_dpi_value = atoi(displaydensitystr); |
|
|
499 | dbg(0, "*****displaydensity int=%d\n", (int) global_have_dpi_value); |
|
|
500 | |
|
|
501 | if (global_have_dpi_value >= 320) |
|
|
502 | { |
|
|
503 | global_dpi_factor = (float) global_have_dpi_value / 240.0f; // multiply with this factor where needed! |
|
|
504 | } |
|
|
505 | else |
|
|
506 | { |
|
|
507 | global_dpi_factor = 1.0f; |
|
|
508 | } |
|
|
509 | |
481 | (*env)->ReleaseStringUTFChars(env, display_density_string, displaydensitystr); |
510 | (*env)->ReleaseStringUTFChars(env, display_density_string, displaydensitystr); |
482 | |
511 | |
483 | //// dbg(0,"before main_real call\n"); |
512 | //// dbg(0,"before main_real call\n"); |
484 | //main_real(1, strings); |
513 | //main_real(1, strings); |
485 | //// dbg(0,"after main_real call\n"); |
514 | //// dbg(0,"after main_real call\n"); |
… | |
… | |
600 | // dbg(0,"+#+:leave\n"); |
629 | // dbg(0,"+#+:leave\n"); |
601 | #endif |
630 | #endif |
602 | } |
631 | } |
603 | |
632 | |
604 | JNIEXPORT void JNICALL |
633 | JNIEXPORT void JNICALL |
605 | Java_com_zoffcc_applications_zanavi_NavitGraphics_MotionCallbackReal(JNIEnv* env, jobject thiz, int x1, int y1, int x2, int y2) |
634 | Java_com_zoffcc_applications_zanavi_NavitGraphics_MotionCallbackReal(JNIEnv* env, jobject thiz, int x1, int y1, int x2, int y2, int draw) |
606 | { |
635 | { |
607 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
636 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
608 | // dbg(0,"+#+:enter\n"); |
637 | // dbg(0,"+#+:enter\n"); |
609 | #endif |
638 | #endif |
610 | |
639 | |
… | |
… | |
634 | pc.pro = transform_get_projection(global_navit->trans); |
663 | pc.pro = transform_get_projection(global_navit->trans); |
635 | navit_set_position(global_navit, &pc); |
664 | navit_set_position(global_navit, &pc); |
636 | */ |
665 | */ |
637 | |
666 | |
638 | // dbg(0,"call async java draw -start-\n"); |
667 | // dbg(0,"call async java draw -start-\n"); |
|
|
668 | if (draw == 1) |
|
|
669 | { |
639 | navit_draw(global_navit); |
670 | navit_draw(global_navit); |
|
|
671 | } |
|
|
672 | else |
|
|
673 | { |
|
|
674 | // if we dont want to draw, then also cancel any drawing that is already in progress! |
|
|
675 | cancel_drawing_global = 1; |
|
|
676 | } |
640 | // navit_draw_async(global_navit, 1); |
677 | // navit_draw_async(global_navit, 1); |
641 | // dbg(0,"call async java draw --end--\n"); |
678 | // dbg(0,"call async java draw --end--\n"); |
642 | |
679 | |
643 | // remove the "wait" screen |
680 | // remove the "wait" screen |
644 | //#ifdef HAVE_API_ANDROID |
681 | //#ifdef HAVE_API_ANDROID |
… | |
… | |
753 | //DBG // dbg(0, "enter %p %p %f %f %f\n", thiz, (void *) id, x, y, z); |
790 | //DBG // dbg(0, "enter %p %p %f %f %f\n", thiz, (void *) id, x, y, z); |
754 | callback_call_4((struct callback *) id, sensor, &x, &y, &z); |
791 | callback_call_4((struct callback *) id, sensor, &x, &y, &z); |
755 | } |
792 | } |
756 | |
793 | |
757 | JNIEXPORT void JNICALL |
794 | JNIEXPORT void JNICALL |
758 | Java_com_zoffcc_applications_zanavi_NavitVehicle_VehicleCallback(JNIEnv *env, jobject thiz, jobject location) |
795 | Java_com_zoffcc_applications_zanavi_NavitVehicle_VehicleCallback(JNIEnv *env, jobject thiz, double lat, double lon, float speed, float direction, double height, float radius, long gpstime) |
759 | { |
796 | { |
760 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
797 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
761 | // dbg(0,"+#+:enter\n"); |
798 | // dbg(0,"+#+:enter\n"); |
762 | #endif |
799 | #endif |
763 | |
800 | |
… | |
… | |
765 | // jnienv2 = jni_getenv(); |
802 | // jnienv2 = jni_getenv(); |
766 | //int thread_id = gettid(); |
803 | //int thread_id = gettid(); |
767 | //dbg(0, "THREAD ID=%d\n", thread_id); |
804 | //dbg(0, "THREAD ID=%d\n", thread_id); |
768 | |
805 | |
769 | //dbg(0,"VehicleCallback location=%p\n", location); |
806 | //dbg(0,"VehicleCallback location=%p\n", location); |
770 | jobject location2 = (*env)->NewGlobalRef(env, location); |
807 | //+++jobject location2 = (*env)->NewGlobalRef(env, location); |
771 | (*env)->DeleteLocalRef(env, location); |
808 | //+++(*env)->DeleteLocalRef(env, location); |
772 | //// dbg(0,"location=%p\n", location2); |
809 | //// dbg(0,"location=%p\n", location2); |
773 | |
810 | |
774 | if ((global_navit) && (global_navit->vehicle) && (global_navit->vehicle->vehicle)) |
811 | if ((global_navit) && (global_navit->vehicle) && (global_navit->vehicle->vehicle)) |
775 | { |
812 | { |
776 | vehicle_update_(global_navit->vehicle->vehicle, location2); |
813 | vehicle_update_(global_navit->vehicle->vehicle, lat, lon, speed, direction, height, radius, gpstime); |
777 | } |
814 | } |
778 | else |
815 | else |
779 | { |
816 | { |
780 | dbg(0, "no vehicle set !!\n"); |
817 | dbg(0, "no vehicle set !!\n"); |
781 | } |
818 | } |
… | |
… | |
1730 | else if (i == 2) |
1767 | else if (i == 2) |
1731 | { |
1768 | { |
1732 | // zoom out |
1769 | // zoom out |
1733 | navit_zoom_out_cursor(global_navit, 2); |
1770 | navit_zoom_out_cursor(global_navit, 2); |
1734 | // navit_zoom_out_cursor(attr.u.navit, 2); |
1771 | // navit_zoom_out_cursor(attr.u.navit, 2); |
|
|
1772 | |
|
|
1773 | } |
|
|
1774 | else if (i == 84) |
|
|
1775 | { |
|
|
1776 | // report data dir |
|
|
1777 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1778 | navit_data_dir = g_strdup(s); |
|
|
1779 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1780 | } |
|
|
1781 | else if (i == 83) |
|
|
1782 | { |
|
|
1783 | // spill all the index files to log output |
|
|
1784 | spill_index(); |
|
|
1785 | } |
|
|
1786 | else if (i == 82) |
|
|
1787 | { |
|
|
1788 | // report share dir |
|
|
1789 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1790 | navit_share_dir = g_strdup(s); |
|
|
1791 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1792 | } |
|
|
1793 | else if (i == 81) |
|
|
1794 | { |
|
|
1795 | // resize layout items by factor |
|
|
1796 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1797 | displaylist_shift_for_dpi_value_in_layers(global_navit, (double)(atof(s))); |
|
|
1798 | (*env)->ReleaseStringUTFChars(env, str, s); |
|
|
1799 | } |
|
|
1800 | else if (i == 80) |
|
|
1801 | { |
|
|
1802 | // autozoom flag to 0 or 1 |
|
|
1803 | s = (*env)->GetStringUTFChars(env, str, NULL); |
|
|
1804 | global_navit->autozoom_active = atoi(s); |
|
|
1805 | (*env)->ReleaseStringUTFChars(env, str, s); |
1735 | } |
1806 | } |
1736 | else if (i == 79) |
1807 | else if (i == 79) |
1737 | { |
1808 | { |
1738 | // set traffic light delay |
1809 | // set traffic light delay |
1739 | s = (*env)->GetStringUTFChars(env, str, NULL); |
1810 | s = (*env)->GetStringUTFChars(env, str, NULL); |
… | |
… | |
2533 | } |
2604 | } |
2534 | |
2605 | |
2535 | (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_set_vehicle_values2, x, y, angle, speed); |
2606 | (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_set_vehicle_values2, x, y, angle, speed); |
2536 | } |
2607 | } |
2537 | |
2608 | |
2538 | void set_vehicle_values_to_java_delta(int dx, int dy, int dangle) |
2609 | void set_vehicle_values_to_java_delta(int dx, int dy, int dangle, int dzoom) |
2539 | { |
2610 | { |
2540 | JNIEnv *jnienv2; |
2611 | JNIEnv *jnienv2; |
2541 | jnienv2 = jni_getenv(); |
2612 | jnienv2 = jni_getenv(); |
2542 | |
2613 | |
2543 | //int thread_id = gettid(); |
2614 | //int thread_id = gettid(); |
… | |
… | |
2552 | } |
2623 | } |
2553 | } |
2624 | } |
2554 | |
2625 | |
2555 | if (NavitGraphics_set_vehicle_values3 == NULL) |
2626 | if (NavitGraphics_set_vehicle_values3 == NULL) |
2556 | { |
2627 | { |
2557 | if (!android_find_static_method(NavitGraphicsClass2, "set_vehicle_values_delta", "(III)V", &NavitGraphics_set_vehicle_values3)) |
2628 | if (!android_find_static_method(NavitGraphicsClass2, "set_vehicle_values_delta", "(IIII)V", &NavitGraphics_set_vehicle_values3)) |
2558 | { |
2629 | { |
2559 | return; |
2630 | return; |
2560 | } |
2631 | } |
2561 | } |
2632 | } |
2562 | |
2633 | |
2563 | (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_set_vehicle_values3, dx, dy, dangle); |
2634 | (*jnienv2)->CallStaticVoidMethod(jnienv2, NavitGraphicsClass2, NavitGraphics_set_vehicle_values3, dx, dy, dangle, dzoom); |
2564 | } |
2635 | } |
2565 | |
2636 | |
2566 | void send_route_rect_to_java(int x1, int y1, int x2, int y2, int order) |
2637 | void send_route_rect_to_java(int x1, int y1, int x2, int y2, int order) |
2567 | { |
2638 | { |
2568 | JNIEnv *jnienv2; |
2639 | JNIEnv *jnienv2; |