googlevr / cardboard

Open source Cardboard SDK and samples
Other
1.48k stars 253 forks source link

Scary permissions #244

Open Mandelbrow opened 3 years ago

Mandelbrow commented 3 years ago

Is it possible to prevent the Cardboard SDK from asking for permissions to access the Camera (,and ”full access to your bank account”…)? At least until it’s really needed for scanning the QR code.

jballoffet commented 3 years ago

Sorry for the delay here. As can be seen here (for Android) and here (for iOS), camera permission is currently only asked when the QR code scanning activity/view has been launched, and not before. Nonetheless, bear in mind that when the app has been installed and no device parameters have been already saved in the device, this activity/view is automatically launched (see https://github.com/googlevr/cardboard/blob/4382d959a62196405ab75a237b5c39094a137c6e/hellocardboard-android/src/main/jni/hello_cardboard_app.cc#L236, https://github.com/googlevr/cardboard/blob/4382d959a62196405ab75a237b5c39094a137c6e/hellocardboard-ios/HelloCardboardViewController.mm#L190 and https://github.com/googlevr/cardboard-xr-plugin/blob/38cb0047bbc1b5a56c113164c9915fe2d22bc664/Samples~/hellocardboard-unity/Scripts/CardboardStartup.cs#L41).

You can prevent the QR code scanner from being launched (and therefore the permission ask from taking place), by calling CardboardQrCode_getCardboardV1DeviceParams instead to get Cardboard v1 device parameters. You could also apply this patch to set the device params from a URI string.

Mandelbrow commented 3 years ago

Ok thanks, I'll have a look. Perhaps the SDK could default to the standard Cardboard 2 parameters?

jballoffet commented 3 years ago

The Cardboard SDK defaults to v1 viewer parameters since for historical reasons, those parameters were always stored in code (see https://github.com/googlevr/cardboard/tree/master/sdk/qrcode/cardboard_v1). Nevertheless, you can easily modify those files to default to Cardboard Viewer v2 instead of v1.