Giter Club home page Giter Club logo

Comments (14)

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

Seems you need to load UIAccessibility.framework.

(lldb) image lookup -vn _accessibilityTreeAsString
1 match found in /Users/mrhappyasthma/Library/Developer/Xcode/iOS DeviceSupport/12.1 (16B92)/Symbols/System/Library/PrivateFrameworks/UIAccessibility.framework

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

So the private APIs do require UIAccessibility.framework, however it's a private framework so there's no way (that I can find) to force this to load via lldb nor using an NSBundle with a fixed path.

However the framework is loaded whenever VoiceOver is enabled. (And stays loaded even if voiceover is disabled in a given session).

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

Actually, at least when building to device, it appears we can use:

NSBundle *bundle = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/UIAccessibility.framework"];
  BOOL success = [bundle load];

This passes and works when building to device. Will test the simulator next. I imagine it will fail, but we'll see.

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

Confirmed it doesn't work on simulator. This will make writing tests very difficult, so I'll probably just do manual testing for these.

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024
  // Precheck for the library.
  for (NSBundle *bundle in [NSBundle allFrameworks]) {
    if ([[bundle resourcePath] isEqual:@"/System/Library/PrivateFrameworks/UIAccessibility.framework"]) {
      return;
    }
  }
  // Load the framework.
  NSBundle *b = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/UIAccessibility.framework"];
  BOOL success = [b load];
  NSLog(@"success = %ld", (long)success);
}

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

Added a command for accessibilityTree in 47378f5. This is more of a proof-of-concept than anything. This can be forked to implement similar checks to add the other accessibility methods.

I'm limited to testing on simulator locally, so I will have to test on device later.

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

Some other potential ones:

- (bool)_accessibilityHasVisibleFrame;
- (id)_accessibilityIndexPath;
- (id)_accessibilityParentView;
- (id)_accessibilityResponderChainForKeyWindow;
- (id)_accessibilitySortedElementsWithin;
- (id)_accessibilityVisibleElements;
- (id)_axDebugTraits;
- (id)_axElementsDescription;

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

For _accessibilityLeftDescendentsWithCount:options: I see:

(lldb) po $arg4
<UIAccessibilityElementTraversalOptions: 0x282f198f0> - next, has predicate

(lldb) ivars 0x282f198f0
<__NSArrayM 0x282f19b30>(
(bool) _shouldReturnScannerGroups,
(bool) _shouldOnlyIncludeElementsWithVisibleFrame,
(bool) _shouldIncludeKeyboardObscuredElements,
(bool) _shouldUseAllSubviews,
(bool) _includeHiddenViews,
(bool) _includeWindowlessViews,
(bool) _sorted,
(bool) _ignoreObscuresScreen,
(bool) _includeDirectDescendantsOnly,
(bool) _includeAncestorsOfSelfInSiblingMatch,
(bool) _forSpeakScreen,
(bool) _shouldIncludeStatusBarWindow,
(long long) _direction,
(~block~) _leafNodePredicate -> 0x282f18930,
(NSArray *) _allowedViewsForTraversal -> nil

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

The header is: https://github.com/w0lfschild/macOS_headers/blob/master/macOS/PrivateFrameworks/UIAccessibility/1.0/UIAccessibilityElementTraversalOptions.h

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

Some of the traversal logger APIs:

https://github.com/w0lfschild/macOS_headers/blob/master/macOS/PrivateFrameworks/UIAccessibility/1.0/UIAccessibilityElementTraversalTreeLogger-Protocol.h

https://github.com/w0lfschild/macOS_headers/blob/master/macOS/PrivateFrameworks/UIAccessibility/1.0/UIAccessibilityInMemoryStringBasedTreeLogger.h

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

The magic sauce seems to be:

 po [0x138ff2570 _accessibilityLeafDescendantsWithOptions:[UIAccessibilityElementTraversalOptions defaultVoiceOverOptions]]

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024
[UIAccessibilityElementTraversalOptions defaultVoiceOverOptions]

Has the following properties:

BOOL shouldIncludeStatusBarWindow => NO
BOOL forSpeakScreen => NO
BOOL includeAncestorsOfSelfInSiblingMatch => NO
BOOL includeDirectDescendantsOnly => NO
BOOL ignoreObscuresScreen => NO
BOOL sorted => YES
BOOL includeHiddenViews => NO
BOOL shouldUseAllSubviews => NO
BOOL shouldIncludeKeyboardObscuredElements => NO
BOOL shouldOnlyIncludeElementsWithVisibleFrame =>NO
BOOL shouldReturnScannerGroups => NO

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

Useful look into the private h eaders: https://github.com/w0lfschild/macOS_headers/tree/master/macOS/PrivateFrameworks/UIAccessibility/1.0

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on June 25, 2024

One thing I noticed is that the a11y commands tend to not print the full tree of data until AFTER I poke around on the app with the a11y inspector. Then anytime in the future it seems to print the right values.

There must be some other type of set up happening between the inspector and the app process that I'm not yet doing.

from happydebugging.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.