Skip to content

Commit 0168086

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Fix emulate-livesync-emulate
Fixes #1031
1 parent b306852 commit 0168086

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

lib/definitions/project.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ interface IPlatformProjectService {
5353
removePluginNativeCode(pluginData: IPluginData): IFuture<void>;
5454
afterPrepareAllPlugins(): IFuture<void>;
5555
getAppResourcesDestinationDirectoryPath(): IFuture<string>;
56-
deploy(device: Mobile.IDevice, appIdentifier: string): IFuture<void>;
56+
deploy(deviceIdentifier: string): IFuture<void>;
5757
}
5858

5959
interface IAndroidProjectPropertiesManager {

lib/services/android-project-service.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Future = require("fibers/future");
66
import * as constants from "../constants";
77
import * as semver from "semver";
88
import * as projectServiceBaseLib from "./platform-project-service-base";
9+
import * as androidDebugBridgePath from "../common/mobile/android/android-debug-bridge";
910

1011
class AndroidProjectService extends projectServiceBaseLib.PlatformProjectServiceBase implements IPlatformProjectService {
1112
private static VALUES_DIRNAME = "values";
@@ -28,7 +29,8 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
2829
$projectData: IProjectData,
2930
$projectDataService: IProjectDataService,
3031
private $sysInfo: ISysInfo,
31-
private $mobileHelper: Mobile.IMobileHelper) {
32+
private $mobileHelper: Mobile.IMobileHelper,
33+
private $injector: IInjector) {
3234
super($fs, $projectData, $projectDataService);
3335
this._androidProjectPropertiesManagers = Object.create(null);
3436
}
@@ -285,10 +287,11 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
285287
return Future.fromResult();
286288
}
287289

288-
public deploy(device: Mobile.IAndroidDevice, appIdentifier: string): IFuture<void> {
290+
public deploy(deviceIdentifier: string): IFuture<void> {
289291
return (() => {
290-
let deviceRootPath = `/data/local/tmp/${appIdentifier}`;
291-
device.adb.executeShellCommand(["rm", "-rf", this.$mobileHelper.buildDevicePath(deviceRootPath, "fullsync"),
292+
let adb = this.$injector.resolve(androidDebugBridgePath.AndroidDebugBridge, { identifier: deviceIdentifier });
293+
let deviceRootPath = `/data/local/tmp/${this.$projectData.projectId}`;
294+
adb.executeShellCommand(["rm", "-rf", this.$mobileHelper.buildDevicePath(deviceRootPath, "fullsync"),
292295
this.$mobileHelper.buildDevicePath(deviceRootPath, "sync"),
293296
this.$mobileHelper.buildDevicePath(deviceRootPath, "removedsync")]).wait();
294297
}).future<void>()();

lib/services/ios-project-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
212212
}).future<void>()();
213213
}
214214

215-
public deploy(device: Mobile.IDevice, appIdentifier: string): IFuture<void> {
215+
public deploy(deviceIdentifier: string): IFuture<void> {
216216
return Future.fromResult();
217217
}
218218

lib/services/platform-service.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export class PlatformService implements IPlatformService {
276276
this.$devicesServices.initialize({platform: platform, deviceId: this.$options.device}).wait();
277277
let action = (device: Mobile.IDevice): IFuture<void> => {
278278
return (() => {
279-
platformData.platformProjectService.deploy(device, this.$projectData.projectId).wait();
279+
platformData.platformProjectService.deploy(device.deviceInfo.identifier).wait();
280280
device.deploy(packageFile, this.$projectData.projectId).wait();
281281

282282
if (!this.$options.justlaunch) {
@@ -301,6 +301,9 @@ export class PlatformService implements IPlatformService {
301301
emulatorServices.checkAvailability().wait();
302302
emulatorServices.checkDependencies().wait();
303303

304+
let emulatorId = emulatorServices.getEmulatorId().wait();
305+
platformData.platformProjectService.deploy(emulatorId).wait();
306+
304307
if(!this.$options.availableDevices) {
305308
this.buildPlatform(platform, buildConfig).wait();
306309

test/stubs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export class PlatformProjectServiceStub implements IPlatformProjectService {
325325
afterPrepareAllPlugins(): IFuture<void> {
326326
return Future.fromResult();
327327
}
328-
deploy(device: Mobile.IAndroidDevice, appIdentifier: string): IFuture<void> {
328+
deploy(deviceIdentifier: string): IFuture<void> {
329329
return Future.fromResult();
330330
}
331331
}

0 commit comments

Comments
 (0)