Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 31ddc26

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Implement android optimizations
1 parent 72c8470 commit 31ddc26

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

definitions/mobile.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ declare module Mobile {
8282
getFile(deviceFilePath: string): IFuture<void>;
8383
putFile(localFilePath: string, deviceFilePath: string): IFuture<void>;
8484
deleteFile?(deviceFilePath: string, appIdentifier: string): void;
85-
transferFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void>;
85+
transferFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectFilesPath?: string): IFuture<void>;
8686
transferFile?(localFilePath: string, deviceFilePath: string): IFuture<void>;
8787
}
8888

mobile/android/android-device-file-system.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem {
88
constructor(private adb: Mobile.IAndroidDebugBridge,
99
private identifier: string,
1010
private $fs: IFileSystem,
11-
private $logger: ILogger) { }
11+
private $logger: ILogger,
12+
private $deviceAppDataFactory: Mobile.IDeviceAppDataFactory) { }
1213

1314
public listFiles(devicePath: string): IFuture<void> {
1415
return future.fromResult();
@@ -22,21 +23,13 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem {
2223
return future.fromResult();
2324
}
2425

25-
public transferFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> {
26+
public transferFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectFilesPath?: string): IFuture<void> {
2627
return (() => {
27-
_(localToDevicePaths)
28-
.filter(localToDevicePathData => this.$fs.getFsStats(localToDevicePathData.getLocalPath()).wait().isFile())
29-
.each(localToDevicePathData =>
30-
this.adb.executeCommand(["push", localToDevicePathData.getLocalPath(), localToDevicePathData.getDevicePath()]).wait()
31-
)
32-
.value();
33-
34-
_(localToDevicePaths)
35-
.filter(localToDevicePathData => this.$fs.getFsStats(localToDevicePathData.getLocalPath()).wait().isDirectory())
36-
.each(localToDevicePathData =>
37-
this.adb.executeShellCommand(["chmod", "0777", localToDevicePathData.getDevicePath()]).wait()
38-
)
39-
.value();
28+
let deviceAppData = this.$deviceAppDataFactory.create(appIdentifier, "Android");
29+
this.adb.executeCommand(["push", projectFilesPath, deviceAppData.deviceProjectRootPath]).wait();
30+
31+
let command = _.map(localToDevicePaths, (localToDevicePathData) => localToDevicePathData.getDevicePath()).join(" ");
32+
this.adb.executeCommand(["chmod", "0777", command]).wait();
4033
}).future<void>()();
4134
}
4235

services/usb-livesync-service-base.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,20 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
148148
return localToDevicePaths;
149149
}
150150

151-
protected transferFiles(device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> {
151+
protected transferFiles(device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectFilesPath: string): IFuture<void> {
152152
return (() => {
153153
this.$logger.info("Transferring project files...");
154-
device.fileSystem.transferFiles(deviceAppData.appIdentifier, localToDevicePaths).wait();
154+
device.fileSystem.transferFiles(deviceAppData.appIdentifier, localToDevicePaths, projectFilesPath).wait();
155155
this.$logger.info("Successfully transferred all project files.");
156156
}).future<void>()();
157157
}
158158

159159
private syncCore(data: ILiveSyncData, projectFiles: string[]): IFuture<void> {
160160
return (() => {
161+
let projectFilesPath = data.localProjectRootPath || data.projectFilesPath;
161162
let platform = data.platform ? this.$mobileHelper.normalizePlatformName(data.platform) : this.$devicesService.platform;
162163
let deviceAppData = this.$deviceAppDataFactory.create(data.appIdentifier, this.$mobileHelper.normalizePlatformName(data.platform));
163-
let localToDevicePaths = this.createLocalToDevicePaths(data.platform, data.appIdentifier, data.localProjectRootPath || data.projectFilesPath, projectFiles);
164+
let localToDevicePaths = this.createLocalToDevicePaths(data.platform, data.appIdentifier, projectFilesPath, projectFiles);
164165

165166
console.log(localToDevicePaths[0]);
166167

@@ -180,7 +181,7 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
180181
}
181182
}
182183

183-
this.transferFiles(device, deviceAppData, localToDevicePaths).wait();
184+
this.transferFiles(device, deviceAppData, localToDevicePaths, projectFilesPath).wait();
184185

185186
this.$logger.info("Applying changes...");
186187
let platformSpecificLiveSyncService = this.resolvePlatformSpecificLiveSyncService(platform, device, data.platformSpecificLiveSyncServices);

0 commit comments

Comments
 (0)