Tizen Native Service 不要求应用程序启动权限

时间:2021-07-04 13:47:00

标签: privileges tizen tizen-native-app

我正在为我的 Samsung Galaxy Active Watch 开发 API 版本 5.5 的 Hybrid App(具有本机服务的 Web UI)。我想从另一个本地服务启动一个本地服务。

问题:

My Service App 在清单文件中拥有 http://tizen.org/privilege/appmanager.launch & http://tizen.org/privilege/application.launch 权限。当我使用 ppm_check_permissionsPrivacy Privilege Manager 方法检查权限时,结果显示 http://tizen.org/privilege/application.launch 被用户永久拒绝。

我从不否认这个特权。我也重置了设备,但结果是一样的。当我尝试使用 ppm_request_permission 强制请求权限时,结果为 PRIVACY_PRIVILEGE_MANAGER_REQUEST_RESULT_DENY_FOREVER

如果我尝试在没有权限的情况下启动目标应用程序,则不会按照要求启动。即使目标应用程序在同一个包中,我也会收到 APP_CONTROL_ERROR_LAUNCH_REJECTED 错误。

预期行为:

服务应用程序应该允许我向用户请求 http://tizen.org/privilege/application.launch 的权限,以便我可以从这个服务启动另一个服务。

清单文件:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="5.5" package="org.example.myservice" version="1.0.0">
    <profile name="wearable"/>
    <service-application appid="org.example.myservice" exec="myservice" multiple="false" nodisplay="true" taskmanage="false" type="capp">
        <label>myservice</label>
        <icon>myservice.png</icon>
        <background-category value="location"/>
        <background-category value="background-network"/>
        <background-category value="sensor"/>
    </service-application>
    <privileges>
        <privilege>http://tizen.org/privilege/network.get</privilege>
        <privilege>http://tizen.org/privilege/appdir.shareddata</privilege>
        <privilege>http://tizen.org/privilege/healthinfo</privilege>
        <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
        <privilege>http://tizen.org/privilege/haptic</privilege>
        <privilege>http://tizen.org/privilege/internet</privilege>
        <privilege>http://tizen.org/privilege/datasharing</privilege>
    </privileges>
    <feature name="http://tizen.org/feature/sensor.accelerometer">true</feature>
    <feature name="http://tizen.org/feature/sensor.pedometer">true</feature>
    <feature name="http://tizen.org/feature/sensor.heart_rate_monitor">true</feature>
    <feature name="http://tizen.org/feature/sensor.gyroscope">true</feature>
    <feature name="http://tizen.org/feature/sensor.gesture_recognition">true</feature>
</manifest>

权限检查代码:

void check_and_request_permissions()
{
    const char* required_privileges[] = {
        "http://tizen.org/privilege/location",
        "http://tizen.org/privilege/internet",
        "http://tizen.org/privilege/network.get",
        "http://tizen.org/privilege/appdir.shareddata",
        "http://tizen.org/privilege/datasharing",
        "http://tizen.org/privilege/healthinfo",
        "http://tizen.org/privilege/haptic",
        "http://tizen.org/privilege/appmanager.launch"
        };
    ppm_check_result_e privilege_permission_results[PRIVILEGESCOUNT];
    int result = ppm_check_permissions(required_privileges, PRIVILEGESCOUNT, privilege_permission_results);
    if(result == PRIVACY_PRIVILEGE_MANAGER_ERROR_NONE)
    {
        //Make the permissions list to be asked
        askable_privileges_count = 0;
        for(int i=0;i<PRIVILEGESCOUNT;i++)
        {
            switch(privilege_permission_results[i])
            {
                //Application already have this particular privilege
                case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ALLOW:
                    #ifdef LOGGING_REQUIRED
                        dlog_print(DLOG_DEBUG, LOG_TAG, "handle_ppm_check_result: Wellbeing Service application has already been granted the \'%s\' privilege.", required_privileges[i]);
                    #endif
                    break;

                //Application is already denied to access this particular privilege
                case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_DENY:
                    #ifdef LOGGING_REQUIRED
                        dlog_print(DLOG_DEBUG, LOG_TAG, "handle_ppm_check_result: Wellbeing Service application has already been denied the \'%s\' privilege.", required_privileges[i]);
                    #endif
                    break;

                case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ASK:
                    #ifdef LOGGING_REQUIRED
                        dlog_print(DLOG_DEBUG, LOG_TAG, "handle_ppm_check_result: \'%s\' privilege is not granted yet.", required_privileges[i]);
                    #endif
                    askable_privileges[askable_privileges_count++] = required_privileges[i];
                    break;
            }
        }

        //Ask for the privileges now
        askable_privileges_index = 0;
        #ifdef LOGGING_REQUIRED
            dlog_print(DLOG_DEBUG, LOG_TAG, "Remaining Privileges: %d - %d = %d.", askable_privileges_count, askable_privileges_index, askable_privileges_count-1-askable_privileges_index);
        #endif
        while (askable_privileges_index < askable_privileges_count)
        {
            #ifdef LOGGING_REQUIRED
                dlog_print(DLOG_DEBUG, LOG_TAG, "handle_ppm_check_result: Asking for the \'%s\' privilege...", askable_privileges[askable_privileges_index]);
            #endif
            ppm_request_permission(askable_privileges[askable_privileges_index], ppm_request_response_callback, NULL);
            askable_privileges_index++;
        }
        if(device_user_name[0] != '\0')
        {
            //Initialize JSON variables
            json_object_root = cJSON_CreateArray();
        }
    }
    else
    {
        if(result == PRIVACY_PRIVILEGE_MANAGER_ERROR_IO_ERROR )
        {
            #ifdef LOGGING_REQUIRED
                dlog_print(DLOG_DEBUG, LOG_TAG, "get_privacy_previleges: \'ppm_check_permission\' method failed to execute. Error: PRIVACY_PRIVILEGE_MANAGER_ERROR_IO_ERROR", result);
            #endif
        }
        else if(result == PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER)
        {
            #ifdef LOGGING_REQUIRED
                dlog_print(DLOG_DEBUG, LOG_TAG, "get_privacy_previleges: \'ppm_check_permission\' method failed to execute. Error: PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER", result);
            #endif
        }
        else if(result == PRIVACY_PRIVILEGE_MANAGER_ERROR_ALREADY_IN_PROGRESS)
        {
            #ifdef LOGGING_REQUIRED
                dlog_print(DLOG_DEBUG, LOG_TAG, "get_privacy_previleges: \'ppm_check_permission\' method failed to execute. Error: PRIVACY_PRIVILEGE_MANAGER_ERROR_ALREADY_IN_PROGRESS", result);
            #endif
        }
        else if(result == PRIVACY_PRIVILEGE_MANAGER_ERROR_OUT_OF_MEMORY)
        {
            #ifdef LOGGING_REQUIRED
                dlog_print(DLOG_DEBUG, LOG_TAG, "get_privacy_previleges: \'ppm_check_permission\' method failed to execute. Error: PRIVACY_PRIVILEGE_MANAGER_ERROR_OUT_OF_MEMORY", result);
            #endif
        }
        else if(result == PRIVACY_PRIVILEGE_MANAGER_ERROR_PERMISSION_DENIED)
        {
            #ifdef LOGGING_REQUIRED
                dlog_print(DLOG_DEBUG, LOG_TAG, "get_privacy_previleges: \'ppm_check_permission\' method failed to execute. Error: PRIVACY_PRIVILEGE_MANAGER_ERROR_PERMISSION_DENIED", result);
            #endif
        }
        else if(result == PRIVACY_PRIVILEGE_MANAGER_ERROR_UNKNOWN)
        {
            #ifdef LOGGING_REQUIRED
                dlog_print(DLOG_DEBUG, LOG_TAG, "get_privacy_previleges: \'ppm_check_permission\' method failed to execute. Error: PRIVACY_PRIVILEGE_MANAGER_ERROR_UNKNOWN", result);
            #endif
        }
    }
}

0 个答案:

没有答案