11import * as path from "path" ;
22import { AndroidDeviceLiveSyncService } from "./android-device-livesync-service" ;
3- import { APP_FOLDER_NAME , SYNC_DIR_NAME , FULLSYNC_DIR_NAME } from "../../constants" ;
3+ import { APP_FOLDER_NAME } from "../../constants" ;
4+ import { PlatformLiveSyncServiceBase } from "./platform-livesync-service-base" ;
45
5- export class AndroidLiveSyncService implements IPlatformLiveSyncService {
6+ export class AndroidLiveSyncService extends PlatformLiveSyncServiceBase implements IPlatformLiveSyncService {
67 constructor ( private $projectFilesManager : IProjectFilesManager ,
78 private $platformsData : IPlatformsData ,
89 private $logger : ILogger ,
910 private $projectFilesProvider : IProjectFilesProvider ,
1011 private $fs : IFileSystem ,
11- private $injector : IInjector ) {
12+ private $injector : IInjector ,
13+ $devicePathProvider : Mobile . IDevicePathProvider ) {
14+ super ( $devicePathProvider ) ;
1215 }
1316
1417 public async fullSync ( syncInfo : IFullSyncInfo ) : Promise < ILiveSyncResultInfo > {
@@ -17,7 +20,7 @@ export class AndroidLiveSyncService implements IPlatformLiveSyncService {
1720 const deviceLiveSyncService = this . $injector . resolve < AndroidDeviceLiveSyncService > ( AndroidDeviceLiveSyncService , { _device : device } ) ;
1821 const platformData = this . $platformsData . getPlatformData ( device . deviceInfo . platform , projectData ) ;
1922
20- const deviceAppData = await this . getAppData ( syncInfo , deviceLiveSyncService ) ;
23+ const deviceAppData = await this . getAppData ( syncInfo ) ;
2124 await deviceLiveSyncService . beforeLiveSyncAction ( deviceAppData ) ;
2225
2326 const projectFilesPath = path . join ( platformData . appDestinationDirectoryPath , APP_FOLDER_NAME ) ;
@@ -34,8 +37,7 @@ export class AndroidLiveSyncService implements IPlatformLiveSyncService {
3437 public async liveSyncWatchAction ( device : Mobile . IDevice , liveSyncInfo : ILiveSyncWatchInfo ) : Promise < ILiveSyncResultInfo > {
3538 const projectData = liveSyncInfo . projectData ;
3639 const syncInfo = _ . merge < IFullSyncInfo > ( { device, watch : true } , liveSyncInfo ) ;
37- const deviceLiveSyncService = this . $injector . resolve < AndroidDeviceLiveSyncService > ( AndroidDeviceLiveSyncService , { _device : device } ) ;
38- const deviceAppData = await this . getAppData ( syncInfo , deviceLiveSyncService ) ;
40+ const deviceAppData = await this . getAppData ( syncInfo ) ;
3941
4042 let modifiedLocalToDevicePaths : Mobile . ILocalToDevicePathData [ ] = [ ] ;
4143 if ( liveSyncInfo . filesToSync . length ) {
@@ -95,20 +97,5 @@ export class AndroidLiveSyncService implements IPlatformLiveSyncService {
9597 await deviceAppData . device . fileSystem . transferFiles ( deviceAppData , localToDevicePaths ) ;
9698 }
9799 }
98-
99- private async getAppData ( syncInfo : IFullSyncInfo , deviceLiveSyncService : IAndroidNativeScriptDeviceLiveSyncService ) : Promise < Mobile . IDeviceAppData > {
100- return {
101- appIdentifier : syncInfo . device . deviceInfo . identifier ,
102- device : syncInfo . device ,
103- platform : syncInfo . device . deviceInfo . platform ,
104- getDeviceProjectRootPath : async ( ) => {
105- const hashService = deviceLiveSyncService . getDeviceHashService ( syncInfo . device . deviceInfo . identifier ) ;
106- const hashFile = syncInfo . syncAllFiles ? null : await hashService . doesShasumFileExistsOnDevice ( ) ;
107- const syncFolderName = syncInfo . watch || hashFile ? SYNC_DIR_NAME : FULLSYNC_DIR_NAME ;
108- return `/data/local/tmp/${ syncInfo . device . deviceInfo . identifier } /${ syncFolderName } ` ;
109- } ,
110- isLiveSyncSupported : async ( ) => true
111- } ;
112- }
113100}
114101$injector . register ( "androidLiveSyncService" , AndroidLiveSyncService ) ;
0 commit comments