From 2af2a84a03fd707cfa4c682aff34d722343d8985 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 27 Jun 2014 23:21:45 -0300 Subject: Misc Fixes ========== -NOTIFICATION_WM_QUIT fixed on android (seems tha way this is reported changed in newer sdk) -WIP implementation of APK Expansion APIs for publishing games larger than 50mb in Play Store -Feaures in the new tutorials are all present in the sourcecode -This (hopefully) should get rid of the animation list order getting corrupted -Improved 3D Scene Importer (Skeletons, Animations and other stuff were not being merged). Anything missing? -In code editor, the automatic syntax checker will only use file_exists() to check preload() else it might freeze the editor too much while typing if the preload is a big resource -Fixed bugs in PolygonPathFinder, stil pending to do a node and a demo --- platform/android/export/export.cpp | 39 ++-- .../android/java/src/com/android/godot/Godot.java | 232 +++++++++++++++++---- .../godot/GodotDownloaderAlarmReceiver.java | 27 +++ .../com/android/godot/GodotDownloaderService.java | 47 +++++ platform/android/java_glue.cpp | 46 ++-- platform/android/os_android.cpp | 21 +- platform/android/os_android.h | 3 +- 7 files changed, 339 insertions(+), 76 deletions(-) create mode 100644 platform/android/java/src/com/android/godot/GodotDownloaderAlarmReceiver.java create mode 100644 platform/android/java/src/com/android/godot/GodotDownloaderService.java (limited to 'platform/android') diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index d1ee7087e..f47ff4ed5 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -258,7 +258,11 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant& String n=p_name; - if (n=="version/code") + if (n=="custom_package/debug") + custom_debug_package=p_value; + else if (n=="custom_package/release") + custom_release_package=p_value; + else if (n=="version/code") version_code=p_value; else if (n=="version/name") version_name=p_value; @@ -317,8 +321,11 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant& bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret) const{ String n=p_name; - - if (n=="version/code") + if (n=="custom_package/debug") + r_ret=custom_debug_package; + else if (n=="custom_package/release") + r_ret=custom_release_package; + else if (n=="version/code") r_ret=version_code; else if (n=="version/name") r_ret=version_name; @@ -389,7 +396,7 @@ void EditorExportPlatformAndroid::_get_property_list( List *p_list p_list->push_back( PropertyInfo( Variant::STRING, "keystore/release_user" ) ); p_list->push_back( PropertyInfo( Variant::BOOL, "apk_expansion/enable" ) ); p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/SALT" ) ); - p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/pubic_key" ) ); + p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/public_key",PROPERTY_HINT_MULTILINE_TEXT ) ); const char **perms = android_perms; while(*perms) { @@ -1095,6 +1102,12 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d ep.step("Adding Files..",1); Error err=OK; Vector cl = cmdline.strip_edges().split(" "); + for(int i=0;i65535) { - System.out.printf("**ERROR** Wrong command len\n"); - return new String[0]; - } - byte[] arg = new byte[strlen]; - r = is.read(arg); - if (r!=strlen) { - cmdline[i]=new String(arg,"UTF-8"); - } - + InputStream is; + try { + is = getAssets().open("_cl_"); + byte[] len = new byte[4]; + int r = is.read(len); + if (r<4) { + System.out.printf("**ERROR** Wrong cmdline length.\n"); + Log.d("GODOT", "**ERROR** Wrong cmdline length.\n"); + return new String[0]; + } + int argc=((int)(len[3]&0xFF)<<24) | ((int)(len[2]&0xFF)<<16) | ((int)(len[1]&0xFF)<<8) | ((int)(len[0]&0xFF)); + String[] cmdline = new String[argc]; + + for(int i=0;i65535) { + Log.d("GODOT", "**ERROR** Wrong command len\n"); + return new String[0]; + } + byte[] arg = new byte[strlen]; + r = is.read(arg); + if (r==strlen) { + cmdline[i]=new String(arg,"UTF-8"); + } } - return cmdline; } catch (Exception e) { - + e.printStackTrace(); + System.out.printf("**ERROR** No commandline.\n"); + Log.d("GODOT", "**ERROR** Exception " + e.getClass().getName() + ":" + e.getMessage()); return new String[0]; } } - @Override protected void onCreate(Bundle icicle) { - System.out.printf("** GODOT ACTIVITY CREATED HERE ***\n"); + String expansion_pack_path; - super.onCreate(icicle); - _self = this; - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON - | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + private void initializeGodot() { + if (expansion_pack_path!=null) { + String[] new_cmdline; + int cll=0; + if (command_line!=null) { + new_cmdline = new String[ command_line.length + 2 ]; + cll=command_line.length; + for(int i=0;i new_args = new LinkedList(); + + + for(int i=0;i 0) { + complete.update(buffer, 0, numRead); + } + } while (numRead != -1); + + + fis.close(); + byte[] messageDigest = complete.digest(); + + // Create Hex String + StringBuffer hexString = new StringBuffer(); + for (int i=0; i + */ +public class GodotDownloaderAlarmReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + try { + DownloaderClientMarshaller.startDownloadServiceIfRequired(context, intent, GodotDownloaderService.class); + } catch (NameNotFoundException e) { + e.printStackTrace(); + } + } +} diff --git a/platform/android/java/src/com/android/godot/GodotDownloaderService.java b/platform/android/java/src/com/android/godot/GodotDownloaderService.java new file mode 100644 index 000000000..e0fe95ad9 --- /dev/null +++ b/platform/android/java/src/com/android/godot/GodotDownloaderService.java @@ -0,0 +1,47 @@ +package com.android.godot; + +import com.google.android.vending.expansion.downloader.impl.DownloaderService; + +/** + * This class demonstrates the minimal client implementation of the + * DownloaderService from the Downloader library. + */ +public class GodotDownloaderService extends DownloaderService { + // stuff for LVL -- MODIFY FOR YOUR APPLICATION! + private static final String BASE64_PUBLIC_KEY = "REPLACE THIS WITH YOUR PUBLIC KEY"; + // used by the preference obfuscater + private static final byte[] SALT = new byte[] { + 1, 43, -12, -1, 54, 98, + -100, -12, 43, 2, -8, -4, 9, 5, -106, -108, -33, 45, -1, 84 + }; + + /** + * This public key comes from your Android Market publisher account, and it + * used by the LVL to validate responses from Market on your behalf. + */ + @Override + public String getPublicKey() { + return BASE64_PUBLIC_KEY; + } + + /** + * This is used by the preference obfuscater to make sure that your + * obfuscated preferences are different than the ones used by other + * applications. + */ + @Override + public byte[] getSALT() { + return SALT; + } + + /** + * Fill this in with the class name for your alarm receiver. We do this + * because receivers must be unique across all of Android (it's a good idea + * to make sure that your receiver is in your unique package) + */ + @Override + public String getAlarmReceiverClassName() { + return GodotDownloaderAlarmReceiver.class.getName(); + } + +} diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index b11994eef..b9e13892d 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -747,8 +747,34 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, } + const char ** cmdline=NULL; + int cmdlen=0; + bool use_apk_expansion=false; + if (p_cmdline) { + int cmdlen = env->GetArrayLength(p_cmdline); + if (cmdlen) { + cmdline = (const char**)malloc((env->GetArrayLength(p_cmdline)+1)*sizeof(const char*)); + cmdline[cmdlen]=NULL; + + for (int i=0; iGetObjectArrayElement(p_cmdline, i); + const char *rawString = env->GetStringUTFChars(string, 0); + if (!rawString) { + __android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is null\n",i); + } else { + // __android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is: %s\n",i,rawString); + + if (strcmp(rawString,"-main_pack")==0) + use_apk_expansion=true; + } + + cmdline[i]=rawString; + } + } + } - os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _play_video, _is_video_playing, _pause_video, _stop_video); + os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _play_video, _is_video_playing, _pause_video, _stop_video,use_apk_expansion); os_android->set_need_reload_hooks(p_need_reload_hook); char wd[500]; @@ -759,16 +785,6 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, __android_log_print(ANDROID_LOG_INFO,"godot","**SETUP"); - const char ** cmdline=NULL; - int cmdlen = env->GetArrayLength(p_cmdline); - cmdline = (const char**)malloc((env->GetArrayLength(p_cmdline)+1)*sizeof(const char*)); - cmdline[cmdlen]=NULL; - for (int i=0; iGetObjectArrayElement(p_cmdline, i); - const char *rawString = env->GetStringUTFChars(string, 0); - cmdline[i]=rawString; - } #if 0 char *args[]={"-test","render",NULL}; @@ -833,6 +849,7 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_quit(JNIEnv * env, jobjec input_mutex->lock(); quit_request=true; + print_line("BACK PRESSED"); input_mutex->unlock(); } @@ -1289,7 +1306,10 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_key(JNIEnv * env, jobject } else if (val == 61453) { ievent.key.scancode = KEY_ENTER; ievent.key.unicode = KEY_ENTER; - } + } else if (p_scancode==4) { + + quit_request=true; + } input_mutex->lock(); key_events.push_back(ievent); @@ -1390,7 +1410,7 @@ static Variant::Type get_jni_type(const String& p_type) { static const char* get_jni_sig(const String& p_type) { - print_line("getting sig for " + p_type); + static struct { const char *name; const char *sig; diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 5bc433e85..5fad4386f 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -87,11 +87,17 @@ void OS_Android::initialize_core() { #else - FileAccess::make_default >(FileAccess::ACCESS_RESOURCES); + if (use_apk_expansion) + FileAccess::make_default(FileAccess::ACCESS_RESOURCES); + else + FileAccess::make_default >(FileAccess::ACCESS_RESOURCES); FileAccess::make_default(FileAccess::ACCESS_USERDATA); FileAccess::make_default(FileAccess::ACCESS_FILESYSTEM); //FileAccessBufferedFA::make_default(); - DirAccess::make_default(DirAccess::ACCESS_RESOURCES); + if (use_apk_expansion) + DirAccess::make_default(DirAccess::ACCESS_RESOURCES); + else + DirAccess::make_default(DirAccess::ACCESS_RESOURCES); DirAccess::make_default(DirAccess::ACCESS_USERDATA); DirAccess::make_default(DirAccess::ACCESS_FILESYSTEM); @@ -698,9 +704,10 @@ void OS_Android::native_video_stop() { video_stop_func(); } -OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func) { +OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func,bool p_use_apk_expansion) { + use_apk_expansion=p_use_apk_expansion; default_videomode.width=800; default_videomode.height=600; default_videomode.fullscreen=true; @@ -720,10 +727,10 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu get_model_func=p_get_model_func; get_unique_id_func=p_get_unique_id; - video_play_func = p_video_play_func; - video_is_playing_func = p_video_is_playing_func; - video_pause_func = p_video_pause_func; - video_stop_func = p_video_stop_func; + video_play_func = p_video_play_func; + video_is_playing_func = p_video_is_playing_func; + video_pause_func = p_video_pause_func; + video_stop_func = p_video_stop_func; show_virtual_keyboard_func = p_show_vk; hide_virtual_keyboard_func = p_hide_vk; diff --git a/platform/android/os_android.h b/platform/android/os_android.h index e6d0f7ede..bc52a4300 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -88,6 +88,7 @@ private: bool use_gl2; bool use_reload_hooks; + bool use_apk_expansion; Rasterizer *rasterizer; VisualServer *visual_server; @@ -213,7 +214,7 @@ public: virtual void native_video_pause(); virtual void native_video_stop(); - OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func); + OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func,bool p_use_apk_expansion); ~OS_Android(); }; -- cgit v1.3.1