Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_47647075
emmagee
提交
bc8f6730
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,体验更适合开发者的 AI 搜索 >>
提交
bc8f6730
编写于
2月 18, 2013
作者:
A
andrewleo2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine code
上级
7c495fb7
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
76 addition
and
50 deletion
+76
-50
src/com/netease/qa/emmagee/activity/MainPageActivity.java
src/com/netease/qa/emmagee/activity/MainPageActivity.java
+21
-10
src/com/netease/qa/emmagee/activity/SettingsActivity.java
src/com/netease/qa/emmagee/activity/SettingsActivity.java
+14
-11
src/com/netease/qa/emmagee/service/EmmageeService.java
src/com/netease/qa/emmagee/service/EmmageeService.java
+9
-9
src/com/netease/qa/emmagee/utils/CpuInfo.java
src/com/netease/qa/emmagee/utils/CpuInfo.java
+6
-5
src/com/netease/qa/emmagee/utils/MemoryInfo.java
src/com/netease/qa/emmagee/utils/MemoryInfo.java
+6
-5
src/com/netease/qa/emmagee/utils/ProcessInfo.java
src/com/netease/qa/emmagee/utils/ProcessInfo.java
+3
-3
src/com/netease/qa/emmagee/utils/TrafficInfo.java
src/com/netease/qa/emmagee/utils/TrafficInfo.java
+17
-7
未找到文件。
src/com/netease/qa/emmagee/activity/MainPageActivity.java
浏览文件 @
bc8f6730
...
...
@@ -59,7 +59,7 @@ public class MainPageActivity extends Activity {
+
MainPageActivity
.
class
.
getSimpleName
();
private
final
int
TIMEOUT
=
20000
;
private
List
<
Programe
>
processList
;
private
ProcessInfo
processInfo
;
private
Intent
MonitorService
;
...
...
@@ -90,7 +90,7 @@ public class MainPageActivity extends Activity {
MonitorService
.
setClass
(
MainPageActivity
.
this
,
EmmageeService
.
class
);
if
(
isTesting
)
{
if
(
isRadioChecked
==
true
)
{
if
(
isRadioChecked
)
{
Intent
intent
=
getPackageManager
()
.
getLaunchIntentForPackage
(
packageName
);
Log
.
d
(
LOG_TAG
,
packageName
);
...
...
@@ -129,7 +129,7 @@ public class MainPageActivity extends Activity {
settingTempFile
=
getBaseContext
().
getFilesDir
().
getPath
()
+
"\\Emmagee_Settings.txt"
;
File
settingFile
=
new
File
(
settingTempFile
);
if
(!
settingFile
.
exists
())
if
(!
settingFile
.
exists
())
{
try
{
settingFile
.
createNewFile
();
BufferedWriter
bw
=
new
BufferedWriter
(
new
OutputStreamWriter
(
...
...
@@ -139,13 +139,14 @@ public class MainPageActivity extends Activity {
}
catch
(
IOException
e
)
{
Log
.
d
(
LOG_TAG
,
"create new file exception :"
+
e
.
getMessage
());
}
}
}
/**
* wait for test application started
* wait for test application started
.
*
* @param packageName
*
package name of test application
* package name of test application
*/
private
void
waitForAppStart
(
String
packageName
)
{
Log
.
d
(
LOG_TAG
,
"wait for app start"
);
...
...
@@ -165,13 +166,14 @@ public class MainPageActivity extends Activity {
}
}
}
if
(
isProcessStarted
)
if
(
isProcessStarted
)
{
break
;
}
}
}
/**
* show a dialog when click return key
* show a dialog when click return key
.
*/
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
&&
event
.
getRepeatCount
()
==
0
)
{
...
...
@@ -181,7 +183,9 @@ public class MainPageActivity extends Activity {
}
/**
* set menu options
* set menu options.
*
* @return true
*/
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
menu
.
add
(
0
,
Menu
.
FIRST
,
0
,
"退出"
).
setIcon
(
...
...
@@ -191,6 +195,11 @@ public class MainPageActivity extends Activity {
return
true
;
}
/**
* trigger menu options.
*
* @return false
*/
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getOrder
())
{
case
0
:
...
...
@@ -209,7 +218,9 @@ public class MainPageActivity extends Activity {
}
/**
* create a dialog
* create a dialog.
*
* @return a dialog
*/
protected
Dialog
onCreateDialog
(
int
id
)
{
switch
(
id
)
{
...
...
@@ -238,7 +249,7 @@ public class MainPageActivity extends Activity {
}
/**
* customizing adapter
* customizing adapter
.
*
*/
private
class
ListAdapter
extends
BaseAdapter
{
...
...
src/com/netease/qa/emmagee/activity/SettingsActivity.java
浏览文件 @
bc8f6730
...
...
@@ -40,7 +40,7 @@ public class SettingsActivity extends Activity {
private
final
String
LOG_TAG
=
"Emmagee-"
+
SettingsActivity
.
class
.
getSimpleName
();
private
CheckBox
chkFloat
;
private
EditText
edtTime
;
private
String
time
;
...
...
@@ -54,34 +54,37 @@ public class SettingsActivity extends Activity {
Intent
intent
=
this
.
getIntent
();
settingTempFile
=
intent
.
getStringExtra
(
"settingTempFile"
);
chkFloat
=
(
CheckBox
)
findViewById
(
R
.
id
.
floating
);
edtTime
=
(
EditText
)
findViewById
(
R
.
id
.
time
);
Button
btnSave
=
(
Button
)
findViewById
(
R
.
id
.
save
);
boolean
floatingTag
=
true
;
RandomAccessFile
raf
;
try
{
RandomAccessFile
raf
=
new
RandomAccessFile
(
settingTempFile
,
"r"
);
raf
=
new
RandomAccessFile
(
settingTempFile
,
"r"
);
String
f
=
raf
.
readLine
();
if
(
f
==
null
||
(
f
!=
null
&&
f
.
equals
(
""
)))
{
time
=
"5"
;
}
else
}
else
{
time
=
f
;
}
String
tag
=
raf
.
readLine
();
if
(
tag
!=
null
&&
tag
.
equals
(
"false"
))
if
(
tag
!=
null
&&
tag
.
equals
(
"false"
))
{
floatingTag
=
false
;
}
raf
.
close
();
}
catch
(
FileNotFoundException
e
)
{
Log
.
e
(
LOG_TAG
,
"FileNotFoundException: "
+
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
"FileNotFoundException: "
+
e
.
getMessage
());
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
Log
.
e
(
LOG_TAG
,
"IOException: "
+
e
.
getMessage
());
e
.
printStackTrace
();
}
edtTime
.
setText
(
time
);
chkFloat
.
setChecked
(
floatingTag
);
// edtTime.setInputType(InputType.TYPE_CLASS_NUMBER);
// edtTime.setInputType(InputType.TYPE_CLASS_NUMBER);
btnSave
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
...
...
@@ -131,11 +134,11 @@ public class SettingsActivity extends Activity {
}
/**
* is input a number
* is input a number
.
*
* @param inputStr
* input string
* @return
* @return
true is numeric
*/
private
boolean
isNumeric
(
String
inputStr
)
{
for
(
int
i
=
inputStr
.
length
();
--
i
>=
0
;)
{
...
...
src/com/netease/qa/emmagee/service/EmmageeService.java
浏览文件 @
bc8f6730
...
...
@@ -18,7 +18,6 @@ package com.netease.qa.emmagee.service;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStreamWriter
;
...
...
@@ -143,7 +142,7 @@ public class EmmageeService extends Service {
}
/**
* read configuration file
* read configuration file
.
*
* @throws IOException
*/
...
...
@@ -153,15 +152,16 @@ public class EmmageeService extends Service {
settingTempFile
),
"r"
);
time
=
raf
.
readLine
();
isFloating
=
raf
.
readLine
().
equals
(
"true"
)
?
true
:
false
;
raf
.
close
();
}
catch
(
IOException
e
)
{
time
=
"5"
;
isFloating
=
true
;
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
}
}
}
/**
* write the test result to csv format report
* write the test result to csv format report
.
*/
private
void
createResultCsv
()
{
Calendar
cal
=
Calendar
.
getInstance
();
...
...
@@ -203,7 +203,7 @@ public class EmmageeService extends Service {
}
/**
* create a floating window to show real-time data
* create a floating window to show real-time data
.
*/
private
void
createFloatingWindow
()
{
SharedPreferences
shared
=
getSharedPreferences
(
"float_flag"
,
...
...
@@ -278,7 +278,7 @@ public class EmmageeService extends Service {
}
/**
* show the image
* show the image
.
*/
private
void
showImg
()
{
if
(
Math
.
abs
(
x
-
startX
)
<
1.5
&&
Math
.
abs
(
y
-
startY
)
<
1.5
...
...
@@ -299,7 +299,7 @@ public class EmmageeService extends Service {
};
/**
* refresh the performance data showing in floating window
* refresh the performance data showing in floating window
.
*
* @throws FileNotFoundException
*
...
...
@@ -348,7 +348,7 @@ public class EmmageeService extends Service {
}
/**
* update the position of floating window
* update the position of floating window
.
*/
private
void
updateViewPosition
()
{
wmParams
.
x
=
(
int
)
(
x
-
mTouchStartX
);
...
...
@@ -357,7 +357,7 @@ public class EmmageeService extends Service {
}
/**
* close all opened stream
* close all opened stream
.
*/
public
static
void
closeOpenedStream
()
{
try
{
...
...
src/com/netease/qa/emmagee/utils/CpuInfo.java
浏览文件 @
bc8f6730
...
...
@@ -65,7 +65,7 @@ public class CpuInfo {
}
/**
* read the status of CPU
* read the status of CPU
.
*
* @throws FileNotFoundException
*/
...
...
@@ -110,15 +110,16 @@ public class CpuInfo {
}
/**
* get CPU name
* get CPU name
.
*
* @return CPU name
*/
public
String
getCpuName
()
{
try
{
RandomAccessFile
cpu
_s
tat
=
new
RandomAccessFile
(
"/proc/cpuinfo"
,
RandomAccessFile
cpu
S
tat
=
new
RandomAccessFile
(
"/proc/cpuinfo"
,
"r"
);
String
[]
cpu
=
cpu_stat
.
readLine
().
split
(
":"
);
// cpu信息的前一段是含有processor字符串,此处替换为不显示
String
[]
cpu
=
cpuStat
.
readLine
().
split
(
":"
);
// cpu信息的前一段是含有processor字符串,此处替换为不显示
cpuStat
.
close
();
return
cpu
[
1
];
}
catch
(
IOException
e
)
{
Log
.
e
(
LOG_TAG
,
"IOException: "
+
e
.
getMessage
());
...
...
@@ -128,7 +129,7 @@ public class CpuInfo {
/**
* reserve used ratio of process CPU and total CPU, meanwhile collect
* network traffic
* network traffic
.
*
* @return network traffic ,used ratio of process CPU and total CPU in
* certain interval
...
...
src/com/netease/qa/emmagee/utils/MemoryInfo.java
浏览文件 @
bc8f6730
...
...
@@ -31,7 +31,7 @@ public class MemoryInfo {
+
MemoryInfo
.
class
.
getSimpleName
();
/**
* get total memory of certain device
* get total memory of certain device
.
*
* @return total memory of device
*/
...
...
@@ -49,6 +49,7 @@ public class MemoryInfo {
memTotal
=
total
[
1
].
trim
();
}
}
localBufferedReader
.
close
();
String
[]
memKb
=
memTotal
.
split
(
" "
);
memTotal
=
memKb
[
0
].
trim
();
Log
.
d
(
LOG_TAG
,
"memTotal: "
+
memTotal
);
...
...
@@ -60,7 +61,7 @@ public class MemoryInfo {
}
/**
* get free memory
* get free memory
.
*
* @return free memory of device
*
...
...
@@ -75,7 +76,7 @@ public class MemoryInfo {
}
/**
* get the memory of process with certain pid
* get the memory of process with certain pid
.
*
* @param pid
* pid of process
...
...
@@ -98,7 +99,7 @@ public class MemoryInfo {
}
/**
* get the sdk version of phone
* get the sdk version of phone
.
*
* @return sdk version
*/
...
...
@@ -107,7 +108,7 @@ public class MemoryInfo {
}
/**
* get phone type
* get phone type
.
*
* @return phone type
*/
...
...
src/com/netease/qa/emmagee/utils/ProcessInfo.java
浏览文件 @
bc8f6730
...
...
@@ -37,7 +37,7 @@ public class ProcessInfo {
/**
* get information of all running processes,including package name ,process
* name ,icon ,pid and uid
* name ,icon ,pid and uid
.
*
* @param context
* context of activity
...
...
@@ -73,7 +73,7 @@ public class ProcessInfo {
}
programe
.
setPackageName
(
appinfo
.
processName
);
programe
.
setProcessName
(
appinfo
.
loadLabel
(
pm
).
toString
());
if
(
launchTag
==
true
)
{
if
(
launchTag
)
{
programe
.
setIcon
(
appinfo
.
loadIcon
(
pm
));
}
progressList
.
add
(
programe
);
...
...
@@ -82,7 +82,7 @@ public class ProcessInfo {
}
/**
* get information of all applications
* get information of all applications
.
*
* @param context
* context of activity
...
...
src/com/netease/qa/emmagee/utils/TrafficInfo.java
浏览文件 @
bc8f6730
...
...
@@ -26,27 +26,29 @@ public class TrafficInfo {
private
static
final
String
LOG_TAG
=
"Emmagee-"
+
TrafficInfo
.
class
.
getSimpleName
();
private
String
uid
;
public
TrafficInfo
(
String
uid
){
public
TrafficInfo
(
String
uid
)
{
this
.
uid
=
uid
;
}
/**
* get total network traffic, which is the sum of upload and download traffic
* get total network traffic, which is the sum of upload and download
* traffic.
*
* @return total traffic include received and send traffic
*/
public
long
getTrafficInfo
()
{
Log
.
i
(
LOG_TAG
,
"get traffic information"
);
Log
.
i
(
LOG_TAG
,
"get traffic information"
);
RandomAccessFile
rafRcv
=
null
,
rafSnd
=
null
;
String
rcvPath
=
"/proc/uid_stat/"
+
uid
+
"/tcp_rcv"
;
String
sndPath
=
"/proc/uid_stat/"
+
uid
+
"/tcp_snd"
;
long
rcvTraffic
=
-
1
;
long
sndTraffic
=
-
1
;
try
{
RandomAccessFile
rafRcv
=
new
RandomAccessFile
(
rcvPath
,
"r"
);
RandomAccessFile
rafSnd
=
new
RandomAccessFile
(
sndPath
,
"r"
);
rafRcv
=
new
RandomAccessFile
(
rcvPath
,
"r"
);
rafSnd
=
new
RandomAccessFile
(
sndPath
,
"r"
);
rcvTraffic
=
Long
.
parseLong
(
rafRcv
.
readLine
());
sndTraffic
=
Long
.
parseLong
(
rafSnd
.
readLine
());
}
catch
(
FileNotFoundException
e
)
{
...
...
@@ -58,6 +60,14 @@ public class TrafficInfo {
}
catch
(
IOException
e
)
{
Log
.
e
(
LOG_TAG
,
"IOException: "
+
e
.
getMessage
());
e
.
printStackTrace
();
}
finally
{
try
{
rafRcv
.
close
();
rafSnd
.
close
();
}
catch
(
IOException
e
)
{
Log
.
i
(
LOG_TAG
,
"close randomAccessFile exception: "
+
e
.
getMessage
());
}
}
if
(
rcvTraffic
==
-
1
||
sndTraffic
==
-
1
)
{
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录