-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathdevice-app-data-provider.ts
93 lines (79 loc) · 3.12 KB
/
device-app-data-provider.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import * as deviceAppDataBaseLib from "../common/mobile/device-app-data/device-app-data-base";
import Future = require("fibers/future");
import * as path from "path";
import {AndroidDeviceHashService} from "../common/mobile/android/android-device-hash-service";
import {DeviceAndroidDebugBridge} from "../common/mobile/android/device-android-debug-bridge";
const SYNC_DIR_NAME = "sync";
const FULLSYNC_DIR_NAME = "fullsync";
export class IOSAppIdentifier extends deviceAppDataBaseLib.DeviceAppDataBase implements Mobile.IDeviceAppData {
private static DEVICE_PROJECT_ROOT_PATH = "Library/Application Support/LiveSync/app";
private _deviceProjectRootPath: string = null;
constructor(_appIdentifier: string,
public device: Mobile.IDevice,
public platform: string,
private $iOSSimResolver: Mobile.IiOSSimResolver) {
super(_appIdentifier);
}
public get deviceProjectRootPath(): string {
if (!this._deviceProjectRootPath) {
if (this.device.isEmulator) {
let applicationPath = this.$iOSSimResolver.iOSSim.getApplicationPath(this.device.deviceInfo.identifier, this.appIdentifier);
this._deviceProjectRootPath = path.join(applicationPath, "app");
} else {
this._deviceProjectRootPath = IOSAppIdentifier.DEVICE_PROJECT_ROOT_PATH;
}
}
return this.getDeviceProjectRootPath(this._deviceProjectRootPath);
}
public get deviceSyncZipPath(): string {
if (this.device.isEmulator) {
return undefined;
} else {
return "Library/Application Support/LiveSync/sync.zip";
}
}
public isLiveSyncSupported(): IFuture<boolean> {
return Future.fromResult(true);
}
}
export class AndroidAppIdentifier extends deviceAppDataBaseLib.DeviceAppDataBase implements Mobile.IDeviceAppData {
constructor(_appIdentifier: string,
public device: Mobile.IDevice,
public platform: string,
private $options: IOptions,
private $injector: IInjector) {
super(_appIdentifier);
}
private _deviceProjectRootPath: string;
public get deviceProjectRootPath(): string {
if(!this._deviceProjectRootPath) {
let syncFolderName = this.getSyncFolderName().wait();
this._deviceProjectRootPath = `/data/local/tmp/${this.appIdentifier}/${syncFolderName}`;
}
return this._deviceProjectRootPath;
}
public isLiveSyncSupported(): IFuture<boolean> {
return Future.fromResult(true);
}
private getSyncFolderName(): IFuture<string> {
return ((): string =>{
let adb = this.$injector.resolve(DeviceAndroidDebugBridge, { identifier: this.device.deviceInfo.identifier });
let deviceHashService = this.$injector.resolve(AndroidDeviceHashService, {adb: adb, appIdentifier: this.appIdentifier});
let hashFile = this.$options.force ? null : deviceHashService.doesShasumFileExistsOnDevice().wait();
return this.$options.watch || hashFile ? SYNC_DIR_NAME : FULLSYNC_DIR_NAME;
}).future<string>()();
}
}
export class DeviceAppDataProvider implements Mobile.IDeviceAppDataProvider {
public createFactoryRules(): IDictionary<Mobile.IDeviceAppDataFactoryRule> {
return {
iOS: {
vanilla: IOSAppIdentifier
},
Android: {
vanilla: AndroidAppIdentifier
}
};
}
}
$injector.register("deviceAppDataProvider", DeviceAppDataProvider);