From 64ae5cf17479ac6e212b8d2406de283e99c7b07d Mon Sep 17 00:00:00 2001 From: fatme Date: Wed, 24 Oct 2018 13:56:18 +0300 Subject: [PATCH 1/2] fix: don't show "TypeError: Invalid Version: null" error in sidekick when emulator is stoped immediately after start --- lib/common/mobile/android/logcat-helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/mobile/android/logcat-helper.ts b/lib/common/mobile/android/logcat-helper.ts index 127c2c7799..a9374758b4 100644 --- a/lib/common/mobile/android/logcat-helper.ts +++ b/lib/common/mobile/android/logcat-helper.ts @@ -61,7 +61,7 @@ export class LogcatHelper implements Mobile.ILogcatHelper { private async getLogcatStream(deviceIdentifier: string, pid?: string) { const device = await this.$devicesService.getDevice(deviceIdentifier); const minAndroidWithLogcatPidSupport = "7.0.0"; - const isLogcatPidSupported = semver.gte(semver.coerce(device.deviceInfo.version), minAndroidWithLogcatPidSupport); + const isLogcatPidSupported = !!device.deviceInfo.version && semver.gte(semver.coerce(device.deviceInfo.version), minAndroidWithLogcatPidSupport); const adb: Mobile.IDeviceAndroidDebugBridge = this.$injector.resolve(DeviceAndroidDebugBridge, { identifier: deviceIdentifier }); const logcatCommand = ["logcat"]; From 3ac0205dead0b3ff043491944f1b4b55da539b0c Mon Sep 17 00:00:00 2001 From: fatme Date: Wed, 24 Oct 2018 13:57:09 +0300 Subject: [PATCH 2/2] refactor: move the private method after the public methods --- lib/common/mobile/android/logcat-helper.ts | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/common/mobile/android/logcat-helper.ts b/lib/common/mobile/android/logcat-helper.ts index a9374758b4..d662733afe 100644 --- a/lib/common/mobile/android/logcat-helper.ts +++ b/lib/common/mobile/android/logcat-helper.ts @@ -58,20 +58,6 @@ export class LogcatHelper implements Mobile.ILogcatHelper { } } - private async getLogcatStream(deviceIdentifier: string, pid?: string) { - const device = await this.$devicesService.getDevice(deviceIdentifier); - const minAndroidWithLogcatPidSupport = "7.0.0"; - const isLogcatPidSupported = !!device.deviceInfo.version && semver.gte(semver.coerce(device.deviceInfo.version), minAndroidWithLogcatPidSupport); - const adb: Mobile.IDeviceAndroidDebugBridge = this.$injector.resolve(DeviceAndroidDebugBridge, { identifier: deviceIdentifier }); - const logcatCommand = ["logcat"]; - - if (pid && isLogcatPidSupported) { - logcatCommand.push(`--pid=${pid}`); - } - const logcatStream = await adb.executeCommand(logcatCommand, { returnChildProcess: true }); - return logcatStream; - } - public async dump(deviceIdentifier: string): Promise { const adb: Mobile.IDeviceAndroidDebugBridge = this.$injector.resolve(DeviceAndroidDebugBridge, { identifier: deviceIdentifier }); const logcatDumpStream = await adb.executeCommand(["logcat", "-d"], { returnChildProcess: true }); @@ -101,6 +87,20 @@ export class LogcatHelper implements Mobile.ILogcatHelper { delete this.mapDevicesLoggingData[deviceIdentifier]; } } + + private async getLogcatStream(deviceIdentifier: string, pid?: string) { + const device = await this.$devicesService.getDevice(deviceIdentifier); + const minAndroidWithLogcatPidSupport = "7.0.0"; + const isLogcatPidSupported = !!device.deviceInfo.version && semver.gte(semver.coerce(device.deviceInfo.version), minAndroidWithLogcatPidSupport); + const adb: Mobile.IDeviceAndroidDebugBridge = this.$injector.resolve(DeviceAndroidDebugBridge, { identifier: deviceIdentifier }); + const logcatCommand = ["logcat"]; + + if (pid && isLogcatPidSupported) { + logcatCommand.push(`--pid=${pid}`); + } + const logcatStream = await adb.executeCommand(logcatCommand, { returnChildProcess: true }); + return logcatStream; + } } $injector.register("logcatHelper", LogcatHelper);