[ATSPI] ignore ScreenReaderEnabled property on suppress mode 39/267839/5
authorShinwoo Kim <cinoo.kim@samsung.com>
Fri, 10 Dec 2021 08:42:21 +0000 (17:42 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Thu, 16 Dec 2021 01:08:17 +0000 (10:08 +0900)
The 'suppress' mode means that we do not want screen-reader working
for our ATSPI related event. In this case, it would be better NOT to
enable ATSPI bridge.

So far we have used 'suppress-screen-reader' attribute. But sometimes
GetAttributes does not work with following error message.

"get attribute error: Did not receive a reply. Possible causes include:
 the remote application did not send a reply, the message bus security
 policy blocked the reply, the reply timeout expired, or the network
 connection was broken."

We could handle this case, but the best is NOT to send unnecessary
ATSPI events.

The screen-reader should turning on ScreenReaderEnabled property only
The ATSPI bridge will be enabled, when IsEnabled property is set by
another AT client such as Aurum.

Change-Id: I529ae8cc29594915b20c23279371a6488d11ea2d

dali/internal/accessibility/bridge/bridge-accessible.cpp
dali/internal/accessibility/bridge/bridge-accessible.h
dali/internal/accessibility/bridge/bridge-base.h
dali/internal/accessibility/bridge/bridge-impl.cpp

index 189a091..00a2107 100644 (file)
@@ -604,11 +604,6 @@ BridgeAccessible::ReadingMaterialType BridgeAccessible::GetReadingMaterial()
     describedByObject};
 }
 
-void BridgeAccessible::SuppressScreenReader(bool suppress)
-{
-  mIsScreenReaderSuppressed = suppress;
-}
-
 DBus::ValueOrError<bool> BridgeAccessible::DoGesture(Dali::Accessibility::Gesture type, int32_t startPositionX, int32_t startPositionY, int32_t endPositionX, int32_t endPositionY, Dali::Accessibility::GestureState state, uint32_t eventTime)
 {
   // Please be aware of sending GestureInfo point in the different order with parameters
index 38fd049..d5f6c95 100644 (file)
@@ -189,11 +189,6 @@ public:
   ReadingMaterialType GetReadingMaterial();
 
   /**
-   * @copydoc Dali::Accessibility::Bridge::SuppressScreenReader()
-   */
-  void SuppressScreenReader(bool) override;
-
-  /**
    * @copydoc Dali::Accessibility::Accessible::DoGesture()
    */
   DBus::ValueOrError<bool> DoGesture(Dali::Accessibility::Gesture type, int32_t startPositionX, int32_t startPositionY, int32_t endPositionX, int32_t endPositionY, Dali::Accessibility::GestureState state, uint32_t eventTime);
@@ -284,9 +279,6 @@ private:
    * @return The Component object
    */
   Dali::Accessibility::Component* CalculateNavigableAccessibleAtPoint(Dali::Accessibility::Accessible* root, Dali::Accessibility::Point point, Dali::Accessibility::CoordinateType type, unsigned int maxRecursionDepth);
-
-protected:
-  bool mIsScreenReaderSuppressed = false;
 };
 
 #endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_ACCESSIBLE_H
index d604994..dacbfc6 100644 (file)
@@ -441,6 +441,7 @@ public:
 protected:
   mutable AppAccessible                         mApplication;
   std::vector<Dali::Accessibility::Accessible*> mDefaultLabels;
+  bool                                          mIsScreenReaderSuppressed = false;
 
 private:
   /**
index 19d519a..116e703 100644 (file)
@@ -443,6 +443,19 @@ public:
     }
   }
 
+  /**
+   * @copydoc Dali::Accessibility::Bridge::SuppressScreenReader()
+   */
+  void SuppressScreenReader(bool suppress) override
+  {
+    if(mIsScreenReaderSuppressed == suppress)
+    {
+      return;
+    }
+    mIsScreenReaderSuppressed = suppress;
+    ReadScreenReaderEnabledProperty();
+  }
+
   bool ReadIsEnabledTimerCallback()
   {
     ReadIsEnabledProperty();
@@ -467,10 +480,14 @@ public:
         return;
       }
       mIsEnabled = std::get<0>(msg);
-      if(mIsEnabled)
+      if((!mIsScreenReaderSuppressed && mIsScreenReaderEnabled) || mIsEnabled)
       {
         ForceUp();
       }
+      else
+      {
+        ForceDown();
+      }
     });
   }
 
@@ -497,6 +514,12 @@ public:
 
   void ReadScreenReaderEnabledProperty()
   {
+    // can be true because of SuppressScreenReader before init
+    if (!mAccessibilityStatusClient)
+    {
+      return;
+    }
+
     mAccessibilityStatusClient.property<bool>("ScreenReaderEnabled").asyncGet([this](DBus::ValueOrError<bool> msg) {
       if(!msg)
       {
@@ -513,10 +536,14 @@ public:
         return;
       }
       mIsScreenReaderEnabled = std::get<0>(msg);
-      if(mIsScreenReaderEnabled)
+      if((!mIsScreenReaderSuppressed && mIsScreenReaderEnabled) || mIsEnabled)
       {
         ForceUp();
       }
+      else
+      {
+        ForceDown();
+      }
     });
   }
 
@@ -524,7 +551,7 @@ public:
   {
     mAccessibilityStatusClient.addPropertyChangedEvent<bool>("ScreenReaderEnabled", [this](bool res) {
       mIsScreenReaderEnabled = res;
-      if(mIsScreenReaderEnabled || mIsEnabled)
+      if((!mIsScreenReaderSuppressed && mIsScreenReaderEnabled) || mIsEnabled)
       {
         ForceUp();
       }