|
2 | 2 | "use strict"; |
3 | 3 | import * as deviceAppDataBaseLib from "../common/mobile/device-app-data/device-app-data-base"; |
4 | 4 | import Future = require("fibers/future"); |
| 5 | +import * as path from "path"; |
5 | 6 |
|
6 | 7 | export class IOSAppIdentifier extends deviceAppDataBaseLib.DeviceAppDataBase implements Mobile.IDeviceAppData { |
7 | | - private static DEVICE_PROJECT_ROOT_PATH = "Library/Application Support/LiveSync"; |
| 8 | + private static DEVICE_PROJECT_ROOT_PATH = "Library/Application Support/LiveSync/app"; |
| 9 | + private _deviceProjectRootPath: string = null; |
8 | 10 |
|
9 | | - constructor(_appIdentifier: string) { |
| 11 | + constructor(_appIdentifier: string, |
| 12 | + public device: Mobile.IDevice, |
| 13 | + public platform: string, |
| 14 | + private $iOSSimResolver: Mobile.IiOSSimResolver) { |
10 | 15 | super(_appIdentifier); |
11 | 16 | } |
12 | 17 |
|
13 | 18 | public get deviceProjectRootPath(): string { |
14 | | - return this.getDeviceProjectRootPath(IOSAppIdentifier.DEVICE_PROJECT_ROOT_PATH); |
| 19 | + if (!this._deviceProjectRootPath) { |
| 20 | + if (this.device.isEmulator) { |
| 21 | + let applicationPath = this.$iOSSimResolver.iOSSim.getApplicationPath(this.device.deviceInfo.identifier, this.appIdentifier); |
| 22 | + this._deviceProjectRootPath = path.join(applicationPath, "app"); |
| 23 | + } else { |
| 24 | + this._deviceProjectRootPath = IOSAppIdentifier.DEVICE_PROJECT_ROOT_PATH; |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + return this.getDeviceProjectRootPath(this._deviceProjectRootPath); |
15 | 29 | } |
16 | 30 |
|
17 | | - public isLiveSyncSupported(device: Mobile.IDevice): IFuture<boolean> { |
| 31 | + public isLiveSyncSupported(): IFuture<boolean> { |
18 | 32 | return Future.fromResult(true); |
19 | 33 | } |
20 | 34 | } |
21 | 35 |
|
22 | 36 | export class AndroidAppIdentifier extends deviceAppDataBaseLib.DeviceAppDataBase implements Mobile.IDeviceAppData { |
23 | | - constructor(_appIdentifier: string) { |
| 37 | + constructor(_appIdentifier: string, |
| 38 | + public device: Mobile.IDevice, |
| 39 | + public platform: string, |
| 40 | + private $options: IOptions) { |
24 | 41 | super(_appIdentifier); |
25 | 42 | } |
26 | 43 |
|
27 | 44 | public get deviceProjectRootPath(): string { |
28 | | - let options: IOptions = $injector.resolve("options"); |
29 | | - let syncFolderName = options.watch ? "sync" : "fullsync"; |
| 45 | + let syncFolderName = this.$options.watch ? "sync" : "fullsync"; |
30 | 46 | return `/data/local/tmp/${this.appIdentifier}/${syncFolderName}`; |
31 | 47 | } |
32 | 48 |
|
33 | | - public isLiveSyncSupported(device: Mobile.IDevice): IFuture<boolean> { |
| 49 | + public isLiveSyncSupported(): IFuture<boolean> { |
34 | 50 | return Future.fromResult(true); |
35 | 51 | } |
36 | 52 | } |
37 | 53 |
|
38 | | -export class AndroidCompanionAppIdentifier extends deviceAppDataBaseLib.CompanionDeviceAppDataBase implements Mobile.IDeviceAppData { |
39 | | - private static APP_IDENTIFIER = "com.telerik.NativeScript"; |
40 | | - |
41 | | - constructor() { |
42 | | - super(AndroidCompanionAppIdentifier.APP_IDENTIFIER); |
43 | | - } |
44 | | - |
45 | | - public get deviceProjectRootPath(): string { |
46 | | - return `/mnt/sdcard/Android/data/${this.appIdentifier}/files/12590FAA-5EDD-4B12-856D-F52A0A1599F2`; |
47 | | - } |
48 | | -} |
49 | | - |
50 | 54 | export class DeviceAppDataProvider implements Mobile.IDeviceAppDataProvider { |
51 | 55 | public createFactoryRules(): IDictionary<Mobile.IDeviceAppDataFactoryRule> { |
52 | 56 | return { |
53 | 57 | iOS: { |
54 | 58 | vanilla: IOSAppIdentifier |
55 | 59 | }, |
56 | 60 | Android: { |
57 | | - vanilla: AndroidAppIdentifier, |
58 | | - companion: AndroidCompanionAppIdentifier |
| 61 | + vanilla: AndroidAppIdentifier |
59 | 62 | } |
60 | 63 | }; |
61 | 64 | } |
|
0 commit comments