diff options
author | Shinwoo Kim <cinoo.kim@samsung.com> | 2021-09-16 21:30:45 +0900 |
---|---|---|
committer | Shinwoo Kim <cinoo.kim@samsung.com> | 2021-09-17 10:52:27 +0900 |
commit | 587433b71ac8900935bee0066e46514f3eb6e749 (patch) | |
tree | 571c8c869bb5e91dc8ded678075787ff0a09a634 /dali/internal/accessibility/bridge | |
parent | c7d6824912dc232e9e3eb46d1fb9b32710bf285d (diff) | |
download | dali-adaptor-587433b71ac8900935bee0066e46514f3eb6e749.tar.gz dali-adaptor-587433b71ac8900935bee0066e46514f3eb6e749.tar.bz2 dali-adaptor-587433b71ac8900935bee0066e46514f3eb6e749.zip |
[ATSPI] Initialize Bridge on Idler
There is an application launching before dbus.
In this case application cannot use ATSPI interface.
Because the Bridge cannot get a dbus connection.
We prepared BridgeDisableAutoInit.
But someone does not want to make application change.
This patch is providing a way to initialize the Bridge
for an application launching before dbus.
Change-Id: Ic254f8e001c3d4f198b0a7bb680e5c5792b818cd
Diffstat (limited to 'dali/internal/accessibility/bridge')
-rw-r--r-- | dali/internal/accessibility/bridge/bridge-impl.cpp | 114 | ||||
-rw-r--r-- | dali/internal/accessibility/bridge/dbus-tizen.cpp | 16 |
2 files changed, 92 insertions, 38 deletions
diff --git a/dali/internal/accessibility/bridge/bridge-impl.cpp b/dali/internal/accessibility/bridge/bridge-impl.cpp index aaed7fbf2..972436836 100644 --- a/dali/internal/accessibility/bridge/bridge-impl.cpp +++ b/dali/internal/accessibility/bridge/bridge-impl.cpp @@ -55,7 +55,7 @@ class BridgeImpl : public virtual BridgeBase, public BridgeSelection, public BridgeApplication { - DBus::DBusClient listenOnAtspiEnabledSignalClient; + DBus::DBusClient accessibilityStatusClient; DBus::DBusClient registryClient, directReadingClient; bool screenReaderEnabled = false; bool isEnabled = false; @@ -63,35 +63,11 @@ class BridgeImpl : public virtual BridgeBase, std::unordered_map<int32_t, std::function<void(std::string)>> directReadingCallbacks; Dali::Actor highlightedActor; std::function<void(Dali::Actor)> highlightClearAction; + Dali::CallbackBase* mIdleCallback = NULL; public: BridgeImpl() { - listenOnAtspiEnabledSignalClient = DBus::DBusClient{A11yDbusName, A11yDbusPath, A11yDbusStatusInterface, DBus::ConnectionType::SESSION}; - - listenOnAtspiEnabledSignalClient.addPropertyChangedEvent<bool>("ScreenReaderEnabled", [this](bool res) { - screenReaderEnabled = res; - if(screenReaderEnabled || isEnabled) - { - ForceUp(); - } - else - { - ForceDown(); - } - }); - - listenOnAtspiEnabledSignalClient.addPropertyChangedEvent<bool>("IsEnabled", [this](bool res) { - isEnabled = res; - if(screenReaderEnabled || isEnabled) - { - ForceUp(); - } - else - { - ForceDown(); - } - }); } Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) override @@ -226,7 +202,11 @@ public: mData->mHighlightActor = {}; } ForceDown(); - listenOnAtspiEnabledSignalClient = {}; + if((NULL != mIdleCallback) && Dali::Adaptor::IsAvailable()) + { + Dali::Adaptor::Get().RemoveIdle(mIdleCallback); + } + accessibilityStatusClient = {}; dbusServer = {}; con = {}; } @@ -315,25 +295,93 @@ public: isShown = true; } - void Initialize() override + void ReadAndListenProperty() { - auto dbusClient = DBus::DBusClient{A11yDbusName, A11yDbusPath, A11yDbusStatusInterface, DBus::ConnectionType::SESSION}; - auto enabled = dbusClient.property<bool>("ScreenReaderEnabled").get(); + // read property + auto enabled = accessibilityStatusClient.property<bool>("ScreenReaderEnabled").get(); if(enabled) { screenReaderEnabled = std::get<0>(enabled); } - - enabled = dbusClient.property<bool>("IsEnabled").get(); + enabled = accessibilityStatusClient.property<bool>("IsEnabled").get(); if(enabled) { isEnabled = std::get<0>(enabled); } - if(screenReaderEnabled || isEnabled) { ForceUp(); } + + // listen property change + accessibilityStatusClient.addPropertyChangedEvent<bool>("ScreenReaderEnabled", [this](bool res) { + screenReaderEnabled = res; + if(screenReaderEnabled || isEnabled) + { + ForceUp(); + } + else + { + ForceDown(); + } + }); + + accessibilityStatusClient.addPropertyChangedEvent<bool>("IsEnabled", [this](bool res) { + isEnabled = res; + if(screenReaderEnabled || isEnabled) + { + ForceUp(); + } + else + { + ForceDown(); + } + }); + } + + bool InitializeAccessibilityStatusClient() + { + accessibilityStatusClient = DBus::DBusClient{A11yDbusName, A11yDbusPath, A11yDbusStatusInterface, DBus::ConnectionType::SESSION}; + + if (!accessibilityStatusClient) + { + DALI_LOG_ERROR("Accessibility Status DbusClient is not ready\n"); + return false; + } + + return true; + } + + bool OnIdleSignal() + { + if ( InitializeAccessibilityStatusClient() ) + { + ReadAndListenProperty(); + mIdleCallback = NULL; + return false; + } + + return true; + } + + void Initialize() override + { + if ( InitializeAccessibilityStatusClient() ) + { + ReadAndListenProperty(); + return; + } + + // Initialize failed. Try it again on Idle + if( Dali::Adaptor::IsAvailable() ) + { + Dali::Adaptor& adaptor = Dali::Adaptor::Get(); + if( NULL == mIdleCallback ) + { + mIdleCallback = MakeCallback( this, &BridgeImpl::OnIdleSignal ); + adaptor.AddIdle( mIdleCallback, true ); + } + } } bool GetScreenReaderEnabled() diff --git a/dali/internal/accessibility/bridge/dbus-tizen.cpp b/dali/internal/accessibility/bridge/dbus-tizen.cpp index cc2a45cc9..bbb265d2c 100644 --- a/dali/internal/accessibility/bridge/dbus-tizen.cpp +++ b/dali/internal/accessibility/bridge/dbus-tizen.cpp @@ -110,9 +110,12 @@ DBus::DBusClient::DBusClient(std::string busName, std::string pathName, std::str else connectionState->connection = conn; - std::ostringstream o; - o << "bus = " << busName << " path = " << pathName << " connection = " << DBUS_W->eldbus_connection_unique_name_get_impl(connectionState->connection); - info = o.str(); + + if (!connectionState->connection) + { + DALI_LOG_ERROR("DBusClient connection is not ready\n"); + return; + } connectionState->object = DBUS_W->eldbus_object_get_impl(connectionState->connection, busName.c_str(), pathName.c_str()); if(connectionState->object) @@ -511,10 +514,13 @@ struct DefaultDBusWrapper : public DBusWrapper } } - eldbus_init(); auto p = eldbus_connection_get(eldbusType); + if (!p) + { + DALI_LOG_ERROR("cannot get dbus connection\n"); + return NULL; + } auto w = create(p, true); - eldbus_shutdown(); return w; } |