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
This commit is contained in:
Anamaria Cotirlea
2018-08-15 02:51:05 -07:00
committed by Facebook Github Bot
parent a35765335e
commit e51b8c0742

View File

@@ -38,6 +38,7 @@ type CPUState = {|
cpuFreq: Array<CPUFrequency>,
cpuCount: number,
monitoring: boolean,
hardwareInfo: string,
|};
type ShellCallBack = (output: string) => void;
@@ -109,12 +110,15 @@ export default class CPUFrequencyTable extends SonarDevicePlugin<CPUState> {
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<CPUState> {
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<CPUState> {
Start
</Button>
)}
&nbsp; {this.state.hardwareInfo}
</Toolbar>
<ManagedTable
multiline={true}