@@ -6,6 +6,7 @@ import constants = require("../constants");
6
6
import helpers = require( "../common/helpers" ) ;
7
7
import usbLivesyncServiceBaseLib = require( "../common/services/usb-livesync-service-base" ) ;
8
8
import path = require( "path" ) ;
9
+ import semver = require( "semver" ) ;
9
10
10
11
export class UsbLiveSyncService extends usbLivesyncServiceBaseLib . UsbLiveSyncServiceBase implements IUsbLiveSyncService {
11
12
private excludedProjectDirsAndFiles = [
@@ -27,16 +28,33 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
27
28
$dispatcher : IFutureDispatcher ,
28
29
$childProcess : IChildProcess ,
29
30
$iOSEmulatorServices : Mobile . IiOSSimulatorService ,
30
- private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ) {
31
+ private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
32
+ private $projectDataService : IProjectDataService ,
33
+ private $prompter : IPrompter ) {
31
34
super ( $devicesServices , $mobileHelper , $localToDevicePathDataFactory , $logger , $options , $deviceAppDataFactory , $fs , $dispatcher , $childProcess , $iOSEmulatorServices ) ;
32
35
}
33
36
34
37
public liveSync ( platform : string ) : IFuture < void > {
35
38
return ( ( ) => {
36
39
platform = platform || this . initialize ( platform ) . wait ( ) ;
40
+ let platformLowerCase = platform . toLowerCase ( ) ;
41
+ let platformData = this . $platformsData . getPlatformData ( platformLowerCase ) ;
42
+
43
+ if ( platformLowerCase === this . $devicePlatformsConstants . Android . toLowerCase ( ) ) {
44
+ this . $projectDataService . initialize ( this . $projectData . projectDir ) ;
45
+ let frameworkVersion = this . $projectDataService . getValue ( platformData . frameworkPackageName ) . wait ( ) . version ;
46
+ if ( semver . lt ( frameworkVersion , "1.2.2" ) ) {
47
+ let shouldUpdate = this . $prompter . confirm ( "You need Android Runtime 1.2.2 or later for LiveSync to work properly. Do you want to update your runtime now?" ) . wait ( ) ;
48
+ if ( shouldUpdate ) {
49
+ this . $platformService . updatePlatforms ( [ this . $devicePlatformsConstants . Android . toLowerCase ( ) ] ) . wait ( ) ;
50
+ } else {
51
+ return ;
52
+ }
53
+ }
54
+ }
55
+
37
56
this . $platformService . preparePlatform ( platform ) . wait ( ) ;
38
57
39
- let platformData = this . $platformsData . getPlatformData ( platform . toLowerCase ( ) ) ;
40
58
let projectFilesPath = path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME ) ;
41
59
42
60
let restartAppOnDeviceAction = ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) : IFuture < void > => {
0 commit comments