Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_47647075
emmagee
提交
fad688ba
E
emmagee
项目概览
weixin_47647075
/
emmagee
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
emmagee
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fad688ba
编写于
9月 09, 2014
作者:
A
andrewleo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed: get cpu_name of x86 architecture
上级
adb9f2dc
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
25 addition
and
4 deletion
+25
-4
src/com/netease/qa/emmagee/utils/CpuInfo.java
src/com/netease/qa/emmagee/utils/CpuInfo.java
+25
-4
未找到文件。
src/com/netease/qa/emmagee/utils/CpuInfo.java
浏览文件 @
fad688ba
...
@@ -59,6 +59,10 @@ public class CpuInfo {
...
@@ -59,6 +59,10 @@ public class CpuInfo {
private
String
totalCpuRatio
=
""
;
private
String
totalCpuRatio
=
""
;
private
int
pid
;
private
int
pid
;
private
static
final
String
INTEL_CPU_NAME
=
"model name"
;
private
static
final
String
CPU_X86
=
"x86"
;
private
static
final
String
CPU_INFO_PATH
=
"/proc/cpuinfo"
;
public
CpuInfo
(
Context
context
,
int
pid
,
String
uid
)
{
public
CpuInfo
(
Context
context
,
int
pid
,
String
uid
)
{
this
.
pid
=
pid
;
this
.
pid
=
pid
;
this
.
context
=
context
;
this
.
context
=
context
;
...
@@ -87,6 +91,9 @@ public class CpuInfo {
...
@@ -87,6 +91,9 @@ public class CpuInfo {
stringBuffer
.
append
(
line
+
"\n"
);
stringBuffer
.
append
(
line
+
"\n"
);
}
}
String
[]
tok
=
stringBuffer
.
toString
().
split
(
" "
);
String
[]
tok
=
stringBuffer
.
toString
().
split
(
" "
);
for
(
int
i
=
0
;
i
<
tok
.
length
;
i
++){
Log
.
w
(
LOG_TAG
,
"tok["
+
i
+
"]=========="
+
tok
[
i
]);
}
processCpu
=
Long
.
parseLong
(
tok
[
13
])
+
Long
.
parseLong
(
tok
[
14
]);
processCpu
=
Long
.
parseLong
(
tok
[
13
])
+
Long
.
parseLong
(
tok
[
14
]);
processCpuInfo
.
close
();
processCpuInfo
.
close
();
}
catch
(
FileNotFoundException
e
)
{
}
catch
(
FileNotFoundException
e
)
{
...
@@ -100,6 +107,9 @@ public class CpuInfo {
...
@@ -100,6 +107,9 @@ public class CpuInfo {
// monitor total and idle cpu stat of certain process
// monitor total and idle cpu stat of certain process
RandomAccessFile
cpuInfo
=
new
RandomAccessFile
(
"/proc/stat"
,
"r"
);
RandomAccessFile
cpuInfo
=
new
RandomAccessFile
(
"/proc/stat"
,
"r"
);
String
[]
toks
=
cpuInfo
.
readLine
().
split
(
"\\s+"
);
String
[]
toks
=
cpuInfo
.
readLine
().
split
(
"\\s+"
);
for
(
int
i
=
0
;
i
<
toks
.
length
;
i
++){
Log
.
w
(
LOG_TAG
,
"toks["
+
i
+
"]=========="
+
toks
[
i
]);
}
idleCpu
=
Long
.
parseLong
(
toks
[
4
]);
idleCpu
=
Long
.
parseLong
(
toks
[
4
]);
totalCpu
=
Long
.
parseLong
(
toks
[
1
])
+
Long
.
parseLong
(
toks
[
2
])
+
Long
.
parseLong
(
toks
[
3
])
+
Long
.
parseLong
(
toks
[
4
])
totalCpu
=
Long
.
parseLong
(
toks
[
1
])
+
Long
.
parseLong
(
toks
[
2
])
+
Long
.
parseLong
(
toks
[
3
])
+
Long
.
parseLong
(
toks
[
4
])
+
Long
.
parseLong
(
toks
[
6
])
+
Long
.
parseLong
(
toks
[
5
])
+
Long
.
parseLong
(
toks
[
7
]);
+
Long
.
parseLong
(
toks
[
6
])
+
Long
.
parseLong
(
toks
[
5
])
+
Long
.
parseLong
(
toks
[
7
]);
...
@@ -118,10 +128,21 @@ public class CpuInfo {
...
@@ -118,10 +128,21 @@ public class CpuInfo {
*/
*/
public
String
getCpuName
()
{
public
String
getCpuName
()
{
try
{
try
{
RandomAccessFile
cpuStat
=
new
RandomAccessFile
(
"/proc/cpuinfo"
,
"r"
);
RandomAccessFile
cpuStat
=
new
RandomAccessFile
(
CPU_INFO_PATH
,
"r"
);
// 需要判断是intel or arm
if
(
Build
.
CPU_ABI
.
equalsIgnoreCase
(
CPU_X86
))
{
String
line
;
while
(
null
!=
(
line
=
cpuStat
.
readLine
()))
{
String
[]
values
=
line
.
split
(
":"
);
if
(
values
[
0
].
contains
(
INTEL_CPU_NAME
))
{
return
values
[
1
];
}
}
}
else
{
String
[]
cpu
=
cpuStat
.
readLine
().
split
(
":"
);
// cpu信息的前一段是含有processor字符串,此处替换为不显示
String
[]
cpu
=
cpuStat
.
readLine
().
split
(
":"
);
// cpu信息的前一段是含有processor字符串,此处替换为不显示
cpuStat
.
close
();
cpuStat
.
close
();
return
cpu
[
1
];
return
cpu
[
1
];
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
Log
.
e
(
LOG_TAG
,
"IOException: "
+
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
"IOException: "
+
e
.
getMessage
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录