cpvrlab / cpvr-vr-suite

Unity VR OpenXR Functionality
1 stars 0 forks source link

Screenshot sending on Quest 2 does not work #1

Closed saschaledermann closed 1 year ago

saschaledermann commented 1 year ago

Sending a screenshot by email does currently not work on a Quest 2 build. The caught exception is: SocketException, Unable to resolve 'smtp.google.com' However, sending an email in playmode does work fine.

A possible cause could be that the app does not have the required permissions to use the network. Some permissions were already added to the Androidmanifest.xml, which did not end up fixing the issue. To troubleshoot it further, a script should be written, which sends network requests (ICMP) to different endpoints like localhost, default gateway and some external addresses (switch.ch, google.com).

DPelts commented 1 year ago

Try this: In Unity Editor

  1. Open Project Settings
  2. Navigate to XR Plug-in Management > OpenXR
  3. Enable Meta Quest Support and click on the gear icon
  4. Uncheck 'Force Remove Internet'
  5. Rebuild This should add the permission to use the internet and connect to the mail server. I don't know why yet, but sometimes unity automatically re-enables this option. So make sure you have the following line in the manifest after building: <uses-permission android:name="android.permission.INTERNET" />
saschaledermann commented 1 year ago

These steps did not resolve the issue. However the necessary line <uses-permission android:name="android.permission.INTERNET" /> was not present in the manifest. This is the current manifest:

<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="32" android:compileSdkVersionCodename="12" android:installLocation="auto" package="com.BFH.las2.CPVRPackageDev" platformBuildVersionCode="32" platformBuildVersionName="12">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-feature android:name="oculus.software.overlay_keyboard" android:required="false"/>
    <uses-feature android:glEsVersion="0x00030000"/>
    <uses-feature android:name="android.hardware.vulkan.version" android:required="false"/>
    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
    <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false"/>
    <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false"/>
    <uses-permission android:name="com.oculus.permission.HAND_TRACKING"/>
    <uses-feature android:name="oculus.software.handtracking" android:required="false"/>
    <uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1"/>
    <application android:extractNativeLibs="true" android:icon="@mipmap/app_icon" android:label="@string/app_name">
        <meta-data android:name="unity.splash-mode" android:value="0"/>
        <meta-data android:name="unity.splash-enable" android:value="true"/>
        <meta-data android:name="unity.launch-fullscreen" android:value="true"/>
        <meta-data android:name="unity.allow-resizable-window" android:value="false"/>
        <meta-data android:name="notch.config" android:value="portrait|landscape"/>
        <meta-data android:name="unity.auto-report-fully-drawn" android:value="true"/>
        <activity android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:exported="true" android:hardwareAccelerated="false" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:resizeableActivity="false" android:screenOrientation="fullUser" android:theme="@style/UnityThemeSelector">
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER"/>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="com.oculus.intent.category.VR"/>
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true"/>
            <meta-data android:name="notch_support" android:value="true"/>
            <meta-data android:name="com.oculus.vr.focusaware" android:value="true"/>
        </activity>
        <meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2|cambria"/>
    </application>
</manifest>

The resulting error is: System.Net.mail.SmtpException: Message could not be sent. ---> System.Net.Sockets.SocketException Will try to get the permission into the build, but already witnessed the re-enabling by unity.

saschaledermann commented 1 year ago

Fixed the issue by changing the option "Internet Access" from "Auto" to "Require" in the Player Settings. Then unchecking the flag in the OpenXR settings described by @DPelts.

image

With these two options set the permission <uses-permission android:name="android.permission.INTERNET" /> shows up in the AndroidManifest.xml in the build. A useful too for debugging was the apktool which allows you to unpack the apk to view the built AndroidManifest.xml.