Permission Dialogs for Users in C

Tango works by using visual cues from the device's cameras. We want users to understand when and why the cameras are being used, so you must ask users for permission prior to using area learning or displaying the camera preview.

TangoService will not work without the user's permission in these cases.

How to request user permission

Android Camera permission

Applications that intend to use depth perception or show the camera preview must request the Android Camera permission in their manifest to get access to the camera feed through the Tango API.

ADF permissions

Currently, permission intents cannot be created directly through the C API functions, so you must call these intents in the Java layer. The functionality can be interfaced through JNI. For more information, see JNI Tips on the Android docs site.

ADF Load/Save intent

To request load/save permission, call the following Android permission intent. If the user hasn't given permission, this intent will show a popup asking for the permission. If you call this intend and the user already gave permission, no popup will be shown.

public static final String EXTRA_KEY_PERMISSIONTYPE = "PERMISSIONTYPE";
public static final String EXTRA_VALUE_ADF = "ADF_LOAD_SAVE_PERMISSION";

Intent intent1 = new Intent();
intent1.setAction("android.intent.action.REQUEST_TANGO_PERMISSION");
intent1.putExtra(EXTRA_KEY_PERMISSIONTYPE, EXTRA_VALUE_ADF);
startActivityForResult(intent1, 1);

ADF Import intent

Use the following intent to import an ADF from the filesystem. A permission screen will appear for each intent you send.

private static final String INTENT_CLASSPACKAGE = "com.projecttango.tango";
private static final String INTENT_IMPORTEXPORT_CLASSNAME = "com.google.atap.tango.RequestImportExportActivity";

// startActivityForResult requires a code number.
public static final int TANGO_INTENT_ACTIVITYCODE = 1129;
private static final String EXTRA_KEY_SOURCEFILE = "SOURCE_FILE";

Intent importIntent = new Intent();
importIntent.setClassName(INTENT_CLASSPACKAGE, INTENT_IMPORTEXPORT_CLASSNAME);
importIntent.putExtra(EXTRA_KEY_SOURCEFILE, filepath);
thisActivity.startActivityForResult(importIntent, TANGO_INTENT_ACTIVITYCODE);

ADF Export intent

Use the following intent to export an ADF to the filesystem. A permission screen will appear for each intent you send.

private static final String INTENT_CLASSPACKAGE = "com.projecttango.tango";
private static final String INTENT_IMPORTEXPORT_CLASSNAME = "com.google.atap.tango.RequestImportExportActivity";

// startActivityForResult requires a code number.
public static final int TANGO_INTENT_ACTIVITYCODE = 1129;
private static final String EXTRA_KEY_SOURCEUUID = "SOURCE_UUID";
private static final String EXTRA_KEY_DESTINATIONFILE = "DESTINATION_FILE";

Intent exportIntent = new Intent();
exportIntent.setClassName(INTENT_CLASSPACKAGE, INTENT_IMPORTEXPORT_CLASSNAME);
exportIntent.putExtra(EXTRA_KEY_SOURCEUUID, mUUIDList[info.position]);
exportIntent.putExtra(EXTRA_KEY_DESTINATIONFILE, mAppSpaceADFFolder);
thisActivity.startActivityForResult(exportIntent, TANGO_INTENT_ACTIVITYCODE);

API return codes

New return codes / exceptions in the API

The TangoErrorType has several enumerated values to let you know if an API call failed due to not having proper user permissions:

  • TANGO_NO_ADF_PERMISSION
  • TANGO_NO_IMPORT_EXPORT_PERMISSION
  • TANGO_NO_CAMERA_PERMISSION

API calls that require permission

The following calls in the C API require the user's permission.

API calls that require ADF_LOAD_SAVE_PERMISSION

  • TangoService_saveAreaDescription
  • TangoService_deleteAreaDescription
  • TangoService_getAreaDescriptionUUIDList
  • TangoService_getAreaDescriptionMetadata
  • TangoService_saveAreaDescriptionMetadata

API calls that require Android Camera permissions

  • TangoService_getCameraIntrinsics
  • TangoService_connectOnXYZijAvailable
  • TangoService_connectOnFrameAvailable
  • TangoService_connectTextureId
  • TangoService_disconnectCamera

Enviar comentarios sobre…