diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 3c7f59703e..efb7abbb93 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -63,8 +63,6 @@ - - diff --git a/android/build.gradle b/android/build.gradle index c53eac1ed0..d2e3a3a183 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -457,9 +457,7 @@ task cleanDependencies(type: Delete) { task generateAssetsFileList() { doLast { def assetsPath = "${appDir}/src/main/assets/" - //def assetsPath = "/Users/cduarte/dev/workspace-hifi/hifiparallel/build_android_hifiqt59/interface/apk/assets/" def addedByAndroidDeployQtName = "--Added-by-androiddeployqt--/" - //def addedByAndroidDeployQtName = "--Added-by-androiddeployqt--/" def addedByAndroidDeployQtPath = assetsPath + addedByAndroidDeployQtName @@ -468,7 +466,6 @@ task generateAssetsFileList() { throw new GradleScriptException("Failed to create directory " + addedByAndroidDeployQtPath, null); } def outputFilename = "/qt_cache_pregenerated_file_list" - //def outputFilename = "/qt_cache_pregenerated_file_list2" def outputFile = new File(addedByAndroidDeployQtPath + outputFilename); Map> directoryContents = new TreeMap<>(); @@ -483,10 +480,6 @@ task generateAssetsFileList() { fileName += "/" } - /*println ("full: [" + file.getAbsolutePath() + "]\n\t" - + "path: [" + pathName + "]\n\t" - + "name: [" + fileName + "]\n\t");*/ - if (!directoryContents.containsKey(pathName)) { directoryContents[pathName] = new ArrayList() } @@ -497,16 +490,12 @@ task generateAssetsFileList() { DataOutputStream fos = new DataOutputStream(new FileOutputStream(outputFile)); for (Map.Entry> e: directoryContents.entrySet()) { def entryList = e.getValue() - //stream << it.key() << entryList.size(); fos.writeInt(e.key.length()*2); // 2 bytes per char fos.writeChars(e.key); fos.writeInt(entryList.size()); - //println ("dir: " + e.key + " size: " + entryList.size()); for (String entry: entryList) { fos.writeInt(entry.length()*2); fos.writeChars(entry); - //println("\tentry: " + entry); - //stream << entry; } } fos.close(); diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 23358092ca..08d5778f18 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -12,7 +12,7 @@ function(JOIN VALUES GLUE OUTPUT) endfunction() -if ANDROID OR (NOT DEV_BUILD) +if (ANDROID OR NOT DEV_BUILD) set(INTERFACE_QML_QRC ${CMAKE_CURRENT_BINARY_DIR}/qml.qrc) generate_qrc(OUTPUT ${INTERFACE_QML_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources GLOBS *.qml *.qss *.js *.html *.ttf *.gif *.svg *.png *.jpg) endif() @@ -82,7 +82,7 @@ qt5_wrap_ui(QT_UI_HEADERS "${QT_UI_FILES}") # add them to the interface source files set(INTERFACE_SRCS ${INTERFACE_SRCS} "${QT_UI_HEADERS}" "${QT_RESOURCES}") -if (NOT DEV_BUILD) +if (ANDROID OR NOT DEV_BUILD) list(APPEND INTERFACE_SRCS ${INTERFACE_QML_QRC}) endif() @@ -267,6 +267,8 @@ include_directories("${PROJECT_SOURCE_DIR}/src") if (ANDROID) #set(ANDROID_PLATFORM_QT_LIBRARIES Qt5::WebView) + find_library(ANDROID_LOG_LIB log) + target_link_libraries(${TARGET_NAME} ${ANDROID_LOG_LIB}) else() set(NON_ANDROID_PLATFORM_QT_LIBRARIES Qt5::WebEngine) endif () diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e5ad9792f8..65005d0605 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -212,6 +212,7 @@ #include "webbrowser/WebBrowserSuggestionsEngine.h" #ifdef ANDROID #include +#include #endif // On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU // FIXME seems to be broken. @@ -556,7 +557,34 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt if (!logMessage.isEmpty()) { #ifdef Q_OS_WIN OutputDebugStringA(logMessage.toLocal8Bit().constData()); - OutputDebugStringA("\n"); + OutputDebugStringA("\n");i +#elif defined Q_OS_ANDROID + QString report=message; + if (context.file && !QString(context.file).isEmpty()) { + report+=" at "; + report+=QString(context.file); + report+=" : "; + report+=QString::number(context.line); + } + const char*const local=report.toLocal8Bit().constData(); + switch (type) { + case QtDebugMsg: + __android_log_write(ANDROID_LOG_DEBUG,"Interface",local); + break; + case QtInfoMsg: + __android_log_write(ANDROID_LOG_INFO,"Interface",local); + break; + case QtWarningMsg: + __android_log_write(ANDROID_LOG_WARN,"Interface",local); + break; + case QtCriticalMsg: + __android_log_write(ANDROID_LOG_ERROR,"Interface",local); + break; + case QtFatalMsg: + default: + __android_log_write(ANDROID_LOG_FATAL,"Interface",local); + abort(); + } #endif qApp->getLogger()->addMessage(qPrintable(logMessage + "\n")); } @@ -845,10 +873,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo #endif _logger = new FileLogger(this); -#ifndef Q_OS_ANDROID - // this prevents using logcat qInstallMessageHandler(messageHandler); -#endif QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); _window->setWindowTitle("High Fidelity Interface"); @@ -2344,8 +2369,11 @@ void Application::initializeUi() { offscreenUi->setProxyWindow(_window->windowHandle()); // OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to // support the window management and scripting proxies for VR use +#ifndef Q_OS_ANDROID offscreenUi->createDesktop(QString("hifi/Desktop.qml")); - +#else + offscreenUi->createDesktop(QString("qrc:///qml/hifi/Desktop.qml")); +#endif // FIXME either expose so that dialogs can set this themselves or // do better detection in the offscreen UI of what has focus offscreenUi->setNavigationFocused(false);