Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
# Simplifying the structure of the class `ApplicationManagerImpl`


## Introduction

Concentration of various functionality within one class violates the single responsibility principle and makes it difficult to work with the class file.
`ApplicationManagerImpl.cc` contains more then 5000 lines of code that solve various problems and can be thematically categorized into separate classes.

## Motivation

Working with the ApplicationManagerImpl would be more convenient if some of the specific functionality would be moved into separate classes and these classes would be combined in a composition in the ApplicationManagerImpl.
With this approach, the ApplicationManagerImpl structure would be simpler and clearer.


## Proposed solution

As mentioned in the previous section, we could move some parts of `ApplicationManagerImpl.cc` to more approprite places.


Proposed edits :


Move next functions to utils

```
get_rand_from_range()
DirectoryTypeToString()
InitDirectory()
IsReadWriteAllowed()
SaveBinary()
IsSOStructValid()
ConvertSOtoMessage()
GenerateGrammarID()
```


Change next predicates to lambda functions where it is used, which will allow us to reduce the amount of code and make the code more expressive

```
device_id_comparator()
PolicyAppIdComparator()
ActiveAppPredicate()
FullOrLimitedAppPredicate()
LimitedMediaAppPredicate()
LimitedNaviAppPredicate()
LimitedVoiceAppPredicate()
NaviAppPredicate()
LimitedMobileProjectionPredicate()
MobileProjectionPredicate()
IsApplication()
MobileAppIdPredicate()
TakeDeviceHandle()
```


Move methods to new sub class `ApplicationDataProvider` since they are closely related
```
applications()
pending_applications()
reregister_applications()
application()
application_by_hmi_app()
application_by_policy_id()
pending_application_by_policy_id()
application_by_name()
reregister_application_by_policy_id()
active_application()
get_full_or_limited_application()
get_limited_media_application()
get_limited_navi_application()
get_limited_voice_application()
applications_with_navi()
get_limited_mobile_projection_application()
applications_with_mobile_projection()
applications_by_button()
applications_by_name()

OnApplicationRegistered()
OnApplicationSwitched()
RegisterApplication()
FinalizeAppRegistration()
ActivateApplication()
CreateApplications()
set_application_id()
SetUnregisterAllApplicationsReason()
UnregisterAllApplications()
RemoveAppsWaitingForRegistration()
UnregisterApplication()
OnAppUnauthorized()
GetHashedAppID()
ProcessApp()
IsApplicationForbidden()
GetAvailableSpaceForApp()
OnApplicationListUpdateTimer()
EraseAppFromReconnectionList()
AddAppToRegisteredAppList()
```


Move methods to new class `GlobalPropertiesHandler`

```
OnTimerSendTTSGlobalProperties()
AddAppToTTSGlobalPropertiesList()
RemoveAppFromTTSGlobalPropertiesList()
ResetGlobalProperties()
ResetAllApplicationGlobalProperties()
CreateAllAppGlobalPropsIDList()
ClearTTSGlobalPropertiesList()
```



Move methods to separate plugin `waypoints_plugin`
```
IsAppSubscribedForWayPoints()
SubscribeAppForWayPoints()
UnsubscribeAppFromWayPoints()
SaveWayPointsMessage()
IsAnyAppSubscribedForWayPoints()
GetAppsSubscribedForWayPoints()
```

Move methods to new class `StreamingHandler`
```
CanAppStream()
ForbidStreaming()
OnAppStreaming()
ProcessOnDataStreamingNotification()
StartEndStreamTimer()
EndNaviStreaming()
DisallowStreaming()
AllowStreaming()
StartNaviService()
StopNaviService()
OnServiceStartedCallback()
OnServiceEndedCallback()
ProcessServiceStatusUpdate()
HandleRejectedServiceStatus()
EndNaviServices()
```

Move methods to new class `HmiHandler`
```
IsHmiLevelFullAllowed()
OnHMIReady()
GetDefaultHmiLevel()
GenerateNewHMIAppID()
RemoveHMIFakeParameters()
hmi_so_factory()
hmi_capabilities()
HMIStateAllowsStreaming()
OnHMIStateChanged()
ProcessPostponedMessages()
IsHMICooperating()
SetHMICooperating()
CompareAppHMIType()
OnUpdateHMIAppType()
ChangeAppsHMILevel()
GetNextHMICorrelationID()
```

Move methods to new class `MobileHandler`
```
GetNextMobileCorrelationID()
GetCorrectMobileIDFromMessage()
mobile_so_factory()
```


Move methods to new class `DevicesHandler`
```
ConnectToDevice()
OnWebEngineDeviceCreated()
GetDeviceName()
GetDeviceTransportType()
RemoveDevice()
OnDeviceSwitchingStart()
OnDeviceSwitchingFinish()
GetUserConsentForDevice()
OnDeviceListUpdated()
```


Move methods to new class `SecurityHandler`
```
OnHandshakeDone()
OnPTUFailed()
OnGetSystemTimeFailed()
OnCertificateUpdateRequired()
GetPolicyCertificateData()
GetHandshakeContext()
OnCertDecryptFinished()
OnCertDecryptFailed()
```


Move methods to new class `ApplicationsHandler`

Choose a reason for hiding this comment

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

@VadymLuchko I think this should be a part of ApplicationDataProvider as it works with the same collection

Copy link
Author

Choose a reason for hiding this comment

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

edited in 5df5aab

```

```

After these edits, the ApplicationManagerImpl class will be engaged in organizing the interaction of the new classes described above

![img][uml-diagram]



## Potential downsides

New files for each new class will be created and added to repository


## Impact on existing code
Only ApplicationManagerImpl class of SDL Core will be impacted.


## Alternatives considered
Leave ApplicationManagerImpl as is


[uml-diagram]: ../assets/proposals/appManagerImpl_refactor/app_manager_uml.png