Skip to content

Commit 751b585

Browse files
committed
Refactor accessibility manager and fix iOS window ID map
Moved Android-specific accessibility logic to a platform-specific file and removed platform checks from the core accessibility_manager.cpp. Updated iOS window ID mapping to use void* as the key to avoid hashing issues with ObjC pointers on iOS.
1 parent 63cb2fb commit 751b585

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/accessibility_manager.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#include "accessibility_manager.h"
22

3-
#ifdef ANDROID
4-
#include <android/log.h>
5-
#define LOG_TAG "NativeApi"
6-
#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
7-
#endif
8-
93
namespace nativeapi {
104

115
AccessibilityManager& AccessibilityManager::GetInstance() {
@@ -17,15 +11,4 @@ AccessibilityManager::AccessibilityManager() : enabled_(false) {}
1711

1812
AccessibilityManager::~AccessibilityManager() {}
1913

20-
void AccessibilityManager::Enable() {
21-
#ifdef ANDROID
22-
ALOGW("AccessibilityManager::Enable requires AccessibilityService on Android");
23-
#endif
24-
enabled_ = true;
25-
}
26-
27-
bool AccessibilityManager::IsEnabled() {
28-
return enabled_;
29-
}
30-
3114
} // namespace nativeapi
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "../../accessibility_manager.h"
2+
3+
namespace nativeapi {
4+
5+
void AccessibilityManager::Enable() {
6+
// On Android, accessibility features are controlled by system settings
7+
enabled_ = true;
8+
}
9+
10+
bool AccessibilityManager::IsEnabled() {
11+
// On Android, accessibility features are controlled by system settings
12+
return enabled_;
13+
}
14+
15+
} // namespace nativeapi
16+

src/platform/ios/window_ios.mm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@
2525
}
2626

2727
// Store the allocated ID in a static map to ensure consistency
28-
static std::unordered_map<UIWindow*, WindowId> window_id_map;
28+
// Note: Use void* as the key to avoid hashing issues for ObjC pointers with libc++ on iOS
29+
static std::unordered_map<void*, WindowId> window_id_map;
2930
static std::mutex map_mutex;
3031

3132
std::lock_guard<std::mutex> lock(map_mutex);
32-
auto it = window_id_map.find(pimpl_->ui_window_);
33+
auto it = window_id_map.find((__bridge void*)pimpl_->ui_window_);
3334
if (it != window_id_map.end()) {
3435
return it->second;
3536
}
3637

3738
// Allocate new ID using the IdAllocator
3839
WindowId new_id = IdAllocator::Allocate<Window>();
3940
if (new_id != IdAllocator::kInvalidId) {
40-
window_id_map[pimpl_->ui_window_] = new_id;
41+
window_id_map[(__bridge void*)pimpl_->ui_window_] = new_id;
4142
}
4243
return new_id;
4344
}

0 commit comments

Comments
 (0)