diff --git a/assets/proposals/appManagerImpl_refactor/app_manager_uml.png b/assets/proposals/appManagerImpl_refactor/app_manager_uml.png new file mode 100644 index 000000000..de2c2e9c6 Binary files /dev/null and b/assets/proposals/appManagerImpl_refactor/app_manager_uml.png differ diff --git a/proposals/____-Simplifying-structure-of-the-class-ApplicationManagerImpl.md b/proposals/____-Simplifying-structure-of-the-class-ApplicationManagerImpl.md new file mode 100644 index 000000000..3af9b79ca --- /dev/null +++ b/proposals/____-Simplifying-structure-of-the-class-ApplicationManagerImpl.md @@ -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` +``` + +``` + +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 \ No newline at end of file