11import { DeviceAndroidDebugBridge } from "../../common/mobile/android/device-android-debug-bridge" ;
22import { AndroidDeviceHashService } from "../../common/mobile/android/android-device-hash-service" ;
3+ import { DeviceLiveSyncServiceBase } from "./device-livesync-service-base" ;
34import * as helpers from "../../common/helpers" ;
45import { SYNC_DIR_NAME , FULLSYNC_DIR_NAME , REMOVEDSYNC_DIR_NAME } from "../../constants" ;
56import { cache } from "../../common/decorators" ;
67import * as path from "path" ;
78import * as net from "net" ;
8- import { EOL } from "os" ;
9-
10- export class AndroidDeviceLiveSyncService implements IAndroidNativeScriptDeviceLiveSyncService {
11- private static FAST_SYNC_FILE_EXTENSIONS = [ ".css" , ".xml" , ".html" ] ;
129
10+ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase implements IAndroidNativeScriptDeviceLiveSyncService {
1311 private static BACKEND_PORT = 18182 ;
1412 private device : Mobile . IAndroidDevice ;
1513
1614 constructor ( _device : Mobile . IDevice ,
1715 private $mobileHelper : Mobile . IMobileHelper ,
1816 private $injector : IInjector ,
19- private $logger : ILogger ,
20- private $androidDebugService : IPlatformDebugService ,
21- private $platformsData : IPlatformsData ) {
17+ protected $platformsData : IPlatformsData ) {
18+ super ( $platformsData ) ;
2219 this . device = < Mobile . IAndroidDevice > ( _device ) ;
2320 }
2421
25- public get debugService ( ) : IPlatformDebugService {
26- return this . $androidDebugService ;
27- }
28-
2922 public async refreshApplication ( projectData : IProjectData , liveSyncInfo : ILiveSyncResultInfo ) : Promise < void > {
3023 const deviceAppData = liveSyncInfo . deviceAppData ;
3124 const localToDevicePaths = liveSyncInfo . modifiedFilesData ;
@@ -38,7 +31,7 @@ export class AndroidDeviceLiveSyncService implements IAndroidNativeScriptDeviceL
3831 `/data/local/tmp/${ deviceAppData . appIdentifier } /sync` ]
3932 ) ;
4033
41- let canExecuteFastSync = ! liveSyncInfo . isFullSync && ! _ . some ( localToDevicePaths ,
34+ const canExecuteFastSync = ! liveSyncInfo . isFullSync && ! _ . some ( localToDevicePaths ,
4235 ( localToDevicePath : Mobile . ILocalToDevicePathData ) => ! this . canExecuteFastSync ( localToDevicePath . getLocalPath ( ) , projectData , this . device . deviceInfo . platform ) ) ;
4336
4437 if ( canExecuteFastSync ) {
@@ -48,25 +41,6 @@ export class AndroidDeviceLiveSyncService implements IAndroidNativeScriptDeviceL
4841 return this . restartApplication ( deviceAppData ) ;
4942 }
5043
51- @cache ( )
52- private getFastLiveSyncFileExtensions ( platform : string , projectData : IProjectData ) : string [ ] {
53- const platformData = this . $platformsData . getPlatformData ( platform , projectData ) ;
54- const fastSyncFileExtensions = AndroidDeviceLiveSyncService . FAST_SYNC_FILE_EXTENSIONS . concat ( platformData . fastLivesyncFileExtensions ) ;
55- return fastSyncFileExtensions ;
56- }
57-
58- public canExecuteFastSync ( filePath : string , projectData : IProjectData , platform : string ) : boolean {
59- console . log ( "called canExecuteFastSync for file: " , filePath ) ;
60- const fastSyncFileExtensions = this . getFastLiveSyncFileExtensions ( platform , projectData ) ;
61- return _ . includes ( fastSyncFileExtensions , path . extname ( filePath ) ) ;
62- }
63-
64- protected printDebugInformation ( information : string [ ] ) : void {
65- _ . each ( information , i => {
66- this . $logger . info ( `To start debugging, open the following URL in Chrome:${ EOL } ${ i } ${ EOL } ` . cyan ) ;
67- } ) ;
68- }
69-
7044 private async restartApplication ( deviceAppData : Mobile . IDeviceAppData ) : Promise < void > {
7145 let devicePathRoot = `/data/data/${ deviceAppData . appIdentifier } /files` ;
7246 let devicePath = this . $mobileHelper . buildDevicePath ( devicePathRoot , "code_cache" , "secondary_dexes" , "proxyThumb" ) ;
0 commit comments