提交 af7f6b4a 编写于 作者: A andrewleo

Added: add a seekbar to manage collect frequency and optimize ui

上级 4d6ec8a3
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.netease.qa.emmagee"
android:versionCode="20"
android:versionName="1.3.2" >
android:versionCode="30"
android:versionName="2.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-sdk android:minSdkVersion="8" />
<application android:name=".utils.MyApplication"
android:icon="@drawable/icon"
android:label="@string/app_name" >
......
res/drawable-hdpi/checked_icon.png

617 字节 | W: | H:

res/drawable-hdpi/checked_icon.png

561 字节 | W: | H:

res/drawable-hdpi/checked_icon.png
res/drawable-hdpi/checked_icon.png
res/drawable-hdpi/checked_icon.png
res/drawable-hdpi/checked_icon.png
  • 2-up
  • Swipe
  • Onion skin
res/drawable-hdpi/unchecked_icon.png

561 字节 | W: | H:

res/drawable-hdpi/unchecked_icon.png

617 字节 | W: | H:

res/drawable-hdpi/unchecked_icon.png
res/drawable-hdpi/unchecked_icon.png
res/drawable-hdpi/unchecked_icon.png
res/drawable-hdpi/unchecked_icon.png
  • 2-up
  • Swipe
  • Onion skin
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<solid android:color="@color/light_gray" />
</shape>
</item>
<item>
<clip>
<shape>
<solid android:color="@color/red" />
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/seekbar_thumb_normal" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/seekbar_thumb_pressed" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/seekbar_thumb_pressed" />
<item android:drawable="@drawable/seekbar_thumb_normal" />
</selector>
\ No newline at end of file
......@@ -50,7 +50,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/layout_vertical_margin_small"
android:gravity="center_vertical"
android:text="Emmagee"
android:text="@string/app_name"
android:textColor="@color/black"
android:textSize="@dimen/text_size_bigest" />
</LinearLayout>
......@@ -65,7 +65,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="版本"
android:text="@string/version_title"
android:textSize="@dimen/text_size" />
<TextView
......@@ -79,7 +79,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/textview_horizontal_margin"
android:background="@color/white"
android:orientation="vertical" >
......@@ -87,38 +86,39 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/layout_vertical_margin_small" >
android:orientation="vertical"
android:padding="@dimen/layout_horizontal_margin" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Emmagee XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
android:text="@string/about_emmagee_intro"
android:textColor="@color/black"
android:textSize="@dimen/text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/light_gray" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/line_height"
android:background="@color/light_gray"
android:layout_marginLeft="@dimen/layout_vertical_margin_small"
android:layout_marginRight="@dimen/layout_vertical_margin_small"
android:layout_marginTop="@dimen/layout_vertical_margin"
android:layout_marginBottom="@dimen/layout_vertical_margin"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_team"
android:textColor="@color/mix_gray"
android:textSize="@dimen/text_size" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_project_address"
android:textColor="@color/mix_gray"
android:textSize="@dimen/text_size" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
......
......@@ -11,7 +11,6 @@
android:orientation="horizontal" >
<include
android:id="@+id/etNumCpuCores"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/navigation_bar" />
......@@ -53,14 +52,14 @@
android:id="@+id/sender"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:layout_marginTop="@dimen/edit_margin"
android:singleLine="true"
android:textSize="@dimen/text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_height="@dimen/line_height"
android:background="@color/light_gray" />
<LinearLayout
......@@ -80,7 +79,7 @@
android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:layout_marginTop="@dimen/edit_margin"
android:inputType="textPassword"
android:singleLine="true"
android:textSize="@dimen/text_size" />
......@@ -88,7 +87,7 @@
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_height="@dimen/line_height"
android:background="@color/light_gray" />
<LinearLayout
......@@ -108,14 +107,14 @@
android:id="@+id/smtp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:layout_marginTop="@dimen/edit_margin"
android:singleLine="true"
android:textSize="@dimen/text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_height="@dimen/line_height"
android:background="@color/light_gray" />
<LinearLayout
......@@ -135,7 +134,7 @@
android:id="@+id/recipients"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:layout_marginTop="@dimen/edit_margin"
android:textSize="@dimen/text_size" />
</LinearLayout>
</LinearLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:layout_height="@dimen/action_bar_height"
android:background="@drawable/actionbar_bg"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal" >
......@@ -10,6 +10,7 @@
android:id="@+id/go_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight ="@dimen/image_padding"
android:src="@drawable/btn_back" />
<TextView
......@@ -26,8 +27,8 @@
<ImageView
android:id="@+id/btn_set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/layout_vertical_margin"
android:layout_height="fill_parent"
android:padding="@dimen/image_padding"
android:src="@drawable/btn_save" />
</LinearLayout>
\ No newline at end of file
......@@ -11,10 +11,9 @@
android:orientation="horizontal" >
<include
android:id="@+id/etNumCpuCores"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/navigation_bar" />
android:layout_height="wrap_content"
layout="@layout/navigation_bar" />
</LinearLayout>
<LinearLayout
......@@ -39,6 +38,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
......@@ -53,25 +53,34 @@
android:layout_height="wrap_content"
android:gravity="right" >
<EditText
<TextView
android:id="@+id/time"
android:layout_width="100sp"
android:layout_width="50sp"
android:layout_height="wrap_content"
android:background="@null"
android:gravity="center_vertical|right"
android:hint="点击输入..."
android:inputType="number"
android:maxLength="5"
android:textSize="@dimen/text_size" >
<requestFocus />
</EditText>
android:textSize="@dimen/text_size"
android:textColor="@color/black" >
</TextView>
</LinearLayout>
</LinearLayout>
<SeekBar
android:id="@+id/timeline"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:max="60"
android:maxHeight="4.0dip"
android:minHeight="4.0dip"
android:paddingLeft="16.0dip"
android:paddingRight="16.0dip"
android:progress="5"
android:progressDrawable="@drawable/custom_seekbar"
android:thumb="@drawable/seekbar_thumb" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_height="@dimen/line_height"
android:background="@color/light_gray" />
<RelativeLayout
......@@ -95,7 +104,10 @@
android:layout_alignParentRight="true"
android:background="@drawable/custom_checkbox"
android:button="@null"
android:checked="true" />
android:checked="true"
android:paddingRight="@dimen/image_padding"
android:paddingLeft="@dimen/image_padding" />
</RelativeLayout>
</LinearLayout>
......@@ -135,11 +147,11 @@
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_height="@dimen/line_height"
android:background="@color/light_gray" />
<LinearLayout
android:id="@+id/about"
android:id="@+id/about"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
......@@ -166,5 +178,6 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -8,8 +8,7 @@
<string name="start_test">开始测试</string>
<string name="stop_test">停止测试</string>
<string name="collecting_frequency">采集频率:</string>
<string name="seconds"></string>
<string name="collecting_frequency">采集频率(s)</string>
<string name="sender">发件人:</string>
<string name="password">密码:</string>
<string name="smtp">SMTP服务器:</string>
......@@ -66,6 +65,11 @@
<string name="confirm">确定退出程序?</string>
<string name="about">关于</string>
<string name="mail_settings">邮件发送配置</string>
<string name="mail_settings">邮件配置</string>
<string name="version_title">版本 </string>
<string name="about_emmagee_intro">Emmagee是一个简单易上手的Android性能监测小工具,
主要用于监控单个App的CPU,内存,流量,电量,电流以及整体性能状态,
同时支持自定义的监控频率以及性能数据的实时显示.</string>
<string name="about_team">开发团队:网易(杭州)质量保障部</string>
<string name="about_project_address">项目地址:https://github.com/NetEase/Emmagee</string>
</resources>
......@@ -18,5 +18,13 @@
<dimen name="button_width">140dp</dimen>
<dimen name="button_height">40dp</dimen>
<dimen name="image_padding">10dp</dimen>
<dimen name="image_padding_small">5dp</dimen>
<dimen name="line_height">1px</dimen>
<dimen name="edit_margin">5px</dimen>
<dimen name="action_bar_height">60dp</dimen>
</resources>
......@@ -8,8 +8,7 @@
<string name="start_test">Start Test</string>
<string name="stop_test">Stop Test</string>
<string name="collecting_frequency">Collecting Frequency:</string>
<string name="seconds">Seconds</string>
<string name="collecting_frequency">Collecting Frequency(s)</string>
<string name="sender">Sender:</string>
<string name="password">Password:</string>
<string name="smtp">SMTP Server:</string>
......@@ -64,5 +63,14 @@
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="confirm">Are you sure to exit?</string>
<string name="about">About</string>
<string name="mail_settings">Mail Settings</string>
<string name="version_title">Version </string>
<string name="about_emmagee_intro">Emmagee is a practical, handy performance test tool for specified
Android App, which can monitor CPU, memory, network traffic, battery current and status.
Additionally, it also provides several cool features such as customizing interval of collecting
data, rendering real-time process status in a floating window, and much more.</string>
<string name="about_team">Team:QA, Netease(Hangzhou)</string>
<string name="about_project_address">Project Address:https://github.com/NetEase/Emmagee</string>
</resources>
......@@ -16,14 +16,6 @@
*/
package com.netease.qa.emmagee.activity;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
......@@ -33,18 +25,13 @@ import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.utils.EncryptData;
/**
* Setting Page of Emmagee
* About Page of Emmagee
*
* @author andrewleo
*/
......@@ -76,17 +63,14 @@ public class AboutActivity extends Activity {
goBack.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent();
intent.setClass(AboutActivity.this, SettingsActivity.class);
startActivityForResult(intent, Activity.RESULT_FIRST_USER);
AboutActivity.this.finish();
}
});
}
/**
* 获取版本号
* @return 当前应用的版本号
* get app version
* @return app version
*/
public String getVersion() {
try {
......
......@@ -31,8 +31,6 @@ import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
......@@ -42,7 +40,7 @@ import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.utils.EncryptData;
/**
* Setting Page of Emmagee
* Mail Setting Page of Emmagee
*
* @author andrewleo
*/
......@@ -116,10 +114,9 @@ public class MailSettingsActivity extends Activity {
MailSettingsActivity.this.finish();
}
});
// edtTime.setInputType(InputType.TYPE_CLASS_NUMBER);
btnSave.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
public void onClick(View v) {
sender = edtSender.getText().toString().trim();
if (!"".equals(sender) && !checkMailFormat(sender)) {
Toast.makeText(MailSettingsActivity.this, getString(R.string.sender_mail_toast) + getString(R.string.format_incorrect_format),
......@@ -146,6 +143,7 @@ public class MailSettingsActivity extends Activity {
}
try {
Properties properties = new Properties();
properties.load(new FileInputStream(settingTempFile));
properties.setProperty("sender", sender);
Log.d(LOG_TAG, "sender=" + sender);
try {
......
......@@ -19,10 +19,7 @@ package com.netease.qa.emmagee.activity;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.Intent;
......@@ -31,12 +28,12 @@ import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.utils.EncryptData;
......@@ -48,11 +45,10 @@ import com.netease.qa.emmagee.utils.EncryptData;
*/
public class SettingsActivity extends Activity {
private static final String LOG_TAG = "Emmagee-"
+ SettingsActivity.class.getSimpleName();
private static final String LOG_TAG = "Emmagee-" + SettingsActivity.class.getSimpleName();
private CheckBox chkFloat;
private EditText edtTime;
private TextView tvTime;
private String time;
private String settingTempFile;
private LinearLayout about;
......@@ -65,15 +61,16 @@ public class SettingsActivity extends Activity {
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.settings);
Properties properties = new Properties();
final EncryptData des = new EncryptData("emmagee");
Intent intent = this.getIntent();
settingTempFile = getBaseContext().getFilesDir().getPath()
+ "\\EmmageeSettings.properties";
settingTempFile = getBaseContext().getFilesDir().getPath() + "\\EmmageeSettings.properties";
chkFloat = (CheckBox) findViewById(R.id.floating);
edtTime = (EditText) findViewById(R.id.time);
tvTime = (TextView) findViewById(R.id.time);
about = (LinearLayout) findViewById(R.id.about);
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);
......@@ -81,10 +78,9 @@ public class SettingsActivity extends Activity {
btnSave.setImageResource(R.drawable.actionbar_bg);
try {
Properties properties = new Properties();
properties.load(new FileInputStream(settingTempFile));
String interval = (null == properties.getProperty("interval"))?"":properties.getProperty("interval").trim();
String isfloat = (null == properties.getProperty("isfloat"))?"":properties.getProperty("isfloat").trim();
String interval = (null == properties.getProperty("interval")) ? "" : properties.getProperty("interval").trim();
String isfloat = (null == properties.getProperty("isfloat")) ? "" : properties.getProperty("isfloat").trim();
time = "".equals(interval) ? "5" : interval;
floatingTag = "false".equals(isfloat) ? false : true;
} catch (FileNotFoundException e) {
......@@ -94,27 +90,52 @@ public class SettingsActivity extends Activity {
Log.e(LOG_TAG, "Exception: " + e.getMessage());
e.printStackTrace();
}
edtTime.setText(time);
tvTime.setText(time);
chkFloat.setChecked(floatingTag);
timeBar.setProgress(Integer.parseInt(time));
timeBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
tvTime.setText(Integer.toString(arg1 + 1));
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
}
@Override
public void onStopTrackingTouch(SeekBar arg0) {
// when tracking stoped, update properties file
int interval = arg0.getProgress() + 1;
try {
Properties properties = new Properties();
properties.load(new FileInputStream(settingTempFile));
properties.setProperty("interval", Integer.toString(interval));
FileOutputStream fos = new FileOutputStream(settingTempFile);
properties.store(fos, "Setting Data");
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
});
goBack.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
SettingsActivity.this.finish();
Intent intent = new Intent();
intent.setClass(SettingsActivity.this,
MainPageActivity.class);
intent.setClass(SettingsActivity.this, MainPageActivity.class);
startActivity(intent);
}
});
mailSettings.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent();
intent.setClass(SettingsActivity.this,
MailSettingsActivity.class);
startActivityForResult(intent, Activity.RESULT_FIRST_USER);
intent.setClass(SettingsActivity.this, MailSettingsActivity.class);
startActivity(intent);
}
});
......@@ -123,7 +144,7 @@ public class SettingsActivity extends Activity {
public void onClick(View arg0) {
Intent intent = new Intent();
intent.setClass(SettingsActivity.this, AboutActivity.class);
startActivityForResult(intent, Activity.RESULT_FIRST_USER);
startActivity(intent);
}
});
......@@ -132,8 +153,8 @@ public class SettingsActivity extends Activity {
public void onClick(View arg0) {
try {
Properties properties = new Properties();
properties.setProperty("isfloat",
chkFloat.isChecked() ? "true" : "false");
properties.load(new FileInputStream(settingTempFile));
properties.setProperty("isfloat", chkFloat.isChecked() ? "true" : "false");
FileOutputStream fos = new FileOutputStream(settingTempFile);
properties.store(fos, "Setting Data");
fos.close();
......@@ -143,46 +164,6 @@ public class SettingsActivity extends Activity {
}
}
});
// edtTime.setInputType(InputType.TYPE_CLASS_NUMBER);
// btnSave.setOnClickListener(new OnClickListener() {
// @Override
// public void onClick(View v) {
// time = edtTime.getText().toString().trim();
// if (!isNumeric(time)) {
// Toast.makeText(SettingsActivity.this, "输入数据无效,请重新输入",
// Toast.LENGTH_LONG).show();
// edtTime.setText("");
// } else if ("".equals(time) || Long.parseLong(time) == 0) {
// Toast.makeText(SettingsActivity.this, "输入数据为空,请重新输入",
// Toast.LENGTH_LONG).show();
// edtTime.setText("");
// } else if (Integer.parseInt(time) > 600) {
// Toast.makeText(SettingsActivity.this, "数据超过最大值600,请重新输入",
// Toast.LENGTH_LONG).show();
// } else {
// try {
// Properties properties = new Properties();
// properties.setProperty("interval", time);
// properties.setProperty("isfloat",
// chkFloat.isChecked() ? "true" : "false");
// FileOutputStream fos = new FileOutputStream(
// settingTempFile);
// properties.store(fos, "Setting Data");
// fos.close();
// Toast.makeText(SettingsActivity.this,
// getString(R.string.save_success_toast),
// Toast.LENGTH_LONG).show();
// Intent intent = new Intent();
// setResult(Activity.RESULT_FIRST_USER, intent);
// SettingsActivity.this.finish();
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// });
}
@Override
......
......@@ -229,13 +229,12 @@ public class EmmageeService extends Service {
try {
Properties properties = new Properties();
properties.load(new FileInputStream(settingTempFile));
String interval = properties.getProperty("interval").trim();
isFloating = "true".equals(properties.getProperty("isfloat").trim()) ? true : false;
sender = properties.getProperty("sender").trim();
password = properties.getProperty("password").trim();
recipients = properties.getProperty("recipients").trim();
String interval = (null == properties.getProperty("interval")) ? "" : properties.getProperty("interval").trim();
isFloating = "true".equals((null == properties.getProperty("isfloat")) ? "" : properties.getProperty("isfloat").trim()) ? true : false;
sender = (null == properties.getProperty("sender")) ? "" : properties.getProperty("sender").trim();
password = (null == properties.getProperty("password")) ? "" : properties.getProperty("password").trim();
recipients = (null == properties.getProperty("recipients")) ? "" : properties.getProperty("recipients").trim();
time = "".equals(interval) ? "5" : interval;
recipients = properties.getProperty("recipients");
receivers = recipients.split("\\s+");
smtp = properties.getProperty("smtp");
} catch (IOException e) {
......@@ -257,9 +256,11 @@ public class EmmageeService extends Service {
else
mDateTime = formatter.format(cal.getTime().getTime());
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
//在4.0以下的低版本上/sdcard连接至/mnt/sdcard,而4.0以上版本则连接至/storage/sdcard0,所以有外接sdcard,/sdcard路径一定存在
resultFilePath = "/sdcard"+ File.separator + "Emmagee_TestResult_" + mDateTime + ".csv";
//resultFilePath = android.os.Environment.getExternalStorageDirectory() + File.separator + "Emmagee_TestResult_" + mDateTime + ".csv";
// 在4.0以下的低版本上/sdcard连接至/mnt/sdcard,而4.0以上版本则连接至/storage/sdcard0,所以有外接sdcard,/sdcard路径一定存在
resultFilePath = "/sdcard" + File.separator + "Emmagee_TestResult_" + mDateTime + ".csv";
// resultFilePath =
// android.os.Environment.getExternalStorageDirectory() +
// File.separator + "Emmagee_TestResult_" + mDateTime + ".csv";
} else {
resultFilePath = getBaseContext().getFilesDir().getPath() + File.separator + "Emmagee_TestResult_" + mDateTime + ".csv";
}
......@@ -272,24 +273,21 @@ public class EmmageeService extends Service {
long totalMemorySize = memoryInfo.getTotalMemory();
String totalMemory = fomart.format((double) totalMemorySize / 1024);
String multiCpuTitle = "";
// titles of multiple cpu cores
// titles of multiple cpu cores
ArrayList<String> cpuList = cpuInfo.getCpuList();
for(int i =0 ; i < cpuList.size(); i++){
for (int i = 0; i < cpuList.size(); i++) {
multiCpuTitle += "," + cpuList.get(i) + " " + getString(R.string.total_usage);
}
bw.write(getString(R.string.process_package) + ": ," + packageName + "\r\n"
+ getString(R.string.process_name) + ": ," + processName + "\r\n"
+ getString(R.string.process_pid) + ": ," + pid + "\r\n"
+ getString(R.string.mem_size) + ": ," + totalMemory + "MB\r\n"
+ 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"
+ START_TIME);
bw.write(getString(R.string.process_package) + ": ," + packageName + "\r\n" + getString(R.string.process_name) + ": ," + processName
+ "\r\n" + getString(R.string.process_pid) + ": ," + pid + "\r\n" + getString(R.string.mem_size) + ": ," + totalMemory + "MB\r\n"
+ 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" + 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) + "," + getString(R.string.total_used_cpu_ratio)
+ multiCpuTitle +"," + getString(R.string.traffic) + "," + getString(R.string.battery) + "," + getString(R.string.current) + ","
+ getString(R.string.temperature) + "," + getString(R.string.voltage) + "\r\n");
+ getString(R.string.mobile_free_mem) + "," + getString(R.string.app_used_cpu_ratio) + ","
+ getString(R.string.total_used_cpu_ratio) + multiCpuTitle + "," + getString(R.string.traffic) + ","
+ getString(R.string.battery) + "," + getString(R.string.current) + "," + getString(R.string.temperature) + ","
+ getString(R.string.voltage) + "\r\n");
} catch (IOException e) {
Log.e(LOG_TAG, e.getMessage());
}
......@@ -507,10 +505,8 @@ public class EmmageeService extends Service {
public void closeOpenedStream() {
try {
if (bw != null) {
bw.write(getString(R.string.comment1) + "\r\n"
+ getString(R.string.comment2) + "\r\n"
+ getString(R.string.comment3) + "\r\n"
+ getString(R.string.comment4) + "\r\n");
bw.write(getString(R.string.comment1) + "\r\n" + getString(R.string.comment2) + "\r\n" + getString(R.string.comment3) + "\r\n"
+ getString(R.string.comment4) + "\r\n");
bw.close();
}
if (osw != null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册