<commit_before>// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

#include <set>

#include "AboutPageViewModule.h"
#include "AndroidApplicationConfigurationVersionProvider.h"
#include "AndroidAppThreadAssertionMacros.h"
#include "AndroidImageNameHelper.h"
#include "AndroidInitialExperienceModule.h"
#include "AndroidMenuReactionModel.h"
#include "AndroidPlatformAbstractionModule.h"
#include "AndroidPlatformConfigBuilder.h"
#include "ApiKey.h"
#include "AppHost.h"
#include "AppInterface.h"
#include "ApplicationConfiguration.h"
#include "ApplicationConfigurationModule.h"
#include "AssertHandler.h"
#include "CompassViewModule.h"
#include "ConnectivityChangedViewMessage.h"
#include "CurrentLocationService.h"
#include "EegeoWorld.h"
#include "EffectHandler.h"
#include "EGL/egl.h"
#include "FlattenButtonViewModule.h"
#include "IAboutPageModule.h"
#include "ICompassModule.h"
#include "IFlattenButtonModule.h"
#include "IInteriorsExplorerModule.h"
#include "IModalityModule.h"
#include "IMyPinCreationDetailsModule.h"
#include "IMyPinCreationModule.h"
#include "IMyPinDetailsModule.h"
#include "InitialExperienceIntroViewModule.h"
#include "InteriorsExplorerViewModule.h"
#include "InteriorMetaDataModule.h"
#include "IOptionsModule.h"
#include "ISearchMenuModule.h"
#include "ISearchResultPoiModule.h"
#include "ISearchResultSectionModule.h"
#include "ISettingsMenuModule.h"
#include "ITagSearchModule.h"
#include "IViewControllerUpdaterModel.h"
#include "IWatermarkModule.h"
#include "jni.h"
#include "JpegLoader.h"
#include "MenuController.h"
#include "MobileExampleApp.h"
#include "ModalBackgroundNativeViewModule.h"
#include "ModalBackgroundViewModule.h"
#include "MyPinCreationDetailsViewModule.h"
#include "MyPinCreationViewModule.h"
#include "MyPinDetailsViewModule.h"
#include "NetworkCapabilities.h"
#include "OptionsViewModule.h"
#include "PlatformConfig.h"
#include "ScreenProperties.h"
#include "SearchMenuViewModule.h"
#include "SearchResultPoiViewModule.h"
#include "SearchResultSectionViewModule.h"
#include "SettingsMenuViewModule.h"
#include "TagSearchViewModule.h"
#include "TtyHandler.h"
#include "UserInteractionEnabledChangedMessage.h"
#include "ViewControllerUpdaterModule.h"
#include "WatermarkViewModule.h"
#include "WebConnectivityValidator.h"
#include "SurveyViewModule.h"
#include "SenionLabBroadcastReceiver.h"

using namespace Eegeo::Android;
using namespace Eegeo::Android::Input;

namespace
{
	ExampleApp::ApplicationConfig::ApplicationConfiguration LoadApplicationConfiguration(AndroidNativeState& nativeState, const std::set<std::string>& customApplicationAssetDirectories)
	{
	    AndroidFileIO tempFileIO(&nativeState, customApplicationAssetDirectories);
	    ExampleApp::ApplicationConfig::SdkModel::AndroidApplicationConfigurationVersionProvider versionProvider(nativeState);

	    return ExampleApp::ApplicationConfig::SdkModel::LoadAppConfig(
	    		tempFileIO,
	    		versionProvider,
	    		ExampleApp::ApplicationConfigurationPath);
	}
}

AppHost::AppHost(
    AndroidNativeState& nativeState,
    Eegeo::Rendering::ScreenProperties screenProperties,
    EGLDisplay display,
    EGLSurface shareSurface,
    EGLContext resourceBuildShareContext
)
    :m_isPaused(false)
    ,m_pJpegLoader(NULL)
    ,m_pAndroidLocationService(NULL)
    ,m_pCurrentLocationService(NULL)
    ,m_pAndroidConnectivityService(NULL)
    ,m_nativeState(nativeState)
    ,m_androidInputBoxFactory(&nativeState)
    ,m_androidKeyboardInputFactory(&nativeState, m_inputHandler)
    ,m_androidAlertBoxFactory(&nativeState)
    ,m_androidNativeUIFactories(m_androidAlertBoxFactory, m_androidInputBoxFactory, m_androidKeyboardInputFactory)
    ,m_pInputProcessor(NULL)
    ,m_pAndroidPlatformAbstractionModule(NULL)
    ,m_pSearchMenuViewModule(NULL)
	,m_pSettingsMenuViewModule(NULL)
	,m_pSearchResultSectionViewModule(NULL)
    ,m_pModalBackgroundViewModule(NULL)
    ,m_pFlattenButtonViewModule(NULL)
    ,m_pMyPinCreationViewModule(NULL)
    ,m_pMyPinCreationDetailsViewModule(NULL)
    ,m_pMyPinDetailsViewModule(NULL)
    ,m_pSearchResultPoiViewModule(NULL)
    ,m_pCompassViewModule(NULL)
    ,m_pApp(NULL)
    ,m_androidPersistentSettingsModel(nativeState)
    ,m_createdUIModules(false)
    ,m_requestedApplicationInitialiseViewState(false)
    ,m_uiCreatedMessageReceivedOnNativeThread(false)
    ,m_pViewControllerUpdaterModule(NULL)
	,m_pAndroidFlurryMetricsService(NULL)
	,m_pInitialExperienceIntroViewModule(NULL)
    ,m_pTagSearchViewModule(NULL)
	,m_failAlertHandler(this, &AppHost::HandleStartupFailure)
	,m_userInteractionEnabledChangedHandler(this, &AppHost::HandleUserInteractionEnabledChanged)
    ,m_pSenionLabLocationModule(NULL)
    ,m_pIndoorAtlasLocationModule(NULL)
    ,m_pSenionLabBroadcastReceiver(NULL)
    ,m_pInteriorsLocationServiceModule(NULL)
{
    ASSERT_NATIVE_THREAD

    Eegeo_ASSERT(resourceBuildShareContext != EGL_NO_CONTEXT);

    Eegeo::TtyHandler::TtyEnabled = true;
    Eegeo::AssertHandler::BreakOnAssert = true;

    m_pAndroidLocationService = Eegeo_NEW(AndroidLocationService)(&nativeState);
    m_pCurrentLocationService = Eegeo_NEW(Eegeo::Helpers::CurrentLocationService::CurrentLocationService)(*m_pAndroidLocationService);
    m_pAndroidConnectivityService = Eegeo_NEW(AndroidConnectivityService)(&nativeState);

    m_pJpegLoader = Eegeo_NEW(Eegeo::Helpers::Jpeg::JpegLoader)();

    std::set<std::string> customApplicationAssetDirectories;
    customApplicationAssetDirectories.insert("SearchResultOnMap");
    customApplicationAssetDirectories.insert("ApplicationConfigs");

    const ExampleApp::ApplicationConfig::ApplicationConfiguration& applicationConfiguration = LoadApplicationConfiguration(nativeState, customApplicationAssetDirectories);
	
    m_pAndroidPlatformAbstractionModule = Eegeo_NEW(Eegeo::Android::AndroidPlatformAbstractionModule)(
            nativeState,
            *m_pJpegLoader,
            display,
            resourceBuildShareContext,
            shareSurface,
            applicationConfiguration.EegeoApiKey(),
            customApplicationAssetDirectories);

    Eegeo::EffectHandler::Initialise();

    std::string deviceModel = std::string(nativeState.deviceModel, strlen(nativeState.deviceModel));
    Eegeo::Android::AndroidImageNameHelper imageHelper(&nativeState);
    Eegeo::Android::AndroidPlatformConfigBuilder androidPlatformConfigBuilder(deviceModel,
																			  imageHelper.GetImageResolutionSuffix(),
																			  imageHelper.GetImageResolutionScale());

    const Eegeo::Config::PlatformConfig& platformConfiguration = ExampleApp::ApplicationConfig::SdkModel::BuildPlatformConfig(androidPlatformConfigBuilder, applicationConfiguration);

    m_pInputProcessor = Eegeo_NEW(Eegeo::Android::Input::AndroidInputProcessor)(&m_inputHandler, screenProperties.GetScreenWidth(), screenProperties.GetScreenHeight());

    m_pInitialExperienceModule = Eegeo_NEW(ExampleApp::InitialExperience::SdkModel::AndroidInitialExperienceModule)(
                                     m_nativeState,
                                     m_androidPersistentSettingsModel,
                                     m_messageBus
                                 );

    m_pNetworkCapabilities = Eegeo_NEW(ExampleApp::Net::SdkModel::NetworkCapabilities)(
    		*m_pAndroidConnectivityService,
    		m_pAndroidPlatformAbstractionModule->GetHttpCache(),
    		m_androidPersistentSettingsModel);

    m_pAndroidFlurryMetricsService = Eegeo_NEW(ExampleApp::Metrics::AndroidFlurryMetricsService)(&m_nativeState);

    m_pMenuReactionModel = Eegeo_NEW(ExampleApp::Menu::View::AndroidMenuReactionModel)();

    m_pApp = Eegeo_NEW(ExampleApp::MobileExampleApp)(
    			 applicationConfiguration,
                 *m_pAndroidPlatformAbstractionModule,
                 screenProperties,
                 *m_pCurrentLocationService,
                 m_androidNativeUIFactories,
                 platformConfiguration,
                 *m_pJpegLoader,
                 *m_pInitialExperienceModule,
                 m_androidPersistentSettingsModel,
                 m_messageBus,
                 m_sdkDomainEventBus,
                 *m_pNetworkCapabilities,
                 *m_pAndroidFlurryMetricsService,
                 *this,
                 *m_pMenuReactionModel,
                 m_userIdleService);

    Eegeo::Modules::Map::MapModule& mapModule = m_pApp->World().GetMapModule();
    Eegeo::Modules::Map::Layers::InteriorsPresentationModule& interiorsPresentationModule = mapModule.GetInteriorsPresentationModule();
    m_pSenionLabLocationModule = Eegeo_NEW(ExampleApp::InteriorsPosition::SdkModel::SenionLab::SenionLabLocationModule)(m_pApp->GetAppModeModel(),
                                                                                                                        interiorsPresentationModule.GetInteriorInteractionModel(),
                                                                                                                        interiorsPresentationModule.GetInteriorSelectionModel(),
                                                                                                                        mapModule.GetEnvironmentFlatteningService(),
                                                                                                                        *m_pAndroidLocationService,
                                                                                                                        mapModule.GetInteriorMetaDataModule().GetInteriorMetaDataRepository(),
                                                                                                                        m_messageBus,
                                                                                                                        m_nativeState);

    m_pIndoorAtlasLocationModule = Eegeo_NEW(ExampleApp::InteriorsPosition::SdkModel::IndoorAtlas::IndoorAtlasLocationModule)(m_pApp->GetAppModeModel(),
                                                                                                                              interiorsPresentationModule.GetInteriorInteractionModel(),
                                                                                                                              interiorsPresentationModule.GetInteriorSelectionModel(),
                                                                                                                              mapModule.GetEnvironmentFlatteningService(),
                                                                                                                              *m_pAndroidLocationService,
                                                                                                                              mapModule.GetInteriorMetaDataModule().GetInteriorMetaDataRepository(),
																															  m_messageBus,
                                                                                                                              m_nativeState);

    const std::map<std::string, Eegeo::Location::ILocationService&> interiorLocationServices{{"Senion", m_pSenionLabLocationModule->GetLocationService()},
                                                                                             {"IndoorAtlas", m_pIndoorAtlasLocationModule->GetLocationService()}};
    m_pInteriorsLocationServiceModule = Eegeo_NEW(ExampleApp::InteriorsPosition::SdkModel::InteriorsLocationServiceModule)(m_pApp->InteriorsExplorerModule().GetInteriorsExplorerModel(),
                                                                                                                           interiorsPresentationModule.GetInteriorSelectionModel(),
                                                                                                                           *m_pCurrentLocationService,
                                                                                                                           *m_pAndroidLocationService,
                                                                                                                           interiorLocationServices,
                                                                                                                           mapModule.GetInteriorMetaDataModule().GetInteriorMetaDataRepository(),
																														   interiorsPresentationModule.GetInteriorInteractionModel(),
																														   m_pApp->CameraTransitionController(),
																														   m_pApp->CompassModule().GetCompassModel(),
                                                                                                                           m_messageBus);

    m_pModalBackgroundNativeViewModule = Eegeo_NEW(ExampleApp::ModalBackground::SdkModel::ModalBackgroundNativeViewModule)(
            m_pApp->World().GetRenderingModule(),
            m_messageBus);

    m_pAppInputDelegate = Eegeo_NEW(AppInputDelegate)(*m_pApp);
    m_inputHandler.AddDelegateInputHandler(m_pAppInputDelegate);
}

AppHost::~AppHost()
{
    ASSERT_NATIVE_THREAD

	Eegeo_DELETE m_pInteriorsLocationServiceModule;
	m_pInteriorsLocationServiceModule = NULL;

	m_pCurrentLocationService->SetLocationService(*m_pAndroidLocationService);

	Eegeo_DELETE m_pSenionLabLocationModule;
	m_pSenionLabLocationModule = NULL;

    m_inputHandler.RemoveDelegateInputHandler(m_pAppInputDelegate);

    Eegeo_DELETE m_pAppInputDelegate;
    m_pAppInputDelegate = NULL;

    Eegeo_DELETE m_pApp;
    m_pApp = NULL;

    Eegeo_DELETE m_pAndroidFlurryMetricsService;
    m_pAndroidFlurryMetricsService = NULL;

    Eegeo_DELETE m_pNetworkCapabilities;
    m_pNetworkCapabilities = NULL;

    Eegeo_DELETE m_pInitialExperienceModule;
    m_pInitialExperienceModule = NULL;

    Eegeo_DELETE m_pInputProcessor;
    m_pInputProcessor = NULL;

    Eegeo::EffectHandler::Reset();
    Eegeo::EffectHandler::Shutdown();

    Eegeo_DELETE m_pAndroidPlatformAbstractionModule;
    m_pAndroidPlatformAbstractionModule = NULL;

    Eegeo_DELETE m_pJpegLoader;
    m_pJpegLoader = NULL;

    Eegeo_DELETE m_pIndoorAtlasLocationModule;
    m_pIndoorAtlasLocationModule = NULL;<commit_msg>Fix MPLY-8164: correct AppHost destructor resource free order (avoiding a dangling reference to IAppModeModel in the indooratlas controller). Buddy: John.<commit_after>// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

#include <set>

#include "AboutPageViewModule.h"
#include "AndroidApplicationConfigurationVersionProvider.h"
#include "AndroidAppThreadAssertionMacros.h"
#include "AndroidImageNameHelper.h"
#include "AndroidInitialExperienceModule.h"
#include "AndroidMenuReactionModel.h"
#include "AndroidPlatformAbstractionModule.h"
#include "AndroidPlatformConfigBuilder.h"
#include "ApiKey.h"
#include "AppHost.h"
#include "AppInterface.h"
#include "ApplicationConfiguration.h"
#include "ApplicationConfigurationModule.h"
#include "AssertHandler.h"
#include "CompassViewModule.h"
#include "ConnectivityChangedViewMessage.h"
#include "CurrentLocationService.h"
#include "EegeoWorld.h"
#include "EffectHandler.h"
#include "EGL/egl.h"
#include "FlattenButtonViewModule.h"
#include "IAboutPageModule.h"
#include "ICompassModule.h"
#include "IFlattenButtonModule.h"
#include "IInteriorsExplorerModule.h"
#include "IModalityModule.h"
#include "IMyPinCreationDetailsModule.h"
#include "IMyPinCreationModule.h"
#include "IMyPinDetailsModule.h"
#include "InitialExperienceIntroViewModule.h"
#include "InteriorsExplorerViewModule.h"
#include "InteriorMetaDataModule.h"
#include "IOptionsModule.h"
#include "ISearchMenuModule.h"
#include "ISearchResultPoiModule.h"
#include "ISearchResultSectionModule.h"
#include "ISettingsMenuModule.h"
#include "ITagSearchModule.h"
#include "IViewControllerUpdaterModel.h"
#include "IWatermarkModule.h"
#include "jni.h"
#include "JpegLoader.h"
#include "MenuController.h"
#include "MobileExampleApp.h"
#include "ModalBackgroundNativeViewModule.h"
#include "ModalBackgroundViewModule.h"
#include "MyPinCreationDetailsViewModule.h"
#include "MyPinCreationViewModule.h"
#include "MyPinDetailsViewModule.h"
#include "NetworkCapabilities.h"
#include "OptionsViewModule.h"
#include "PlatformConfig.h"
#include "ScreenProperties.h"
#include "SearchMenuViewModule.h"
#include "SearchResultPoiViewModule.h"
#include "SearchResultSectionViewModule.h"
#include "SettingsMenuViewModule.h"
#include "TagSearchViewModule.h"
#include "TtyHandler.h"
#include "UserInteractionEnabledChangedMessage.h"
#include "ViewControllerUpdaterModule.h"
#include "WatermarkViewModule.h"
#include "WebConnectivityValidator.h"
#include "SurveyViewModule.h"
#include "SenionLabBroadcastReceiver.h"

using namespace Eegeo::Android;
using namespace Eegeo::Android::Input;

namespace
{
	ExampleApp::ApplicationConfig::ApplicationConfiguration LoadApplicationConfiguration(AndroidNativeState& nativeState, const std::set<std::string>& customApplicationAssetDirectories)
	{
	    AndroidFileIO tempFileIO(&nativeState, customApplicationAssetDirectories);
	    ExampleApp::ApplicationConfig::SdkModel::AndroidApplicationConfigurationVersionProvider versionProvider(nativeState);

	    return ExampleApp::ApplicationConfig::SdkModel::LoadAppConfig(
	    		tempFileIO,
	    		versionProvider,
	    		ExampleApp::ApplicationConfigurationPath);
	}
}

AppHost::AppHost(
    AndroidNativeState& nativeState,
    Eegeo::Rendering::ScreenProperties screenProperties,
    EGLDisplay display,
    EGLSurface shareSurface,
    EGLContext resourceBuildShareContext
)
    :m_isPaused(false)
    ,m_pJpegLoader(NULL)
    ,m_pAndroidLocationService(NULL)
    ,m_pCurrentLocationService(NULL)
    ,m_pAndroidConnectivityService(NULL)
    ,m_nativeState(nativeState)
    ,m_androidInputBoxFactory(&nativeState)
    ,m_androidKeyboardInputFactory(&nativeState, m_inputHandler)
    ,m_androidAlertBoxFactory(&nativeState)
    ,m_androidNativeUIFactories(m_androidAlertBoxFactory, m_androidInputBoxFactory, m_androidKeyboardInputFactory)
    ,m_pInputProcessor(NULL)
    ,m_pAndroidPlatformAbstractionModule(NULL)
    ,m_pSearchMenuViewModule(NULL)
	,m_pSettingsMenuViewModule(NULL)
	,m_pSearchResultSectionViewModule(NULL)
    ,m_pModalBackgroundViewModule(NULL)
    ,m_pFlattenButtonViewModule(NULL)
    ,m_pMyPinCreationViewModule(NULL)
    ,m_pMyPinCreationDetailsViewModule(NULL)
    ,m_pMyPinDetailsViewModule(NULL)
    ,m_pSearchResultPoiViewModule(NULL)
    ,m_pCompassViewModule(NULL)
    ,m_pApp(NULL)
    ,m_androidPersistentSettingsModel(nativeState)
    ,m_createdUIModules(false)
    ,m_requestedApplicationInitialiseViewState(false)
    ,m_uiCreatedMessageReceivedOnNativeThread(false)
    ,m_pViewControllerUpdaterModule(NULL)
	,m_pAndroidFlurryMetricsService(NULL)
	,m_pInitialExperienceIntroViewModule(NULL)
    ,m_pTagSearchViewModule(NULL)
	,m_failAlertHandler(this, &AppHost::HandleStartupFailure)
	,m_userInteractionEnabledChangedHandler(this, &AppHost::HandleUserInteractionEnabledChanged)
    ,m_pSenionLabLocationModule(NULL)
    ,m_pIndoorAtlasLocationModule(NULL)
    ,m_pSenionLabBroadcastReceiver(NULL)
    ,m_pInteriorsLocationServiceModule(NULL)
{
    ASSERT_NATIVE_THREAD

    Eegeo_ASSERT(resourceBuildShareContext != EGL_NO_CONTEXT);

    Eegeo::TtyHandler::TtyEnabled = true;
    Eegeo::AssertHandler::BreakOnAssert = true;

    m_pAndroidLocationService = Eegeo_NEW(AndroidLocationService)(&nativeState);
    m_pCurrentLocationService = Eegeo_NEW(Eegeo::Helpers::CurrentLocationService::CurrentLocationService)(*m_pAndroidLocationService);
    m_pAndroidConnectivityService = Eegeo_NEW(AndroidConnectivityService)(&nativeState);

    m_pJpegLoader = Eegeo_NEW(Eegeo::Helpers::Jpeg::JpegLoader)();

    std::set<std::string> customApplicationAssetDirectories;
    customApplicationAssetDirectories.insert("SearchResultOnMap");
    customApplicationAssetDirectories.insert("ApplicationConfigs");

    const ExampleApp::ApplicationConfig::ApplicationConfiguration& applicationConfiguration = LoadApplicationConfiguration(nativeState, customApplicationAssetDirectories);
	
    m_pAndroidPlatformAbstractionModule = Eegeo_NEW(Eegeo::Android::AndroidPlatformAbstractionModule)(
            nativeState,
            *m_pJpegLoader,
            display,
            resourceBuildShareContext,
            shareSurface,
            applicationConfiguration.EegeoApiKey(),
            customApplicationAssetDirectories);

    Eegeo::EffectHandler::Initialise();

    std::string deviceModel = std::string(nativeState.deviceModel, strlen(nativeState.deviceModel));
    Eegeo::Android::AndroidImageNameHelper imageHelper(&nativeState);
    Eegeo::Android::AndroidPlatformConfigBuilder androidPlatformConfigBuilder(deviceModel,
																			  imageHelper.GetImageResolutionSuffix(),
																			  imageHelper.GetImageResolutionScale());

    const Eegeo::Config::PlatformConfig& platformConfiguration = ExampleApp::ApplicationConfig::SdkModel::BuildPlatformConfig(androidPlatformConfigBuilder, applicationConfiguration);

    m_pInputProcessor = Eegeo_NEW(Eegeo::Android::Input::AndroidInputProcessor)(&m_inputHandler, screenProperties.GetScreenWidth(), screenProperties.GetScreenHeight());

    m_pInitialExperienceModule = Eegeo_NEW(ExampleApp::InitialExperience::SdkModel::AndroidInitialExperienceModule)(
                                     m_nativeState,
                                     m_androidPersistentSettingsModel,
                                     m_messageBus
                                 );

    m_pNetworkCapabilities = Eegeo_NEW(ExampleApp::Net::SdkModel::NetworkCapabilities)(
    		*m_pAndroidConnectivityService,
    		m_pAndroidPlatformAbstractionModule->GetHttpCache(),
    		m_androidPersistentSettingsModel);

    m_pAndroidFlurryMetricsService = Eegeo_NEW(ExampleApp::Metrics::AndroidFlurryMetricsService)(&m_nativeState);

    m_pMenuReactionModel = Eegeo_NEW(ExampleApp::Menu::View::AndroidMenuReactionModel)();

    m_pApp = Eegeo_NEW(ExampleApp::MobileExampleApp)(
    			 applicationConfiguration,
                 *m_pAndroidPlatformAbstractionModule,
                 screenProperties,
                 *m_pCurrentLocationService,
                 m_androidNativeUIFactories,
                 platformConfiguration,
                 *m_pJpegLoader,
                 *m_pInitialExperienceModule,
                 m_androidPersistentSettingsModel,
                 m_messageBus,
                 m_sdkDomainEventBus,
                 *m_pNetworkCapabilities,
                 *m_pAndroidFlurryMetricsService,
                 *this,
                 *m_pMenuReactionModel,
                 m_userIdleService);

    Eegeo::Modules::Map::MapModule& mapModule = m_pApp->World().GetMapModule();
    Eegeo::Modules::Map::Layers::InteriorsPresentationModule& interiorsPresentationModule = mapModule.GetInteriorsPresentationModule();
    m_pSenionLabLocationModule = Eegeo_NEW(ExampleApp::InteriorsPosition::SdkModel::SenionLab::SenionLabLocationModule)(m_pApp->GetAppModeModel(),
                                                                                                                        interiorsPresentationModule.GetInteriorInteractionModel(),
                                                                                                                        interiorsPresentationModule.GetInteriorSelectionModel(),
                                                                                                                        mapModule.GetEnvironmentFlatteningService(),
                                                                                                                        *m_pAndroidLocationService,
                                                                                                                        mapModule.GetInteriorMetaDataModule().GetInteriorMetaDataRepository(),
                                                                                                                        m_messageBus,
                                                                                                                        m_nativeState);

    m_pIndoorAtlasLocationModule = Eegeo_NEW(ExampleApp::InteriorsPosition::SdkModel::IndoorAtlas::IndoorAtlasLocationModule)(m_pApp->GetAppModeModel(),
                                                                                                                              interiorsPresentationModule.GetInteriorInteractionModel(),
                                                                                                                              interiorsPresentationModule.GetInteriorSelectionModel(),
                                                                                                                              mapModule.GetEnvironmentFlatteningService(),
                                                                                                                              *m_pAndroidLocationService,
                                                                                                                              mapModule.GetInteriorMetaDataModule().GetInteriorMetaDataRepository(),
																															  m_messageBus,
                                                                                                                              m_nativeState);

    const std::map<std::string, Eegeo::Location::ILocationService&> interiorLocationServices{{"Senion", m_pSenionLabLocationModule->GetLocationService()},
                                                                                             {"IndoorAtlas", m_pIndoorAtlasLocationModule->GetLocationService()}};
    m_pInteriorsLocationServiceModule = Eegeo_NEW(ExampleApp::InteriorsPosition::SdkModel::InteriorsLocationServiceModule)(m_pApp->InteriorsExplorerModule().GetInteriorsExplorerModel(),
                                                                                                                           interiorsPresentationModule.GetInteriorSelectionModel(),
                                                                                                                           *m_pCurrentLocationService,
                                                                                                                           *m_pAndroidLocationService,
                                                                                                                           interiorLocationServices,
                                                                                                                           mapModule.GetInteriorMetaDataModule().GetInteriorMetaDataRepository(),
																														   interiorsPresentationModule.GetInteriorInteractionModel(),
																														   m_pApp->CameraTransitionController(),
																														   m_pApp->CompassModule().GetCompassModel(),
                                                                                                                           m_messageBus);

    m_pModalBackgroundNativeViewModule = Eegeo_NEW(ExampleApp::ModalBackground::SdkModel::ModalBackgroundNativeViewModule)(
            m_pApp->World().GetRenderingModule(),
            m_messageBus);

    m_pAppInputDelegate = Eegeo_NEW(AppInputDelegate)(*m_pApp);
    m_inputHandler.AddDelegateInputHandler(m_pAppInputDelegate);
}

AppHost::~AppHost()
{
    ASSERT_NATIVE_THREAD

    m_inputHandler.RemoveDelegateInputHandler(m_pAppInputDelegate);

    Eegeo_DELETE m_pAppInputDelegate;
    m_pAppInputDelegate = NULL;

    Eegeo_DELETE m_pModalBackgroundNativeViewModule;
    m_pModalBackgroundNativeViewModule = NULL;

    m_pCurrentLocationService->SetLocationService(*m_pAndroidLocationService);

	Eegeo_DELETE m_pInteriorsLocationServiceModule;
	m_pInteriorsLocationServiceModule = NULL;

    Eegeo_DELETE m_pIndoorAtlasLocationModule;
    m_pIndoorAtlasLocationModule = NULL;

	Eegeo_DELETE m_pSenionLabLocationModule;
	m_pSenionLabLocationModule = NULL;

    Eegeo_DELETE m_pApp;
    m_pApp = NULL;

    Eegeo_DELETE m_pMenuReactionModel;
    m_pMenuReactionModel = NULL;

    Eegeo_DELETE m_pAndroidFlurryMetricsService;
    m_pAndroidFlurryMetricsService = NULL;

    Eegeo_DELETE m_pNetworkCapabilities;
    m_pNetworkCapabilities = NULL;

    Eegeo_DELETE m_pInitialExperienceModule;
    m_pInitialExperienceModule = NULL;

    Eegeo_DELETE m_pInputProcessor;
    m_pInputProcessor = NULL;

    Eegeo::EffectHandler::Reset();
    Eegeo::EffectHandler::Shutdown();

    Eegeo_DELETE m_pAndroidPlatformAbstractionModule;
    m_pAndroidPlatformAbstractionModule = NULL;

    Eegeo_DELETE m_pJpegLoader;
    m_pJpegLoader = NULL;
{'fraction_non_alphanumeric': 0.07221835883171071, 'fraction_numerical': 0.0006954102920723226, 'mean_word_length': 2.4477343562694798, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 204, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3358370', 'n_tokens_mistral': 7124, 'n_tokens_neox': 6911, 'n_words': 826}