-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathandroid-platform-livesync-service.ts
57 lines (49 loc) · 2.77 KB
/
android-platform-livesync-service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import {PlatformLiveSyncServiceBase} from "./platform-livesync-service-base";
class AndroidPlatformLiveSyncService extends PlatformLiveSyncServiceBase {
constructor(_liveSyncData: ILiveSyncData,
protected $devicesService: Mobile.IDevicesService,
protected $mobileHelper: Mobile.IMobileHelper,
protected $logger: ILogger,
protected $options: ICommonOptions,
protected $deviceAppDataFactory: Mobile.IDeviceAppDataFactory,
protected $fs: IFileSystem,
protected $injector: IInjector,
protected $projectFilesManager: IProjectFilesManager,
protected $projectFilesProvider: IProjectFilesProvider,
protected $liveSyncProvider: ILiveSyncProvider) {
super(_liveSyncData, $devicesService, $mobileHelper, $logger, $options, $deviceAppDataFactory, $fs, $injector, $projectFilesManager, $projectFilesProvider, $liveSyncProvider);
}
public fullSync(postAction?: (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => IFuture<void>): IFuture<void> {
return (() => {
let appIdentifier = this.liveSyncData.appIdentifier;
let platform = this.liveSyncData.platform;
let projectFilesPath = this.liveSyncData.projectFilesPath;
let canExecute = this.getCanExecuteAction(platform, appIdentifier);
let action = (device: Mobile.IDevice): IFuture<void> => {
return (() => {
let deviceLiveSyncService = this.resolveDeviceSpecificLiveSyncService(platform, device);
let deviceAppData = this.$deviceAppDataFactory.create(appIdentifier, this.$mobileHelper.normalizePlatformName(platform), device);
deviceLiveSyncService.beforeLiveSyncAction(deviceAppData).wait();;
let installed = this.tryInstallApplication(device, deviceAppData).wait();
let localToDevicePaths = this.$projectFilesManager.createLocalToDevicePaths(deviceAppData, projectFilesPath, null, this.liveSyncData.excludedProjectDirsAndFiles);
let afterSyncAction: () => IFuture<void>;
if (installed) {
deviceLiveSyncService.afterInstallApplicationAction(deviceAppData, localToDevicePaths).wait();
afterSyncAction = () => device.applicationManager.tryStartApplication(deviceAppData.appIdentifier);
} else {
this.transferFiles(deviceAppData, localToDevicePaths, this.liveSyncData.projectFilesPath, true).wait();
afterSyncAction = () => this.refreshApplication(deviceAppData, localToDevicePaths);
}
if (postAction) {
this.finishLivesync(deviceAppData).wait();
return postAction(deviceAppData, localToDevicePaths).wait();
}
afterSyncAction().wait();
this.finishLivesync(deviceAppData).wait();
}).future<void>()();
};
this.$devicesService.execute(action, canExecute).wait();
}).future<void>()();
}
}
$injector.register("androidPlatformLiveSyncServiceLocator", {factory: AndroidPlatformLiveSyncService});