-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
14 changed files
with
123 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
app/src/common/shared/com/igalia/wolvic/VersionCheckActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters