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

Feature/New remote control modules and parameters #2207

Merged
merged 13 commits into from
Aug 17, 2018

Conversation

LitvinenkoIra
Copy link
Contributor

@LitvinenkoIra LitvinenkoIra commented May 23, 2018

Technical task : #1798
This PR is ready for review.

This pull request contains the implementation of new remote control modules and parameters
(proposal: https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0099-new-remote-control-modules-and-parameters.md)
For testing use the following test set:
https://github.com/smartdevicelink/sdl_atf_test_scripts/blob/feature/rc_new_modules/test_sets/rc_AUDIO_LIGHT_HMI_SETTINGS.txt

Pull request with ATF scripts: smartdevicelink/sdl_atf_test_scripts#1909

For manual testing use:
HMI from : smartdevicelink/sdl_hmi#52
mobile application SPT from HockeyApp 20180213-Nightly-Android

Risk

This PR makes [major] API changes.

CLA

@@ -118,6 +118,10 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
RCAppExtensionPtr GetApplicationExtention(
application_manager::ApplicationSharedPtr application) FINAL;

bool is_rc_enabled() const FINAL;

Choose a reason for hiding this comment

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

not related to new module?

@@ -118,6 +118,10 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
RCAppExtensionPtr GetApplicationExtention(
application_manager::ApplicationSharedPtr application) FINAL;

bool is_rc_enabled() const FINAL;

void set_rc_enabled(const bool value) FINAL;

Choose a reason for hiding this comment

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

not related to new module?

@@ -204,6 +208,7 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
hmi_apis::Common_RCAccessMode::eType current_access_mode_;
application_manager::ApplicationManager& app_mngr_;
application_manager::rpc_service::RPCService& rpc_service_;
bool is_rc_enabled_;

Choose a reason for hiding this comment

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

shall not be new code

@@ -144,6 +144,10 @@ class ResourceAllocationManager {
virtual RCAppExtensionPtr GetApplicationExtention(
application_manager::ApplicationSharedPtr application) = 0;

virtual bool is_rc_enabled() const = 0;

Choose a reason for hiding this comment

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

not new module related

@@ -131,6 +131,7 @@ void RCOnRemoteControlSettingsNotification::Run() {
hmi_apis::Common_RCAccessMode::eType access_mode =
hmi_apis::Common_RCAccessMode::INVALID_ENUM;
LOG4CXX_DEBUG(logger_, "Allowing RC Functionality");
resource_allocation_manager_.set_rc_enabled(true);

Choose a reason for hiding this comment

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

that 's #2197

if (message_params::kLightState == request_parameter) {
return CheckLightNameByCapabilities(
module_caps[strings::kSupportedLights],
control_data[request_parameter][0]);

Choose a reason for hiding this comment

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

control_data[request_parameter][0], this only checks the first element of LightState array ? How about there is more than 1 element?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bool module_type_and_data_match = false;
for (const auto& data : data_mapping) {
if (data.first == module_type) {
module_type_and_data_match = module_data.keyExists(data.second);

Choose a reason for hiding this comment

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

  • break;


if (app_wants_to_set_audio_src && !app->IsAllowedToChangeAudioSource()) {
LOG4CXX_WARN(logger_, "App is not allowed to change audio source");
SetResourceState(ModuleType(), ResourceState::FREE);

Choose a reason for hiding this comment

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

why need SetResourceState(ModuleType(), ResourceState::FREE);?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yang1070 because we execute the command only if the resource successfully acquired https://github.com/smartdevicelink/sdl_core/blob/feature/rc_new_modules/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc#L144

and release it when we received response from HMI
https://github.com/smartdevicelink/sdl_core/blob/feature/rc_new_modules/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc#L192

so in case when smthg goes wrong (when we execute the command) and we did not send a request to HMI, we need to release the resource before sending a response to mobile.

Copy link

@yang1070 yang1070 May 30, 2018

Choose a reason for hiding this comment

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

Let's consider the scenario
app1 set the volume, it succeeds, AUDIO module is assigned to app1
app1 set some value of equalizer, it succeeds, AUDIO module is still assigned to app1
app1 tried to set the audio source, and does not pass the check of line 374, AUDIO shall still be allocated to app1, AUDIO module shall not be set to free in line 376, it shall be unchanged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yang1070
I tested this case, so in current implementation:

  1. app1 set the volume, it succeeds, AUDIO module is assigned to app1 (SDL don't receive response from HMI)
  2. app1 set some value of equalizer and receive from SDL response "IN_USE"

then when we receive response from HMI for step 1 -> AUDIO module is released

  1. app1 tried to set the audio source (and acquire AUDIO module), and does not pass the check of line 374 -> AUDIO module becomes free.

maybe we should change this logic, but actually this is an old RC functionality, here is a link for our requirements for resource allocation
https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/RC/resource_allocation.md

return module_data[data.second];
}
}
NOTREACHED();

Choose a reason for hiding this comment

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

what is NOTREACHED()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yang1070 DCHECK(!"Unreachable code")

}
application_manager_.set_current_audio_source(

Choose a reason for hiding this comment

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

shall this be set only after sdl forward the request to HMI and get a successful response?

Copy link
Contributor Author

@LitvinenkoIra LitvinenkoIra May 30, 2018

Choose a reason for hiding this comment

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

bool SetInteriorVehicleDataRequest::AreReadOnlyParamsPresent(
const smart_objects::SmartObject& module_data) {
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& module_type_params =
ControlData(module_data);
auto it = module_type_params.map_begin();
std::vector<std::string> ro_params = GetModuleReadOnlyParams(ModuleType());
const std::string module_type = ModuleType();
std::vector<std::string> ro_params = GetModuleReadOnlyParams(module_type);

Choose a reason for hiding this comment

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

it is strange kChannelName is not returned in GetModuleReadOnlyParams()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -143,6 +143,14 @@ void RCCommandRequest::Run() {
SendResponse(false, mobile_apis::Result::DISALLOWED, "");
return;
}
if (!resource_allocation_manager_.is_rc_enabled()) {

Choose a reason for hiding this comment

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

shall be PR #2197

@@ -227,7 +227,8 @@ mobile_apis::HMILevel::eType AudioSource::hmi_level() const {
// Should be investigated (used in multiple places here), since looks weird
if (Compare<HMILevel::eType, EQ, ONE>(parent()->hmi_level(),
HMILevel::HMI_BACKGROUND,
HMILevel::HMI_NONE)) {
HMILevel::HMI_NONE,
HMILevel::HMI_FULL)) {

Choose a reason for hiding this comment

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

why need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yang1070 This is a fix for the case when a media remote control app is in FULL and it sends a SetInteriorVehicleData to change the audio source to Radio and has keepContext=true, HMI sends AUDIO_SOURCE event to core, SDL shall keep the app’s HMI in FULL and set audioStreamingState to NOT_AUDIBLE.
(before SDL brings app from FULL state to BACKGROUND)

Choose a reason for hiding this comment

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

@LitvinenkoIra Got it. Thanks,

<description>
This parameter shall not be present in any getter responses or notifications.
This parameter is optional in a setter request. The default value is false.
If it is true, the system not only changes the audio source but also brings the default application

Choose a reason for hiding this comment

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

I have it wrong (the opposite) in the proposal.
Shall be
If it is false, the system not only changes the audio source but also brings the default application ...
If it is true, the system changes the audio source, but still keeps the current application in foreground.


// audio
mapping["source"] = "sourceAvailable";
mapping["keepContext"] = "sourceAvailable";
Copy link

@yang1070 yang1070 May 29, 2018

Choose a reason for hiding this comment

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

I think adding a keepContextAvailable to the capabilities in mobile api and hmi api xml might be a good way to resolve this
mapping["keepContext"] = "keepContextAvailable";

+ <struct name="AudioControlCapabilities">
+     <param name="moduleName" type="String" maxlength="100" mandatory="true">
+         <description>
+         The short friendly name of the light control module.
+         It should not be used to identify a module by mobile application.
+         </description>
+     </param>
+     <param name="sourceAvailable" type="Boolean" mandatory="false">
+         <description>Availability of the control of audio source. </description>
+     </param>
+     <param name="keepContextAvailable" type="Boolean" mandatory="false">
+         <description>Availability of the keepContext paramter. </description>
+     </param>
+     <param name="volumeAvailable" type="Boolean" mandatory="false">
+         <description>Availability of the control of audio volume.</description>
+     </param>
+     <param name="equalizerAvailable" type="Boolean" mandatory="false">
+         <description>Availability of the control of Equalizer Settings.</description>
+     </param>
+     <param name="equalizerMaxChannelId" type="Integer" minvalue="1" maxvalue="100" mandatory="false">
+         <description>Must be included if equalizerAvailable=true, and assume all IDs starting from 1 to this value are valid</description>
+     </param>
+ </struct>

@@ -219,6 +220,14 @@ void ResourceAllocationManagerImpl::SetResourceAquired(
allocated_resources_[module_type] = app_id;
}

bool ResourceAllocationManagerImpl::is_rc_enabled() const {

Choose a reason for hiding this comment

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

PR #2197 ?

@@ -292,6 +292,13 @@ const HmiStatePtr ApplicationImpl::RegularHmiState() const {
return state_.GetState(HmiState::STATE_ID_REGULAR);
}

bool ApplicationImpl::IsAllowedToChangeAudioSource() const {
if (!is_remote_control_supported() || !is_media_application()) {
Copy link

@yang1070 yang1070 May 29, 2018

Choose a reason for hiding this comment

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

return (is_remote_control_supported() && is_media_application());

<param name="sourceAvailable" type="Boolean" mandatory="false">
<description>Availability of the control of audio source. </description>
</param>
<param name="volumeAvailable" type="Boolean" mandatory="false">

Choose a reason for hiding this comment

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

add

+     <param name="keepContextAvailable" type="Boolean" mandatory="false">
+         <description>Availability of the keepContext paramter. </description>
+     </param>

</param>
<param name="sourceAvailable" type="Boolean" mandatory="false">
<description>Availability of the control of audio source. </description>
</param>

Choose a reason for hiding this comment

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

add

+     <param name="keepContextAvailable" type="Boolean" mandatory="false">
+         <description>Availability of the keepContext paramter. </description>
+     </param>

<description>
This parameter shall not be present in any getter responses or notifications.
This parameter is optional in a setter request. The default value is false.
If it is true, the system not only changes the audio source but also brings the default application

Choose a reason for hiding this comment

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

I have it wrong in the proposal.
shall be

If it is false,  the system not only changes the audio source but also brings the default application ...
If it is true, the system changes the audio source, but still keeps the current application in foreground.

@ghost
Copy link

ghost commented Aug 15, 2018

@yang1070 @jacobkeeler All comments were fixed.

Availability of the reading of current temperature.
True: Available, False: Not Available, Not present: Not Available.
</description>
<param name="currentTemperatureAvailable" type="Boolean" mandatory="false" since="5.0">
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was description removed?

Copy link

Choose a reason for hiding this comment

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

@jacobkeeler According to your first comment in #2207 (review)

Copy link
Contributor

@jacobkeeler jacobkeeler Aug 15, 2018

Choose a reason for hiding this comment

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

I was referring to the parameter as a whole, not the description. currentTemperatureAvailable should not be added in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jacobkeeler yes, this is not related to the proposal, I suppose it was done as bugfix.

This parameter is added with 36f37bb (within RemoteControllbaseline)
#1708

Then it was removed with ccd116f

The proposal https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0071-remote-control-baseline.md also does not contain this parameter. But I suppose that it is the bug, because currentTemperature parameters exist in ClimateControlData. I will remove it from this PR with separate commit 6575ede

<element name="SEAT"/>
<element name="RADIO"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not rearrange existing order of ModuleTypes

Copy link
Contributor

Choose a reason for hiding this comment

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

@jacobkeeler rearrange removed

<element name="RADIO"/>
<element name="SEAT" since="5.0"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not rearrange order of existing modules

Copy link
Contributor

Choose a reason for hiding this comment

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

@jacobkeeler rearrange removed

LuxoftAKutsan and others added 11 commits August 16, 2018 16:16
Mobile API and HMI capabilities for the rc new modules

Fix RC defects

- Fixed Mobile & HMI API: removed redundant default value
- FIxed GetInteriorVehicleData request behavior
- Fixed OnInteriorDataNotification behavior

Fix header guards and add missed includes

Fix control data checking by capabilities

Answered to review comments

Commit
Save current audio source and check it in SetInteriorVehicleDataRequest

Save current audio source in app manager

Fix SDL behavior when app wants to change audio source
…event to core

UTs to verify that SDL keeps app's HMI level in FULL in case when HMI sends AUDIO_SOURCE even
Availability of the reading of current temperature.
True: Available, False: Not Available, Not present: Not Available.
</description>
</param>
Copy link
Contributor

@jacobkeeler jacobkeeler Aug 16, 2018

Choose a reason for hiding this comment

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

If this already exists in the HMI API, it shouldn't be removed from here. This discrepancy should be handled in another PR.

<param name="volume" type="Integer" mandatory="false" minvalue="0" maxvalue="100">
<description>Reflects the volume of audio, from 0%-100%.</description>
</param>
<param name="equalizerSettings" type="EqualizerSettings" minsize="1" maxsize="100" mandatory="false" array ="true">
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary space in array ="true"

<param name="blue" type="Integer" minvalue="0" maxvalue="255" mandatory="true" />
</struct>

<struct name="TemplateColorScheme" since="5.0">
Copy link
Contributor

Choose a reason for hiding this comment

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

No reason to move this struct.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jacobkeeler there is the reason to move RGBColor, and I just would like to keep it near the TemplateColorScheme because they are related to the same area. Should I move TemplateColorScheme back?

Copy link
Contributor

Choose a reason for hiding this comment

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

Already taken care of

@AStasiuk
Copy link

This PR was successfully rebased, all feature related ATF tests are PASSED.
@yang1070 could you please review provided changes?

@yang1070
Copy link

The change looks good to me.

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

Successfully merging this pull request may close these issues.

9 participants