Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ask for permission only when needed #272

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

PerrineAguiar
Copy link

Fixes #270.

getTangoPermission(EXTRA_VALUE_ADF, REQUEST_CODE_ADF_PERMISSION);
if (!mParameterNode.getStringParam(getString(R.string.dataset_datasets_path_key)).isEmpty() &&
!mParameterNode.getStringParam(getString(R.string.dataset_uuid_key)).isEmpty())
getTangoPermission(EXTRA_VALUE_DATASET, REQUEST_CODE_DATASET_PERMISSION);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it required to get Tango permissions before connecting to Tango (SERVICE_CONNECTED)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation is not really clear about it but I think not, they are required only for specific Tango API calls like: TangoService_getAreaDescriptionUUIDList, TangoService_getAreaDescriptionMetadata, TangoService_saveAreaDescription or TangoService_Experimental_getDatasetUUIDs.

What we could also do is, each time we do one of this call from the C++ code, somehow trigger this intent in the Java code. I think it could be possible using a ros topic.

Copy link
Contributor

@mcopejans mcopejans May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tango Connect returns TANGO_NO_DATASET_PERMISSION if permissions are not granted for recording a dataset BEFORE connecting.

See: https://github.com/googlesamples/tango-examples-c/blob/master/tango_client_api/include/tango_client_api.h#L76

The documentation is very clear: https://github.com/googlesamples/tango-examples-c/blob/master/tango_client_api/include/tango_client_api.h#L676

Perrine Aguiar added 3 commits May 11, 2017 11:27
…ure/ask_from_permission_only_when_needed

Conflicts:
	TangoRosStreamer/app/src/main/java/eu/intermodalics/tango_ros_streamer/activities/RunningActivity.java
@PerrineAguiar
Copy link
Author

@mcopejans Thanks for your comment. I changed the code to trigger the permission intent from c++ using the tango status topic, ptal.

UpdateAndPublishTangoStatus(TangoStatus::NEED_TO_REQUEST_ADF_PERMISSION);
while (tango_status_ != TangoStatus::ADF_PERMISSION_REQUEST_ANSWERED) {
ros::Duration(0.1).sleep();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to implement this using a service call? Sleeping does not look like an elegant solution. Why did you choose not to request permissions before connecting on the Java side.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to trigger permission request from the C++ side because this is where we know exactly when and which permission we need. For example, if the user reconnect to Tango using the ros command line tool, the Java side does not know that a service call to /tango/connect has been made.
Here we are using the /tango/status topic to trigger the permission request from C++ to Java, and know when the request has been answered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is abusing the /tango/status the best way to do this? Why not using a ros service call between the java side (server) and the c++ side (client)?

Perrine Aguiar added 5 commits June 1, 2017 12:53
…ure/ask_from_permission_only_when_needed

Conflicts:
	TangoRosStreamer/app/src/main/java/eu/intermodalics/tango_ros_streamer/activities/RunningActivity.java
	tango_ros_common/tango_ros_common/src/main/java/eu/intermodalics/tango_ros_common/ParameterNode.java
@PerrineAguiar
Copy link
Author

PerrineAguiar commented Jun 1, 2017

@mcopejans @smits Thanks for your comments.
I implemented a service to request permissions as suggested, ptal.

Copy link
Contributor

@mcopejans mcopejans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good, but I added one comment to improve the app flow. For this feature, I think it is useful to have a schema in mind that illustrates what happens when each permission is granted vs. not granted.

if (srv.response.granted) {
LOG(INFO) << "Dataset permission has been requested and granted by the user.";
} else {
LOG(WARNING) << "Dataset permission has been requested but not granted by the user.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, a permission that was not granted will lead to a connection failure? I would resend the request in this case or force the user to go back to the settings screen. The app cannot continue in any other way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will indeed fail to connect if we try to load/record dataset while dataset premission is not granted. I would like to test it but I did not find a proper way to revoke the dataset permission.

@PerrineAguiar
Copy link
Author

@mcopejans Thanks for the review.

I think the schema for ADF and dataset permission is as follow:

  • ADF permission is needed only when saving an ADF or accessing its metadata. In our case it means that if the user does not grant ADF permission, he will not be able to save a map or see the list of available maps.
  • Dataset permission is needed when loading/recording dataset. If the user does not grant dataset permission while loading or recording a dataset, connection to Tango will fail.

@mcopejans
Copy link
Contributor

Jenkins failed with the following error, is this expected:

ros_common/tango_ros_native/include/tango_ros_native/tango_ros_node.h:43:50: fatal error: tango_ros_messages/RequestPermission.h: No such file or directory
 #include <tango_ros_messages/RequestPermission.h>

@mcopejans
Copy link
Contributor

test this please

@PerrineAguiar
Copy link
Author

@mcopejans Yes, I think one line is missing here.
It should be:

RequestPermission
RequestPermissionRequest
RequestPermissionResponse

@mcopejans
Copy link
Contributor

Yay, one point for Jenkins :)

@meyerj
Copy link
Contributor

meyerj commented Feb 20, 2018

retest this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants