Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_47647075
emmagee
提交
81834cf3
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 搜索 >>
提交
81834cf3
编写于
2月 04, 2013
作者:
A
andrewleo2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine javadoc and add apache license
上级
95aa373d
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
211 addition
and
46 deletion
+211
-46
LICENSE
LICENSE
+13
-0
src/com/netease/qa/emmagee/activity/MainPageActivity.java
src/com/netease/qa/emmagee/activity/MainPageActivity.java
+21
-4
src/com/netease/qa/emmagee/activity/SettingsActivity.java
src/com/netease/qa/emmagee/activity/SettingsActivity.java
+16
-0
src/com/netease/qa/emmagee/service/EmmageeService.java
src/com/netease/qa/emmagee/service/EmmageeService.java
+47
-29
src/com/netease/qa/emmagee/utils/CpuInfo.java
src/com/netease/qa/emmagee/utils/CpuInfo.java
+24
-6
src/com/netease/qa/emmagee/utils/MemoryInfo.java
src/com/netease/qa/emmagee/utils/MemoryInfo.java
+16
-0
src/com/netease/qa/emmagee/utils/MyApplication.java
src/com/netease/qa/emmagee/utils/MyApplication.java
+16
-0
src/com/netease/qa/emmagee/utils/ProcessInfo.java
src/com/netease/qa/emmagee/utils/ProcessInfo.java
+25
-6
src/com/netease/qa/emmagee/utils/Programe.java
src/com/netease/qa/emmagee/utils/Programe.java
+16
-0
src/com/netease/qa/emmagee/utils/TrafficInfo.java
src/com/netease/qa/emmagee/utils/TrafficInfo.java
+17
-1
未找到文件。
LICENSE
0 → 100644
浏览文件 @
81834cf3
Copyright (c) 2012-2013 NetEase, Inc. and other contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
src/com/netease/qa/emmagee/activity/MainPageActivity.java
浏览文件 @
81834cf3
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
com.netease.qa.emmagee.activity
;
import
java.io.BufferedWriter
;
...
...
@@ -77,6 +93,7 @@ public class MainPageActivity extends Activity {
if
(
isRadioChecked
==
true
)
{
Intent
intent
=
getPackageManager
()
.
getLaunchIntentForPackage
(
packageName
);
Log
.
d
(
LOG_TAG
,
packageName
);
startActivity
(
intent
);
waitForAppStart
(
packageName
);
MonitorService
.
putExtra
(
"processName"
,
processName
);
...
...
@@ -125,10 +142,10 @@ public class MainPageActivity extends Activity {
}
/**
* wait for test app
start
, timeout is 20s
* wait for test app
lication started
, timeout is 20s
*
* @param packageName
*
the package name of test app
*
package name of test application
*/
private
void
waitForAppStart
(
String
packageName
)
{
Log
.
d
(
LOG_TAG
,
"wait for app start"
);
...
...
@@ -154,7 +171,7 @@ public class MainPageActivity extends Activity {
}
/**
* override return key to
implement a dialog appeared
* override return key to
show a dialog
*/
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
&&
event
.
getRepeatCount
()
==
0
)
{
...
...
@@ -221,7 +238,7 @@ public class MainPageActivity extends Activity {
}
/**
* custom adapter
* custom
izing
adapter
*
*/
private
class
ListAdapter
extends
BaseAdapter
{
...
...
src/com/netease/qa/emmagee/activity/SettingsActivity.java
浏览文件 @
81834cf3
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
com.netease.qa.emmagee.activity
;
import
java.io.BufferedWriter
;
...
...
src/com/netease/qa/emmagee/service/EmmageeService.java
浏览文件 @
81834cf3
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
com.netease.qa.emmagee.service
;
import
java.io.BufferedWriter
;
...
...
@@ -39,7 +55,7 @@ import com.netease.qa.emmagee.utils.MyApplication;
import
com.netease.qa.emmagee.R
;
public
class
EmmageeService
extends
Service
{
private
final
static
String
LOG_TAG
=
"Emmagee-"
+
EmmageeService
.
class
.
getSimpleName
();
...
...
@@ -64,9 +80,9 @@ public class EmmageeService extends Service {
private
Handler
handler
=
new
Handler
();
private
CpuInfo
cpuInfo
;
private
String
time
;
private
boolean
isFloating
;
private
String
processName
,
packageName
,
settingTempFile
;
private
int
pid
,
uid
;
private
boolean
isFloating
;
private
String
processName
,
packageName
,
settingTempFile
;
private
int
pid
,
uid
;
public
static
BufferedWriter
bw
;
public
static
FileOutputStream
out
;
...
...
@@ -88,14 +104,14 @@ public class EmmageeService extends Service {
Log
.
i
(
LOG_TAG
,
"onStart"
);
setForeground
(
true
);
super
.
onStart
(
intent
,
startId
);
pid
=
intent
.
getExtras
().
getInt
(
"pid"
);
uid
=
intent
.
getExtras
().
getInt
(
"uid"
);
processName
=
intent
.
getExtras
().
getString
(
"processName"
);
packageName
=
intent
.
getExtras
().
getString
(
"packageName"
);
settingTempFile
=
intent
.
getExtras
().
getString
(
"settingTempFile"
);
cpuInfo
=
new
CpuInfo
(
getBaseContext
(),
pid
,
Integer
.
toString
(
uid
));
cpuInfo
=
new
CpuInfo
(
getBaseContext
(),
pid
,
Integer
.
toString
(
uid
));
readSettingInfo
(
intent
);
delaytime
=
Integer
.
parseInt
(
time
)
*
1000
;
if
(
isFloating
)
{
...
...
@@ -127,15 +143,16 @@ public class EmmageeService extends Service {
}
/**
* read config file
* read config
uration
file
*
* @throws IOException
*/
private
void
readSettingInfo
(
Intent
intent
)
{
try
{
RandomAccessFile
raf
=
new
RandomAccessFile
(
new
File
(
settingTempFile
),
"r"
);
RandomAccessFile
raf
=
new
RandomAccessFile
(
new
File
(
settingTempFile
),
"r"
);
time
=
raf
.
readLine
();
isFloating
=
raf
.
readLine
().
equals
(
"true"
)
?
true
:
false
;
isFloating
=
raf
.
readLine
().
equals
(
"true"
)
?
true
:
false
;
}
catch
(
IOException
e
)
{
time
=
"5"
;
isFloating
=
true
;
...
...
@@ -158,8 +175,9 @@ public class EmmageeService extends Service {
+
File
.
separator
+
"Emmagee_TestResult_"
+
mDateTime
+
".csv"
;
}
else
{
resultFilePath
=
getBaseContext
().
getFilesDir
().
getPath
()
+
File
.
separator
+
"Emmagee_TestResult_"
+
mDateTime
+
".csv"
;
resultFilePath
=
getBaseContext
().
getFilesDir
().
getPath
()
+
File
.
separator
+
"Emmagee_TestResult_"
+
mDateTime
+
".csv"
;
}
try
{
File
resultFile
=
new
File
(
resultFilePath
);
...
...
@@ -169,14 +187,12 @@ public class EmmageeService extends Service {
bw
=
new
BufferedWriter
(
osw
);
long
totalMemorySize
=
memoryInfo
.
getTotalMemory
();
String
totalMemory
=
fomart
.
format
((
double
)
totalMemorySize
/
1024
);
bw
.
write
(
"指定应用的CPU内存监控情况\r\n"
+
"应用包名:,"
+
packageName
+
"\r\n"
+
"应用名称: ,"
+
processName
+
"\r\n"
+
"应用PID: ,"
+
pid
+
"\r\n"
+
"机器内存大小(MB):,"
+
totalMemory
+
"MB\r\n"
+
"机器CPU型号:,"
+
cpuInfo
.
getCpuName
()
+
"\r\n"
+
"机器android系统版本:,"
+
memoryInfo
.
getSDKVersion
()
+
"\r\n"
+
"手机型号:,"
+
memoryInfo
.
getPhoneType
()
+
"\r\n"
+
"UID:,"
bw
.
write
(
"指定应用的CPU内存监控情况\r\n"
+
"应用包名:,"
+
packageName
+
"\r\n"
+
"应用名称: ,"
+
processName
+
"\r\n"
+
"应用PID: ,"
+
pid
+
"\r\n"
+
"机器内存大小(MB):,"
+
totalMemory
+
"MB\r\n"
+
"机器CPU型号:,"
+
cpuInfo
.
getCpuName
()
+
"\r\n"
+
"机器android系统版本:,"
+
memoryInfo
.
getSDKVersion
()
+
"\r\n"
+
"手机型号:,"
+
memoryInfo
.
getPhoneType
()
+
"\r\n"
+
"UID:,"
+
uid
+
"\r\n"
);
bw
.
write
(
"时间"
+
","
+
"应用占用内存PSS(MB)"
+
","
+
"应用占用内存比(%)"
+
","
+
" 机器剩余内存(MB)"
+
","
+
"应用占用CPU率(%)"
+
","
+
"CPU总使用率(%)"
...
...
@@ -195,11 +211,12 @@ public class EmmageeService extends Service {
SharedPreferences
.
Editor
editor
=
shared
.
edit
();
editor
.
putInt
(
"float"
,
1
);
editor
.
commit
();
windowManager
=
(
WindowManager
)
getApplicationContext
().
getSystemService
(
"window"
);
windowManager
=
(
WindowManager
)
getApplicationContext
()
.
getSystemService
(
"window"
);
wmParams
=
((
MyApplication
)
getApplication
()).
getMywmParams
();
wmParams
.
type
=
2002
;
wmParams
.
flags
|=
8
;
wmParams
.
gravity
=
Gravity
.
LEFT
|
Gravity
.
TOP
;
wmParams
.
gravity
=
Gravity
.
LEFT
|
Gravity
.
TOP
;
wmParams
.
x
=
0
;
wmParams
.
y
=
0
;
wmParams
.
width
=
WindowManager
.
LayoutParams
.
WRAP_CONTENT
;
...
...
@@ -209,7 +226,7 @@ public class EmmageeService extends Service {
viFloatingWindow
.
setOnTouchListener
(
new
OnTouchListener
()
{
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
x
=
event
.
getRawX
();
y
=
event
.
getRawY
()
-
25
;
y
=
event
.
getRawY
()
-
25
;
switch
(
event
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
// state = MotionEvent.ACTION_DOWN;
...
...
@@ -226,7 +243,7 @@ public class EmmageeService extends Service {
break
;
case
MotionEvent
.
ACTION_UP
:
//state = MotionEvent.ACTION_UP;
//
state = MotionEvent.ACTION_UP;
updateViewPosition
();
showImg
();
mTouchStartX
=
mTouchStartY
=
0
;
...
...
@@ -242,7 +259,8 @@ public class EmmageeService extends Service {
try
{
btnWifi
=
(
Button
)
viFloatingWindow
.
findViewById
(
R
.
id
.
wifi
);
String
buttonText
=
(
String
)
btnWifi
.
getText
();
String
wifiText
=
getResources
().
getString
(
R
.
string
.
openwifi
);
String
wifiText
=
getResources
().
getString
(
R
.
string
.
openwifi
);
if
(
buttonText
.
equals
(
wifiText
))
{
wifiManager
.
setWifiEnabled
(
true
);
btnWifi
.
setText
(
R
.
string
.
closewifi
);
...
...
@@ -281,14 +299,14 @@ public class EmmageeService extends Service {
};
/**
* refresh the data
displayed
in floating window
* refresh the data
showing
in floating window
*
* @throws FileNotFoundException
*
* @throws IOException
*/
private
void
dataRefresh
()
{
int
pidMemory
=
memoryInfo
.
getPidMemorySize
(
pid
,
getBaseContext
());
int
pidMemory
=
memoryInfo
.
getPidMemorySize
(
pid
,
getBaseContext
());
long
freeMemory
=
memoryInfo
.
getFreeMemorySize
(
getBaseContext
());
String
freeMemoryKb
=
fomart
.
format
((
double
)
freeMemory
/
1024
);
String
processMemory
=
fomart
.
format
((
double
)
pidMemory
/
1024
);
...
...
@@ -314,8 +332,8 @@ public class EmmageeService extends Service {
}
}
if
(
processCpuRatio
!=
null
&&
totalCpuRatio
!=
null
)
{
txtUnusedMem
.
setText
(
"占用内存:"
+
processMemory
+
"MB"
+
",机器剩余:"
+
freeMemoryKb
+
"MB"
);
txtUnusedMem
.
setText
(
"占用内存:"
+
processMemory
+
"MB"
+
",机器剩余:"
+
freeMemoryKb
+
"MB"
);
txtTotalMem
.
setText
(
"占用CPU:"
+
processCpuRatio
+
"%"
+
",总体CPU:"
+
totalCpuRatio
+
"%"
);
if
(
trafficSize
.
equals
(
"-1"
))
{
...
...
src/com/netease/qa/emmagee/utils/CpuInfo.java
浏览文件 @
81834cf3
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
com.netease.qa.emmagee.utils
;
import
java.io.FileNotFoundException
;
...
...
@@ -49,7 +65,7 @@ public class CpuInfo {
}
/**
* read the stat
of Cpu
* read the stat
us of CPU
*
* @throws FileNotFoundException
*/
...
...
@@ -94,9 +110,9 @@ public class CpuInfo {
}
/**
* get
the name of current cpu
* get
CPU name
*
* @return
* @return
CPU name
*/
public
String
getCpuName
()
{
try
{
...
...
@@ -111,9 +127,11 @@ public class CpuInfo {
}
/**
* reserve process Cpu and total Cpu use ratio
* reserve used ratio of process CPU and total CPU, meanwhile collect
* network traffic
*
* @return
* @return network traffic ,used ratio of process CPU and total CPU in
* certain interval
*/
public
ArrayList
<
String
>
getCpuRatioInfo
()
{
...
...
@@ -178,7 +196,7 @@ public class CpuInfo {
}
//TODO coming soon
//
TODO coming soon
// public String cpuinfo() {
// String sys_info = "";
// String s;
...
...
src/com/netease/qa/emmagee/utils/MemoryInfo.java
浏览文件 @
81834cf3
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
com.netease.qa.emmagee.utils
;
import
java.io.BufferedReader
;
...
...
src/com/netease/qa/emmagee/utils/MyApplication.java
浏览文件 @
81834cf3
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
com.netease.qa.emmagee.utils
;
import
android.app.Application
;
...
...
src/com/netease/qa/emmagee/utils/ProcessInfo.java
浏览文件 @
81834cf3
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
com.netease.qa.emmagee.utils
;
import
java.util.ArrayList
;
...
...
@@ -16,14 +32,16 @@ public class ProcessInfo {
private
final
String
LOG_TAG
=
"Emmagee-"
+
ProcessInfo
.
class
.
getSimpleName
();
private
final
String
PACKAGE_NAME
=
"com.netease.qa.emmagee"
;
/**
* get information of all running processes
* get information of all running processes,including package name ,process
* name ,icon ,pid and uid
*
* @param context context of activity
* @return running process lists
* @param context
* context of activity
* @return running processes list
*/
public
List
<
Programe
>
getRunningProcess
(
Context
context
)
{
Log
.
i
(
LOG_TAG
,
"get running processes"
);
...
...
@@ -66,7 +84,8 @@ public class ProcessInfo {
/**
* get information of all applications
*
* @param context context of activity
* @param context
* context of activity
* @return packages information of all applications
*/
private
List
<
ApplicationInfo
>
getPackagesInfo
(
Context
context
)
{
...
...
src/com/netease/qa/emmagee/utils/Programe.java
浏览文件 @
81834cf3
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
com.netease.qa.emmagee.utils
;
import
android.graphics.drawable.Drawable
;
...
...
src/com/netease/qa/emmagee/utils/TrafficInfo.java
浏览文件 @
81834cf3
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
com.netease.qa.emmagee.utils
;
import
java.io.FileNotFoundException
;
...
...
@@ -18,7 +34,7 @@ public class TrafficInfo {
}
/**
* get t
raffic information include received and sen
d traffic
* get t
otal network traffic, which is the sum of upload and downloa
d traffic
*
* @return total traffic include received and send traffic
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录