Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_47647075
emmagee
提交
527a55b4
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 搜索 >>
提交
527a55b4
编写于
1月 29, 2013
作者:
K
kevinkong
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
ssh://git@github.com/kevinkong/Emmagee.git
上级
9bb22660
2dea49f5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
59 addition
and
41 deletion
+59
-41
src/com/netease/qa/emmagee/activity/MainPageActivity.java
src/com/netease/qa/emmagee/activity/MainPageActivity.java
+23
-16
src/com/netease/qa/emmagee/service/EmmageeService.java
src/com/netease/qa/emmagee/service/EmmageeService.java
+5
-5
src/com/netease/qa/emmagee/utils/CpuInfo.java
src/com/netease/qa/emmagee/utils/CpuInfo.java
+2
-3
src/com/netease/qa/emmagee/utils/MemoryInfo.java
src/com/netease/qa/emmagee/utils/MemoryInfo.java
+15
-7
src/com/netease/qa/emmagee/utils/MyApplication.java
src/com/netease/qa/emmagee/utils/MyApplication.java
+0
-5
src/com/netease/qa/emmagee/utils/ProcessInfo.java
src/com/netease/qa/emmagee/utils/ProcessInfo.java
+8
-5
src/com/netease/qa/emmagee/utils/TrafficInfo.java
src/com/netease/qa/emmagee/utils/TrafficInfo.java
+6
-0
未找到文件。
src/com/netease/qa/emmagee/activity/MainPageActivity.java
浏览文件 @
527a55b4
...
@@ -42,6 +42,8 @@ public class MainPageActivity extends Activity {
...
@@ -42,6 +42,8 @@ public class MainPageActivity extends Activity {
private
final
String
LOG_TAG
=
"Emmagee-"
private
final
String
LOG_TAG
=
"Emmagee-"
+
MainPageActivity
.
class
.
getSimpleName
();
+
MainPageActivity
.
class
.
getSimpleName
();
private
final
int
TIMEOUT
=
20000
;
private
List
<
Programe
>
processList
;
private
List
<
Programe
>
processList
;
private
ProcessInfo
processInfo
;
private
ProcessInfo
processInfo
;
private
Intent
MonitorService
;
private
Intent
MonitorService
;
...
@@ -49,7 +51,6 @@ public class MainPageActivity extends Activity {
...
@@ -49,7 +51,6 @@ public class MainPageActivity extends Activity {
private
Button
btnTest
;
private
Button
btnTest
;
private
boolean
isTesting
=
true
;
private
boolean
isTesting
=
true
;
private
boolean
isRadioChecked
=
false
;
private
boolean
isRadioChecked
=
false
;
private
int
pid
,
uid
;
private
int
pid
,
uid
;
private
String
processName
,
packageName
,
settingTempFile
;
private
String
processName
,
packageName
,
settingTempFile
;
...
@@ -61,7 +62,6 @@ public class MainPageActivity extends Activity {
...
@@ -61,7 +62,6 @@ public class MainPageActivity extends Activity {
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
,
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
,
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
);
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
);
setContentView
(
R
.
layout
.
mainpage
);
setContentView
(
R
.
layout
.
mainpage
);
createNewFile
();
createNewFile
();
processInfo
=
new
ProcessInfo
();
processInfo
=
new
ProcessInfo
();
lstViProgramme
=
(
ListView
)
findViewById
(
R
.
id
.
processList
);
lstViProgramme
=
(
ListView
)
findViewById
(
R
.
id
.
processList
);
...
@@ -71,8 +71,8 @@ public class MainPageActivity extends Activity {
...
@@ -71,8 +71,8 @@ public class MainPageActivity extends Activity {
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
MonitorService
=
new
Intent
();
MonitorService
=
new
Intent
();
MonitorService
MonitorService
.
setClass
(
MainPageActivity
.
this
,
.
setClass
(
MainPageActivity
.
this
,
EmmageeService
.
class
);
EmmageeService
.
class
);
if
(
isTesting
)
{
if
(
isTesting
)
{
if
(
isRadioChecked
==
true
)
{
if
(
isRadioChecked
==
true
)
{
Intent
intent
=
getPackageManager
()
Intent
intent
=
getPackageManager
()
...
@@ -112,7 +112,7 @@ public class MainPageActivity extends Activity {
...
@@ -112,7 +112,7 @@ public class MainPageActivity extends Activity {
settingTempFile
=
getBaseContext
().
getFilesDir
().
getPath
()
settingTempFile
=
getBaseContext
().
getFilesDir
().
getPath
()
+
"\\Emmagee_Settings.txt"
;
+
"\\Emmagee_Settings.txt"
;
File
settingFile
=
new
File
(
settingTempFile
);
File
settingFile
=
new
File
(
settingTempFile
);
if
(!
settingFile
.
exists
())
// 若文件不存在
if
(!
settingFile
.
exists
())
try
{
try
{
settingFile
.
createNewFile
();
settingFile
.
createNewFile
();
BufferedWriter
bw
=
new
BufferedWriter
(
new
OutputStreamWriter
(
BufferedWriter
bw
=
new
BufferedWriter
(
new
OutputStreamWriter
(
...
@@ -125,23 +125,31 @@ public class MainPageActivity extends Activity {
...
@@ -125,23 +125,31 @@ public class MainPageActivity extends Activity {
}
}
/**
/**
* wait for test app start
* wait for test app start
, timeout is 20s
*
*
* @param packageName
* @param packageName
* the package name of test app
* the package name of test app
*/
*/
private
void
waitForAppStart
(
String
packageName
)
{
private
void
waitForAppStart
(
String
packageName
)
{
Log
.
d
(
LOG_TAG
,
"wait for app start"
);
Log
.
d
(
LOG_TAG
,
"wait for app start"
);
processList
=
processInfo
.
getRunningProcess
(
getBaseContext
());
boolean
isProcessStarted
=
false
;
for
(
Programe
programe
:
processList
)
{
long
startTime
=
System
.
currentTimeMillis
();
if
((
programe
.
getPackageName
()
!=
null
)
while
(
System
.
currentTimeMillis
()
<
startTime
+
TIMEOUT
)
{
&&
(
programe
.
getPackageName
().
equals
(
packageName
)))
{
processList
=
processInfo
.
getRunningProcess
(
getBaseContext
());
pid
=
programe
.
getPid
();
for
(
Programe
programe
:
processList
)
{
uid
=
programe
.
getUid
();
if
((
programe
.
getPackageName
()
!=
null
)
if
(
pid
!=
0
)
{
&&
(
programe
.
getPackageName
().
equals
(
packageName
)))
{
break
;
pid
=
programe
.
getPid
();
Log
.
d
(
LOG_TAG
,
"pid:"
+
pid
);
uid
=
programe
.
getUid
();
if
(
pid
!=
0
)
{
isProcessStarted
=
true
;
break
;
}
}
}
}
}
if
(
isProcessStarted
)
break
;
}
}
}
}
...
@@ -163,7 +171,6 @@ public class MainPageActivity extends Activity {
...
@@ -163,7 +171,6 @@ public class MainPageActivity extends Activity {
android
.
R
.
drawable
.
ic_menu_delete
);
android
.
R
.
drawable
.
ic_menu_delete
);
menu
.
add
(
0
,
Menu
.
FIRST
,
1
,
"设置"
).
setIcon
(
menu
.
add
(
0
,
Menu
.
FIRST
,
1
,
"设置"
).
setIcon
(
android
.
R
.
drawable
.
ic_menu_directions
);
android
.
R
.
drawable
.
ic_menu_directions
);
return
true
;
return
true
;
}
}
...
@@ -291,7 +298,7 @@ public class MainPageActivity extends Activity {
...
@@ -291,7 +298,7 @@ public class MainPageActivity extends Activity {
return
convertView
;
return
convertView
;
}
}
}
}
@Override
@Override
public
void
finish
()
{
public
void
finish
()
{
super
.
finish
();
super
.
finish
();
...
...
src/com/netease/qa/emmagee/service/EmmageeService.java
浏览文件 @
527a55b4
...
@@ -39,6 +39,7 @@ import com.netease.qa.emmagee.utils.MyApplication;
...
@@ -39,6 +39,7 @@ import com.netease.qa.emmagee.utils.MyApplication;
import
com.netease.qa.emmagee.R
;
import
com.netease.qa.emmagee.R
;
public
class
EmmageeService
extends
Service
{
public
class
EmmageeService
extends
Service
{
private
final
static
String
LOG_TAG
=
"Emmagee-"
private
final
static
String
LOG_TAG
=
"Emmagee-"
+
EmmageeService
.
class
.
getSimpleName
();
+
EmmageeService
.
class
.
getSimpleName
();
...
@@ -51,7 +52,6 @@ public class EmmageeService extends Service {
...
@@ -51,7 +52,6 @@ public class EmmageeService extends Service {
private
float
startY
;
private
float
startY
;
private
float
x
;
private
float
x
;
private
float
y
;
private
float
y
;
private
TextView
txtTotalMem
;
private
TextView
txtTotalMem
;
private
TextView
txtUnusedMem
;
private
TextView
txtUnusedMem
;
private
TextView
txtTraffic
;
private
TextView
txtTraffic
;
...
@@ -98,7 +98,6 @@ public class EmmageeService extends Service {
...
@@ -98,7 +98,6 @@ public class EmmageeService extends Service {
cpuInfo
=
new
CpuInfo
(
getBaseContext
(),
pid
,
Integer
.
toString
(
uid
));
cpuInfo
=
new
CpuInfo
(
getBaseContext
(),
pid
,
Integer
.
toString
(
uid
));
readSettingInfo
(
intent
);
readSettingInfo
(
intent
);
delaytime
=
Integer
.
parseInt
(
time
)
*
1000
;
delaytime
=
Integer
.
parseInt
(
time
)
*
1000
;
// 如果设置选项是显示浮窗的这里才展示出来
if
(
isFloating
)
{
if
(
isFloating
)
{
viFloatingWindow
=
LayoutInflater
.
from
(
this
).
inflate
(
viFloatingWindow
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
floating
,
null
);
R
.
layout
.
floating
,
null
);
...
@@ -213,7 +212,8 @@ public class EmmageeService extends Service {
...
@@ -213,7 +212,8 @@ public class EmmageeService extends Service {
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
// 获取相对屏幕的坐标,即以屏幕左上角为原点
// 获取相对屏幕的坐标,即以屏幕左上角为原点
x
=
event
.
getRawX
();
x
=
event
.
getRawX
();
y
=
event
.
getRawY
()
-
25
;
// 25是系统状态栏的高度
// 25是系统状态栏的高度
y
=
event
.
getRawY
()
-
25
;
switch
(
event
.
getAction
())
{
switch
(
event
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
case
MotionEvent
.
ACTION_DOWN
:
// state = MotionEvent.ACTION_DOWN;
// state = MotionEvent.ACTION_DOWN;
...
@@ -230,7 +230,7 @@ public class EmmageeService extends Service {
...
@@ -230,7 +230,7 @@ public class EmmageeService extends Service {
break
;
break
;
case
MotionEvent
.
ACTION_UP
:
case
MotionEvent
.
ACTION_UP
:
//
state = MotionEvent.ACTION_UP;
//
state = MotionEvent.ACTION_UP;
updateViewPosition
();
updateViewPosition
();
showImg
();
showImg
();
mTouchStartX
=
mTouchStartY
=
0
;
mTouchStartX
=
mTouchStartY
=
0
;
...
@@ -285,7 +285,7 @@ public class EmmageeService extends Service {
...
@@ -285,7 +285,7 @@ public class EmmageeService extends Service {
};
};
/**
/**
* refresh
data
* refresh
the data displayed in floating window
*
*
* @throws FileNotFoundException
* @throws FileNotFoundException
*
*
...
...
src/com/netease/qa/emmagee/utils/CpuInfo.java
浏览文件 @
527a55b4
...
@@ -38,7 +38,7 @@ public class CpuInfo {
...
@@ -38,7 +38,7 @@ public class CpuInfo {
private
String
totalCpuRatio
=
""
;
private
String
totalCpuRatio
=
""
;
private
int
pid
;
private
int
pid
;
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
;
trafficInfo
=
new
TrafficInfo
(
uid
);
trafficInfo
=
new
TrafficInfo
(
uid
);
...
@@ -143,8 +143,7 @@ public class CpuInfo {
...
@@ -143,8 +143,7 @@ public class CpuInfo {
.
format
(
100
*
((
double
)
(
processCpu
-
processCpu2
)
/
(
double
)
(
totalCpu
-
totalCpu2
)));
.
format
(
100
*
((
double
)
(
processCpu
-
processCpu2
)
/
(
double
)
(
totalCpu
-
totalCpu2
)));
totalCpuRatio
=
fomart
totalCpuRatio
=
fomart
.
format
(
100
*
((
double
)
((
totalCpu
-
idleCpu
)
-
(
totalCpu2
-
idleCpu2
))
/
(
double
)
(
totalCpu
-
totalCpu2
)));
.
format
(
100
*
((
double
)
((
totalCpu
-
idleCpu
)
-
(
totalCpu2
-
idleCpu2
))
/
(
double
)
(
totalCpu
-
totalCpu2
)));
long
pidMemory
=
mi
.
getPidMemorySize
(
pid
,
long
pidMemory
=
mi
.
getPidMemorySize
(
pid
,
context
);
context
);
String
pMemory
=
fomart
.
format
((
double
)
pidMemory
/
1024
);
String
pMemory
=
fomart
.
format
((
double
)
pidMemory
/
1024
);
long
freeMemory
=
mi
.
getFreeMemorySize
(
context
);
long
freeMemory
=
mi
.
getFreeMemorySize
(
context
);
String
fMemory
=
fomart
.
format
((
double
)
freeMemory
/
1024
);
String
fMemory
=
fomart
.
format
((
double
)
freeMemory
/
1024
);
...
...
src/com/netease/qa/emmagee/utils/MemoryInfo.java
浏览文件 @
527a55b4
...
@@ -15,7 +15,9 @@ public class MemoryInfo {
...
@@ -15,7 +15,9 @@ public class MemoryInfo {
+
MemoryInfo
.
class
.
getSimpleName
();
+
MemoryInfo
.
class
.
getSimpleName
();
/**
/**
* read the total memory of certain device 读取当前机器的内存总数,返回值为KB
* read the total memory of certain device
*
* @return total memory of device
*/
*/
public
long
getTotalMemory
()
{
public
long
getTotalMemory
()
{
String
memInfoPath
=
"/proc/meminfo"
;
String
memInfoPath
=
"/proc/meminfo"
;
...
@@ -43,6 +45,9 @@ public class MemoryInfo {
...
@@ -43,6 +45,9 @@ public class MemoryInfo {
/**
/**
* get free memory
* get free memory
*
* @return free memory of device
*
*/
*/
public
long
getFreeMemorySize
(
Context
context
)
{
public
long
getFreeMemorySize
(
Context
context
)
{
ActivityManager
.
MemoryInfo
outInfo
=
new
ActivityManager
.
MemoryInfo
();
ActivityManager
.
MemoryInfo
outInfo
=
new
ActivityManager
.
MemoryInfo
();
...
@@ -54,30 +59,31 @@ public class MemoryInfo {
...
@@ -54,30 +59,31 @@ public class MemoryInfo {
}
}
/**
/**
* get the memory of process with certain pid
获取指定pid的进程,当前占用的内存,返回值为KB
* get the memory of process with certain pid
*
*
* @param pid
* @param pid
*
进程pid
*
pid of process
* @param context
* @param context
*
activity上下文
*
context of certain activity
* @return
* @return
memory usage of certain process
*/
*/
public
int
getPidMemorySize
(
int
pid
,
Context
context
)
{
public
int
getPidMemorySize
(
int
pid
,
Context
context
)
{
ActivityManager
am
=
(
ActivityManager
)
context
ActivityManager
am
=
(
ActivityManager
)
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
int
[]
myMempid
=
new
int
[]
{
pid
};
int
[]
myMempid
=
new
int
[]
{
pid
};
// 此MemoryInfo位于android.os.Debug.MemoryInfo包中,用来统计进程的内存信息
Debug
.
MemoryInfo
[]
memoryInfo
=
am
.
getProcessMemoryInfo
(
myMempid
);
Debug
.
MemoryInfo
[]
memoryInfo
=
am
.
getProcessMemoryInfo
(
myMempid
);
memoryInfo
[
0
].
getTotalSharedDirty
();
memoryInfo
[
0
].
getTotalSharedDirty
();
// int memSize = memoryInfo[0].dalvikPrivateDirty;
// int memSize = memoryInfo[0].dalvikPrivateDirty;
// TODO 不一定是PSS,可能是其他的
// TODO 不一定是PSS,可能是其他的
int
memSize
=
memoryInfo
[
0
].
getTotalPss
();
int
memSize
=
memoryInfo
[
0
].
getTotalPss
();
//
int memSize = memoryInfo[0].getTotalPrivateDirty();
//
int memSize = memoryInfo[0].getTotalPrivateDirty();
return
memSize
;
return
memSize
;
}
}
/**
/**
* get the sdk version of phone
* get the sdk version of phone
*
* @return sdk version
*/
*/
public
String
getSDKVersion
()
{
public
String
getSDKVersion
()
{
return
android
.
os
.
Build
.
VERSION
.
RELEASE
;
return
android
.
os
.
Build
.
VERSION
.
RELEASE
;
...
@@ -85,6 +91,8 @@ public class MemoryInfo {
...
@@ -85,6 +91,8 @@ public class MemoryInfo {
/**
/**
* get phone type
* get phone type
*
* @return phone type
*/
*/
public
String
getPhoneType
()
{
public
String
getPhoneType
()
{
return
android
.
os
.
Build
.
MODEL
;
return
android
.
os
.
Build
.
MODEL
;
...
...
src/com/netease/qa/emmagee/utils/MyApplication.java
浏览文件 @
527a55b4
...
@@ -8,11 +8,6 @@ public class MyApplication extends Application {
...
@@ -8,11 +8,6 @@ public class MyApplication extends Application {
private
static
final
String
LOG_TAG
=
"Emmagee-"
private
static
final
String
LOG_TAG
=
"Emmagee-"
+
MyApplication
.
class
.
getSimpleName
();
+
MyApplication
.
class
.
getSimpleName
();
/**
* 创建全局变量 全局变量一般都比较倾向于创建一个单独的数据类文件,并使用static静态变量
* 这里使用了在Application中添加数据的方法实现全局变量
* 注意在AndroidManifest.xml中的Application节点添加android:name=".MyApplication"属性
*/
private
WindowManager
.
LayoutParams
wmParams
=
new
WindowManager
.
LayoutParams
();
private
WindowManager
.
LayoutParams
wmParams
=
new
WindowManager
.
LayoutParams
();
public
WindowManager
.
LayoutParams
getMywmParams
()
{
public
WindowManager
.
LayoutParams
getMywmParams
()
{
...
...
src/com/netease/qa/emmagee/utils/ProcessInfo.java
浏览文件 @
527a55b4
...
@@ -10,6 +10,7 @@ import android.app.ActivityManager.RunningAppProcessInfo;
...
@@ -10,6 +10,7 @@ import android.app.ActivityManager.RunningAppProcessInfo;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
import
android.util.Log
;
public
class
ProcessInfo
{
public
class
ProcessInfo
{
...
@@ -17,13 +18,15 @@ public class ProcessInfo {
...
@@ -17,13 +18,15 @@ public class ProcessInfo {
+
ProcessInfo
.
class
.
getSimpleName
();
+
ProcessInfo
.
class
.
getSimpleName
();
private
final
String
PACKAGE_NAME
=
"com.netease.qa.emmagee"
;
private
final
String
PACKAGE_NAME
=
"com.netease.qa.emmagee"
;
/**
/**
* get information of all running processes
* get information of all running processes
*
*
* @param context
* @param context
context of activity
* @return
* @return
running process lists
*/
*/
public
List
<
Programe
>
getRunningProcess
(
Context
context
)
{
public
List
<
Programe
>
getRunningProcess
(
Context
context
)
{
Log
.
i
(
LOG_TAG
,
"get running processes"
);
ActivityManager
am
=
(
ActivityManager
)
context
ActivityManager
am
=
(
ActivityManager
)
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
...
@@ -61,10 +64,10 @@ public class ProcessInfo {
...
@@ -61,10 +64,10 @@ public class ProcessInfo {
}
}
/**
/**
* get information of all apps
* get information of all app
lication
s
*
*
* @param context
* @param context
context of activity
* @return
* @return
packages information of all applications
*/
*/
private
List
<
ApplicationInfo
>
getPackagesInfo
(
Context
context
)
{
private
List
<
ApplicationInfo
>
getPackagesInfo
(
Context
context
)
{
PackageManager
pm
=
context
.
getApplicationContext
().
getPackageManager
();
PackageManager
pm
=
context
.
getApplicationContext
().
getPackageManager
();
...
...
src/com/netease/qa/emmagee/utils/TrafficInfo.java
浏览文件 @
527a55b4
...
@@ -17,7 +17,13 @@ public class TrafficInfo {
...
@@ -17,7 +17,13 @@ public class TrafficInfo {
this
.
uid
=
uid
;
this
.
uid
=
uid
;
}
}
/**
* get traffic information include received and send traffic
*
* @return total traffic include received and send traffic
*/
public
long
getTrafficInfo
()
{
public
long
getTrafficInfo
()
{
Log
.
i
(
LOG_TAG
,
"get traffic information"
);
String
rcvPath
=
"/proc/uid_stat/"
+
uid
+
"/tcp_rcv"
;
String
rcvPath
=
"/proc/uid_stat/"
+
uid
+
"/tcp_rcv"
;
String
sndPath
=
"/proc/uid_stat/"
+
uid
+
"/tcp_snd"
;
String
sndPath
=
"/proc/uid_stat/"
+
uid
+
"/tcp_snd"
;
long
rcvTraffic
=
-
1
;
long
rcvTraffic
=
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录