/************************************************************************************************* * Java_com_waze_FreeMapNativeManager_ConnectivityChangedNTV * Starts the application * */ JNIEXPORT void JNICALL Java_com_waze_FreeMapNativeManager_ConnectivityChangedNTV ( JNIEnv* aJNIEnv, jobject aJObj, jboolean aConnected, jint aConnType, jstring aConnTypeStr ) { const char* conn_type_str = (*aJNIEnv)->GetStringUTFChars( aJNIEnv, aConnTypeStr, NULL ); static int conn_state = -1; roadmap_log( ROADMAP_WARNING, "Android Connectivity Event. Connected: %d (Previous: %d). Network Type: %s ( Code: %d )", aConnected == JNI_TRUE, conn_state, conn_type_str, aConnType ); if ( conn_state != (int) aConnected ) { if ( aConnected == JNI_TRUE ) roadmap_device_event_notification( device_event_network_connected ); else roadmap_device_event_notification( device_event_network_disconnected ); conn_state = ( int ) aConnected; } (*aJNIEnv)->ReleaseStringUTFChars( aJNIEnv, aConnTypeStr, conn_type_str ); }
/************************************************************************************************* * roadmap_canvas_set_properties * Initializes the canvas_agg context this the display dvice parameters */ EXTERN_C void roadmap_canvas_set_properties( int aWidth, int aHeight, int aPixelFormat ) { int cur_orientation = ( gAndrCanvas.height > gAndrCanvas.width ); int new_orientation = ( aHeight > aWidth ); if ( cur_orientation != new_orientation ) roadmap_device_event_notification( device_event_window_orientation_changed ); gAndrCanvas.height = aHeight; gAndrCanvas.width = aWidth; gAndrCanvas.pixel_format = aPixelFormat; // The buffer gAndrCanvas.pCanvasBuf will be allocated later gAndrCanvas.pCanvasBuf = NULL; }
/************************************************************************************************* * roadmap_canvas_new() * Memory allocation for the new canvas */ EXTERN_C void roadmap_canvas_new () { int lBytes2Allocate; int lStride; roadmap_log( ROADMAP_INFO, "Canvas new .... \n" ); // The gAndrCanvas has to be initialized before calling this function if ( !gAndrCanvas.width || !gAndrCanvas.height ) { roadmap_log( ROADMAP_ERROR, "Canvas failed - canvas properties are incorrect or weren't set \n" ); return; } // If canvas already allocated - free the memory if ( gAndrCanvas.pCanvasBuf ) { free( gAndrCanvas.pCanvasBuf ); gAndrCanvas.pCanvasBuf = NULL; } // Allocate the memory for the canvas lStride = DEFAULT_BPP * gAndrCanvas.width; lBytes2Allocate = lStride * gAndrCanvas.height; gAndrCanvas.pCanvasBuf = ( unsigned int * ) calloc( lBytes2Allocate, 1 ); if ( !gAndrCanvas.pCanvasBuf ) { roadmap_log( ROADMAP_ERROR, "Canvas allocation failed \n" ); return; } // There are no alignment problems .... roadmap_canvas_agg_configure( ( unsigned char* ) gAndrCanvas.pCanvasBuf, gAndrCanvas.width, gAndrCanvas.height, lStride ); // Run the configurator (*RoadMapCanvasConfigure) (); // Notify about system event roadmap_device_event_notification( device_event_window_orientation_changed); // Restore keyboard if suppposed to be visible if ( roadmap_native_keyboard_visible() ) { RMNativeKBParams params; roadmap_native_keyboard_get_params( ¶ms ); roadmap_native_keyboard_show( ¶ms ); } }