From eacf83594a5bf063665fdecc6c438673dc9f2cf6 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Fri, 3 Jul 2020 19:02:17 +0300 Subject: [PATCH] Android: check for debug mode before fetching extraappparams In pre Qt 5.14, the assets folder used to have the file "--Added-by-androiddeployqt--/debugger.command", that indicate debug mode, however, in Qt 5.14+ the assets are compressed into one file, so this current check is obsolete. Qt Creator uses extraappparams to pass QML debugger args, without it the debugger won't start. Pick-to: 5.15 Task-number: QTCREATORBUG-24155 Change-Id: Ib3037f4dc8c55af6932d598c6491a046efe13033 Reviewed-by: Andy Shaw Reviewed-by: Ulf Hermann Reviewed-by: Alessandro Portale --- .../qtproject/qt5/android/QtActivityDelegate.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java index a7c5802c43..c8bf7dc534 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -45,6 +45,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.AssetManager; @@ -711,12 +712,9 @@ public class QtActivityDelegate Bundle extras = m_activity.getIntent().getExtras(); if (extras != null) { try { - // do NOT remove !!!! - final String dc = "--Added-by-androiddeployqt--/debugger.command"; - new BufferedReader(new InputStreamReader(m_activity.getAssets().open(dc))).readLine(); - // do NOT remove !!!! - // The previous lines are needed to check if the debug mode is enabled. - // We are not allowed to use extraenvvars or extraappparams in a non debuggable environment. + final boolean isDebuggable = (m_activity.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; + if (!isDebuggable) + throw new Exception(); if (extras.containsKey("extraenvvars")) { try { @@ -734,6 +732,8 @@ public class QtActivityDelegate } } } catch (Exception e) { + Log.e(QtNative.QtTAG, "Not in debug mode! It is not allowed to use " + + "extra arguments in non-debug mode."); // This is not an error, so keep it silent // e.printStackTrace(); }