我正在为我的Gear S3 Frontier开发API版本4.0的Hybrid App(带有本机服务的Web UI)。
我的Service App在清单文件中具有“传感器和位置”的特权。当我检查代码中的特权时,结果表明我需要从用户那里获得特权,这很好。
我已经使用Privacy Privilege Manager实现了它,但是当我使用ppm_request_permission方法请求特权时,它没有显示任何请求权限的消息,因此它没有。不要使用ppm_request_response_cb方法。
以下是相关代码:
响应处理程序的实现:
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);
方法调用以获取许可:
//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);
预期行为:
Service App应该显示任何询问用户有关权限的消息,然后应调用ppm_request_response_handler
方法来处理用户的响应。
答案 0 :(得分:1)
网络搜索显示,即使重新安装应用程序后,存储在设备上的特权设置也可能不会更新。在Tizen开发者论坛上发布的一个问题也说明了这一点,在讨论过程中,我说服我重置设备,为我完成了工作。
答案 1 :(得分:1)
据我所知,多权限调用仅在 Tizen 5+ 中可用,因此如果您使用 Tizen 4.0 API,则需要单独询问每个权限。