Summary: Make sure mobile client and sonar desktop app keep debugger mode in sync Desktop client listens to available modes and currently selected mode which is what we use here. Later we can tweak the logic to try to restore last mode if desktop or mobile clients crash / disconnect etc Reviewed By: lblasa Differential Revision: D49384358 fbshipit-source-id: 5bc1f4240253b68a746dfa5feba4b352f4e261a2
76 lines
1.9 KiB
Plaintext
76 lines
1.9 KiB
Plaintext
/*
|
|
* 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.
|
|
*/
|
|
|
|
#if FB_SONARKIT_ENABLED
|
|
|
|
#import "FlipperKitUIDebuggerPlugin.h"
|
|
#import <FlipperKit/FlipperClient.h>
|
|
#import <FlipperKit/FlipperConnection.h>
|
|
#import <FlipperKit/FlipperResponder.h>
|
|
#import <UIKit/UIKit.h>
|
|
|
|
#import "Core/UIDContext.h"
|
|
|
|
#import "Descriptors/UIDDescriptorRegister.h"
|
|
#import "Observer/UIDTreeObserverFactory.h"
|
|
#import "Observer/UIDTreeObserverManager.h"
|
|
|
|
#import "UIDTraversalMode.h"
|
|
|
|
@implementation FlipperKitUIDebuggerPlugin {
|
|
UIDContext* _context;
|
|
}
|
|
|
|
- (instancetype)initWithContext:(UIDContext*)context {
|
|
if (self = [super init]) {
|
|
self->_context = context;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)init {
|
|
UIDContext* context = [[UIDContext alloc]
|
|
initWithApplication:[UIApplication sharedApplication]
|
|
descriptorRegister:[UIDDescriptorRegister defaultRegister]
|
|
observerFactory:[UIDTreeObserverFactory shared]];
|
|
return [self initWithContext:context];
|
|
}
|
|
|
|
- (NSString*)identifier {
|
|
return @"ui-debugger";
|
|
}
|
|
|
|
- (void)didConnect:(id<FlipperConnection>)connection {
|
|
if (!_context.application) {
|
|
_context.application = [UIApplication sharedApplication];
|
|
}
|
|
|
|
_context.connection = connection;
|
|
[[UIDTreeObserverManager shared] startWithContext:_context];
|
|
|
|
NSSet<id<UIDConnectionListener>>* connectionListeners =
|
|
_context.connectionListeners;
|
|
for (id<UIDConnectionListener> listener in connectionListeners) {
|
|
[listener onDidConnect];
|
|
}
|
|
}
|
|
|
|
- (void)didDisconnect {
|
|
_context.connection = nil;
|
|
[[UIDTreeObserverManager shared] stop];
|
|
|
|
NSSet<id<UIDConnectionListener>>* connectionListeners =
|
|
_context.connectionListeners;
|
|
for (id<UIDConnectionListener> listener in connectionListeners) {
|
|
[listener onDidDisconnect];
|
|
}
|
|
}
|
|
|
|
@end
|
|
|
|
#endif
|