Skip to content

Commit ccf2b84

Browse files
committed
fix: restart application when ios-runtime is lower than 6.1.0 and device is only connected via wifi
In case when device is only connected via WiFi and the runtime is with version lower than 6.1.0, we should restart application without awaiting the socket's setup as this setup requires around 30seconds.
1 parent d6852c7 commit ccf2b84

File tree

7 files changed

+17
-1
lines changed

7 files changed

+17
-1
lines changed

lib/common/definitions/mobile.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ declare global {
105105
applicationManager: Mobile.IDeviceApplicationManager;
106106
fileSystem: Mobile.IDeviceFileSystem;
107107
isEmulator: boolean;
108+
isOnlyWiFiConnected: boolean;
108109
openDeviceLogStream(): Promise<void>;
109110

110111
/**

lib/common/mobile/android/android-device.ts

+4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ export class AndroidDevice implements Mobile.IAndroidDevice {
105105
return this.deviceInfo.type === constants.DeviceTypes.Emulator;
106106
}
107107

108+
public get isOnlyWiFiConnected(): boolean {
109+
return false;
110+
}
111+
108112
public async openDeviceLogStream(): Promise<void> {
109113
if (this.deviceInfo.status === constants.CONNECTED_STATUS) {
110114
await this.$logcatHelper.start({

lib/common/mobile/ios/device/ios-device.ts

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export class IOSDevice extends IOSDeviceBase {
5959
return false;
6060
}
6161

62+
public get isOnlyWiFiConnected(): boolean {
63+
const result = this.deviceInfo.connectionTypes.every(connectionType => connectionType === constants.DeviceConnectionType.Wifi);
64+
return result;
65+
}
66+
6267
@cache()
6368
public async openDeviceLogStream(): Promise<void> {
6469
if (this.deviceInfo.status !== commonConstants.UNREACHABLE_STATUS) {

lib/common/mobile/ios/ios-device-base.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export abstract class IOSDeviceBase implements Mobile.IiOSDevice {
1212
abstract applicationManager: Mobile.IDeviceApplicationManager;
1313
abstract fileSystem: Mobile.IDeviceFileSystem;
1414
abstract isEmulator: boolean;
15+
abstract isOnlyWiFiConnected: boolean;
1516
abstract openDeviceLogStream(options?: Mobile.IiOSLogStreamOptions): Promise<void>;
1617

1718
@performanceLog()

lib/common/mobile/ios/simulator/ios-simulator-device.ts

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export class IOSSimulator extends IOSDeviceBase implements Mobile.IiOSDevice {
4747
return true;
4848
}
4949

50+
public get isOnlyWiFiConnected(): boolean {
51+
return false;
52+
}
53+
5054
@cache()
5155
public async openDeviceLogStream(options?: Mobile.IiOSLogStreamOptions): Promise<void> {
5256
options = options || {};

lib/services/livesync/ios-device-livesync-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
7272
shouldRestart = true;
7373
} else {
7474
const canExecuteFastSync = this.canExecuteFastSyncForPaths(liveSyncInfo, localToDevicePaths, projectData, deviceAppData.platform);
75-
const isRefreshConnectionSetup = this.canRefreshWithNotification(projectData) || await this.setupSocketIfNeeded(projectData);
75+
const isRefreshConnectionSetup = this.canRefreshWithNotification(projectData) || (!this.device.isOnlyWiFiConnected && await this.setupSocketIfNeeded(projectData));
7676
if (!canExecuteFastSync || !isRefreshConnectionSetup) {
7777
shouldRestart = true;
7878
}

test/services/livesync/android-device-livesync-service-base.ts

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function mockDevice(deviceHashService: Mobile.IAndroidDeviceHashService): Mobile
8787
applicationManager: mockDeviceApplicationManager(),
8888
fileSystem: mockDeviceFileSystem(deviceHashService),
8989
isEmulator: true,
90+
isOnlyWiFiConnected: false,
9091
openDeviceLogStream: () => Promise.resolve(),
9192
init: () => Promise.resolve()
9293
};

0 commit comments

Comments
 (0)