diff --git a/React/CoreModules/RCTAccessibilityManager+Internal.h b/React/CoreModules/RCTAccessibilityManager+Internal.h new file mode 100644 index 00000000000..b3a17b5f3c5 --- /dev/null +++ b/React/CoreModules/RCTAccessibilityManager+Internal.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import "RCTAccessibilityManager.h" + +#import + +NS_ASSUME_NONNULL_BEGIN + +RCT_EXTERN_C_BEGIN + +// Only to be used for testing and internal tooling. Do not use this in production. +void RCTAccessibilityManagerSetIsVoiceOverEnabled(RCTAccessibilityManager *accessibiltyManager, BOOL isVoiceOverEnabled); + +RCT_EXTERN_C_END + +NS_ASSUME_NONNULL_END diff --git a/React/CoreModules/RCTAccessibilityManager.mm b/React/CoreModules/RCTAccessibilityManager.mm index 1ea4436cf33..3d0c7765d05 100644 --- a/React/CoreModules/RCTAccessibilityManager.mm +++ b/React/CoreModules/RCTAccessibilityManager.mm @@ -6,6 +6,7 @@ */ #import "RCTAccessibilityManager.h" +#import "RCTAccessibilityManager+Internal.h" #import #import @@ -183,9 +184,14 @@ RCT_EXPORT_MODULE() - (void)voiceVoiceOverStatusDidChange:(__unused NSNotification *)notification { - BOOL newIsVoiceOverEnabled = UIAccessibilityIsVoiceOverRunning(); - if (_isVoiceOverEnabled != newIsVoiceOverEnabled) { - _isVoiceOverEnabled = newIsVoiceOverEnabled; + BOOL isVoiceOverEnabled = UIAccessibilityIsVoiceOverRunning(); + [self _setIsVoiceOverEnabled:isVoiceOverEnabled]; +} + +- (void)_setIsVoiceOverEnabled:(BOOL)isVoiceOverEnabled +{ + if (_isVoiceOverEnabled != isVoiceOverEnabled) { + _isVoiceOverEnabled = isVoiceOverEnabled; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"screenReaderChanged" @@ -350,6 +356,15 @@ RCT_EXPORT_METHOD(getCurrentVoiceOverState return std::make_shared(params); } +#pragma mark - Internal + +void RCTAccessibilityManagerSetIsVoiceOverEnabled( + RCTAccessibilityManager *accessibilityManager, + BOOL isVoiceOverEnabled) +{ + [accessibilityManager _setIsVoiceOverEnabled:isVoiceOverEnabled]; +} + @end @implementation RCTBridge (RCTAccessibilityManager)