1// Copyright 2020-present 650 Industries. All rights reserved. 2 3#if __has_include(<EXUpdates/EXUpdatesService.h>) 4 5#import "EXUpdatesBinding.h" 6 7NS_ASSUME_NONNULL_BEGIN 8 9@interface EXUpdatesBinding () 10 11@property (nonatomic, strong) NSString *scopeKey; 12@property (nonatomic, weak) id<EXUpdatesBindingDelegate> updatesKernelService; 13@property (nonatomic, weak) id<EXUpdatesDatabaseBindingDelegate> databaseKernelService; 14 15@end 16 17@implementation EXUpdatesBinding : EXUpdatesService 18 19- (instancetype)initWithScopeKey:(NSString *)scopeKey updatesKernelService:(id<EXUpdatesBindingDelegate>)updatesKernelService databaseKernelService:(id<EXUpdatesDatabaseBindingDelegate>)databaseKernelService 20{ 21 if (self = [super init]) { 22 _scopeKey = scopeKey; 23 _updatesKernelService = updatesKernelService; 24 _databaseKernelService = databaseKernelService; 25 } 26 return self; 27} 28 29- (EXUpdatesConfig *)config 30{ 31 return [_updatesKernelService configForScopeKey:_scopeKey]; 32} 33 34- (EXUpdatesDatabase *)database 35{ 36 return _databaseKernelService.database; 37} 38 39- (EXUpdatesSelectionPolicy *)selectionPolicy 40{ 41 return [_updatesKernelService selectionPolicyForScopeKey:_scopeKey]; 42} 43 44- (NSURL *)directory 45{ 46 return _databaseKernelService.updatesDirectory; 47} 48 49- (nullable EXUpdatesUpdate *)embeddedUpdate 50{ 51 return nil; 52} 53 54- (nullable EXUpdatesUpdate *)launchedUpdate 55{ 56 return [_updatesKernelService launchedUpdateForScopeKey:_scopeKey]; 57} 58 59- (nullable NSDictionary *)assetFilesMap 60{ 61 return [_updatesKernelService assetFilesMapForScopeKey:_scopeKey]; 62} 63 64- (BOOL)isUsingEmbeddedAssets 65{ 66 return [_updatesKernelService isUsingEmbeddedAssetsForScopeKey:_scopeKey]; 67} 68 69- (BOOL)isStarted 70{ 71 return [_updatesKernelService isStartedForScopeKey:_scopeKey]; 72} 73 74- (BOOL)isEmergencyLaunch 75{ 76 return [_updatesKernelService isEmergencyLaunchForScopeKey:_scopeKey]; 77} 78 79- (BOOL)canRelaunch 80{ 81 return YES; 82} 83 84- (void)requestRelaunchWithCompletion:(EXUpdatesAppRelaunchCompletionBlock)completion 85{ 86 return [_updatesKernelService requestRelaunchForScopeKey:_scopeKey withCompletion:completion]; 87} 88 89- (void)resetSelectionPolicy 90{ 91 // no-op in managed 92} 93 94+ (const NSArray<Protocol *> *)exportedInterfaces { 95 return @[@protocol(EXUpdatesModuleInterface)]; 96} 97 98@end 99 100NS_ASSUME_NONNULL_END 101 102#endif 103