-
Notifications
You must be signed in to change notification settings - Fork 22
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
base: master
Are you sure you want to change the base?
Ask for permission only when needed #272
Conversation
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); |
There was a problem hiding this comment.
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
)?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
The documentation is very clear: https://github.com/googlesamples/tango-examples-c/blob/master/tango_client_api/include/tango_client_api.h#L676
…ure/ask_from_permission_only_when_needed Conflicts: TangoRosStreamer/app/src/main/java/eu/intermodalics/tango_ros_streamer/activities/RunningActivity.java
…ure/ask_from_permission_only_when_needed
@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(); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)?
…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
@mcopejans @smits Thanks for your comments. |
There was a problem hiding this 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."; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@mcopejans Thanks for the review. I think the schema for ADF and dataset permission is as follow:
|
Jenkins failed with the following error, is this expected:
|
test this please |
@mcopejans Yes, I think one line is missing here.
|
Yay, one point for Jenkins :) |
retest this please |
Fixes #270.