11import { DeviceLiveSyncServiceBase } from './device-livesync-service-base' ;
2- import { AndroidDeviceHashService } from "../../common/mobile/android/android-device-hash-service" ;
32
43export abstract class AndroidDeviceLiveSyncServiceBase extends DeviceLiveSyncServiceBase {
5- private deviceHashServices : IDictionary < Mobile . IAndroidDeviceHashService > ;
6-
74 constructor ( protected $injector : IInjector ,
85 protected $platformsData : IPlatformsData ,
96 protected $filesHashService : IFilesHashService ,
107 protected $logger : ILogger ,
118 protected device : Mobile . IAndroidDevice ) {
129 super ( $platformsData , device ) ;
13- this . deviceHashServices = { } ;
1410 }
1511
1612 public abstract async transferFilesOnDevice ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] ) : Promise < void > ;
1713 public abstract async transferDirectoryOnDevice ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string ) : Promise < void > ;
1814
19- public getDeviceHashService ( appIdentifier : string ) : Mobile . IAndroidDeviceHashService {
20- const key = `${ this . device . deviceInfo . identifier } ${ appIdentifier } ` ;
21- if ( ! this . deviceHashServices [ key ] ) {
22- const deviceHashService = this . $injector . resolve ( AndroidDeviceHashService , { adb : this . device . adb , appIdentifier } ) ;
23- this . deviceHashServices [ key ] = deviceHashService ;
24- }
25-
26- return this . deviceHashServices [ key ] ;
27- }
28-
2915 public async transferFiles ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string , projectData : IProjectData , liveSyncDeviceInfo : ILiveSyncDeviceInfo , options : ITransferFilesOptions ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
30- const deviceHashService = this . getDeviceHashService ( deviceAppData . appIdentifier ) ;
16+ const deviceHashService = this . device . fileSystem . getDeviceHashService ( deviceAppData . appIdentifier ) ;
3117 const currentHashes = await deviceHashService . generateHashesFromLocalToDevicePaths ( localToDevicePaths ) ;
3218 const transferredFiles = await this . transferFilesCore ( deviceAppData , localToDevicePaths , projectFilesPath , currentHashes , options ) ;
33- await this . updateHashes ( deviceAppData , currentHashes , projectData , liveSyncDeviceInfo ) ;
19+ await this . device . fileSystem . updateHashesOnDevice ( currentHashes , deviceAppData . appIdentifier ) ;
3420 return transferredFiles ;
3521 }
3622
3723 private async transferFilesCore ( deviceAppData : Mobile . IDeviceAppData , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , projectFilesPath : string , currentHashes : IStringDictionary , options : ITransferFilesOptions ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
3824 if ( options . force && options . isFullSync ) {
39- const hashFileDevicePath = this . getDeviceHashService ( deviceAppData . appIdentifier ) . hashFileDevicePath ;
25+ const hashFileDevicePath = this . device . fileSystem . getDeviceHashService ( deviceAppData . appIdentifier ) . hashFileDevicePath ;
4026 await this . device . fileSystem . deleteFile ( hashFileDevicePath , deviceAppData . appIdentifier ) ;
4127 this . $logger . trace ( "Before transfer directory on device " , localToDevicePaths ) ;
4228 await this . transferDirectoryOnDevice ( deviceAppData , localToDevicePaths , projectFilesPath ) ;
@@ -59,27 +45,11 @@ export abstract class AndroidDeviceLiveSyncServiceBase extends DeviceLiveSyncSer
5945 }
6046
6147 private async getChangedLocalToDevicePaths ( appIdentifier : string , localToDevicePaths : Mobile . ILocalToDevicePathData [ ] , currentHashes : IStringDictionary ) : Promise < Mobile . ILocalToDevicePathData [ ] > {
62- const deviceHashService = this . getDeviceHashService ( appIdentifier ) ;
48+ const deviceHashService = this . device . fileSystem . getDeviceHashService ( appIdentifier ) ;
6349 const oldHashes = ( await deviceHashService . getShasumsFromDevice ( ) ) || { } ;
6450 const changedHashes = deviceHashService . getChangedShasums ( oldHashes , currentHashes ) ;
6551 const changedFiles = _ . keys ( changedHashes ) ;
6652 const changedLocalToDevicePaths = localToDevicePaths . filter ( localToDevicePathData => changedFiles . indexOf ( localToDevicePathData . getLocalPath ( ) ) >= 0 ) ;
6753 return changedLocalToDevicePaths ;
6854 }
69-
70- private async updateHashes ( deviceAppData : Mobile . IDeviceAppData , currentHashes : IStringDictionary , projectData : IProjectData , liveSyncDeviceInfo : ILiveSyncDeviceInfo ) : Promise < void > {
71- const hashes = await this . updateHashesOnDevice ( deviceAppData , currentHashes , projectData , liveSyncDeviceInfo ) ;
72- this . updateLocalHashes ( hashes , deviceAppData , projectData , liveSyncDeviceInfo ) ;
73- }
74-
75- private async updateHashesOnDevice ( deviceAppData : Mobile . IDeviceAppData , currentHashes : IStringDictionary , projectData : IProjectData , liveSyncDeviceInfo : ILiveSyncDeviceInfo ) : Promise < IStringDictionary > {
76- const deviceHashService = this . getDeviceHashService ( deviceAppData . appIdentifier ) ;
77- await deviceHashService . uploadHashFileToDevice ( currentHashes ) ;
78- return currentHashes ;
79- }
80-
81- private updateLocalHashes ( hashes : IStringDictionary , deviceAppData : Mobile . IDeviceAppData , projectData : IProjectData , liveSyncDeviceInfo : ILiveSyncDeviceInfo ) : void {
82- const hashFilePath = liveSyncDeviceInfo . outputPath || this . $platformsData . getPlatformData ( deviceAppData . platform , projectData ) . deviceBuildOutputPath ;
83- this . $filesHashService . saveHashes ( hashes , hashFilePath ) ;
84- }
8555}
0 commit comments