Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_47647075
emmagee
提交
615ee0b7
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 搜索 >>
提交
615ee0b7
编写于
4月 01, 2013
作者:
A
andrewleo2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
solve some issues on github,refine code
上级
232debd7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
82 addition
and
20 deletion
+82
-20
src/com/netease/qa/emmagee/activity/MainPageActivity.java
src/com/netease/qa/emmagee/activity/MainPageActivity.java
+53
-11
src/com/netease/qa/emmagee/service/EmmageeService.java
src/com/netease/qa/emmagee/service/EmmageeService.java
+29
-7
src/com/netease/qa/emmagee/utils/ProcessInfo.java
src/com/netease/qa/emmagee/utils/ProcessInfo.java
+0
-2
未找到文件。
src/com/netease/qa/emmagee/activity/MainPageActivity.java
浏览文件 @
615ee0b7
...
...
@@ -26,8 +26,11 @@ import java.util.List;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.app.Dialog
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.KeyEvent
;
...
...
@@ -55,7 +58,7 @@ import com.netease.qa.emmagee.R;
/**
* Main Page of Emmagee
*
*
*/
public
class
MainPageActivity
extends
Activity
{
...
...
@@ -69,10 +72,11 @@ public class MainPageActivity extends Activity {
private
Intent
monitorService
;
private
ListView
lstViProgramme
;
private
Button
btnTest
;
private
boolean
isTesting
=
true
;
private
boolean
isRadioChecked
=
false
;
private
int
pid
,
uid
;
private
String
processName
,
packageName
,
settingTempFile
;
private
boolean
isServiceStop
=
false
;
private
UpdateReceiver
receiver
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -86,19 +90,24 @@ public class MainPageActivity extends Activity {
processInfo
=
new
ProcessInfo
();
lstViProgramme
=
(
ListView
)
findViewById
(
R
.
id
.
processList
);
btnTest
=
(
Button
)
findViewById
(
R
.
id
.
test
);
lstViProgramme
.
setAdapter
(
new
ListAdapter
());
btnTest
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
monitorService
=
new
Intent
();
monitorService
.
setClass
(
MainPageActivity
.
this
,
EmmageeService
.
class
);
if
(
isTesting
)
{
if
(
"开始测试"
.
equals
(
btnTest
.
getText
().
toString
())
)
{
if
(
isRadioChecked
)
{
Intent
intent
=
getPackageManager
()
.
getLaunchIntentForPackage
(
packageName
);
Log
.
d
(
LOG_TAG
,
packageName
);
startActivity
(
intent
);
try
{
startActivity
(
intent
);
}
catch
(
NullPointerException
e
)
{
Toast
.
makeText
(
MainPageActivity
.
this
,
"该程序无法启动"
,
Toast
.
LENGTH_LONG
).
show
();
return
;
}
waitForAppStart
(
packageName
);
monitorService
.
putExtra
(
"processName"
,
processName
);
monitorService
.
putExtra
(
"pid"
,
pid
);
...
...
@@ -108,14 +117,12 @@ public class MainPageActivity extends Activity {
settingTempFile
);
startService
(
monitorService
);
btnTest
.
setText
(
"停止测试"
);
isTesting
=
false
;
}
else
{
Toast
.
makeText
(
MainPageActivity
.
this
,
"请选择需要测试的应用程序"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
else
{
btnTest
.
setText
(
"开始测试"
);
isTesting
=
true
;
Toast
.
makeText
(
MainPageActivity
.
this
,
"测试结果文件:"
+
EmmageeService
.
resultFilePath
,
Toast
.
LENGTH_LONG
).
show
();
...
...
@@ -125,6 +132,36 @@ public class MainPageActivity extends Activity {
});
}
public
class
UpdateReceiver
extends
BroadcastReceiver
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
isServiceStop
=
intent
.
getExtras
().
getBoolean
(
"isServiceStop"
);
if
(
isServiceStop
)
{
btnTest
.
setText
(
"开始测试"
);
}
}
}
protected
void
onStart
()
{
Log
.
d
(
LOG_TAG
,
"onStart"
);
receiver
=
new
UpdateReceiver
();
IntentFilter
filter
=
new
IntentFilter
();
filter
.
addAction
(
"com.netease.action.emmageeService"
);
this
.
registerReceiver
(
receiver
,
filter
);
super
.
onStart
();
}
@Override
public
void
onResume
()
{
super
.
onResume
();
Log
.
d
(
LOG_TAG
,
"onResume"
);
if
(
EmmageeService
.
isStop
)
{
btnTest
.
setText
(
"开始测试"
);
}
lstViProgramme
.
setAdapter
(
new
ListAdapter
());
}
/**
* create new file to reserve setting data.
*/
...
...
@@ -192,7 +229,7 @@ public class MainPageActivity extends Activity {
/**
* set menu options,including cancel and setting options.
*
*
* @return true
*/
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
...
...
@@ -205,7 +242,7 @@ public class MainPageActivity extends Activity {
/**
* trigger menu options.
*
*
* @return false
*/
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
...
...
@@ -227,7 +264,7 @@ public class MainPageActivity extends Activity {
/**
* create a dialog.
*
*
* @return a dialog
*/
protected
Dialog
onCreateDialog
(
int
id
)
{
...
...
@@ -258,7 +295,7 @@ public class MainPageActivity extends Activity {
/**
* customizing adapter.
*
*
*/
private
class
ListAdapter
extends
BaseAdapter
{
List
<
Programe
>
programe
;
...
...
@@ -343,6 +380,11 @@ public class MainPageActivity extends Activity {
super
.
finish
();
}
protected
void
onStop
()
{
unregisterReceiver
(
receiver
);
super
.
onStop
();
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
...
...
src/com/netease/qa/emmagee/service/EmmageeService.java
浏览文件 @
615ee0b7
...
...
@@ -49,6 +49,7 @@ import android.widget.ImageView;
import
android.widget.TextView
;
import
android.widget.Toast
;
//import com.netease.qa.emmagee.activity.MainPageActivity;
import
com.netease.qa.emmagee.utils.CpuInfo
;
import
com.netease.qa.emmagee.utils.MemoryInfo
;
import
com.netease.qa.emmagee.utils.MyApplication
;
...
...
@@ -87,16 +88,20 @@ public class EmmageeService extends Service {
private
boolean
isFloating
;
private
String
processName
,
packageName
,
settingTempFile
;
private
int
pid
,
uid
;
private
boolean
isServiceStop
=
false
;
public
static
BufferedWriter
bw
;
public
static
FileOutputStream
out
;
public
static
OutputStreamWriter
osw
;
public
static
String
resultFilePath
;
public
static
boolean
isStop
=
false
;
@Override
public
void
onCreate
()
{
Log
.
i
(
LOG_TAG
,
"onCreate"
);
super
.
onCreate
();
isServiceStop
=
false
;
isStop
=
false
;
memoryInfo
=
new
MemoryInfo
();
fomart
=
new
DecimalFormat
();
fomart
.
setMaximumFractionDigits
(
2
);
...
...
@@ -143,7 +148,7 @@ public class EmmageeService extends Service {
createFloatingWindow
();
}
createResultCsv
();
handler
.
postDelayed
(
task
,
delaytime
);
handler
.
postDelayed
(
task
,
1000
);
}
/**
...
...
@@ -300,11 +305,20 @@ public class EmmageeService extends Service {
}
private
Runnable
task
=
new
Runnable
()
{
public
void
run
()
{
dataRefresh
();
handler
.
postDelayed
(
this
,
delaytime
);
if
(
isFloating
)
windowManager
.
updateViewLayout
(
viFloatingWindow
,
wmParams
);
if
(!
isServiceStop
)
{
dataRefresh
();
handler
.
postDelayed
(
this
,
delaytime
);
if
(
isFloating
)
windowManager
.
updateViewLayout
(
viFloatingWindow
,
wmParams
);
}
else
{
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"isServiceStop"
,
true
);
intent
.
setAction
(
"com.netease.action.emmageeService"
);
// action与接收器相同
sendBroadcast
(
intent
);
stopSelf
();
}
}
};
...
...
@@ -340,6 +354,11 @@ public class EmmageeService extends Service {
}
}
}
if
(
"0"
.
equals
(
processMemory
)
&&
"0.00"
.
equals
(
processCpuRatio
))
{
closeOpenedStream
();
isServiceStop
=
true
;
return
;
}
if
(
processCpuRatio
!=
null
&&
totalCpuRatio
!=
null
)
{
txtUnusedMem
.
setText
(
"占用内存:"
+
processMemory
+
"MB"
+
",机器剩余:"
+
freeMemoryKb
+
"MB"
);
...
...
@@ -384,15 +403,18 @@ public class EmmageeService extends Service {
@Override
public
void
onDestroy
()
{
Log
.
i
(
LOG_TAG
,
"onDestroy"
);
super
.
onDestroy
();
if
(
windowManager
!=
null
)
windowManager
.
removeView
(
viFloatingWindow
);
handler
.
removeCallbacks
(
task
);
closeOpenedStream
();
isStop
=
true
;
Toast
.
makeText
(
this
,
"测试结果文件:"
+
EmmageeService
.
resultFilePath
,
Toast
.
LENGTH_LONG
).
show
();
super
.
onDestroy
();
}
@Override
public
IBinder
onBind
(
Intent
intent
)
{
return
null
;
}
}
}
\ No newline at end of file
src/com/netease/qa/emmagee/utils/ProcessInfo.java
浏览文件 @
615ee0b7
...
...
@@ -19,8 +19,6 @@ package com.netease.qa.emmagee.utils;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.netease.qa.emmagee.activity.MainPageActivity
;
import
android.app.ActivityManager
;
import
android.app.ActivityManager.RunningAppProcessInfo
;
import
android.content.Context
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录