From e51b8c0742badc32ec38d5abf7af28666e4354da Mon Sep 17 00:00:00 2001 From: Anamaria Cotirlea Date: Wed, 15 Aug 2018 02:51:05 -0700 Subject: [PATCH] Add Hardware Details to CPU Info Plugin. Summary: Added an additional field which contains hardware information regarding the chipset manufacturer and model. Reviewed By: danielbuechele Differential Revision: D9294547 fbshipit-source-id: 45c577475f156ee4a83140f506df161cd4ed4330 --- src/device-plugins/cpu/index.js | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/device-plugins/cpu/index.js b/src/device-plugins/cpu/index.js index fb809fd80..69fff9482 100644 --- a/src/device-plugins/cpu/index.js +++ b/src/device-plugins/cpu/index.js @@ -38,6 +38,7 @@ type CPUState = {| cpuFreq: Array, cpuCount: number, monitoring: boolean, + hardwareInfo: string, |}; type ShellCallBack = (output: string) => void; @@ -109,12 +110,15 @@ export default class CPUFrequencyTable extends SonarDevicePlugin { cpuFreq: [], cpuCount: 0, monitoring: false, + hardwareInfo: '', }; init() { let device = ((this.device: any): AndroidDevice); this.adbClient = device.adb; + this.updateHardwareInfo(); + // check how many cores we have on this device this.executeShell((output: string) => { let idx = output.indexOf('-'); @@ -179,6 +183,41 @@ export default class CPUFrequencyTable extends SonarDevicePlugin { this.updateCoreFrequency(core, 'scaling_max_freq'); }; + updateHardwareInfo = () => { + this.executeShell((output: string) => { + let hwInfo = ''; + if ( + output.startsWith('msm') || + output.startsWith('apq') || + output.startsWith('sdm') + ) { + hwInfo = 'QUALCOMM ' + output.toUpperCase(); + } else if (output.startsWith('exynos')) { + this.executeShell((output: string) => { + if (output != null) { + this.setState({ + hardwareInfo: 'SAMSUMG ' + output.toUpperCase(), + }); + } + }, 'getprop ro.chipname'); + return; + } else if (output.startsWith('mt')) { + hwInfo = 'MEDIATEK ' + output.toUpperCase(); + } else if (output.startsWith('sc')) { + hwInfo = 'SPREADTRUM ' + output.toUpperCase(); + } else if (output.startsWith('hi') || output.startsWith('kirin')) { + hwInfo = 'HISILICON ' + output.toUpperCase(); + } else if (output.startsWith('rk')) { + hwInfo = 'ROCKCHIP ' + output.toUpperCase(); + } else if (output.startsWith('bcm')) { + hwInfo = 'BROADCOM ' + output.toUpperCase(); + } + this.setState({ + hardwareInfo: hwInfo, + }); + }, 'getprop ro.board.platform'); + }; + onStartMonitor = () => { if (this.intervalID) { return; @@ -308,6 +347,7 @@ export default class CPUFrequencyTable extends SonarDevicePlugin { Start )} +   {this.state.hardwareInfo}