From 88e779cd5e4cbd2e2703c03c4e386cf85aaaa049 Mon Sep 17 00:00:00 2001 From: Xavier Sellier Date: Thu, 22 Feb 2018 00:38:04 -0500 Subject: [PATCH] Improve android java support - Use Log.d/Log.w instead of System.printf - Remove commented code - Cherry-pick: Manual backport of d69881436757fce0d81f42736879ed69747ddcbe --- platform/android/audio_driver_jandroid.cpp | 39 ----- platform/android/audio_driver_opensl.cpp | 2 - platform/android/dir_access_jandroid.cpp | 17 --- platform/android/file_access_jandroid.cpp | 27 ---- platform/android/godot_android.cpp | 20 +-- .../src/org/godotengine/godot/Dictionary.java | 1 + .../java/src/org/godotengine/godot/Godot.java | 139 +++++------------- .../godot/GodotDownloaderAlarmReceiver.java | 4 +- .../godot/GodotDownloaderService.java | 8 +- .../src/org/godotengine/godot/GodotIO.java | 64 ++++---- .../org/godotengine/godot/GodotPaymentV3.java | 2 - .../src/org/godotengine/godot/GodotView.java | 6 - .../godot/input/GodotTextInputWrapper.java | 20 --- .../godot/input/InputManagerV9.java | 4 +- .../godot/payments/ConsumeTask.java | 11 +- .../godot/payments/GenericConsumeTask.java | 6 +- .../godot/payments/HandlePurchaseTask.java | 14 +- .../godot/payments/PaymentsCache.java | 2 - .../godot/payments/PaymentsManager.java | 11 +- .../godot/payments/PurchaseTask.java | 20 +-- .../payments/ReleaseAllConsumablesTask.java | 11 +- .../godot/payments/ValidateTask.java | 5 - .../godot/utils/HttpRequester.java | 32 ++-- platform/android/java_class_wrapper.cpp | 14 +- platform/android/java_glue.cpp | 81 +--------- 25 files changed, 127 insertions(+), 433 deletions(-) diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index ce89c9a02d4..e078833e118 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -58,21 +58,6 @@ const char *AudioDriverAndroid::get_name() const { Error AudioDriverAndroid::init() { mutex = Mutex::create(); - /* - // TODO: pass in/return a (Java) device ID, also whether we're opening for input or output - this->spec.samples = Android_JNI_OpenAudioDevice(this->spec.freq, this->spec.format == AUDIO_U8 ? 0 : 1, this->spec.channels, this->spec.samples); - SDL_CalculateAudioSpec(&this->spec); - - if (this->spec.samples == 0) { - // Init failed? - SDL_SetError("Java-side initialization failed!"); - return 0; - } -*/ - - // Android_JNI_SetupThread(); - - // __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device"); JNIEnv *env = ThreadAndroid::get_env(); int mix_rate = GLOBAL_DEF("audio/mix_rate", 44100); @@ -84,7 +69,6 @@ Error AudioDriverAndroid::init() { print_line("audio buffer size: " + itos(buffer_size)); } - __android_log_print(ANDROID_LOG_INFO, "godot", "Initializing audio! params: %i,%i ", mix_rate, buffer_size); audioBuffer = env->CallObjectMethod(io, _init_audio, mix_rate, buffer_size); ERR_FAIL_COND_V(audioBuffer == NULL, ERR_INVALID_PARAMETER); @@ -111,29 +95,10 @@ void AudioDriverAndroid::setup(jobject p_io) { jclass c = env->GetObjectClass(io); cls = (jclass)env->NewGlobalRef(c); - __android_log_print(ANDROID_LOG_INFO, "godot", "starting to attempt get methods"); - _init_audio = env->GetMethodID(cls, "audioInit", "(II)Ljava/lang/Object;"); - if (_init_audio != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _init_audio ok!!"); - } else { - __android_log_print(ANDROID_LOG_INFO, "godot", "audioinit ok!"); - } - _write_buffer = env->GetMethodID(cls, "audioWriteShortBuffer", "([S)V"); - if (_write_buffer != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _write_buffer ok!!"); - } - _quit = env->GetMethodID(cls, "audioQuit", "()V"); - if (_quit != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _quit ok!!"); - } - _pause = env->GetMethodID(cls, "audioPause", "(Z)V"); - if (_quit != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _pause ok!!"); - } } void AudioDriverAndroid::thread_func(JNIEnv *env) { @@ -142,7 +107,6 @@ void AudioDriverAndroid::thread_func(JNIEnv *env) { if (cls) { cls = (jclass)env->NewGlobalRef(cls); - __android_log_print(ANDROID_LOG_INFO, "godot", "*******CLASS FOUND!!!"); } jfieldID fid = env->GetStaticFieldID(cls, "io", "Lorg/godotengine/godot/GodotIO;"); jobject ob = env->GetStaticObjectField(cls, fid); @@ -150,9 +114,6 @@ void AudioDriverAndroid::thread_func(JNIEnv *env) { jclass c = env->GetObjectClass(gob); jclass lcls = (jclass)env->NewGlobalRef(c); _write_buffer = env->GetMethodID(lcls, "audioWriteShortBuffer", "([S)V"); - if (_write_buffer != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _write_buffer ok!!"); - } while (!quit) { diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index c8131cade66..345c14fe2b1 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -193,8 +193,6 @@ Error AudioDriverOpenSL::init() { ERR_FAIL_V(ERR_INVALID_PARAMETER); } - print_line("OpenSL Init OK!"); - return OK; } diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index c7799b5574c..81b7b397195 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -129,7 +129,6 @@ Error DirAccessJAndroid::change_dir(String p_dir) { else new_dir = current_dir.plus_file(p_dir); - //print_line("new dir is: "+new_dir); //test if newdir exists new_dir = new_dir.simplify_path(); @@ -225,30 +224,14 @@ void DirAccessJAndroid::setup(jobject p_io) { JNIEnv *env = ThreadAndroid::get_env(); io = p_io; - __android_log_print(ANDROID_LOG_INFO, "godot", "STEP7"); jclass c = env->GetObjectClass(io); cls = (jclass)env->NewGlobalRef(c); - __android_log_print(ANDROID_LOG_INFO, "godot", "STEP8"); _dir_open = env->GetMethodID(cls, "dir_open", "(Ljava/lang/String;)I"); - if (_dir_open != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _dir_open ok!!"); - } _dir_next = env->GetMethodID(cls, "dir_next", "(I)Ljava/lang/String;"); - if (_dir_next != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _dir_next ok!!"); - } _dir_close = env->GetMethodID(cls, "dir_close", "(I)V"); - if (_dir_close != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _dir_close ok!!"); - } _dir_is_dir = env->GetMethodID(cls, "dir_is_dir", "(I)Z"); - if (_dir_is_dir != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _dir_is_dir ok!!"); - } - - // (*env)->CallVoidMethod(env,obj,aMethodID, myvar); } DirAccessJAndroid::DirAccessJAndroid() { diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp index 27e7bbf8512..9aeeb5fb0f6 100644 --- a/platform/android/file_access_jandroid.cpp +++ b/platform/android/file_access_jandroid.cpp @@ -186,43 +186,16 @@ void FileAccessJAndroid::setup(jobject p_io) { io = p_io; JNIEnv *env = ThreadAndroid::get_env(); - __android_log_print(ANDROID_LOG_INFO, "godot", "STEP5"); - jclass c = env->GetObjectClass(io); - __android_log_print(ANDROID_LOG_INFO, "godot", "STEP6"); cls = (jclass)env->NewGlobalRef(c); _file_open = env->GetMethodID(cls, "file_open", "(Ljava/lang/String;Z)I"); - if (_file_open != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _file_open ok!!"); - } _file_get_size = env->GetMethodID(cls, "file_get_size", "(I)I"); - if (_file_get_size != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _file_get_size ok!!"); - } _file_tell = env->GetMethodID(cls, "file_tell", "(I)I"); - if (_file_tell != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _file_tell ok!!"); - } _file_eof = env->GetMethodID(cls, "file_eof", "(I)Z"); - - if (_file_eof != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _file_eof ok!!"); - } _file_seek = env->GetMethodID(cls, "file_seek", "(II)V"); - if (_file_seek != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _file_seek ok!!"); - } _file_read = env->GetMethodID(cls, "file_read", "(II)[B"); - if (_file_read != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _file_read ok!!"); - } _file_close = env->GetMethodID(cls, "file_close", "(I)V"); - if (_file_close != 0) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*******GOT METHOD _file_close ok!!"); - } - - // (*env)->CallVoidMethod(env,obj,aMethodID, myvar); } FileAccessJAndroid::FileAccessJAndroid() { diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 03757de0e8e..25f767e3baf 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -75,14 +75,11 @@ public: virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { - print_line("attempt to call " + String(p_method)); - r_error.error = Variant::CallError::CALL_OK; Map::Element *E = method_map.find(p_method); if (!E) { - print_line("no exists"); r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; return Variant(); } @@ -90,7 +87,6 @@ public: int ac = E->get().argtypes.size(); if (ac < p_argcount) { - print_line("fewargs"); r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument = ac; return Variant(); @@ -98,7 +94,6 @@ public: if (ac > p_argcount) { - print_line("manyargs"); r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.argument = ac; return Variant(); @@ -180,26 +175,21 @@ public: } } - print_line("calling method!!"); - Variant ret; switch (E->get().ret_type) { case Variant::NIL: { - print_line("call void"); env->CallVoidMethodA(instance, E->get().method, v); } break; case Variant::BOOL: { ret = env->CallBooleanMethodA(instance, E->get().method, v); - print_line("call bool"); } break; case Variant::INT: { ret = env->CallIntMethodA(instance, E->get().method, v); - print_line("call int"); } break; case Variant::REAL: { @@ -254,13 +244,10 @@ public: } break; default: { - print_line("failure.."); ERR_FAIL_V(Variant()); } break; } - print_line("success"); - return ret; } @@ -389,7 +376,6 @@ static int engine_init_display(struct engine *engine, bool p_gl2) { eglQuerySurface(display, surface, EGL_WIDTH, &w); eglQuerySurface(display, surface, EGL_HEIGHT, &h); - print_line("INIT VIDEO MODE: " + itos(w) + "," + itos(h)); //engine->os->set_egl_extensions(eglQueryString(display,EGL_EXTENSIONS)); engine->os->init_video_mode(w, h); @@ -570,7 +556,6 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) { eglQuerySurface(engine->display, engine->surface, EGL_WIDTH, &w); eglQuerySurface(engine->display, engine->surface, EGL_HEIGHT, &h); engine->os->init_video_mode(w,h); - //print_line("RESIZED VIDEO MODE: "+itos(w)+","+itos(h)); engine_draw_frame(engine); } @@ -596,7 +581,6 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) { eglQuerySurface(engine->display, engine->surface, EGL_WIDTH, &w); eglQuerySurface(engine->display, engine->surface, EGL_HEIGHT, &h); engine->os->init_video_mode(w,h); - //print_line("RESIZED VIDEO MODE: "+itos(w)+","+itos(h)); }*/ @@ -959,7 +943,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_Godot_registerMethod(JNIEnv *e int stringCount = env->GetArrayLength(args); - print_line("Singl: " + singname + " Method: " + mname + " RetVal: " + retval); for (int i = 0; i < stringCount; i++) { jstring string = (jstring)env->GetObjectArrayElement(args, i); @@ -971,11 +954,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_Godot_registerMethod(JNIEnv *e cs += ")"; cs += get_jni_sig(retval); jclass cls = env->GetObjectClass(s->get_instance()); - print_line("METHOD: " + mname + " sig: " + cs); jmethodID mid = env->GetMethodID(cls, mname.ascii().get_data(), cs.ascii().get_data()); if (!mid) { - print_line("FAILED GETTING METHOID " + mname); + print_line("Failed getting method id: " + mname); } s->add_method(mname, mid, types, get_jni_type(retval)); diff --git a/platform/android/java/src/org/godotengine/godot/Dictionary.java b/platform/android/java/src/org/godotengine/godot/Dictionary.java index b7ced69d0ec..ae54c225ecf 100644 --- a/platform/android/java/src/org/godotengine/godot/Dictionary.java +++ b/platform/android/java/src/org/godotengine/godot/Dictionary.java @@ -78,3 +78,4 @@ public class Dictionary extends HashMap { keys_cache = null; }; }; + diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index f3d48bd9206..0dfb3c2c5fb 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -91,7 +91,7 @@ import android.os.Messenger; import android.os.SystemClock; public class Godot extends Activity implements SensorEventListener, IDownloaderClient { - + private static final String TAG = "Godot"; static final int MAX_SINGLETONS = 64; private IStub mDownloaderClientStub; private IDownloaderService mRemoteService; @@ -149,21 +149,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC Method[] methods = clazz.getDeclaredMethods(); for (Method method : methods) { boolean found = false; - Log.d("XXX", "METHOD: %s\n" + method.getName()); for (String s : p_methods) { - Log.d("XXX", "METHOD CMP WITH: %s\n" + s); if (s.equals(method.getName())) { found = true; - Log.d("XXX", "METHOD CMP VALID"); break; } } if (!found) continue; - Log.d("XXX", "METHOD FOUND: %s\n" + method.getName()); - List ptr = new ArrayList(); Class[] paramTypes = method.getParameterTypes(); @@ -190,21 +185,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC protected void onGLDrawFrame(GL10 gl) {} protected void onGLSurfaceChanged(GL10 gl, int width, int height) {} // singletons will always miss first onGLSurfaceChanged call - //protected void onGLSurfaceCreated(GL10 gl, EGLConfig config) {} // singletons won't be ready until first GodotLib.step() public void registerMethods() {} } - /* - protected List singletons = new ArrayList(); - protected void instanceSingleton(SingletonBase s) { - - s.registerMethods(); - singletons.add(s); - } - -*/ - private String[] command_line; public GodotView mView; @@ -222,7 +206,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC static public GodotIO io; public static void setWindowTitle(String title) { - //setTitle(title); } static SingletonBase singletons[] = new SingletonBase[MAX_SINGLETONS]; @@ -253,9 +236,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC public void onVideoInit(boolean use_gl2) { - // mView = new GodotView(getApplication(),io,use_gl2); - // setContentView(mView); - layout = new FrameLayout(this); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); setContentView(layout); @@ -273,7 +253,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC edittext.setView(mView); io.setEdit(edittext); - // Ad layout + // Add layout adLayout = new RelativeLayout(this); adLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.addView(adLayout); @@ -323,8 +303,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC byte[] len = new byte[4]; int r = is.read(len); if (r < 4) { - Log.d("XXX", "**ERROR** Wrong cmdline length.\n"); - Log.d("GODOT", "**ERROR** Wrong cmdline length.\n"); + Log.w(TAG, "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)); @@ -334,12 +313,12 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC r = is.read(len); if (r < 4) { - Log.d("GODOT", "**ERROR** Wrong cmdline param lenght.\n"); + Log.w(TAG, "Wrong cmdline param length.\n"); return new String[0]; } int strlen = ((int)(len[3] & 0xFF) << 24) | ((int)(len[2] & 0xFF) << 16) | ((int)(len[1] & 0xFF) << 8) | ((int)(len[0] & 0xFF)); if (strlen > 65535) { - Log.d("GODOT", "**ERROR** Wrong command len\n"); + Log.w(TAG, "Wrong command length\n"); return new String[0]; } byte[] arg = new byte[strlen]; @@ -351,7 +330,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC return cmdline; } catch (Exception e) { e.printStackTrace(); - Log.d("GODOT", "**ERROR** Exception " + e.getClass().getName() + ":" + e.getMessage()); + Log.w(TAG, "Exception " + e.getClass().getName() + ":" + e.getMessage()); return new String[0]; } } @@ -365,14 +344,14 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC String[] new_cmdline; int cll = 0; if (command_line != null) { - Log.d("GODOT", "initializeGodot: command_line: is not null"); + Log.d(TAG, "initializeGodot: command_line: is not null"); new_cmdline = new String[command_line.length + 2]; cll = command_line.length; for (int i = 0; i < command_line.length; i++) { new_cmdline[i] = command_line[i]; } } else { - Log.d("GODOT", "initializeGodot: command_line: is null"); + Log.d(TAG, "initializeGodot: command_line: is null"); new_cmdline = new String[2]; } @@ -384,13 +363,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC io = new GodotIO(this); io.unique_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID); GodotLib.io = io; - Log.d("GODOT", "command_line is null? " + ((command_line == null) ? "yes" : "no")); - /*if(command_line != null){ - Log.d("GODOT", "Command Line:"); - for(int w=0;w */ public class GodotDownloaderAlarmReceiver extends BroadcastReceiver { + private static final String TAG = "GodotDownloaderAlarmReceiver"; @Override public void onReceive(Context context, Intent intent) { - Log.d("GODOT", "Alarma recivida"); try { DownloaderClientMarshaller.startDownloadServiceIfRequired(context, intent, GodotDownloaderService.class); } catch (NameNotFoundException e) { e.printStackTrace(); - Log.d("GODOT", "Exception: " + e.getClass().getName() + ":" + e.getMessage()); + Log.d(TAG, "Exception: " + e.getClass().getName() + ":" + e.getMessage()); } } } diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java index 8a8a084a39e..611eb60b789 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java +++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java @@ -40,6 +40,8 @@ import com.google.android.vending.expansion.downloader.impl.DownloaderService; * DownloaderService from the Downloader library. */ public class GodotDownloaderService extends DownloaderService { + private static final String TAG = "GodotDownloaderService"; + // 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 @@ -55,10 +57,8 @@ public class GodotDownloaderService extends DownloaderService { @Override public String getPublicKey() { SharedPreferences prefs = getApplicationContext().getSharedPreferences("app_data_keys", Context.MODE_PRIVATE); - Log.d("GODOT", "getting public key:" + prefs.getString("store_public_key", null)); + Log.d(TAG, "getting public key:" + prefs.getString("store_public_key", null)); return prefs.getString("store_public_key", null); - - // return BASE64_PUBLIC_KEY; } /** @@ -78,7 +78,7 @@ public class GodotDownloaderService extends DownloaderService { */ @Override public String getAlarmReceiverClassName() { - Log.d("GODOT", "getAlarmReceiverClassName()"); + Log.d(TAG, "getAlarmReceiverClassName()"); return GodotDownloaderAlarmReceiver.class.getName(); } } diff --git a/platform/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java index c221ff90189..ce057f4005f 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java @@ -56,6 +56,8 @@ import org.godotengine.godot.input.*; public class GodotIO { + private static String TAG = "GodotIO"; + AssetManager am; Godot activity; GodotEditText edit; @@ -103,7 +105,7 @@ public class GodotIO { } catch (Exception e) { - //System.out.printf("Exception on file_open: %s\n",path); + // Cannot open file return -1; } @@ -111,7 +113,7 @@ public class GodotIO { ad.len = ad.is.available(); } catch (Exception e) { - System.out.printf("Exception availabling on file_open: %s\n", path); + Log.w(TAG, "Exception availabling on file_open: " + path); return -1; } @@ -125,7 +127,8 @@ public class GodotIO { public int file_get_size(int id) { if (!streams.containsKey(id)) { - System.out.printf("file_get_size: Invalid file id: %d\n", id); + + Log.w(TAG, "file_get_size: Invalid file id: " + id); return -1; } @@ -134,10 +137,12 @@ public class GodotIO { public void file_seek(int id, int bytes) { if (!streams.containsKey(id)) { - System.out.printf("file_get_size: Invalid file id: %d\n", id); + + Log.w(TAG, "file_get_size: Invalid file id: " + id); return; } - //seek sucks + + // More efficient than "seek" built-in function AssetData ad = streams.get(id); if (bytes > ad.len) bytes = ad.len; @@ -166,7 +171,7 @@ public class GodotIO { ad.eof = false; } catch (IOException e) { - System.out.printf("Exception on file_seek: %s\n", e); + Log.w(TAG, "Exception on file_seek: " + e); return; } } @@ -174,7 +179,8 @@ public class GodotIO { public int file_tell(int id) { if (!streams.containsKey(id)) { - System.out.printf("file_read: Can't tell eof for invalid file id: %d\n", id); + + Log.w(TAG, "file_read: Can't tell eof for invalid file id: " + id); return 0; } @@ -184,7 +190,8 @@ public class GodotIO { public boolean file_eof(int id) { if (!streams.containsKey(id)) { - System.out.printf("file_read: Can't check eof for invalid file id: %d\n", id); + + Log.w(TAG, "file_read: Can't check eof for invalid file id: " + id); return false; } @@ -195,7 +202,8 @@ public class GodotIO { public byte[] file_read(int id, int bytes) { if (!streams.containsKey(id)) { - System.out.printf("file_read: Can't read invalid file id: %d\n", id); + + Log.w(TAG, "file_read: Can't read invalid file id: " + id); return new byte[0]; } @@ -218,7 +226,7 @@ public class GodotIO { r = ad.is.read(buf1); } catch (IOException e) { - System.out.printf("Exception on file_read: %s\n", e); + Log.w(TAG, "Exception on file_read: " + e); return new byte[bytes]; } @@ -243,7 +251,8 @@ public class GodotIO { public void file_close(int id) { if (!streams.containsKey(id)) { - System.out.printf("file_close: Can't close invalid file id: %d\n", id); + + Log.w(TAG, "file_close: Can't close invalid file id: " + id); return; } @@ -280,7 +289,7 @@ public class GodotIO { } } catch (IOException e) { - System.out.printf("Exception on dir_open: %s\n", e); + Log.w(TAG, "Exception on dir_open: " + e); return -1; } @@ -293,7 +302,7 @@ public class GodotIO { public boolean dir_is_dir(int id) { if (!dirs.containsKey(id)) { - System.out.printf("dir_next: invalid dir id: %d\n", id); + Log.w(TAG, "dir_next: invalid dir id: " + id); return false; } AssetDir ad = dirs.get(id); @@ -320,7 +329,8 @@ public class GodotIO { public String dir_next(int id) { if (!dirs.containsKey(id)) { - System.out.printf("dir_next: invalid dir id: %d\n", id); + + Log.w(TAG, "dir_next: invalid dir id: " + id); return ""; } @@ -339,7 +349,8 @@ public class GodotIO { public void dir_close(int id) { if (!dirs.containsKey(id)) { - System.out.printf("dir_close: invalid dir id: %d\n", id); + + Log.w(TAG, "dir_next: invalid dir id: " + id); return; } @@ -368,9 +379,7 @@ public class GodotIO { int audioFormat = AudioFormat.ENCODING_PCM_16BIT; int frameSize = 4; - System.out.printf("audioInit: initializing audio:\n"); - - //Log.v("Godot", "Godot audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + ((float)sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer"); + Log.d(TAG, "audioInit: initializing audio: "); // Let the user pick a larger buffer if they really want -- but ye // gods they probably shouldn't, the minimums are horrifyingly high @@ -396,7 +405,7 @@ public class GodotIO { } }); - // I'd take REALTIME if I could get it! + // Max priority mAudioThread.setPriority(Thread.MAX_PRIORITY); mAudioThread.start(); } @@ -410,10 +419,10 @@ public class GodotIO { try { Thread.sleep(1); } catch (InterruptedException e) { - // Nom nom + // Action interrupted, nothing to do } } else { - Log.w("Godot", "Godot audio: error return from write(short)"); + Log.w(TAG, "Godot audio: error return from write(short)"); return; } } @@ -424,11 +433,10 @@ public class GodotIO { try { mAudioThread.join(); } catch (Exception e) { - Log.v("Godot", "Problem stopping audio thread: " + e); + Log.v(TAG, "Problem stopping audio thread: " + e); } mAudioThread = null; - //Log.v("Godot", "Finished waiting for audio thread"); } if (mAudioTrack != null) { @@ -452,11 +460,11 @@ public class GodotIO { public int openURI(String p_uri) { try { - Log.v("MyApp", "TRYING TO OPEN URI: " + p_uri); + Log.v(TAG, "Trying to open uri: " + p_uri); String path = p_uri; String type = ""; if (path.startsWith("/")) { - //absolute path to filesystem, prepend file:// + // Absolute path to filesystem, prepend file:// path = "file://" + path; if (p_uri.endsWith(".png") || p_uri.endsWith(".jpg") || p_uri.endsWith(".gif") || p_uri.endsWith(".webp")) { @@ -508,8 +516,6 @@ public class GodotIO { if (edit != null) edit.showKeyboard(p_existing_text); - //InputMethodManager inputMgr = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE); - //inputMgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); }; public void hideKeyboard() { @@ -567,7 +573,7 @@ public class GodotIO { mediaPlayer.prepare(); mediaPlayer.start(); } catch (IOException e) { - System.out.println("IOError while playing video"); + Log.w(TAG, "IOError while playing video"); } } @@ -605,7 +611,6 @@ public class GodotIO { String what = ""; switch (idx) { case SYSTEM_DIR_DESKTOP: { - //what=Environment.DIRECTORY_DOCUMENTS; what = Environment.DIRECTORY_DOWNLOADS; } break; case SYSTEM_DIR_DCIM: { @@ -614,7 +619,6 @@ public class GodotIO { } break; case SYSTEM_DIR_DOCUMENTS: { what = Environment.DIRECTORY_DOWNLOADS; - //what=Environment.DIRECTORY_DOCUMENTS; } break; case SYSTEM_DIR_DOWNLOADS: { what = Environment.DIRECTORY_DOWNLOADS; diff --git a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java index 206af3b45ca..91f21b6edb2 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java +++ b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java @@ -30,7 +30,6 @@ package org.godotengine.godot; import android.app.Activity; -import android.util.Log; import org.godotengine.godot.payments.PaymentsManager; import org.json.JSONException; @@ -92,7 +91,6 @@ public class GodotPaymentV3 extends Godot.SingletonBase { } public void callbackSuccessProductMassConsumed(String ticket, String signature, String sku) { - Log.d(this.getClass().getName(), "callbackSuccessProductMassConsumed > " + ticket + "," + signature + "," + sku); GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[] { ticket, signature, sku }); } diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java index 90826de5535..8dae0d8fbd2 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotView.java +++ b/platform/android/java/src/org/godotengine/godot/GodotView.java @@ -278,7 +278,6 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener { }; int source = event.getSource(); - //Log.e(TAG, String.format("Key down! source %d, device %d, joystick %d, %d, %d", event.getDeviceId(), source, (source & InputDevice.SOURCE_JOYSTICK), (source & InputDevice.SOURCE_DPAD), (source & InputDevice.SOURCE_GAMEPAD))); if ((source & InputDevice.SOURCE_JOYSTICK) != 0 || (source & InputDevice.SOURCE_DPAD) != 0 || (source & InputDevice.SOURCE_GAMEPAD) != 0) { @@ -287,8 +286,6 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener { int button = get_godot_button(keyCode); int device = find_joy_device(event.getDeviceId()); - //Log.e(TAG, String.format("joy button down! button %x, %d, device %d", keyCode, button, device)); - GodotLib.joybutton(device, button, true); return true; @@ -309,14 +306,12 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener { for (int i = 0; i < joy.axes.size(); i++) { InputDevice.MotionRange range = joy.axes.get(i); float value = (event.getAxisValue(range.getAxis()) - range.getMin()) / range.getRange() * 2.0f - 1.0f; - //Log.e(TAG, String.format("axis event: %d, value %f", i, value)); GodotLib.joyaxis(device_id, i, value); } for (int i = 0; i < joy.hats.size(); i += 2) { int hatX = Math.round(event.getAxisValue(joy.hats.get(i).getAxis())); int hatY = Math.round(event.getAxisValue(joy.hats.get(i + 1).getAxis())); - //Log.e(TAG, String.format("HAT EVENT %d, %d", hatX, hatY)); GodotLib.joyhat(device_id, hatX, hatY); } return true; @@ -598,7 +593,6 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener { if (egl.eglGetConfigAttrib(display, config, attribute, value)) { Log.w(TAG, String.format(" %s: %d\n", name, value[0])); } else { - // Log.w(TAG, String.format(" %s: failed\n", name)); while (egl.eglGetError() != EGL10.EGL_SUCCESS) ; } diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java index 303009ace37..2a82bc037ac 100644 --- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java +++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java @@ -85,7 +85,6 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene @Override public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) { - //Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after); for (int i = 0; i < count; i++) { GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true); @@ -95,7 +94,6 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene @Override public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) { - //Log.d(TAG, "onTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",before: " + before); for (int i = start; i < start + count; i++) { int ch = pCharSequence.charAt(i); @@ -111,11 +109,6 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene for (int i = this.mOriginText.length(); i > 0; i--) { GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true); GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false); - /* - if (BuildConfig.DEBUG) { - Log.d(TAG, "deleteBackward"); - } - */ } String text = pTextView.getText().toString(); @@ -133,11 +126,6 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene GodotLib.key(0, ch, true); GodotLib.key(0, ch, false); } - /* - if (BuildConfig.DEBUG) { - Log.d(TAG, "insertText(" + insertText + ")"); - } - */ } if (pActionID == EditorInfo.IME_ACTION_DONE) { @@ -145,12 +133,4 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene } return false; } - - // =========================================================== - // Methods - // =========================================================== - - // =========================================================== - // Inner and Anonymous Classes - // =========================================================== } diff --git a/platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java b/platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java index a1418c58998..670d053bde0 100644 --- a/platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java +++ b/platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.Queue; public class InputManagerV9 implements InputManagerCompat { - private static final String LOG_TAG = "InputManagerV9"; + private static final String TAG = "InputManagerV9"; private static final int MESSAGE_TEST_FOR_DISCONNECT = 101; private static final long CHECK_ELAPSED_TIME = 3000L; @@ -175,7 +175,7 @@ public class InputManagerV9 implements InputManagerCompat { mListener.onInputDeviceRemoved(mId); break; default: - Log.e(LOG_TAG, "Unknown Message Type"); + Log.e(TAG, "Unknown Message Type"); break; } // dump this runnable back in the queue diff --git a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java index 6f2a97164ac..fecca360f8b 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java @@ -47,19 +47,15 @@ abstract public class ConsumeTask { } public void consume(final String sku) { - // Log.d("XXX", "Consuming product " + sku); PaymentsCache pc = new PaymentsCache(context); Boolean isBlocked = pc.getConsumableFlag("block", sku); String _token = pc.getConsumableValue("token", sku); - // Log.d("XXX", "token " + _token); if (!isBlocked && _token == null) { - // _token = "inapp:"+context.getPackageName()+":android.test.purchased"; - // Log.d("XXX", "Consuming product " + sku + " with token " + _token); + // Consuming product, nothing to do } else if (!isBlocked) { - // Log.d("XXX", "It is not blocked ¿?"); return; } else if (_token == null) { - // Log.d("XXX", "No token available"); + // Token is not available this.error("No token for sku:" + sku); return; } @@ -69,9 +65,8 @@ abstract public class ConsumeTask { @Override protected String doInBackground(String... params) { try { - // Log.d("XXX", "Requesting to release item."); + // Requesting to release item int response = mService.consumePurchase(3, context.getPackageName(), token); - // Log.d("XXX", "release response code: " + response); if (response == 0 || response == 8) { return null; } diff --git a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java index 7f6514087a6..3de40ce6c1c 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java @@ -37,7 +37,7 @@ import android.os.RemoteException; import android.util.Log; abstract public class GenericConsumeTask extends AsyncTask { - + private static String TAG = "GenericConsumeTask"; private Context context; private IInAppBillingService mService; @@ -58,14 +58,12 @@ abstract public class GenericConsumeTask extends AsyncTask responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { - Log.d("godot", "response = " + thisResponse); + Log.d(TAG, "response = " + thisResponse); godotPaymentV3.addSkuDetail(thisResponse); } } catch (RemoteException e) { diff --git a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java index d4926c75151..ab571c25680 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java @@ -49,6 +49,8 @@ import android.util.Log; abstract public class PurchaseTask { + private static String TAG = "PurchaseTask"; + private Activity context; private IInAppBillingService mService; @@ -60,21 +62,16 @@ abstract public class PurchaseTask { private boolean isLooping = false; public void purchase(final String sku, final String transactionId) { - Log.d("XXX", "Starting purchase for: " + sku); + Log.d(TAG, "Starting purchase for: " + sku); PaymentsCache pc = new PaymentsCache(context); Boolean isBlocked = pc.getConsumableFlag("block", sku); - // if(isBlocked){ - // Log.d("XXX", "Is awaiting payment confirmation"); - // error("Awaiting payment confirmation"); - // return; - // } + final String hash = transactionId; Bundle buyIntentBundle; try { buyIntentBundle = mService.getBuyIntent(3, context.getApplicationContext().getPackageName(), sku, "inapp", hash); } catch (RemoteException e) { - // Log.d("XXX", "Error: " + e.getMessage()); error(e.getMessage()); return; } @@ -87,7 +84,7 @@ abstract public class PurchaseTask { } else if (rc instanceof Long) { responseCode = (int)((Long)rc).longValue(); } - // Log.d("XXX", "Buy intent response code: " + responseCode); + if (responseCode == 1 || responseCode == 3 || responseCode == 4) { canceled(); return; @@ -100,13 +97,6 @@ abstract public class PurchaseTask { PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); pc.setConsumableValue("validation_hash", sku, hash); try { - if (context == null) { - // Log.d("XXX", "No context!"); - } - if (pendingIntent == null) { - // Log.d("XXX", "No pending intent"); - } - // Log.d("XXX", "Starting activity for purchase!"); context.startIntentSenderForResult( pendingIntent.getIntentSender(), PaymentsManager.REQUEST_CODE_FOR_PURCHASE, diff --git a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java index 0373ea9dc35..4091bfcf047 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java @@ -46,6 +46,7 @@ import android.util.Log; abstract public class ReleaseAllConsumablesTask { + private static final String TAG = "ReleaseAllConsumablesTask"; private Context context; private IInAppBillingService mService; @@ -56,13 +57,12 @@ abstract public class ReleaseAllConsumablesTask { public void consumeItAll() { try { - // Log.d("godot", "consumeItall for " + context.getPackageName()); Bundle bundle = mService.getPurchases(3, context.getPackageName(), "inapp", null); + // TODO: + // Check if this loop is useful and remove it if not for (String key : bundle.keySet()) { Object value = bundle.get(key); - // Log.d("godot", String.format("%s %s (%s)", key, - // value.toString(), value.getClass().getName())); } if (bundle.getInt("RESPONSE_CODE") == 0) { @@ -71,12 +71,10 @@ abstract public class ReleaseAllConsumablesTask { final ArrayList mySignatures = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST"); if (myPurchases == null || myPurchases.size() == 0) { - // Log.d("godot", "No purchases!"); notRequired(); return; } - // Log.d("godot", "# products to be consumed:" + myPurchases.size()); for (int i = 0; i < myPurchases.size(); i++) { try { @@ -85,7 +83,6 @@ abstract public class ReleaseAllConsumablesTask { String sku = inappPurchaseData.getString("productId"); String token = inappPurchaseData.getString("purchaseToken"); String signature = mySignatures.get(i); - // Log.d("godot", "A punto de consumir un item con token:" + token + "\n" + receipt); new GenericConsumeTask(context, mService, sku, receipt, signature, token) { @Override @@ -100,7 +97,7 @@ abstract public class ReleaseAllConsumablesTask { } } } catch (Exception e) { - Log.d("godot", "Error releasing products:" + e.getClass().getName() + ":" + e.getMessage()); + Log.d(TAG, "Error releasing products:" + e.getClass().getName() + ":" + e.getMessage()); } } diff --git a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java index 53f1dd3d095..1d8da3773a6 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java @@ -79,14 +79,9 @@ abstract public class ValidateTask { param.put("ticket", pc.getConsumableValue("ticket", sku)); param.put("purchaseToken", pc.getConsumableValue("token", sku)); param.put("sku", sku); - // Log.d("XXX", "Haciendo request a " + url); - // Log.d("XXX", "ticket: " + pc.getConsumableValue("ticket", sku)); - // Log.d("XXX", "purchaseToken: " + pc.getConsumableValue("token", sku)); - // Log.d("XXX", "sku: " + sku); param.put("package", context.getApplicationContext().getPackageName()); HttpRequester requester = new HttpRequester(); String jsonResponse = requester.post(param); - // Log.d("XXX", "Validation response:\n"+jsonResponse); return jsonResponse; } diff --git a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java index 8e8cc421e4d..9757192adcf 100644 --- a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java +++ b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java @@ -73,17 +73,19 @@ import android.util.Log; */ public class HttpRequester { + private static String TAG = "HttpRequester"; + private Context context; - private static final int TTL = 600000; // 10 minutos + private static final int TTL = 600000; // 10 minutes private long cttl = 0; public HttpRequester() { - // Log.d("XXX", "Creando http request sin contexto"); + // Creating a HTTP request without context, nothing to do } public HttpRequester(Context context) { + // Creating a HTTP request with context this.context = context; - // Log.d("XXX", "Creando http request con contexto"); } public String post(RequestParams params) { @@ -99,7 +101,7 @@ public class HttpRequester { public String get(RequestParams params) { String response = getResponseFromCache(params.getUrl()); if (response == null) { - // Log.d("XXX", "Cache miss!"); + // Cache miss, trying to get data HttpGet httpget = new HttpGet(params.getUrl()); long timeInit = new Date().getTime(); response = request(httpget); @@ -111,14 +113,13 @@ public class HttpRequester { saveResponseIntoCache(params.getUrl(), response); } } - Log.d("XXX", "Req: " + params.getUrl()); - Log.d("XXX", "Resp: " + response); + Log.d(TAG, "Req: " + params.getUrl()); + Log.d(TAG, "Resp: " + response); return response; } private String request(HttpUriRequest request) { - // Log.d("XXX", "Haciendo request a: " + request.getURI() ); - Log.d("PPP", "Haciendo request a: " + request.getURI()); + Log.d(TAG, "Sending request to uri: " + request.getURI()); long init = new Date().getTime(); HttpClient httpclient = getNewHttpClient(); HttpParams httpParameters = httpclient.getParams(); @@ -127,21 +128,19 @@ public class HttpRequester { HttpConnectionParams.setTcpNoDelay(httpParameters, true); try { HttpResponse response = httpclient.execute(request); - Log.d("PPP", "Fin de request (" + (new Date().getTime() - init) + ") a: " + request.getURI()); - // Log.d("XXX1", "Status:" + response.getStatusLine().toString()); + Log.d(TAG, "Fin de request (" + (new Date().getTime() - init) + ") a: " + request.getURI()); if (response.getStatusLine().getStatusCode() == 200) { String strResponse = EntityUtils.toString(response.getEntity()); - // Log.d("XXX2", strResponse); return strResponse; } else { - Log.d("XXX3", "Response status code:" + response.getStatusLine().getStatusCode() + "\n" + EntityUtils.toString(response.getEntity())); + Log.d(TAG, "Response status code:" + response.getStatusLine().getStatusCode() + "\n" + EntityUtils.toString(response.getEntity())); return null; } } catch (ClientProtocolException e) { - Log.d("XXX3", e.getMessage()); + Log.d(TAG, e.getMessage()); } catch (IOException e) { - Log.d("XXX4", e.getMessage()); + Log.d(TAG, e.getMessage()); } return null; } @@ -192,7 +191,6 @@ public class HttpRequester { public void saveResponseIntoCache(String request, String response) { if (context == null) { - // Log.d("XXX", "No context, cache failed!"); return; } SharedPreferences sharedPref = context.getSharedPreferences("http_get_cache", Context.MODE_PRIVATE); @@ -204,13 +202,13 @@ public class HttpRequester { public String getResponseFromCache(String request) { if (context == null) { - Log.d("XXX", "No context, cache miss"); + Log.d(TAG, "No context, cache miss"); return null; } SharedPreferences sharedPref = context.getSharedPreferences("http_get_cache", Context.MODE_PRIVATE); long ttl = getResponseTtl(request); if (ttl == 0l || (new Date().getTime() - ttl) > 0l) { - Log.d("XXX", "Cache invalid ttl:" + ttl + " vs now:" + new Date().getTime()); + Log.d(TAG, "Cache invalid ttl:" + ttl + " vs now:" + new Date().getTime()); return null; } return sharedPref.getString("request_" + Crypt.md5(request), null); diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index 2017bc825c4..e24d956a58a 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -553,7 +553,6 @@ bool JavaClassWrapper::_get_type_sig(JNIEnv *env, jobject obj, uint32_t &sig, St jstring name2 = (jstring)env->CallObjectMethod(obj, Class_getName); String str_type = env->GetStringUTFChars(name2, NULL); - print_line("name: " + str_type); env->DeleteLocalRef(name2); uint32_t t = 0; @@ -1116,7 +1115,7 @@ Ref JavaClassWrapper::wrap(const String &p_class) { } if (!valid) { - print_line("Method Can't be bound (unsupported arguments): " + p_class + "::" + str_method); + print_line("Method can't be bound (unsupported arguments): " + p_class + "::" + str_method); env->DeleteLocalRef(obj); env->DeleteLocalRef(param_types); continue; @@ -1129,7 +1128,7 @@ Ref JavaClassWrapper::wrap(const String &p_class) { String strsig; uint32_t sig = 0; if (!_get_type_sig(env, return_type, sig, strsig)) { - print_line("Method Can't be bound (unsupported return type): " + p_class + "::" + str_method); + print_line("Method can't be bound (unsupported return type): " + p_class + "::" + str_method); env->DeleteLocalRef(obj); env->DeleteLocalRef(param_types); env->DeleteLocalRef(return_type); @@ -1139,8 +1138,6 @@ Ref JavaClassWrapper::wrap(const String &p_class) { signature += strsig; mi.return_type = sig; - print_line("METHOD: " + str_method + " SIG: " + signature + " static: " + itos(mi._static)); - bool discard = false; for (List::Element *E = java_class->methods[str_method].front(); E; E = E->next()) { @@ -1172,11 +1169,9 @@ Ref JavaClassWrapper::wrap(const String &p_class) { if (new_likeliness > existing_likeliness) { java_class->methods[str_method].erase(E); - print_line("replace old"); break; } else { discard = true; - print_line("old is better"); } } @@ -1194,9 +1189,6 @@ Ref JavaClassWrapper::wrap(const String &p_class) { env->DeleteLocalRef(obj); env->DeleteLocalRef(param_types); env->DeleteLocalRef(return_type); - - //args[i] = _jobject_to_variant(env, obj); - // print_line("\targ"+itos(i)+": "+Variant::get_type_name(args[i].get_type())); }; env->DeleteLocalRef(methods); @@ -1213,7 +1205,7 @@ Ref JavaClassWrapper::wrap(const String &p_class) { jstring name = (jstring)env->CallObjectMethod(obj, Field_getName); String str_field = env->GetStringUTFChars(name, NULL); env->DeleteLocalRef(name); - print_line("FIELD: " + str_field); + int mods = env->CallIntMethod(obj, Field_getModifiers); if ((mods & 0x8) && (mods & 0x10) && (mods & 0x1)) { //static final public! diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 1cc70c1101b..ee9d44b69fb 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -238,9 +238,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { jclass c = env->GetObjectClass(obj); bool array; String name = _get_class_name(env, c, &array); - //print_line("name is " + name + ", array "+Variant(array)); - print_line("ARGNAME: " + name); if (name == "java.lang.String") { return String::utf8(env->GetStringUTFChars((jstring)obj, NULL)); @@ -249,8 +247,9 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { if (name == "[Ljava.lang.String;") { jobjectArray arr = (jobjectArray)obj; + int stringCount = env->GetArrayLength(arr); - //print_line("String array! " + String::num(stringCount)); + DVector sarr; for (int i = 0; i < stringCount; i++) { @@ -379,7 +378,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { Array vals = _jobject_to_variant(env, arr); env->DeleteLocalRef(arr); - //print_line("adding " + String::num(keys.size()) + " to Dictionary!"); for (int i = 0; i < keys.size(); i++) { ret[keys[i]] = vals[i]; @@ -410,7 +408,6 @@ class JNISingleton : public Object { public: virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { - //print_line("attempt to call "+String(p_method)); ERR_FAIL_COND_V(!instance, Variant()); r_error.error = Variant::CallError::CALL_OK; @@ -418,7 +415,6 @@ public: Map::Element *E = method_map.find(p_method); if (!E) { - print_line("no exists"); r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; return Variant(); } @@ -426,7 +422,6 @@ public: int ac = E->get().argtypes.size(); if (ac < p_argcount) { - print_line("fewargs"); r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument = ac; return Variant(); @@ -434,7 +429,6 @@ public: if (ac > p_argcount) { - print_line("manyargs"); r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.argument = ac; return Variant(); @@ -463,7 +457,6 @@ public: ERR_FAIL_COND_V(res != 0, Variant()); - //print_line("argcount "+String::num(p_argcount)); List to_erase; for (int i = 0; i < p_argcount; i++) { @@ -473,26 +466,21 @@ public: to_erase.push_back(vr.obj); } - //print_line("calling method!!"); - Variant ret; switch (E->get().ret_type) { case Variant::NIL: { - //print_line("call void"); env->CallVoidMethodA(instance, E->get().method, v); } break; case Variant::BOOL: { ret = env->CallBooleanMethodA(instance, E->get().method, v) == JNI_TRUE; - //print_line("call bool"); } break; case Variant::INT: { ret = env->CallIntMethodA(instance, E->get().method, v); - //print_line("call int"); } break; case Variant::REAL: { @@ -543,7 +531,6 @@ public: case Variant::DICTIONARY: { - //print_line("call dictionary"); jobject obj = env->CallObjectMethodA(instance, E->get().method, v); ret = _jobject_to_variant(env, obj); env->DeleteLocalRef(obj); @@ -551,7 +538,6 @@ public: } break; default: { - print_line("failure.."); env->PopLocalFrame(NULL); ERR_FAIL_V(Variant()); } break; @@ -563,7 +549,6 @@ public: } env->PopLocalFrame(NULL); - //print_line("success"); return ret; } @@ -759,8 +744,6 @@ static void _alert(const String &p_message, const String &p_title) { JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *env, jobject obj, jobject activity, jboolean p_need_reload_hook, jobjectArray p_cmdline, jobject p_asset_manager) { - __android_log_print(ANDROID_LOG_INFO, "godot", "**INIT EVENT! - %p\n", env); - initialized = true; JavaVM *jvm; @@ -769,8 +752,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en _godot_instance = env->NewGlobalRef(activity); // _godot_instance=activity; - __android_log_print(ANDROID_LOG_INFO, "godot", "***************** HELLO FROM JNI!!!!!!!!"); - { //setup IO Object @@ -778,17 +759,12 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en if (cls) { cls = (jclass)env->NewGlobalRef(cls); - __android_log_print(ANDROID_LOG_INFO, "godot", "*******CLASS FOUND!!!"); } - __android_log_print(ANDROID_LOG_INFO, "godot", "STEP2, %p", cls); jfieldID fid = env->GetStaticFieldID(cls, "io", "Lorg/godotengine/godot/GodotIO;"); - __android_log_print(ANDROID_LOG_INFO, "godot", "STEP3 %i", fid); jobject ob = env->GetStaticObjectField(cls, fid); - __android_log_print(ANDROID_LOG_INFO, "godot", "STEP4, %p", ob); jobject gob = env->NewGlobalRef(ob); - __android_log_print(ANDROID_LOG_INFO, "godot", "STEP4.5, %p", gob); godot_io = gob; _on_video_init = env->GetMethodID(cls, "onVideoInit", "(Z)V"); @@ -841,10 +817,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en jstring string = (jstring)env->GetObjectArrayElement(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); + // Nothing to do } 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; } @@ -854,64 +828,40 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en } } - __android_log_print(ANDROID_LOG_INFO, "godot", "CMDLINE LEN %i - APK EXPANSION %I\n", cmdlen, int(use_apk_expansion)); - os_android = new OS_Android(_gfx_init_func, env, _open_uri, _get_data_dir, _get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk, _set_screen_orient, _get_unique_id, _get_system_dir, _play_video, _is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, _alert, use_apk_expansion); os_android->set_need_reload_hooks(p_need_reload_hook); char wd[500]; getcwd(wd, 500); - __android_log_print(ANDROID_LOG_INFO, "godot", "test construction %i\n", tst.a); - __android_log_print(ANDROID_LOG_INFO, "godot", "running from dir %s\n", wd); - - __android_log_print(ANDROID_LOG_INFO, "godot", "**SETUP"); - #if 0 char *args[]={"-test","render",NULL}; - __android_log_print(ANDROID_LOG_INFO,"godot","pre asdasd setup..."); Error err = Main::setup("apk",2,args,false); #else Error err = Main::setup("apk", cmdlen, (char **)cmdline, false); #endif if (err != OK) { - __android_log_print(ANDROID_LOG_INFO, "godot", "*****UNABLE TO SETUP"); - return; //should exit instead and print the error } - __android_log_print(ANDROID_LOG_INFO, "godot", "*****SETUP OK"); - //video driver is determined here, because once initialized, it cant be changed String vd = Globals::get_singleton()->get("display/driver"); env->CallVoidMethod(_godot_instance, _on_video_init, (jboolean) true); - __android_log_print(ANDROID_LOG_INFO, "godot", "**START"); - input_mutex = Mutex::create(); suspend_mutex = Mutex::create(); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jobject obj, jint width, jint height, jboolean reload) { - __android_log_print(ANDROID_LOG_INFO, "godot", "^_^_^_^_^ resize %lld, %i, %i\n", Thread::get_caller_ID(), width, height); if (os_android) os_android->set_display_size(Size2(width, height)); - - /*input_mutex->lock(); - resized=true; - if (reload) - resized_reload=true; - new_size=Size2(width,height); - input_mutex->unlock();*/ } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jobject obj, bool p_32_bits) { - __android_log_print(ANDROID_LOG_INFO, "godot", "^_^_^_^_^ newcontext %lld\n", Thread::get_caller_ID()); - if (os_android) { os_android->set_context_is_16_bits(!p_32_bits); } @@ -926,7 +876,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_quit(JNIEnv *env, job input_mutex->lock(); quit_request = true; - print_line("BACK PRESSED"); input_mutex->unlock(); } @@ -934,8 +883,6 @@ static void _initialize_java_modules() { String modules = Globals::get_singleton()->get("android/modules"); Vector mods = modules.split(",", false); - print_line("ANDROID MODULES : " + modules); - __android_log_print(ANDROID_LOG_INFO, "godot", "mod count: %i", mods.size()); if (mods.size()) { @@ -958,7 +905,7 @@ static void _initialize_java_modules() { String m = mods[i]; //jclass singletonClass = env->FindClass(m.utf8().get_data()); - print_line("LOADING MODULE: " + m); + print_line("Loading module: " + m); jstring strClassName = env->NewStringUTF(m.utf8().get_data()); jclass singletonClass = (jclass)env->CallObjectMethod(cls, findClass, strClassName); @@ -969,7 +916,6 @@ static void _initialize_java_modules() { } //singletonClass=(jclass)env->NewGlobalRef(singletonClass); - __android_log_print(ANDROID_LOG_INFO, "godot", "****^*^*?^*^*class data %x", singletonClass); jmethodID initialize = env->GetStaticMethodID(singletonClass, "initialize", "(Landroid/app/Activity;)Lorg/godotengine/godot/Godot$SingletonBase;"); if (!initialize) { @@ -978,7 +924,6 @@ static void _initialize_java_modules() { ERR_CONTINUE(!initialize); } jobject obj = env->CallStaticObjectMethod(singletonClass, initialize, _godot_instance); - __android_log_print(ANDROID_LOG_INFO, "godot", "****^*^*?^*^*class instance %x", obj); jobject gob = env->NewGlobalRef(obj); } } @@ -988,8 +933,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job ThreadAndroid::setup_thread(); - //__android_log_print(ANDROID_LOG_INFO,"godot","**STEP EVENT! - %p-%i\n",env,Thread::get_caller_ID()); - suspend_mutex->lock(); input_mutex->lock(); //first time step happens, initialize @@ -1066,7 +1009,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job jclass cls = env->FindClass("org/godotengine/godot/Godot"); jmethodID _finish = env->GetMethodID(cls, "forceQuit", "()V"); env->CallVoidMethod(_godot_instance, _finish); - __android_log_print(ANDROID_LOG_INFO, "godot", "**FINISH REQUEST!!! - %p-%i\n", env, Thread::get_caller_ID()); } suspend_mutex->unlock(); @@ -1074,8 +1016,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch(JNIEnv *env, jobject obj, jint ev, jint pointer, jint count, jintArray positions) { - //__android_log_print(ANDROID_LOG_INFO,"godot","**TOUCH EVENT! - %p-%i\n",env,Thread::get_caller_ID()); - Vector points; for (int i = 0; i < count; i++) { @@ -1347,7 +1287,6 @@ static unsigned int android_get_keysym(unsigned int p_code) { for (int i = 0; _ak_to_keycode[i].keysym != KEY_UNKNOWN; i++) { if (_ak_to_keycode[i].keycode == p_code) { - //print_line("outcode: " + _ak_to_keycode[i].keysym); return _ak_to_keycode[i].keysym; } @@ -1617,11 +1556,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_method(JNIEnv *env, j cs += ")"; cs += get_jni_sig(retval); jclass cls = env->GetObjectClass(s->get_instance()); - print_line("METHOD: " + mname + " sig: " + cs); jmethodID mid = env->GetMethodID(cls, mname.ascii().get_data(), cs.ascii().get_data()); if (!mid) { - print_line("FAILED GETTING METHOID " + mname); + print_line("Failed getting method: " + mname); } s->add_method(mname, mid, types, get_jni_type(retval)); @@ -1672,24 +1610,17 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * int count = env->GetArrayLength(params); Variant args[VARIANT_ARG_MAX]; - //print_line("Java->GD call: "+obj->get_type()+"::"+str_method+" argc "+itos(count)); - for (int i = 0; i < MIN(count, VARIANT_ARG_MAX); i++) { jobject obj = env->GetObjectArrayElement(params, i); if (obj) args[i] = _jobject_to_variant(env, obj); env->DeleteLocalRef(obj); - - // print_line("\targ"+itos(i)+": "+Variant::get_type_name(args[i].get_type())); }; obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4]); - // something + env->PopLocalFrame(NULL); } -//Main::cleanup(); - -//return os.get_exit_code(); #endif