Skip to content

Commit 0b357ce

Browse files
refac: Implement gvr/noGvr App flavours (#372)
* Implement gvr/noGvr variants * Probably fix tests * hopefully fix tests fr this time (they pass on my physical device) * fix screenshot path for CI * Upgrade zxing-cpp for x86 support * address review comments * add flavour doc to readme * minor fixes and cleanups --------- Co-authored-by: Harsha Raghu <[email protected]>
1 parent bd07328 commit 0b357ce

File tree

37 files changed

+398
-253
lines changed

37 files changed

+398
-253
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,22 +201,22 @@ jobs:
201201
Store: ${{ secrets.STORE }}
202202
run: |
203203
cd code/mobile/android/PhoneVR
204-
./gradlew :${{ env.MAIN_PROJECT_MODULE }}:assemble --warning-mode=all --stacktrace -Dorg.gradle.java.home=${{env.JAVA_HOME}}
204+
./gradlew :${{ env.MAIN_PROJECT_MODULE }}:assembleRelease --warning-mode=all --stacktrace -Dorg.gradle.java.home=${{env.JAVA_HOME}}
205205
206206
# Upload Artifact Build
207-
# Noted For Output [MAIN_PROJECT_MODULE]/build/outputs/apk/debug/
208-
- name: Upload APK Debug
207+
# Noted For Output eg. [MAIN_PROJECT_MODULE]/build/outputs/apk/gvr/debug/
208+
- name: Upload Debug APKs
209209
uses: actions/upload-artifact@v2
210210
with:
211211
name: ${{ env.PROJECT_NAME }}-debug-${{ steps.vars.outputs.sha_short }}-${{ env.date_today }} APK
212-
path: ${{env.GRADLE_DIR}}/${{ env.MAIN_PROJECT_MODULE }}/build/outputs/apk/debug/
212+
path: ${{env.GRADLE_DIR}}/${{ env.MAIN_PROJECT_MODULE }}/build/outputs/apk/**/debug/
213213

214-
# Noted For Output [MAIN_PROJECT_MODULE]/build/outputs/apk/release/
215-
- name: Upload APK Release
214+
# Noted For Output eg. [MAIN_PROJECT_MODULE]/build/outputs/apk/gvr/release/
215+
- name: Upload Release APKs
216216
uses: actions/upload-artifact@v2
217217
with:
218218
name: ${{ env.PROJECT_NAME }}-${{ steps.vars.outputs.sha_short }}-${{ env.date_today }} APK
219-
path: ${{env.GRADLE_DIR}}/${{ env.MAIN_PROJECT_MODULE }}/build/outputs/apk/release/
219+
path: ${{env.GRADLE_DIR}}/${{ env.MAIN_PROJECT_MODULE }}/build/outputs/apk/**/release/
220220

221221
- name: Upload Build outputs on failure
222222
if: failure()
@@ -230,18 +230,31 @@ jobs:
230230
GRADLE_PVR_DIR: ${{ env.GRADLE_DIR }}
231231
MODULE: ${{ env.MAIN_PROJECT_MODULE }}
232232
run: |
233-
cd "$GRADLE_DIR/$MAIN_PROJECT_MODULE/build/outputs/apk/release/"
233+
cd "$GRADLE_DIR/$MAIN_PROJECT_MODULE/build/outputs/apk/gvr/release/"
234234
mv -f PhoneVR*.apk PhoneVR.apk
235+
cd -
236+
cd "$GRADLE_DIR/$MAIN_PROJECT_MODULE/build/outputs/apk/noGvr/release/"
237+
mv -f PhoneVR*.apk PhoneVR-noGvr.apk
235238
236239
- name: Upload PVR APK
237240
uses: actions/upload-release-asset@v1
238241
env:
239242
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
240243
with:
241244
upload_url: ${{ needs.prepare_release.outputs.upload_url }}
242-
asset_path: ${{env.GRADLE_DIR}}/${{ env.MAIN_PROJECT_MODULE }}/build/outputs/apk/release/PhoneVR.apk
245+
asset_path: ${{env.GRADLE_DIR}}/${{ env.MAIN_PROJECT_MODULE }}/build/outputs/apk/gvr/release/PhoneVR.apk
243246
asset_name: PhoneVR-v${{ github.event.inputs.version }}.apk
244247
asset_content_type: application/vnd.android.package-archive
248+
249+
- name: Upload PVR noGvr APK
250+
uses: actions/upload-release-asset@v1
251+
env:
252+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
253+
with:
254+
upload_url: ${{ needs.prepare_release.outputs.upload_url }}
255+
asset_path: ${{env.GRADLE_DIR}}/${{ env.MAIN_PROJECT_MODULE }}/build/outputs/apk/noGvr/release/PhoneVR-noGvr.apk
256+
asset_name: PhoneVR-v${{ github.event.inputs.version }}-noGvr.apk
257+
asset_content_type: application/vnd.android.package-archive
245258

246259
# Step is needed because the PVRServerBuild runs as a matrix and adds files to the same artifact
247260
Upload_release_assets:
@@ -278,4 +291,4 @@ jobs:
278291
upload_url: ${{ needs.prepare_release.outputs.upload_url }}
279292
asset_path: ${{ env.PROJECT_NAME }}-Server-Release.zip
280293
asset_name: ${{ env.PROJECT_NAME }}-Server-v${{ github.event.inputs.version }}.zip
281-
asset_content_type: application/gzip
294+
asset_content_type: application/gzip

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ PhoneVR(PVR) can be used with two servers ALVR and PVRServer. ALVR Server is rec
7373

7474
### Common Instructions for both Servers
7575
* Install the Android Apk on your mobile from [`Releases`](https://github.com/PhoneVR-Developers/PhoneVR/releases/latest) page.
76+
* There are two Apks on the release page, one with GoogleVR(GVR) SDK and other without GVR SDK. If you plan to use ALVR-Server only you can install `PhoneVR-vX.X.X.noGvr.apk`.
7677
* Make sure that "Run in Background", "Auto Start"(Restart on Crash) permissions, if exists on your device(especially Xiaomi users), are given. Also make sure that any kind of 3rd party battery saver app dosen't kill PhoneVR when in background.
7778
* After opening the installed app, Choose ALVR(recommended) or PhoneVR Server, according to the server you installed.
7879

@@ -141,9 +142,18 @@ This Project is presently under testing. But, pull requests are welcome.
141142
* Android App: App folder: `<root>/code/mobile/android/PhoneVR`
142143
* Compiled/Tested on `Android Studio 4.0.1`
143144
* For testing, this project has 2 Build Configs, Debug and Release. Debug has lots of debugging callouts to logcat from both JAVA and JNI.
144-
* PhoneVR is Android AVD compatible, though PhoneVR Server networking is also AVD compatible, but ALVR Server networking need some more work for simulation.
145-
* PhoneVR APK when run on AVD automatically assigns 10.0.2.2 (default emu addr) to pcIP
146-
* After starting the AVD Emulator, need to run "adb forward tcp:33333 tcp:33333", in terminal/cmd, this will enable PVRServer -> Android Emulator based PVRAndroidApp communication.
145+
* There are also two build flavours: gvr and noGvr. The gvr flavour is a superset of the noGvr flavour that adds support for legacy PhoneVR server with Google VR SDK (deprecated).
146+
* The source code of the gvr flavour is in app/src/gvr/ and app/src/main/. The code of the noGvr flavour is in app/src/noGvr/ and app/src/main/. Respectively, any shared code in app/src/main/ has to be tested with both flavours.
147+
* The prepare-alvr-deps.sh script, which needs to be run before building supports the optional "nogvr" argument. If you run the script without arguments, you can build both flavours. If you run the script with the "nogvr" argument, you can only build the noGvr flavour.
148+
* PhoneVR is Android AVD compatible.
149+
* PhoneVR Legacy Server networking
150+
* PhoneVR with GVR APK when run on AVD automatically assigns 10.0.2.2 (default emu addr) to pcIP
151+
* After starting the AVD Emulator, need to run `adb forward tcp:33333 tcp:33333`, in terminal/cmd, this will enable PVRServer -> Android Emulator based PVRAndroidApp communication.
152+
* ALVR Server networking
153+
* Similar to ALVR-Over-USB (https://github.com/alvr-org/ALVR/wiki/ALVR-wired-setup-(ALVR-over-USB))
154+
* Once `ALVR Streamer (PC) Configuration` is done from the above link. Then you should, in terminal/cmd, execute
155+
* `adb forward tcp:9943 tcp:9943`
156+
* `adb forward tcp:9944 tcp:9944`
147157

148158
* External Vendor Libraries used (all Headers included in respective Projects):
149159
* Json v3.8.0 (https://github.com/nlohmann/json) (code\windows\libs\json)

code/mobile/android/PhoneVR/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/cardboard
1313
/gvr-android-sdk-1.200
1414
/app/libraries
15+
/app/libraries_gvr
1516

1617
# Android Gitignore https://github.com/github/gitignore/blob/main/Android.gitignore
1718
# Gradle files

code/mobile/android/PhoneVR/app/CMakeLists.txt

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ file(GLOB_RECURSE LIB_SRC
1414
../../../../common/libs/json/single_include/*.hpp
1515
)
1616

17-
file(GLOB_RECURSE GVR_SRC
18-
../../../../common/src/*.cpp
19-
../../../mobile-common/*.cpp
20-
)
21-
2217
add_library(native-lib-alvr SHARED
2318
src/main/cpp/alvr_main.cpp
2419
${LIB_SRC}
@@ -44,27 +39,6 @@ target_link_libraries(native-lib-alvr
4439
${libs_dir}/jni/${ANDROID_ABI}/libGfxPluginCardboard.so
4540
)
4641

47-
IF (NOT "${ANDROID_ABI}" STREQUAL "x86_64")
48-
add_library(native-lib-gvr SHARED
49-
src/main/cpp/native-lib.cpp
50-
${LIB_SRC}
51-
${GVR_SRC}
52-
)
53-
54-
target_include_directories(native-lib-gvr
55-
PUBLIC ./libraries/headers
56-
PUBLIC ../../../../common/libs/asio/asio/include
57-
PUBLIC ../../../../common/libs/eigen/Eigen
58-
PUBLIC ../../../../common/libs/ifaddrs
59-
PUBLIC ../../../../common/libs/json/single_include/
60-
61-
PUBLIC ../../../../common/src
62-
PUBLIC ../../../mobile-common
63-
)
64-
65-
target_link_libraries(native-lib-gvr
66-
log android EGL GLESv3 mediandk
67-
${libs_dir}/jni/${ANDROID_ABI}/libgvr.so
68-
${libs_dir}/jni/${ANDROID_ABI}/libgvr_audio.so
69-
)
70-
ENDIF ()
42+
IF(${HAVEGVR})
43+
add_subdirectory(src/gvr)
44+
ENDIF()

code/mobile/android/PhoneVR/app/build-pr.gradle

Lines changed: 0 additions & 107 deletions
This file was deleted.

code/mobile/android/PhoneVR/app/build.gradle

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import com.android.build.gradle.internal.dsl.PackagingOptions
22

33
apply plugin: 'com.android.application'
44
apply plugin: 'kotlin-android'
5-
apply plugin: 'kotlin-android-extensions'
65
apply plugin: 'com.android.application'
76
apply plugin: 'com.google.gms.google-services'
87
apply from: '../versioning.gradle'
@@ -35,8 +34,7 @@ android {
3534
}
3635
}
3736
}
38-
compileSdkVersion 33
39-
buildToolsVersion = "33.0.0"
37+
compileSdkVersion 34
4038
namespace 'viritualisres.phonevr'
4139
ndkVersion '25.2.9519653' // r25c
4240
defaultConfig {
@@ -80,12 +78,31 @@ android {
8078
}
8179
}
8280
buildFeatures {
83-
buildConfig = true // TODO: Remove BuildConifg, Gradle suggests this usage is inefficient > v8 disabled by default
81+
buildConfig = true // TODO: Remove BuildConfig, Gradle suggests this usage is inefficient > v8 disabled by default
82+
viewBinding true
83+
}
84+
flavorDimensions "gvr"
85+
productFlavors {
86+
gvr {
87+
dimension "gvr"
88+
externalNativeBuild {
89+
cmake {
90+
arguments "-D HAVEGVR=true"
91+
}
92+
}
93+
}
94+
noGvr {
95+
dimension "gvr"
96+
versionNameSuffix "-nogvr"
97+
}
8498
}
8599
sourceSets {
86100
main {
87101
jniLibs.srcDirs = ["libraries/jni", "../ALVR/build/alvr_client_core"]
88102
}
103+
gvr {
104+
jniLibs.srcDirs = ["libraries/jni", "libraries_gvr/jni", "../ALVR/build/alvr_client_core"]
105+
}
89106
}
90107
externalNativeBuild {
91108
cmake {
@@ -115,6 +132,7 @@ android {
115132
}
116133

117134
packagingOptions {
135+
jniLibs.useLegacyPackaging = true
118136
gradle.startParameter.getTaskNames().each { task ->
119137
println("[PVR] task is " + task)
120138
if (task.contains('debug') || task.contains('Debug')) {
@@ -135,9 +153,9 @@ android {
135153
dependencies {
136154
implementation fileTree(dir: 'libs', include: ['*.jar'])
137155
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
138-
implementation 'androidx.appcompat:appcompat:1.6.1'
156+
implementation 'androidx.appcompat:appcompat:1.7.0'
139157
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
140-
implementation 'com.google.android.material:material:1.2.1'
158+
implementation 'com.google.android.material:material:1.6.1'
141159

142160
implementation "androidx.tracing:tracing:1.1.0"
143161
testImplementation 'junit:junit:4.13.2'
@@ -148,10 +166,14 @@ dependencies {
148166
androidTestImplementation "androidx.test:rules:$androidXTestVersion"
149167
androidTestUtil "androidx.test.services:test-services:$servicesVersion"
150168

151-
implementation 'com.google.vr:sdk-base:1.200.0@aar'
169+
gvrImplementation 'com.google.vr:sdk-base:1.200.0@aar'
152170
implementation 'com.google.cardboard.sdk:cardboard-sdk:1.17.0@aar'
153-
implementation 'com.google.android.gms:play-services-vision:20.1.3'
171+
implementation 'io.github.zxing-cpp:android:2.2.0-SNAPSHOT'
154172
implementation 'com.google.protobuf:protobuf-javalite:3.19.4'
173+
implementation 'androidx.camera:camera-core:1.3.4'
174+
implementation 'androidx.camera:camera-view:1.3.4'
175+
implementation 'androidx.camera:camera-lifecycle:1.3.4'
176+
implementation 'androidx.camera:camera-camera2:1.3.4'
155177

156178
def acraVersion = '5.7.0'
157179
implementation "ch.acra:acra-mail:$acraVersion"
@@ -169,12 +191,14 @@ task extractNdk(type: Copy) {
169191
into "libraries/"
170192
include "jni/**/libGfxPluginCardboard.so"
171193
}
172-
copy {
173-
from zipTree("../gvr-android-sdk-1.200/libraries/sdk-base-1.200.0.aar")
174-
into "libraries/"
175-
include "headers/vr/gvr/capi/**/*h"
176-
include "jni/**/libgvr_audio.so"
177-
include "jni/**/libgvr.so"
194+
if (file("../gvr-android-sdk-1.200/libraries/sdk-base-1.200.0.aar").exists()) {
195+
copy {
196+
from zipTree("../gvr-android-sdk-1.200/libraries/sdk-base-1.200.0.aar")
197+
into "libraries_gvr/"
198+
include "headers/vr/gvr/capi/**/*h"
199+
include "jni/**/libgvr_audio.so"
200+
include "jni/**/libgvr.so"
201+
}
178202
}
179203
}
180204

code/mobile/android/PhoneVR/app/src/androidTest/java/viritualisres/phonevr/MainActivityTest.kt renamed to code/mobile/android/PhoneVR/app/src/androidTestGvr/java/viritualisres/phonevr/MainActivityTest.kt

File renamed without changes.

code/mobile/android/PhoneVR/app/src/androidTest/java/viritualisres/phonevr/SettingsActivityTest.kt renamed to code/mobile/android/PhoneVR/app/src/androidTestGvr/java/viritualisres/phonevr/SettingsActivityTest.kt

File renamed without changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<application>
4+
<activity
5+
android:name=".MainActivity"
6+
android:launchMode="singleTop" />
7+
<activity
8+
android:name=".GameActivity"
9+
android:configChanges="orientation|keyboardHidden|screenSize"
10+
android:enableVrMode="@string/gvr_vr_mode_component"
11+
android:resizeableActivity="false"
12+
android:screenOrientation="landscape"
13+
android:theme="@style/GameTheme" />
14+
<activity
15+
android:name=".SettingsActivity"
16+
android:label="Settings"
17+
android:parentActivityName=".MainActivity" />
18+
</application>
19+
20+
</manifest>

0 commit comments

Comments
 (0)