From 3a69e394b60ad5f23888f16af41a11f303015c66 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 28 Jan 2015 10:04:27 -0800 Subject: [PATCH 1/8] use the git commit count for version code --- cmake/android/AndroidManifest.xml.in | 2 +- gvr-interface/CMakeLists.txt | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cmake/android/AndroidManifest.xml.in b/cmake/android/AndroidManifest.xml.in index 111c0c9d3d..f22fc091a8 100755 --- a/cmake/android/AndroidManifest.xml.in +++ b/cmake/android/AndroidManifest.xml.in @@ -2,7 +2,7 @@ - + diff --git a/gvr-interface/CMakeLists.txt b/gvr-interface/CMakeLists.txt index f8108580a8..c62584916a 100644 --- a/gvr-interface/CMakeLists.txt +++ b/gvr-interface/CMakeLists.txt @@ -20,6 +20,8 @@ set(ANDROID_APP_DISPLAY_NAME Interface) set(ANDROID_API_LEVEL 19) set(ANDROID_APK_PACKAGE io.highfidelity.gvrinterface) set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceActivity) +set(ANDROID_APK_VERSION_NAME "0.1") +set(ANDROID_APK_VERSION_CODE 1) set(ANDROID_DEPLOY_QT_INSTALL "--install") find_package(LibOVR REQUIRED) @@ -39,6 +41,16 @@ if (HOCKEY_APP_ID) set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceBetaActivity) set(ANDROID_DEPLOY_QT_INSTALL "") + # set the ANDROID_APK_VERSION_CODE to the number of git commits + execute_process( + COMMAND git rev-list --first-parent --count HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_COUNT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + set(ANDROID_APK_VERSION_CODE ${GIT_COMMIT_COUNT}) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/templates/InterfaceBetaActivity.java.in" "${ANDROID_APK_BUILD_DIR}/src/io/highfidelity/gvrinterface/InterfaceBetaActivity.java") else () set(HOCKEY_APP_ENABLED false) From 0c1babe6f9521228f9ba087bce4939a944324697 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 28 Jan 2015 10:25:11 -0800 Subject: [PATCH 2/8] allow APK rename, fix hockey app update --- cmake/android/AndroidManifest.xml.in | 4 ++-- cmake/android/QtCreateAPK.cmake | 10 +++++++++- gvr-interface/CMakeLists.txt | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmake/android/AndroidManifest.xml.in b/cmake/android/AndroidManifest.xml.in index f22fc091a8..f6ce914148 100755 --- a/cmake/android/AndroidManifest.xml.in +++ b/cmake/android/AndroidManifest.xml.in @@ -51,6 +51,8 @@ android:configChanges="screenSize|orientation|keyboardHidden|keyboard"> + ${HOCKEY_APP_ACTIVITY} + @@ -68,6 +70,4 @@ - - ${HOCKEY_APP_ACTIVITY} \ No newline at end of file diff --git a/cmake/android/QtCreateAPK.cmake b/cmake/android/QtCreateAPK.cmake index 0591acb0ae..9b5bdfd4c4 100644 --- a/cmake/android/QtCreateAPK.cmake +++ b/cmake/android/QtCreateAPK.cmake @@ -123,5 +123,13 @@ macro(qt_create_apk) add_custom_target(${TARGET_NAME}-apk COMMAND ${ANDROID_DEPLOY_QT} --input "${TARGET_NAME}-deployment.json" --output "${ANDROID_APK_OUTPUT_DIR}" --android-platform android-${ANDROID_API_LEVEL} ${ANDROID_DEPLOY_QT_INSTALL} --verbose --deployment bundled "\\$(ARGS)" DEPENDS ${TARGET_NAME} ${TARGET_NAME}-copy-res ${TARGET_NAME}-copy-assets ${TARGET_NAME}-copy-java ${TARGET_NAME}-copy-libs - ) + ) + + if (ANDROID_APK_CUSTOM_NAME) + add_custom_command( + TARGET ${TARGET_NAME}-apk + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E rename "${ANDROID_APK_OUTPUT_DIR}/bin/QtApp-debug.apk" "${ANDROID_APK_OUTPUT_DIR}/bin/${ANDROID_APK_CUSTOM_NAME}" + ) + endif () endmacro() \ No newline at end of file diff --git a/gvr-interface/CMakeLists.txt b/gvr-interface/CMakeLists.txt index c62584916a..9a9c3c3987 100644 --- a/gvr-interface/CMakeLists.txt +++ b/gvr-interface/CMakeLists.txt @@ -40,6 +40,7 @@ if (HOCKEY_APP_ID) set(HOCKEY_APP_ACTIVITY "") set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceBetaActivity) set(ANDROID_DEPLOY_QT_INSTALL "") + set(ANDROID_APK_CUSTOM_NAME "Interface-beta.apk") # set the ANDROID_APK_VERSION_CODE to the number of git commits execute_process( From 42d064a613d7845faa3a51e4685c4e636db4973b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 28 Jan 2015 10:29:12 -0800 Subject: [PATCH 3/8] add a comment to push build count --- cmake/android/QtCreateAPK.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/android/QtCreateAPK.cmake b/cmake/android/QtCreateAPK.cmake index 9b5bdfd4c4..3d757d481b 100644 --- a/cmake/android/QtCreateAPK.cmake +++ b/cmake/android/QtCreateAPK.cmake @@ -125,6 +125,7 @@ macro(qt_create_apk) DEPENDS ${TARGET_NAME} ${TARGET_NAME}-copy-res ${TARGET_NAME}-copy-assets ${TARGET_NAME}-copy-java ${TARGET_NAME}-copy-libs ) + # rename the APK if the caller asked us to if (ANDROID_APK_CUSTOM_NAME) add_custom_command( TARGET ${TARGET_NAME}-apk From 067ffad122687a174da0674049a71e38b776ebfc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 28 Jan 2015 11:04:21 -0800 Subject: [PATCH 4/8] add instructions for hybrid GVR testing --- BUILD_ANDROID.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BUILD_ANDROID.md b/BUILD_ANDROID.md index 9812d144a4..ef908b47b9 100644 --- a/BUILD_ANDROID.md +++ b/BUILD_ANDROID.md @@ -101,6 +101,14 @@ Download the [Oculus Mobile SDK](https://developer.oculus.com/downloads/#sdk=mob From the VrLib directory, use ndk-build to build VrLib. This will create the liboculus.a archive that our FindLibOVR module will look for when cmake is run. +#####Hybrid testing + +Currently the 'vr_dual' mode that would allow us to run a hybrid app has limited support in the Oculus Mobile SDK. The best way to have an application we can launch without having to connect to the GearVR is to put the Gear VR Service into developer mode. This stops Oculus Home from taking over the device when it is plugged into the Gear VR headset, and allows the application to be launched from the Applications page. + +To put the Gear VR Service into developer mode you need an application with an Oculus Signature File on your device. Generate an Oculus Signature File for your device on the [Oculus osig tool page](https://developer.oculus.com/tools/osig/). Place this file in the gvr-interface/assets directory. Cmake will automatically copy it into your apk in the right place when you execute `make gvr-interface-apk`. + +Once the application is on your device, go to `Settings->Application Manager->Gear VR Service->Manage Storage`. Tap on `VR Service Version` six times. It will scan your device to verify that you have an osig file in an application on your device, and then it will let you enable Developer mode. + ####GLM Since GLM is a header only library, assuming it is installed at a system path or a path where our FindGLM module will find it you do not need to do anything specific for the Android build. From f1c6d26ed1e0f53b2acc7bbabf811417cc034282 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 28 Jan 2015 11:20:25 -0800 Subject: [PATCH 5/8] don't explicitly require LibOVR for android build --- BUILD_ANDROID.md | 7 ++++++- gvr-interface/CMakeLists.txt | 19 +++++++++++-------- gvr-interface/src/GVRInterface.cpp | 12 +++++++++++- gvr-interface/src/GVRInterface.h | 5 +++++ libraries/audio-client/src/AudioClient.cpp | 4 ++-- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/BUILD_ANDROID.md b/BUILD_ANDROID.md index ef908b47b9..da473c69af 100644 --- a/BUILD_ANDROID.md +++ b/BUILD_ANDROID.md @@ -7,10 +7,13 @@ You will need the following tools to build our Android targets. * [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html) = r10c * [Android SDK](http://developer.android.com/sdk/installing/index.html) ~> 24.0.2 * Be sure to install SDK Platform for API Level 19 -* [Oculus Mobile SDK](https://developer.oculus.com/downloads/#sdk=mobile) ~> 0.4.2 You will also need to cross-compile the dependencies required for all platforms for Android, and help CMake find these compiled libraries on your machine. +####Optional Components + +* [Oculus Mobile SDK](https://developer.oculus.com/downloads/#sdk=mobile) ~> 0.4.2 + ####ANDROID_LIB_DIR Since you won't be installing Android dependencies to system paths on your development machine, CMake will need a little help tracking down your Android dependencies. @@ -97,6 +100,8 @@ This will create the `lib` and `include` folders inside `ANDROID_LIB_DIR/soxr` t ####Oculus Mobile SDK +The Oculus Mobile SDK is optional, for Gear VR support. It is not required to compile gvr-interface. + Download the [Oculus Mobile SDK](https://developer.oculus.com/downloads/#sdk=mobile) and extract the archive inside your `ANDROID_LIB_DIR` folder. Rename the extracted folder to `libovr`. From the VrLib directory, use ndk-build to build VrLib. This will create the liboculus.a archive that our FindLibOVR module will look for when cmake is run. diff --git a/gvr-interface/CMakeLists.txt b/gvr-interface/CMakeLists.txt index 9a9c3c3987..f360e3416e 100644 --- a/gvr-interface/CMakeLists.txt +++ b/gvr-interface/CMakeLists.txt @@ -24,15 +24,18 @@ set(ANDROID_APK_VERSION_NAME "0.1") set(ANDROID_APK_VERSION_CODE 1) set(ANDROID_DEPLOY_QT_INSTALL "--install") -find_package(LibOVR REQUIRED) -target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES}) -include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS}) +find_package(LibOVR) +if (LIBOVR_FOUND) + add_definitions(-DHAVE_LIBOVR) + target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES}) + include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS}) -# we need VRLib, so add a project.properties to our apk build folder that says that -file(RELATIVE_PATH RELATIVE_VRLIB_PATH ${ANDROID_APK_OUTPUT_DIR} "${LIBOVR_VRLIB_DIR}") -file(WRITE "${ANDROID_APK_BUILD_DIR}/project.properties" "android.library.reference.1=${RELATIVE_VRLIB_PATH}") - -list(APPEND IGNORE_COPY_LIBS ${LIBOVR_ANDROID_LIBRARIES}) + # we need VRLib, so add a project.properties to our apk build folder that says that + file(RELATIVE_PATH RELATIVE_VRLIB_PATH ${ANDROID_APK_OUTPUT_DIR} "${LIBOVR_VRLIB_DIR}") + file(WRITE "${ANDROID_APK_BUILD_DIR}/project.properties" "android.library.reference.1=${RELATIVE_VRLIB_PATH}") + + list(APPEND IGNORE_COPY_LIBS ${LIBOVR_ANDROID_LIBRARIES}) +endif () # the presence of a HOCKEY_APP_ID means we are making a beta build if (HOCKEY_APP_ID) diff --git a/gvr-interface/src/GVRInterface.cpp b/gvr-interface/src/GVRInterface.cpp index 85f568aa57..31ae20a0d3 100644 --- a/gvr-interface/src/GVRInterface.cpp +++ b/gvr-interface/src/GVRInterface.cpp @@ -15,11 +15,15 @@ #include #include +#ifdef HAVE_LIBOVR + #include #include #include #include +#endif + #include "GVRMainWindow.h" #include "RenderingClient.h" @@ -32,13 +36,16 @@ GVRInterface::GVRInterface(int argc, char* argv[]) : _client = new RenderingClient(this); connect(this, &QGuiApplication::applicationStateChanged, this, &GVRInterface::handleApplicationStateChange); - + +#ifdef HAVE_LIBOVR QAndroidJniEnvironment jniEnv; QPlatformNativeInterface* interface = QApplication::platformNativeInterface(); jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity"); + ovr_RegisterHmtReceivers(&*jniEnv, activity); +#endif // call our idle function whenever we can QTimer* idleTimer = new QTimer(this); @@ -60,10 +67,12 @@ GVRInterface::GVRInterface(int argc, char* argv[]) : } void GVRInterface::idle() { +#ifdef HAVE_LIBOVR if (!_inVRMode && ovr_IsHeadsetDocked()) { qDebug() << "The headset just got docked - assume we are in VR mode."; _inVRMode = true; } else if (_inVRMode) { + if (ovr_IsHeadsetDocked()) { static int counter = 0; @@ -90,6 +99,7 @@ void GVRInterface::idle() { _inVRMode = false; } } +#endif } void GVRInterface::handleApplicationStateChange(Qt::ApplicationState state) { diff --git a/gvr-interface/src/GVRInterface.h b/gvr-interface/src/GVRInterface.h index 6d38406e7f..58fe80f7c0 100644 --- a/gvr-interface/src/GVRInterface.h +++ b/gvr-interface/src/GVRInterface.h @@ -15,8 +15,11 @@ #include class RenderingClient; + +#ifdef HAVE_LIBOVR class ovrMobile; class ovrHmdInfo; +#endif #if defined(qApp) #undef qApp @@ -37,8 +40,10 @@ private: RenderingClient* _client; bool _inVRMode; +#ifdef HAVE_LIBOVR ovrMobile* _ovr; ovrHmdInfo* _hmdInfo; +#endif }; #endif // hifi_GVRInterface_h diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 607dbd0a1c..59e063e353 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -328,7 +328,7 @@ bool sampleChannelConversion(const int16_t* sourceSamples, int16_t* destinationS const QAudioFormat& sourceAudioFormat, const QAudioFormat& destinationAudioFormat) { if (sourceAudioFormat.channelCount() == 2 && destinationAudioFormat.channelCount() == 1) { // loop through the stereo input audio samples and average every two samples - for (int i = 0; i < numSourceSamples; i += 2) { + for (uint i = 0; i < numSourceSamples; i += 2) { destinationSamples[i / 2] = (sourceSamples[i] / 2) + (sourceSamples[i + 1] / 2); } @@ -336,7 +336,7 @@ bool sampleChannelConversion(const int16_t* sourceSamples, int16_t* destinationS } else if (sourceAudioFormat.channelCount() == 1 && destinationAudioFormat.channelCount() == 2) { // loop through the mono input audio and repeat each sample twice - for (int i = 0; i < numSourceSamples; ++i) { + for (uint i = 0; i < numSourceSamples; ++i) { destinationSamples[i * 2] = destinationSamples[(i * 2) + 1] = sourceSamples[i]; } From dae9246c87d722dc12600c5c81122b328b8a4743 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 28 Jan 2015 12:56:40 -0800 Subject: [PATCH 6/8] updates to build guide for SDK requirements --- BUILD_ANDROID.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD_ANDROID.md b/BUILD_ANDROID.md index da473c69af..bbdc194aa2 100644 --- a/BUILD_ANDROID.md +++ b/BUILD_ANDROID.md @@ -6,7 +6,7 @@ You will need the following tools to build our Android targets. * [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html) = r10c * [Android SDK](http://developer.android.com/sdk/installing/index.html) ~> 24.0.2 - * Be sure to install SDK Platform for API Level 19 + * You must install the latest Platform-tools, latest Build-tools, the SDK Platform for API Level 19 and Sources for Android SDK for API Level 19. If you want to run on an emulator you will also need the ARM EABI v7a System Image. You will also need to cross-compile the dependencies required for all platforms for Android, and help CMake find these compiled libraries on your machine. From 31e46cf70de053cca2b7787553b3439909d33fb2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 28 Jan 2015 12:57:41 -0800 Subject: [PATCH 7/8] bullet out android-sdk requirements --- BUILD_ANDROID.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BUILD_ANDROID.md b/BUILD_ANDROID.md index bbdc194aa2..c1d4cefc02 100644 --- a/BUILD_ANDROID.md +++ b/BUILD_ANDROID.md @@ -6,7 +6,11 @@ You will need the following tools to build our Android targets. * [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html) = r10c * [Android SDK](http://developer.android.com/sdk/installing/index.html) ~> 24.0.2 - * You must install the latest Platform-tools, latest Build-tools, the SDK Platform for API Level 19 and Sources for Android SDK for API Level 19. If you want to run on an emulator you will also need the ARM EABI v7a System Image. + * Install the latest Platform-tools + * Install the latest Build-tools + * Install the SDK Platform for API Level 19 + * Install Sources for Android SDK for API Level 19 + * If you want to run on an emulator you will also need the ARM EABI v7a System Image. You will also need to cross-compile the dependencies required for all platforms for Android, and help CMake find these compiled libraries on your machine. From 8abbac6bb2ca0709a81ebbe70d41fbf9531b5b3e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 28 Jan 2015 13:00:05 -0800 Subject: [PATCH 8/8] fix system image explanation in build guide --- BUILD_ANDROID.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD_ANDROID.md b/BUILD_ANDROID.md index c1d4cefc02..9e3dc3b0be 100644 --- a/BUILD_ANDROID.md +++ b/BUILD_ANDROID.md @@ -10,7 +10,7 @@ You will need the following tools to build our Android targets. * Install the latest Build-tools * Install the SDK Platform for API Level 19 * Install Sources for Android SDK for API Level 19 - * If you want to run on an emulator you will also need the ARM EABI v7a System Image. + * Install the ARM EABI v7a System Image if you want to run an emulator. You will also need to cross-compile the dependencies required for all platforms for Android, and help CMake find these compiled libraries on your machine.