Skip to content

Commit

Permalink
Add a version check activity
Browse files Browse the repository at this point in the history
This new activity becomes the new MAIN activity, so it'll be launched
before anything else including the VRBrowserActivity. It'll perform
an OS version check. On success it'll invoke the VRBrowserActivity.
Should the test fail, a dialog with a text asking user to upgrade the
OS will be shown and Wolvic will refuse to start.

So far the test is only performed for Meta builds (because the Khronos
OpenXR loader is only available in v62+ VROS. Nevertheless it could be
easily extended to other flavours.

I've verified that it works as expected in: Pico4, Quest2, HVR,
VisionGlass, Lenovo VRX, LynxR1 and the NoAPI flavour.
  • Loading branch information
svillar committed Sep 4, 2024
1 parent 52a1311 commit 2eec227
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 39 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ Restart Wolvic XR and close and re-open the WebIDE page.

- When using the native debugger you can ignore the first SIGSEGV: address access protected stop in GV thread. It's not a crash; you can click *Resume* to continue debugging.
- On some platforms such as Oculus Go the native debugger stops on each input event. You can set this LLDB post-attach command in Android Studio to fix the problem: `pro hand -p true -s false SIGILL`
- You can use `adb shell am start -a android.intent.action.VIEW -d "https://aframe.io" com.igalia.wolvic/com.igalia.wolvic.VRBrowserActivity` to load a URL from the command line
- You can use `adb shell am start -a android.intent.action.VIEW -n com.igalia.wolvic/com.igalia.wolvic.VRBrowserActivity -e homepage "https://example.com"` to override the homepage
- You can use `adb shell am start -a android.intent.action.VIEW -d "https://aframe.io" com.igalia.wolvic/com.igalia.wolvic.VersionCheckActivity` to load a URL from the command line
- You can use `adb shell am start -a android.intent.action.VIEW -n com.igalia.wolvic/com.igalia.wolvic.VersionCheckActivity -e homepage "https://example.com"` to override the homepage
- You can use `adb shell setprop debug.oculus.enableVideoCapture 1` to record a video on the Oculus Go. Remember to run `adb shell setprop debug.oculus.enableVideoCapture 0` to stop recording the video.
- You can also record videos on the Oculus Go by exiting to the system library, and from the Oculus tray menu (toggle with the Oculus button on the controller): **`Sharing > Record Video`**
- You can set `disableCrashRestart=true` in the gradle `user.properties` to disable app relaunch on crash.
6 changes: 2 additions & 4 deletions app/src/aosp/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
<provider android:authorities="org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker"/>
</queries>
<application>
<activity android:name=".VRBrowserActivity" android:screenOrientation="landscape">
<activity android:name=".VRBrowserActivity">
<meta-data android:name="android.app.lib_name" android:value="native-lib" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD" />
</intent-filter>
</activity>
Expand Down
91 changes: 91 additions & 0 deletions app/src/common/shared/com/igalia/wolvic/VersionCheckActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.igalia.wolvic;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.igalia.wolvic.utils.SystemUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

public class VersionCheckActivity extends Activity {
private static final String META_OS_VERSION = "ro.vros.build.version";
private static final int MIN_META_OS_VERSION_WITH_KHR_LOADER = 62;
static final String LOGTAG = SystemUtils.createLogtag(VersionCheckActivity.class);
private int minSupportedVersion = 0;
private boolean browserActivityStarted = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (isOSVersionCompatible()) {
Intent receivedIntent = getIntent();
Bundle extras = receivedIntent.getExtras();

// Start VRBrowserActivity if OS version is compatible
Intent intent = new Intent(this, VRBrowserActivity.class);
if (extras != null)
intent.putExtras(extras);

startActivity(intent);
browserActivityStarted = true;
finish();
} else {
// Show dialog if OS version is incompatible
showIncompatibleOSDialog();
}
}

@Override
protected void onDestroy() {
super.onDestroy();
if (!browserActivityStarted)
System.exit(0);
}

private static String getSystemProperty(String key) {
String value = null;
try {
Process process = Runtime.getRuntime().exec("getprop " + key);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
value = reader.readLine();
reader.close();
process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
return value;
}

private boolean isOSVersionCompatible() {
if (BuildConfig.FLAVOR_platform.equals("oculusvr")) {
minSupportedVersion = MIN_META_OS_VERSION_WITH_KHR_LOADER;
String osVersion = getSystemProperty(META_OS_VERSION);
Log.i(LOGTAG, "Checking that OS version is at least " + minSupportedVersion + " (found " + osVersion + ")");
try {
if (osVersion == null || Integer.parseInt(osVersion) < MIN_META_OS_VERSION_WITH_KHR_LOADER)
return false;
} catch (NumberFormatException e) {
Log.e(LOGTAG, "Failed to parse OS version: " + osVersion);
return false;
}
}
return true;
}

private void showIncompatibleOSDialog() {
new AlertDialog.Builder(this)
.setTitle(R.string.incompatible_os_version_title)
.setMessage(getString(R.string.incompatible_os_version_message, minSupportedVersion))
.setOnDismissListener((dialog) -> finish())
.setPositiveButton("OK", (dialog, which) -> dialog.dismiss())
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
}
1 change: 0 additions & 1 deletion app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<application android:name=".VRBrowserApplication">
<activity android:name=".VRBrowserActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER"/>
<category android:name="android.intent.category.APP_BROWSER" />
Expand Down
6 changes: 2 additions & 4 deletions app/src/hvr/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@
</meta-data>
<activity
android:name=".VRBrowserActivity"
android:label="@string/app_name"
android:screenOrientation="landscape">
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Expand Down
5 changes: 2 additions & 3 deletions app/src/lynx/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
<package android:name="com.ultraleap.openxr.api_layer" />
</queries>
<application>
<activity android:name=".VRBrowserActivity" android:screenOrientation="landscape">
<activity android:name=".VRBrowserActivity">
<meta-data android:name="android.app.lib_name" android:value="native-lib" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD" />
</intent-filter>
</activity>
Expand Down
14 changes: 11 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,24 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/FxR.Dark">
<activity
android:name=".VersionCheckActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="com.oculus.intent.category.2D" />
</intent-filter>
</activity>
<activity
android:name="com.igalia.wolvic.VRBrowserActivity"
android:launchMode="singleInstance"
android:exported="true"
android:exported="false"
android:configChanges="density|keyboardHidden|navigation|orientation|screenSize|uiMode|locale|layoutDirection"
android:windowSoftInputMode="stateAlwaysHidden">
<!-- Declares Wolvic as a browser app -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />

Expand All @@ -47,7 +56,6 @@
</intent-filter>
<!-- Used for the special wolvic:// links -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2565,4 +2565,8 @@ the Select` button. When clicked it closes all the previously selected tabs -->
<string name="eye_tracking_permission_title">Eye Tracking Permissions</string>
<string name="eye_tracking_permission_message">Enabling eye tracking for browsing the web poses significant privacy risks. This technology captures where and how long a user looks at specific parts of a webpage, revealing intimate details about their interests and emotional reactions. Advertisers and third parties can exploit this data for intrusive marketing and profiling. Moreover, eye movement patterns could infer sensitive information such as medical conditions, cognitive states, or personal habits. Therefore, it is crucial to consider the privacy implications before granting access to eye tracking information to webpages.</string>

<!-- Shown when starting the application if the OS version is not compatible -->
<string name="incompatible_os_version_title">Incompatible OS Version</string>
<string name="incompatible_os_version_message">Your OS version is not supported. This version of Wolvic requires at least version %1$d</string>

</resources>
5 changes: 3 additions & 2 deletions app/src/noapi/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity android:name=".VRBrowserActivity"
<activity
android:name=".VRBrowserActivity"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ protected Intent getStoreIntent() {

@Override
protected void onCreate(Bundle savedInstanceState) {
Log.e(LOGTAG,"in onCreate");
super.onCreate(savedInstanceState);
//getWindow().takeInputQueue(null);
// Keep the screen on
Expand Down
4 changes: 1 addition & 3 deletions app/src/oculusvrArmRelease/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@
android:windowSoftInputMode="stateAlwaysHidden"
android:resizeableActivity="false"
android:supportsPictureInPicture="false"
tools:replace="android:launchMode, android:configChanges"
android:exported="true">
tools:replace="android:launchMode, android:configChanges">
<meta-data android:name="com.oculus.vr.focusaware" android:value="true" />
<meta-data android:name="android.app.lib_name" android:value="native-lib" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.INFO" />
<category android:name="com.oculus.intent.category.VR" android:value="vr_only"/>
</intent-filter>
Expand Down
6 changes: 1 addition & 5 deletions app/src/picoxr/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
<uses-permission android:name="com.picovr.permission.EYE_TRACKING"/>

<application android:requestLegacyExternalStorage="true">
<activity android:name=".VRBrowserActivity" android:screenOrientation="landscape">
<activity android:name=".VRBrowserActivity">
<meta-data android:name="android.app.lib_name" android:value="native-lib" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="pvr.app.type" android:value="vr" />
<meta-data android:name="handtracking" android:value="1" />
Expand Down
8 changes: 2 additions & 6 deletions app/src/spaces/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,12 @@

<application>
<activity
android:name=".VRBrowserActivity"
android:screenOrientation="landscape">
android:name=".VRBrowserActivity">
<meta-data
android:name="android.app.lib_name"
android:value="native-lib" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<category android:name="snapdragon.intent.category.SPACES" />
</intent-filter>
</activity>
Expand Down
7 changes: 2 additions & 5 deletions app/src/visionglass/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
android:required="false" />

<application>
<activity
android:name=".VRBrowserActivity"
android:screenOrientation="portrait"
android:exported="true">
<activity android:name=".VRBrowserActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down

0 comments on commit 2eec227

Please sign in to comment.