mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Backout D69745459 to resolve more Twilight headset pairing issues (#49656)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49656 changelog: [internal] Differential Revision: D70116923 fbshipit-source-id: ead8b1551acd6713372e1b500d921c8590bf6ac0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d8df3a68fc
commit
823ede1fab
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RCTInitialAppStateProxy : NSObject
|
||||
|
||||
+ (instancetype)sharedInstance;
|
||||
|
||||
/*
|
||||
* Property to access initial application state.
|
||||
* Thread safe.
|
||||
*/
|
||||
@property (nonatomic, readonly) UIApplicationState initialAppState;
|
||||
|
||||
- (void)recordAppState;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTInitialAppStateProxy.h"
|
||||
#import <React/RCTUtils.h>
|
||||
#import <mutex>
|
||||
|
||||
#import <React/RCTConstants.h>
|
||||
|
||||
@implementation RCTInitialAppStateProxy {
|
||||
BOOL _hasRecordedInitialAppState;
|
||||
UIApplicationState _initialAppState;
|
||||
std::mutex _mutex;
|
||||
}
|
||||
|
||||
+ (instancetype)sharedInstance
|
||||
{
|
||||
static RCTInitialAppStateProxy *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [RCTInitialAppStateProxy new];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (UIApplicationState)initialAppState
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
if (_hasRecordedInitialAppState) {
|
||||
return _initialAppState;
|
||||
}
|
||||
}
|
||||
|
||||
__block UIApplicationState initialAppState;
|
||||
RCTUnsafeExecuteOnMainQueueSync(^{
|
||||
initialAppState = [UIApplication sharedApplication].applicationState;
|
||||
});
|
||||
|
||||
return initialAppState;
|
||||
}
|
||||
|
||||
- (void)recordAppState
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
_hasRecordedInitialAppState = YES;
|
||||
_initialAppState = [UIApplication sharedApplication].applicationState;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#import "RCTInitializeUIKitProxies.h"
|
||||
#import "RCTInitialAccessibilityValuesProxy.h"
|
||||
#import "RCTInitialAppStateProxy.h"
|
||||
#import "RCTKeyWindowValuesProxy.h"
|
||||
#import "RCTTraitCollectionProxy.h"
|
||||
#import "RCTWindowSafeAreaProxy.h"
|
||||
@@ -18,7 +17,6 @@ void RCTInitializeUIKitProxies(void)
|
||||
dispatch_once(&onceToken, ^{
|
||||
[[RCTWindowSafeAreaProxy sharedInstance] startObservingSafeArea];
|
||||
[[RCTTraitCollectionProxy sharedInstance] startObservingTraitCollection];
|
||||
[[RCTInitialAppStateProxy sharedInstance] recordAppState];
|
||||
[[RCTInitialAccessibilityValuesProxy sharedInstance] recordAccessibilityValues];
|
||||
[[RCTKeyWindowValuesProxy sharedInstance] startObservingWindowSizeIfNecessary];
|
||||
});
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
#import <React/RCTAssert.h>
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTEventDispatcherProtocol.h>
|
||||
|
||||
#import <React/RCTInitialAppStateProxy.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
#import "CoreModulesPlugins.h"
|
||||
@@ -33,7 +31,7 @@ static NSString *RCTCurrentAppState()
|
||||
return @"extension";
|
||||
}
|
||||
|
||||
return states[@([RCTInitialAppStateProxy sharedInstance].initialAppState)] ?: @"unknown";
|
||||
return states[@(RCTSharedApplication().applicationState)] ?: @"unknown";
|
||||
}
|
||||
|
||||
@interface RCTAppState () <NativeAppStateSpec>
|
||||
@@ -47,7 +45,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
@@ -62,9 +60,14 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (facebook::react::ModuleConstants<JS::NativeAppState::Constants>)getConstants
|
||||
{
|
||||
return facebook::react::typedConstants<JS::NativeAppState::Constants>({
|
||||
.initialAppState = RCTCurrentAppState(),
|
||||
__block facebook::react::ModuleConstants<JS::NativeAppState::Constants> constants;
|
||||
RCTUnsafeExecuteOnMainQueueSync(^{
|
||||
constants = facebook::react::typedConstants<JS::NativeAppState::Constants>({
|
||||
.initialAppState = RCTCurrentAppState(),
|
||||
});
|
||||
});
|
||||
|
||||
return constants;
|
||||
}
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
Reference in New Issue
Block a user