Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_47647075
emmagee
提交
8e6089f1
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 搜索 >>
提交
8e6089f1
编写于
10月 16, 2014
作者:
A
andrewleo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Misc: code review
上级
5abd03d7
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
165 addition
and
184 deletion
+165
-184
src/com/netease/qa/emmagee/activity/AboutActivity.java
src/com/netease/qa/emmagee/activity/AboutActivity.java
+0
-3
src/com/netease/qa/emmagee/activity/MailSettingsActivity.java
...com/netease/qa/emmagee/activity/MailSettingsActivity.java
+33
-31
src/com/netease/qa/emmagee/activity/MainPageActivity.java
src/com/netease/qa/emmagee/activity/MainPageActivity.java
+43
-50
src/com/netease/qa/emmagee/activity/SettingsActivity.java
src/com/netease/qa/emmagee/activity/SettingsActivity.java
+0
-3
src/com/netease/qa/emmagee/service/EmmageeService.java
src/com/netease/qa/emmagee/service/EmmageeService.java
+33
-35
src/com/netease/qa/emmagee/utils/CpuInfo.java
src/com/netease/qa/emmagee/utils/CpuInfo.java
+14
-12
src/com/netease/qa/emmagee/utils/CurrentInfo.java
src/com/netease/qa/emmagee/utils/CurrentInfo.java
+10
-5
src/com/netease/qa/emmagee/utils/MailSender.java
src/com/netease/qa/emmagee/utils/MailSender.java
+14
-19
src/com/netease/qa/emmagee/utils/MemoryInfo.java
src/com/netease/qa/emmagee/utils/MemoryInfo.java
+0
-4
src/com/netease/qa/emmagee/utils/ProcessInfo.java
src/com/netease/qa/emmagee/utils/ProcessInfo.java
+0
-11
src/com/netease/qa/emmagee/utils/Settings.java
src/com/netease/qa/emmagee/utils/Settings.java
+18
-11
未找到文件。
src/com/netease/qa/emmagee/activity/AboutActivity.java
浏览文件 @
8e6089f1
...
...
@@ -17,7 +17,6 @@
package
com.netease.qa.emmagee.activity
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
...
...
@@ -42,7 +41,6 @@ public class AboutActivity extends Activity {
+
AboutActivity
.
class
.
getSimpleName
();
private
TextView
appVersion
;
private
ImageView
goBack
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -60,7 +58,6 @@ public class AboutActivity extends Activity {
ImageView
btnSave
=
(
ImageView
)
findViewById
(
R
.
id
.
btn_set
);
btnSave
.
setVisibility
(
ImageView
.
INVISIBLE
);
goBack
=
(
ImageView
)
findViewById
(
R
.
id
.
go_back
);
LinearLayout
layGoBack
=
(
LinearLayout
)
findViewById
(
R
.
id
.
lay_go_back
);
layGoBack
.
setOnClickListener
(
new
OnClickListener
()
{
...
...
src/com/netease/qa/emmagee/activity/MailSettingsActivity.java
浏览文件 @
8e6089f1
...
...
@@ -30,7 +30,6 @@ import android.view.View;
import
android.view.Window
;
import
android.view.View.OnClickListener
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
...
...
@@ -46,8 +45,8 @@ import com.netease.qa.emmagee.utils.Settings;
*/
public
class
MailSettingsActivity
extends
Activity
{
private
static
final
String
LOG_TAG
=
"Emmagee-"
+
MailSettingsActivity
.
class
.
getSimpleName
()
;
private
static
final
String
LOG_TAG
=
"Emmagee-"
+
MailSettingsActivity
.
class
.
getSimpleName
();
private
static
final
String
BLANK_STRING
=
""
;
private
EditText
edtRecipients
;
private
EditText
edtSender
;
...
...
@@ -72,17 +71,17 @@ public class MailSettingsActivity extends Activity {
edtPassword
=
(
EditText
)
findViewById
(
R
.
id
.
password
);
edtRecipients
=
(
EditText
)
findViewById
(
R
.
id
.
recipients
);
edtSmtp
=
(
EditText
)
findViewById
(
R
.
id
.
smtp
);
title
=
(
TextView
)
findViewById
(
R
.
id
.
nb_title
);
title
=
(
TextView
)
findViewById
(
R
.
id
.
nb_title
);
LinearLayout
layGoBack
=
(
LinearLayout
)
findViewById
(
R
.
id
.
lay_go_back
);
LinearLayout
layBtnSet
=
(
LinearLayout
)
findViewById
(
R
.
id
.
lay_btn_set
);
title
.
setText
(
R
.
string
.
mail_settings
);
SharedPreferences
preferences
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
sender
=
preferences
.
getString
(
Settings
.
KEY_SENDER
,
""
);
prePassword
=
preferences
.
getString
(
Settings
.
KEY_PASSWORD
,
""
);
recipients
=
preferences
.
getString
(
Settings
.
KEY_RECIPIENTS
,
""
);
smtp
=
preferences
.
getString
(
Settings
.
KEY_SMTP
,
""
);
sender
=
preferences
.
getString
(
Settings
.
KEY_SENDER
,
BLANK_STRING
);
prePassword
=
preferences
.
getString
(
Settings
.
KEY_PASSWORD
,
BLANK_STRING
);
recipients
=
preferences
.
getString
(
Settings
.
KEY_RECIPIENTS
,
BLANK_STRING
);
smtp
=
preferences
.
getString
(
Settings
.
KEY_SMTP
,
BLANK_STRING
);
edtRecipients
.
setText
(
recipients
);
edtSender
.
setText
(
sender
);
...
...
@@ -97,9 +96,9 @@ public class MailSettingsActivity extends Activity {
});
layBtnSet
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
sender
=
edtSender
.
getText
().
toString
().
trim
();
if
(!
""
.
equals
(
sender
)
&&
!
checkMailFormat
(
sender
))
{
if
(!
BLANK_STRING
.
equals
(
sender
)
&&
!
checkMailFormat
(
sender
))
{
Toast
.
makeText
(
MailSettingsActivity
.
this
,
getString
(
R
.
string
.
sender_mail_toast
)
+
getString
(
R
.
string
.
format_incorrect_format
),
Toast
.
LENGTH_LONG
).
show
();
return
;
...
...
@@ -107,8 +106,7 @@ public class MailSettingsActivity extends Activity {
recipients
=
edtRecipients
.
getText
().
toString
().
trim
();
receivers
=
recipients
.
split
(
"\\s+"
);
for
(
int
i
=
0
;
i
<
receivers
.
length
;
i
++)
{
if
(!
""
.
equals
(
receivers
[
i
])
&&
!
checkMailFormat
(
receivers
[
i
]))
{
if
(!
BLANK_STRING
.
equals
(
receivers
[
i
])
&&
!
checkMailFormat
(
receivers
[
i
]))
{
Toast
.
makeText
(
MailSettingsActivity
.
this
,
getString
(
R
.
string
.
receiver_mail_toast
)
+
"["
+
receivers
[
i
]
+
"]"
+
getString
(
R
.
string
.
format_incorrect_format
),
Toast
.
LENGTH_LONG
).
show
();
...
...
@@ -118,24 +116,22 @@ public class MailSettingsActivity extends Activity {
curPassword
=
edtPassword
.
getText
().
toString
().
trim
();
smtp
=
edtSmtp
.
getText
().
toString
().
trim
();
if
(
checkMailConfig
(
sender
,
recipients
,
smtp
,
curPassword
)
==
-
1
)
{
Toast
.
makeText
(
MailSettingsActivity
.
this
,
getString
(
R
.
string
.
info_incomplete_toast
),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
MailSettingsActivity
.
this
,
getString
(
R
.
string
.
info_incomplete_toast
),
Toast
.
LENGTH_LONG
).
show
();
return
;
}
SharedPreferences
preferences
=
Settings
.
getDefaultSharedPreferences
(
getApplicationContext
());
Editor
editor
=
preferences
.
edit
();
editor
.
putString
(
Settings
.
KEY_SENDER
,
sender
);
try
{
editor
.
putString
(
Settings
.
KEY_PASSWORD
,
curPassword
.
equals
(
prePassword
)
?
curPassword
:
des
.
encrypt
(
curPassword
));
}
catch
(
Exception
e
)
{
editor
.
putString
(
Settings
.
KEY_PASSWORD
,
curPassword
);
}
editor
.
putString
(
Settings
.
KEY_PASSWORD
,
curPassword
.
equals
(
prePassword
)
?
curPassword
:
des
.
encrypt
(
curPassword
));
}
catch
(
Exception
e
)
{
editor
.
putString
(
Settings
.
KEY_PASSWORD
,
curPassword
);
}
editor
.
putString
(
Settings
.
KEY_RECIPIENTS
,
recipients
);
editor
.
putString
(
Settings
.
KEY_SMTP
,
smtp
);
editor
.
commit
();
Toast
.
makeText
(
MailSettingsActivity
.
this
,
getString
(
R
.
string
.
save_success_toast
),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
MailSettingsActivity
.
this
,
getString
(
R
.
string
.
save_success_toast
),
Toast
.
LENGTH_LONG
).
show
();
Intent
intent
=
new
Intent
();
setResult
(
Activity
.
RESULT_FIRST_USER
,
intent
);
MailSettingsActivity
.
this
.
finish
();
...
...
@@ -153,13 +149,20 @@ public class MailSettingsActivity extends Activity {
super
.
onDestroy
();
}
private
int
checkMailConfig
(
String
sender
,
String
recipients
,
String
smtp
,
String
curPassword
)
{
if
(!
""
.
equals
(
curPassword
)
&&
!
""
.
equals
(
sender
)
&&
!
""
.
equals
(
recipients
)
&&
!
""
.
equals
(
smtp
))
{
/**
* check if mail configurations are available
*
* @param sender
* @param recipients
* @param smtp
* @param curPassword
* @return true: valid configurations
*
*/
private
int
checkMailConfig
(
String
sender
,
String
recipients
,
String
smtp
,
String
curPassword
)
{
if
(!
BLANK_STRING
.
equals
(
curPassword
)
&&
!
BLANK_STRING
.
equals
(
sender
)
&&
!
BLANK_STRING
.
equals
(
recipients
)
&&
!
BLANK_STRING
.
equals
(
smtp
))
{
return
1
;
}
else
if
(
""
.
equals
(
curPassword
)
&&
""
.
equals
(
sender
)
&&
""
.
equals
(
recipients
)
&&
""
.
equals
(
smtp
))
{
}
else
if
(
BLANK_STRING
.
equals
(
curPassword
)
&&
BLANK_STRING
.
equals
(
sender
)
&&
BLANK_STRING
.
equals
(
recipients
)
&&
BLANK_STRING
.
equals
(
smtp
))
{
return
0
;
}
else
return
-
1
;
...
...
@@ -171,8 +174,7 @@ public class MailSettingsActivity extends Activity {
* @return true: valid email address
*/
private
boolean
checkMailFormat
(
String
mail
)
{
String
strPattern
=
"^[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*"
+
"[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$"
;
String
strPattern
=
"^[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*"
+
"[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$"
;
Pattern
p
=
Pattern
.
compile
(
strPattern
);
Matcher
m
=
p
.
matcher
(
mail
);
return
m
.
matches
();
...
...
src/com/netease/qa/emmagee/activity/MainPageActivity.java
浏览文件 @
8e6089f1
...
...
@@ -16,11 +16,8 @@
*/
package
com.netease.qa.emmagee.activity
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Properties
;
import
android.app.Activity
;
import
android.content.BroadcastReceiver
;
...
...
@@ -82,10 +79,10 @@ public class MainPageActivity extends Activity {
monitorService
=
new
Intent
();
monitorService
.
setClass
(
MainPageActivity
.
this
,
EmmageeService
.
class
);
if
(
getString
(
R
.
string
.
start_test
).
equals
(
btnTest
.
getText
().
toString
()))
{
ListAdapter
adapter
=
(
ListAdapter
)
lstViProgramme
.
getAdapter
();
ListAdapter
adapter
=
(
ListAdapter
)
lstViProgramme
.
getAdapter
();
if
(
adapter
.
checkedProg
!=
null
)
{
String
packageName
=
adapter
.
checkedProg
.
getPackageName
();
String
processName
=
adapter
.
checkedProg
.
getProcessName
();
String
packageName
=
adapter
.
checkedProg
.
getPackageName
();
String
processName
=
adapter
.
checkedProg
.
getProcessName
();
Intent
intent
=
getPackageManager
().
getLaunchIntentForPackage
(
packageName
);
String
startActivity
=
""
;
Log
.
d
(
LOG_TAG
,
packageName
);
...
...
@@ -141,9 +138,9 @@ public class MainPageActivity extends Activity {
}
});
receiver
=
new
UpdateReceiver
();
IntentFilter
filter
=
new
IntentFilter
();
filter
.
addAction
(
"com.netease.action.emmageeService"
);
registerReceiver
(
receiver
,
filter
);
IntentFilter
filter
=
new
IntentFilter
();
filter
.
addAction
(
EmmageeService
.
SERVICE_ACTION
);
registerReceiver
(
receiver
,
filter
);
}
private
void
initTitleLayout
()
{
...
...
@@ -186,7 +183,6 @@ public class MainPageActivity extends Activity {
}
}
/**
* wait for test application started.
*
...
...
@@ -279,56 +275,53 @@ public class MainPageActivity extends Activity {
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
Programe
pr
=
(
Programe
)
programes
.
get
(
position
);
if
(
convertView
==
null
)
convertView
=
getLayoutInflater
().
inflate
(
R
.
layout
.
list_item
,
parent
,
false
);
if
(
convertView
==
null
)
convertView
=
getLayoutInflater
().
inflate
(
R
.
layout
.
list_item
,
parent
,
false
);
Viewholder
holder
=
(
Viewholder
)
convertView
.
getTag
();
if
(
holder
==
null
)
{
holder
=
new
Viewholder
();
convertView
.
setTag
(
holder
);
holder
.
imgViAppIcon
=
(
ImageView
)
convertView
.
findViewById
(
R
.
id
.
image
);
holder
.
txtAppName
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
text
);
holder
.
rdoBtnApp
=
(
RadioButton
)
convertView
.
findViewById
(
R
.
id
.
rb
);
holder
.
rdoBtnApp
.
setFocusable
(
false
);
holder
.
rdoBtnApp
.
setOnCheckedChangeListener
(
checkedChangeListener
);
if
(
holder
==
null
)
{
holder
=
new
Viewholder
();
convertView
.
setTag
(
holder
);
holder
.
imgViAppIcon
=
(
ImageView
)
convertView
.
findViewById
(
R
.
id
.
image
);
holder
.
txtAppName
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
text
);
holder
.
rdoBtnApp
=
(
RadioButton
)
convertView
.
findViewById
(
R
.
id
.
rb
);
holder
.
rdoBtnApp
.
setFocusable
(
false
);
holder
.
rdoBtnApp
.
setOnCheckedChangeListener
(
checkedChangeListener
);
}
holder
.
imgViAppIcon
.
setImageDrawable
(
pr
.
getIcon
());
holder
.
txtAppName
.
setText
(
pr
.
getProcessName
());
holder
.
rdoBtnApp
.
setId
(
position
);
holder
.
rdoBtnApp
.
setChecked
(
checkedProg
!=
null
&&
getItem
(
position
)
==
checkedProg
);
holder
.
rdoBtnApp
.
setChecked
(
checkedProg
!=
null
&&
getItem
(
position
)
==
checkedProg
);
return
convertView
;
}
OnCheckedChangeListener
checkedChangeListener
=
new
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
buttonView
,
boolean
isChecked
)
{
if
(
isChecked
)
{
final
int
checkedPosition
=
buttonView
.
getId
();
if
(
lastCheckedPosition
!=
-
1
)
{
RadioButton
tempButton
=
(
RadioButton
)
findViewById
(
lastCheckedPosition
);
if
((
tempButton
!=
null
)
&&
(
lastCheckedPosition
!=
checkedPosition
))
{
tempButton
.
setChecked
(
false
);
}
}
checkedProg
=
programes
.
get
(
checkedPosition
);
lastCheckedPosition
=
checkedPosition
;
}
}
};
@Override
public
void
onCheckedChanged
(
CompoundButton
buttonView
,
boolean
isChecked
)
{
if
(
isChecked
)
{
final
int
checkedPosition
=
buttonView
.
getId
();
if
(
lastCheckedPosition
!=
-
1
)
{
RadioButton
tempButton
=
(
RadioButton
)
findViewById
(
lastCheckedPosition
);
if
((
tempButton
!=
null
)
&&
(
lastCheckedPosition
!=
checkedPosition
))
{
tempButton
.
setChecked
(
false
);
}
}
checkedProg
=
programes
.
get
(
checkedPosition
);
lastCheckedPosition
=
checkedPosition
;
}
}
};
}
/**
* save status of all installed processes
*
* @author andrewleo
*/
static
class
Viewholder
{
TextView
txtAppName
;
ImageView
imgViAppIcon
;
RadioButton
rdoBtnApp
;
}
* save status of all installed processes
*
* @author andrewleo
*/
static
class
Viewholder
{
TextView
txtAppName
;
ImageView
imgViAppIcon
;
RadioButton
rdoBtnApp
;
}
@Override
protected
void
onDestroy
()
{
...
...
src/com/netease/qa/emmagee/activity/SettingsActivity.java
浏览文件 @
8e6089f1
...
...
@@ -64,17 +64,14 @@ public class SettingsActivity extends Activity {
mailSettings
=
(
LinearLayout
)
findViewById
(
R
.
id
.
mail_settings
);
SeekBar
timeBar
=
(
SeekBar
)
findViewById
(
R
.
id
.
timeline
);
ImageView
btnSave
=
(
ImageView
)
findViewById
(
R
.
id
.
btn_set
);
ImageView
goBack
=
(
ImageView
)
findViewById
(
R
.
id
.
go_back
);
RelativeLayout
floatingItem
=
(
RelativeLayout
)
findViewById
(
R
.
id
.
floating_item
);
LinearLayout
layGoBack
=
(
LinearLayout
)
findViewById
(
R
.
id
.
lay_go_back
);
btnSave
.
setVisibility
(
ImageView
.
INVISIBLE
);
preferences
=
Settings
.
getDefaultSharedPreferences
(
getApplicationContext
());
int
interval
=
preferences
.
getInt
(
Settings
.
KEY_INTERVAL
,
5
);
boolean
isfloat
=
preferences
.
getBoolean
(
Settings
.
KEY_ISFLOAT
,
true
);
tvTime
.
setText
(
String
.
valueOf
(
interval
));
chkFloat
.
setChecked
(
isfloat
);
timeBar
.
setProgress
(
interval
);
...
...
src/com/netease/qa/emmagee/service/EmmageeService.java
浏览文件 @
8e6089f1
...
...
@@ -76,13 +76,13 @@ public class EmmageeService extends Service {
private
final
static
String
LOG_TAG
=
"Emmagee-"
+
EmmageeService
.
class
.
getSimpleName
();
private
static
final
String
BLANK_STRING
=
""
;
private
WindowManager
windowManager
=
null
;
private
WindowManager
.
LayoutParams
wmParams
=
null
;
private
View
viFloatingWindow
;
private
float
mTouchStartX
;
private
float
mTouchStartY
;
private
float
startX
;
private
float
startY
;
private
float
x
;
private
float
y
;
private
TextView
txtTotalMem
;
...
...
@@ -122,7 +122,7 @@ public class EmmageeService extends Service {
private
int
getStartTimeCount
=
0
;
private
boolean
isGetStartTime
=
true
;
private
String
startTime
=
""
;
p
rivate
static
final
String
SERVICE_ACTION
=
"com.netease.action.emmageeService"
;
p
ublic
static
final
String
SERVICE_ACTION
=
"com.netease.action.emmageeService"
;
@Override
public
void
onCreate
()
{
...
...
@@ -153,12 +153,9 @@ public class EmmageeService extends Service {
if
(
Intent
.
ACTION_BATTERY_CHANGED
.
equals
(
intent
.
getAction
()))
{
int
level
=
intent
.
getIntExtra
(
BatteryManager
.
EXTRA_LEVEL
,
0
);
int
scale
=
intent
.
getIntExtra
(
BatteryManager
.
EXTRA_SCALE
,
-
1
);
totalBatt
=
String
.
valueOf
(
level
*
100
/
scale
);
voltage
=
String
.
valueOf
(
intent
.
getIntExtra
(
BatteryManager
.
EXTRA_VOLTAGE
,
-
1
)
*
1.0
/
1000
);
temperature
=
String
.
valueOf
(
intent
.
getIntExtra
(
BatteryManager
.
EXTRA_TEMPERATURE
,
-
1
)
*
1.0
/
10
);
}
...
...
@@ -224,15 +221,15 @@ public class EmmageeService extends Service {
* @throws IOException
*/
private
void
readSettingInfo
()
{
SharedPreferences
preferences
=
Settings
.
getDefaultSharedPreferences
(
getApplicationContext
());
int
interval
=
preferences
.
getInt
(
Settings
.
KEY_INTERVAL
,
5
);
delaytime
=
interval
*
1000
;
isFloating
=
preferences
.
getBoolean
(
Settings
.
KEY_ISFLOAT
,
true
);
sender
=
preferences
.
getString
(
Settings
.
KEY_SENDER
,
""
);
password
=
preferences
.
getString
(
Settings
.
KEY_PASSWORD
,
""
);
recipients
=
preferences
.
getString
(
Settings
.
KEY_RECIPIENTS
,
""
);
receivers
=
recipients
.
split
(
"\\s+"
);
smtp
=
preferences
.
getString
(
Settings
.
KEY_SMTP
,
""
);
SharedPreferences
preferences
=
Settings
.
getDefaultSharedPreferences
(
getApplicationContext
());
int
interval
=
preferences
.
getInt
(
Settings
.
KEY_INTERVAL
,
5
);
delaytime
=
interval
*
1000
;
isFloating
=
preferences
.
getBoolean
(
Settings
.
KEY_ISFLOAT
,
true
);
sender
=
preferences
.
getString
(
Settings
.
KEY_SENDER
,
BLANK_STRING
);
password
=
preferences
.
getString
(
Settings
.
KEY_PASSWORD
,
BLANK_STRING
);
recipients
=
preferences
.
getString
(
Settings
.
KEY_RECIPIENTS
,
BLANK_STRING
);
receivers
=
recipients
.
split
(
"\\s+"
);
smtp
=
preferences
.
getString
(
Settings
.
KEY_SMTP
,
BLANK_STRING
);
}
/**
...
...
@@ -263,7 +260,7 @@ public class EmmageeService extends Service {
bw
=
new
BufferedWriter
(
osw
);
long
totalMemorySize
=
memoryInfo
.
getTotalMemory
();
String
totalMemory
=
fomart
.
format
((
double
)
totalMemorySize
/
1024
);
String
multiCpuTitle
=
""
;
String
multiCpuTitle
=
BLANK_STRING
;
// titles of multiple cpu cores
ArrayList
<
String
>
cpuList
=
cpuInfo
.
getCpuList
();
for
(
int
i
=
0
;
i
<
cpuList
.
size
();
i
++)
{
...
...
@@ -274,9 +271,9 @@ public class EmmageeService extends Service {
+
getString
(
R
.
string
.
cpu_type
)
+
": ,"
+
cpuInfo
.
getCpuName
()
+
"\r\n"
+
getString
(
R
.
string
.
android_system_version
)
+
": ,"
+
memoryInfo
.
getSDKVersion
()
+
"\r\n"
+
getString
(
R
.
string
.
mobile_type
)
+
": ,"
+
memoryInfo
.
getPhoneType
()
+
"\r\n"
+
"UID"
+
": ,"
+
uid
+
"\r\n"
);
if
(
isGrantedReadLogsPermission
())
{
bw
.
write
(
START_TIME
);
if
(
isGrantedReadLogsPermission
())
{
bw
.
write
(
START_TIME
);
}
bw
.
write
(
getString
(
R
.
string
.
timestamp
)
+
","
+
getString
(
R
.
string
.
used_mem_PSS
)
+
","
+
getString
(
R
.
string
.
used_mem_ratio
)
+
","
+
getString
(
R
.
string
.
mobile_free_mem
)
+
","
+
getString
(
R
.
string
.
app_used_cpu_ratio
)
+
","
...
...
@@ -313,8 +310,6 @@ public class EmmageeService extends Service {
y
=
event
.
getRawY
()
-
25
;
switch
(
event
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
startX
=
x
;
startY
=
y
;
mTouchStartX
=
event
.
getX
();
mTouchStartY
=
event
.
getY
();
break
;
...
...
@@ -387,7 +382,7 @@ public class EmmageeService extends Service {
Process
process
=
Runtime
.
getRuntime
().
exec
(
logcatCommand
);
BufferedReader
bufferedReader
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
StringBuilder
strBuilder
=
new
StringBuilder
();
String
line
=
""
;
String
line
=
BLANK_STRING
;
while
((
line
=
bufferedReader
.
readLine
())
!=
null
)
{
strBuilder
.
append
(
line
);
...
...
@@ -409,14 +404,16 @@ public class EmmageeService extends Service {
Log
.
d
(
LOG_TAG
,
e
.
getMessage
());
}
}
/**
* Above JellyBean, we cannot grant READ_LOGS permission...
*
* @return
*/
private
boolean
isGrantedReadLogsPermission
()
{
int
permissionState
=
getPackageManager
().
checkPermission
(
android
.
Manifest
.
permission
.
READ_LOGS
,
getPackageName
());
return
permissionState
==
PackageManager
.
PERMISSION_GRANTED
;
}
private
boolean
isGrantedReadLogsPermission
()
{
int
permissionState
=
getPackageManager
().
checkPermission
(
android
.
Manifest
.
permission
.
READ_LOGS
,
getPackageName
());
return
permissionState
==
PackageManager
.
PERMISSION_GRANTED
;
}
/**
* refresh the performance data showing in floating window.
...
...
@@ -451,7 +448,7 @@ public class EmmageeService extends Service {
processCpuRatio
=
processInfo
.
get
(
0
);
totalCpuRatio
=
processInfo
.
get
(
1
);
trafficSize
=
processInfo
.
get
(
2
);
if
(!(
""
.
equals
(
trafficSize
))
&&
!(
"-1"
.
equals
(
trafficSize
)))
{
if
(!(
BLANK_STRING
.
equals
(
trafficSize
))
&&
!(
"-1"
.
equals
(
trafficSize
)))
{
tempTraffic
=
Integer
.
parseInt
(
trafficSize
);
if
(
tempTraffic
>
1024
)
{
isMb
=
true
;
...
...
@@ -517,13 +514,13 @@ public class EmmageeService extends Service {
handler
.
removeCallbacks
(
task
);
closeOpenedStream
();
// replace the start time in file
if
(
isGrantedReadLogsPermission
())
{
if
(!
""
.
equals
(
startTime
))
{
replaceFileString
(
resultFilePath
,
START_TIME
,
getString
(
R
.
string
.
start_time
)
+
startTime
+
"\r\n"
);
}
else
{
replaceFileString
(
resultFilePath
,
START_TIME
,
""
);
}
}
if
(
isGrantedReadLogsPermission
())
{
if
(!
BLANK_STRING
.
equals
(
startTime
))
{
replaceFileString
(
resultFilePath
,
START_TIME
,
getString
(
R
.
string
.
start_time
)
+
startTime
+
"\r\n"
);
}
else
{
replaceFileString
(
resultFilePath
,
START_TIME
,
BLANK_STRING
);
}
}
isStop
=
true
;
unregisterReceiver
(
batteryBroadcast
);
boolean
isSendSuccessfully
=
false
;
...
...
@@ -554,7 +551,8 @@ public class EmmageeService extends Service {
try
{
File
file
=
new
File
(
filePath
);
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
file
));
String
line
=
""
,
oldtext
=
""
;
String
line
=
BLANK_STRING
;
String
oldtext
=
BLANK_STRING
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
oldtext
+=
line
+
"\r\n"
;
}
...
...
src/com/netease/qa/emmagee/utils/CpuInfo.java
浏览文件 @
8e6089f1
...
...
@@ -69,6 +69,8 @@ public class CpuInfo {
private
static
final
String
CPU_X86
=
"x86"
;
private
static
final
String
CPU_INFO_PATH
=
"/proc/cpuinfo"
;
private
static
final
String
CPU_STAT
=
"/proc/stat"
;
private
static
final
String
NA
=
"N/A"
;
private
static
final
String
COMMA
=
","
;
public
CpuInfo
(
Context
context
,
int
pid
,
String
uid
)
{
this
.
pid
=
pid
;
...
...
@@ -139,7 +141,7 @@ public class CpuInfo {
public
String
getCpuName
()
{
try
{
RandomAccessFile
cpuStat
=
new
RandomAccessFile
(
CPU_INFO_PATH
,
"r"
);
//
需要判断是intel or arm
//
check cpu type
if
(
Build
.
CPU_ABI
.
equalsIgnoreCase
(
CPU_X86
))
{
String
line
;
while
(
null
!=
(
line
=
cpuStat
.
readLine
()))
{
...
...
@@ -242,10 +244,10 @@ public class CpuInfo {
Calendar
cal
=
Calendar
.
getInstance
();
if
((
Build
.
MODEL
.
equals
(
"sdk"
))
||
(
Build
.
MODEL
.
equals
(
"google_sdk"
)))
{
mDateTime2
=
formatterFile
.
format
(
cal
.
getTime
().
getTime
()
+
8
*
60
*
60
*
1000
);
totalBatt
=
"N/A"
;
currentBatt
=
"N/A"
;
temperature
=
"N/A"
;
voltage
=
"N/A"
;
totalBatt
=
NA
;
currentBatt
=
NA
;
temperature
=
NA
;
voltage
=
NA
;
}
else
mDateTime2
=
formatterFile
.
format
(
cal
.
getTime
().
getTime
());
if
(
isInitialStatics
)
{
...
...
@@ -268,7 +270,7 @@ public class CpuInfo {
.
get
(
i
)
-
totalCpu2
.
get
(
i
))));
}
totalCpuRatio
.
add
(
cpuRatio
);
totalCpuBuffer
.
append
(
cpuRatio
+
","
);
totalCpuBuffer
.
append
(
cpuRatio
+
COMMA
);
}
}
else
{
processCpuRatio
=
"0"
;
...
...
@@ -292,16 +294,16 @@ public class CpuInfo {
}
if
(
isPositive
(
processCpuRatio
)
&&
isPositive
(
totalCpuRatio
.
get
(
0
)))
{
String
trafValue
;
// whether certain device supports traffic statics or not
if
(
traffic
==
-
1
)
{
EmmageeService
.
bw
.
write
(
mDateTime2
+
","
+
pMemory
+
","
+
percent
+
","
+
fMemory
+
","
+
processCpuRatio
+
","
+
totalCpuBuffer
.
toString
()
+
"N/A"
+
","
+
totalBatt
+
","
+
currentBatt
+
","
+
temperature
+
","
+
voltage
+
"\r\n"
);
trafValue
=
NA
;
}
else
{
EmmageeService
.
bw
.
write
(
mDateTime2
+
","
+
pMemory
+
","
+
percent
+
","
+
fMemory
+
","
+
processCpuRatio
+
","
+
totalCpuBuffer
.
toString
()
+
traffic
+
","
+
totalBatt
+
","
+
currentBatt
+
","
+
temperature
+
","
+
voltage
+
"\r\n"
);
trafValue
=
String
.
valueOf
(
traffic
);
}
EmmageeService
.
bw
.
write
(
mDateTime2
+
COMMA
+
pMemory
+
COMMA
+
percent
+
COMMA
+
fMemory
+
COMMA
+
processCpuRatio
+
COMMA
+
totalCpuBuffer
.
toString
()
+
trafValue
+
COMMA
+
totalBatt
+
COMMA
+
currentBatt
+
COMMA
+
temperature
+
COMMA
+
voltage
+
"\r\n"
);
totalCpu2
=
(
ArrayList
<
Long
>)
totalCpu
.
clone
();
processCpu2
=
processCpu
;
idleCpu2
=
(
ArrayList
<
Long
>)
idleCpu
.
clone
();
...
...
src/com/netease/qa/emmagee/utils/CurrentInfo.java
浏览文件 @
8e6089f1
...
...
@@ -26,6 +26,11 @@ public class CurrentInfo {
private
static
final
String
BATT_CURRENT_ADC
=
"/sys/class/power_supply/battery/batt_current_adc"
;
private
static
final
String
CURRENT_AVG
=
"/sys/class/power_supply/battery/current_avg"
;
/**
* read system file to get current value
*
* @return current value
*/
public
Long
getCurrentValue
()
{
File
f
=
null
;
Log
.
d
(
LOG_TAG
,
BUILD_MODEL
);
...
...
@@ -88,9 +93,9 @@ public class CurrentInfo {
}
/**
*
从smem_text文件中读取电流数据
*
get current value from smem_text
*
* @return
* @return
current value
*/
public
Long
getSMemValue
()
{
boolean
success
=
false
;
...
...
@@ -125,11 +130,11 @@ public class CurrentInfo {
}
/**
*
获取当前的电流值
*
read system file to get current value
*
* @param file
* @param convertToMillis
* @return
* @param convertToMillis
* @return
current value
*/
public
Long
getCurrentValue
(
File
file
,
boolean
convertToMillis
)
{
Log
.
d
(
LOG_TAG
,
"*** getCurrentValue ***"
);
...
...
src/com/netease/qa/emmagee/utils/MailSender.java
浏览文件 @
8e6089f1
...
...
@@ -34,13 +34,11 @@ public class MailSender {
/**
* 以文本格式发送邮件
*
*
待发送的邮件的信息
* 待发送的邮件的信息
*/
public
static
boolean
sendTextMail
(
String
sender
,
String
encryptPassword
,
String
smtp
,
String
subject
,
String
content
,
String
file
,
public
static
boolean
sendTextMail
(
String
sender
,
String
encryptPassword
,
String
smtp
,
String
subject
,
String
content
,
String
file
,
String
[]
maillists
)
{
if
(
maillists
==
null
||
maillists
.
length
==
0
||
(
""
.
equals
(
maillists
[
0
].
trim
())))
{
if
(
maillists
==
null
||
maillists
.
length
==
0
||
(
""
.
equals
(
maillists
[
0
].
trim
())))
{
return
false
;
}
else
{
// Get system properties
...
...
@@ -56,12 +54,10 @@ public class MailSender {
CustomizedAuthenticator
authenticator
=
null
;
if
(
true
)
{
// 如果需要身份认证,则创建一个密码验证器
authenticator
=
new
CustomizedAuthenticator
(
sender
,
encryptPassword
);
authenticator
=
new
CustomizedAuthenticator
(
sender
,
encryptPassword
);
}
// 根据邮件会话属性和密码验证器构造一个发送邮件的session
Session
sendMailSession
=
Session
.
getInstance
(
props
,
authenticator
);
Session
sendMailSession
=
Session
.
getInstance
(
props
,
authenticator
);
try
{
// 根据session创建一个邮件消息
Message
mailMessage
=
new
MimeMessage
(
sendMailSession
);
...
...
@@ -71,7 +67,7 @@ public class MailSender {
mailMessage
.
setFrom
(
from
);
// 创建邮件的接收者地址,并设置到邮件消息中
for
(
int
i
=
0
;
i
<
maillists
.
length
;
i
++)
{
// Message.RecipientType.TO属性表示接收者的类型为TO
// Message.RecipientType.TO属性表示接收者的类型为TO
mailMessage
.
addRecipient
(
Message
.
RecipientType
.
TO
,
new
InternetAddress
(
maillists
[
i
]));
}
...
...
@@ -86,17 +82,16 @@ public class MailSender {
multipart
.
addBodyPart
(
bodyPart
);
File
attach
=
new
File
(
file
);
if
(
attach
.
exists
())
{
MimeBodyPart
attachPart
=
new
MimeBodyPart
();
DataSource
source
=
new
FileDataSource
(
attach
);
attachPart
.
setDataHandler
(
new
DataHandler
(
source
));
attachPart
.
setFileName
(
attach
.
getName
());
multipart
.
addBodyPart
(
attachPart
);
if
(
attach
.
exists
())
{
MimeBodyPart
attachPart
=
new
MimeBodyPart
();
DataSource
source
=
new
FileDataSource
(
attach
);
attachPart
.
setDataHandler
(
new
DataHandler
(
source
));
attachPart
.
setFileName
(
attach
.
getName
());
multipart
.
addBodyPart
(
attachPart
);
}
mailMessage
.
setContent
(
multipart
);
MailcapCommandMap
mc
=
(
MailcapCommandMap
)
CommandMap
.
getDefaultCommandMap
();
MailcapCommandMap
mc
=
(
MailcapCommandMap
)
CommandMap
.
getDefaultCommandMap
();
mc
.
addMailcap
(
"text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"
);
mc
.
addMailcap
(
"text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"
);
mc
.
addMailcap
(
"text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"
);
...
...
src/com/netease/qa/emmagee/utils/MemoryInfo.java
浏览文件 @
8e6089f1
...
...
@@ -95,11 +95,7 @@ public class MemoryInfo {
int
[]
myMempid
=
new
int
[]
{
pid
};
Debug
.
MemoryInfo
[]
memoryInfo
=
am
.
getProcessMemoryInfo
(
myMempid
);
memoryInfo
[
0
].
getTotalSharedDirty
();
// int memSize = memoryInfo[0].dalvikPrivateDirty;
// TODO PSS
int
memSize
=
memoryInfo
[
0
].
getTotalPss
();
// int memSize = memoryInfo[0].getTotalPrivateDirty();
return
memSize
;
}
...
...
src/com/netease/qa/emmagee/utils/ProcessInfo.java
浏览文件 @
8e6089f1
...
...
@@ -23,10 +23,8 @@ import java.util.List;
import
android.app.ActivityManager
;
import
android.app.ActivityManager.RunningAppProcessInfo
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageManager
;
import
android.content.pm.ResolveInfo
;
import
android.util.Log
;
/**
...
...
@@ -68,15 +66,6 @@ public class ProcessInfo {
break
;
}
}
// Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
// mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
// List<ResolveInfo> appList = pm.queryIntentActivities(mainIntent, PackageManager.MATCH_DEFAULT_ONLY);
// for (ResolveInfo temp : appList) {
// Log.d("my logs", temp.activityInfo.packageName);
// if (temp.activityInfo.packageName.toLowerCase().contains("uc")) {
// Log.v("my logs", "package and activity name = " + temp.activityInfo.packageName + " " + temp.activityInfo.name);
// }
// }
programe
.
setPackageName
(
appinfo
.
processName
);
programe
.
setProcessName
(
appinfo
.
loadLabel
(
pm
).
toString
());
programe
.
setIcon
(
appinfo
.
loadIcon
(
pm
));
...
...
src/com/netease/qa/emmagee/utils/Settings.java
浏览文件 @
8e6089f1
...
...
@@ -4,16 +4,23 @@ import android.content.Context;
import
android.content.SharedPreferences
;
import
android.preference.PreferenceManager
;
/**
* Parameters in Setting Activity
*
* @author yrom
*
*/
public
final
class
Settings
{
public
static
final
String
KEY_SENDER
=
"sender"
;
public
static
final
String
KEY_PASSWORD
=
"password"
;
public
static
final
String
KEY_RECIPIENTS
=
"recipients"
;
public
static
final
String
KEY_SMTP
=
"smtp"
;
public
static
final
String
KEY_ISFLOAT
=
"isfloat"
;
public
static
final
String
KEY_INTERVAL
=
"interval"
;
public
static
SharedPreferences
getDefaultSharedPreferences
(
Context
context
){
return
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
}
public
static
final
String
KEY_SENDER
=
"sender"
;
public
static
final
String
KEY_PASSWORD
=
"password"
;
public
static
final
String
KEY_RECIPIENTS
=
"recipients"
;
public
static
final
String
KEY_SMTP
=
"smtp"
;
public
static
final
String
KEY_ISFLOAT
=
"isfloat"
;
public
static
final
String
KEY_INTERVAL
=
"interval"
;
public
static
SharedPreferences
getDefaultSharedPreferences
(
Context
context
)
{
return
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录