Languages

Menu
Sites
Language
How to Request Privacy Privileges

I am working on a Hybrid App (Web UI with Native Service) of API version 4.0 for my Gear S3 Frontier.

  • The Web UI launches the Service.
  • Native Service uses the Sensor and Location data.

My Service App has the privilege of Senor and Location in the manifest file. When I check the privileges in code, the results show that I need to get privilege from user, which is perfectly fine.

 

I've implemented it using the Privacy Privilege Manager but when I request for privilege using the ppm_request_permission method, it doesn't show any message asking for the permission, and so it doesn't go the ppm_request_response_cb method

 

Here's the relevant code:

 

Response Handler Implementation:

void ppm_request_response_handler(ppm_call_cause_e cause, ppm_request_result_e result, const char *privilege, void *user_data)
{
    dlog_print(DLOG_DEBUG, TAG, "In the ppm_request_response_handler.");

	/*
	 * The result of a response triggered by calling ppm_request_permission() is a valid value only if
	 * the cause parameter is equal to PRIVACY_PRIVILEGE_MANAGER_CALL_CAUSE_ANSWER.
	 */
	if(cause == PRIVACY_PRIVILEGE_MANAGER_CALL_CAUSE_ANSWER)
	{
		if(result == PRIVACY_PRIVILEGE_MANAGER_REQUEST_RESULT_ALLOW_FOREVER)
		{
			if(!strcmp(privilege, "http://tizen.org/privilege/location"))
			{
				bIsLocationPrivilegeGranted = true;
				dlog_print(DLOG_DEBUG, TAG, "Service Application has been granted the Location privilege.");
			}

			if(!strcmp(privilege, "http://tizen.org/privilege/healthinfo"))
			{
				bIsHealthInfoPrivilegeGranted = true;
				dlog_print(DLOG_DEBUG, TAG, "Service Application has been granted the Health Info privilege.");
			}
		}
		else
		{
			if(!strcmp(privilege, "http://tizen.org/privilege/location"))
			{
				dlog_print(DLOG_DEBUG, TAG, "Service Application is denied to access the Location.");
			}

			if(!strcmp(privilege, "http://tizen.org/privilege/healthinfo"))
			{
				dlog_print(DLOG_DEBUG, TAG, "Service Application is denied to access the Health Information.");
			}
		}
	}
	else
	{
		if(!strcmp(privilege, "http://tizen.org/privilege/location"))
		{
			dlog_print(DLOG_DEBUG, TAG, "Service Application did not get any response to access the Location.");
		}

		if(!strcmp(privilege, "http://tizen.org/privilege/healthinfo"))
		{
			dlog_print(DLOG_DEBUG, TAG, "Service Application did not get any response to access the Health Information.");
		}
	}
}

typedef void(* ppm_request_response)(ppm_call_cause_e cause, ppm_request_result_e result, const char *privilege, void *user_data);

 

Method Call to Request for Permission:

//Set the function pointer value
ppm_request_response ppm_request_response_cb = ppm_request_response_handler;

//Request the user for the permission
ppm_request_permission(requiredPrivileges[i], ppm_request_response_cb, NULL);

 

Expected Behaviour:

Service App should show any message asking the user about the permission, the ppm_request_response_handler method should be invoked then to handle the response of the user.

 

Edited by: Itban Saeed on 17 Sep, 2019
View Selected Answer

Responses

3 Replies
Kim Kidong

https://developer.tizen.org/development/guides/native-application/security/privacy-related-permissions

Did you do following the above link?

The ppm_request_permission makes a popup and user should select 'Allow' or 'Deny'.

Those use decision is returned in the callback function. (ppm_request_response_cb)

 

I think ppm_request_permission was not called or user didn't select anything in the popup.

 

Itban Saeed

Hi, many thanks for the response. I am already following the link you mentioned. The ppm_request_permission method returns 0 (which indicates success) but it does not makes any popup as expected. The control is also NOT transfered to the callback which seems weird.

Mark as answer
Itban Saeed

My issue is resolved after resetting the device. I don't know what was the exact reason which was preventing the pop up to be shown on the screen. Posting this to help anyone else who may face the same wierd behavior.