提交 2533df93 编写于 作者: A andrewleo2013

refine code according to checkstyle

上级 87558e2f
......@@ -54,16 +54,15 @@ import com.netease.qa.emmagee.utils.Programe;
import com.netease.qa.emmagee.R;
/**
* Main Page of Emmagee.
* @author andrewleo
* Main Page of Emmagee
*
*/
public class MainPageActivity extends Activity {
private final String LOG_TAG = "Emmagee-"
private static final String LOG_TAG = "Emmagee-"
+ MainPageActivity.class.getSimpleName();
private final int TIMEOUT = 20000;
private static final int TIMEOUT = 20000;
private List<Programe> processList;
private ProcessInfo processInfo;
......@@ -265,6 +264,9 @@ public class MainPageActivity extends Activity {
List<Programe> programe;
int tempPosition = -1;
/**
* save status of all installed processes
*/
class Viewholder {
TextView txtAppName;
ImageView imgViAppIcon;
......
......@@ -36,9 +36,13 @@ import android.widget.Toast;
import com.netease.qa.emmagee.R;
/**
* Setting Page of Emmagee
*
*/
public class SettingsActivity extends Activity {
private final String LOG_TAG = "Emmagee-"
private static final String LOG_TAG = "Emmagee-"
+ SettingsActivity.class.getSimpleName();
private CheckBox chkFloat;
......@@ -64,13 +68,13 @@ public class SettingsActivity extends Activity {
try {
raf = new RandomAccessFile(settingTempFile, "r");
String f = raf.readLine();
if (f == null || (f != null && f.equals(""))) {
if (f == null || ("".equals(f))) {
time = "5";
} else {
time = f;
}
String tag = raf.readLine();
if (tag != null && tag.equals("false")) {
if ("false".equals(tag)) {
floatingTag = false;
}
raf.close();
......@@ -92,7 +96,7 @@ public class SettingsActivity extends Activity {
Toast.makeText(SettingsActivity.this, "输入数据无效,请重新输入",
Toast.LENGTH_LONG).show();
edtTime.setText("");
} else if (time.equals("") || Long.parseLong(time) == 0) {
} else if ("".equals(time) || Long.parseLong(time) == 0) {
Toast.makeText(SettingsActivity.this, "输入数据为空,请重新输入",
Toast.LENGTH_LONG).show();
edtTime.setText("");
......
......@@ -53,6 +53,10 @@ import com.netease.qa.emmagee.utils.MemoryInfo;
import com.netease.qa.emmagee.utils.MyApplication;
import com.netease.qa.emmagee.R;
/**
* Service running in background
*
*/
public class EmmageeService extends Service {
private final static String LOG_TAG = "Emmagee-"
......@@ -151,7 +155,7 @@ public class EmmageeService extends Service {
RandomAccessFile raf = new RandomAccessFile(new File(
settingTempFile), "r");
time = raf.readLine();
isFloating = raf.readLine().equals("true") ? true : false;
isFloating = ("true".equals(raf.readLine())) ? true : false;
raf.close();
} catch (IOException e) {
time = "5";
......@@ -322,8 +326,8 @@ public class EmmageeService extends Service {
processCpuRatio = processInfo.get(0);
totalCpuRatio = processInfo.get(1);
trafficSize = processInfo.get(2);
if (trafficSize != null && !trafficSize.equals("")
&& !trafficSize.equals("-1")) {
if ("".equals(trafficSize)
&& !("-1".equals(trafficSize))) {
tempTraffic = Integer.parseInt(trafficSize);
if (tempTraffic > 1024) {
isMb = true;
......@@ -336,7 +340,7 @@ public class EmmageeService extends Service {
+ freeMemoryKb + "MB");
txtTotalMem.setText("占用CPU:" + processCpuRatio + "%"
+ ",总体CPU:" + totalCpuRatio + "%");
if (trafficSize.equals("-1")) {
if ("-1".equals(trafficSize)) {
txtTraffic.setText("本程序或本设备不支持流量统计");
} else if (isMb)
txtTraffic.setText("消耗流量:" + fomart.format(trafficMb)
......
......@@ -29,6 +29,10 @@ import com.netease.qa.emmagee.service.EmmageeService;
import android.content.Context;
import android.util.Log;
/**
* operate CPU information
*
*/
public class CpuInfo {
private static final String LOG_TAG = "Emmagee-"
......@@ -46,7 +50,7 @@ public class CpuInfo {
private long lastestTraffic;
private long traffic;
private TrafficInfo trafficInfo;
private ArrayList<String> CpuUsedRatio;
private ArrayList<String> cpuUsedRatio;
private long totalCpu2;
private long processCpu2;
private long idleCpu2;
......@@ -61,7 +65,7 @@ public class CpuInfo {
formatterFile = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
mi = new MemoryInfo();
totalMemorySize = mi.getTotalMemory();
CpuUsedRatio = new ArrayList<String>();
cpuUsedRatio = new ArrayList<String>();
}
/**
......@@ -141,7 +145,7 @@ public class CpuInfo {
fomart.setMinimumFractionDigits(2);
readCpuStat();
CpuUsedRatio.clear();
cpuUsedRatio.clear();
try {
Calendar cal = Calendar.getInstance();
......@@ -160,7 +164,8 @@ public class CpuInfo {
processCpuRatio = fomart
.format(100 * ((double) (processCpu - processCpu2) / (double) (totalCpu - totalCpu2)));
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, context);
String pMemory = fomart.format((double) pidMemory / 1024);
long freeMemory = mi.getFreeMemorySize(context);
......@@ -186,14 +191,14 @@ public class CpuInfo {
totalCpu2 = totalCpu;
processCpu2 = processCpu;
idleCpu2 = idleCpu;
CpuUsedRatio.add(processCpuRatio);
CpuUsedRatio.add(totalCpuRatio);
CpuUsedRatio.add(String.valueOf(traffic));
cpuUsedRatio.add(processCpuRatio);
cpuUsedRatio.add(totalCpuRatio);
cpuUsedRatio.add(String.valueOf(traffic));
} catch (IOException e) {
e.printStackTrace();
// PttService.closeOpenedStream()
}
return CpuUsedRatio;
return cpuUsedRatio;
}
......
......@@ -25,6 +25,10 @@ import android.content.Context;
import android.os.Debug;
import android.util.Log;
/**
* operate memory information
*
*/
public class MemoryInfo {
private static final String LOG_TAG = "Emmagee-"
......@@ -100,7 +104,7 @@ public class MemoryInfo {
/**
* get the sdk version of phone.
*
*
* @return sdk version
*/
public String getSDKVersion() {
......@@ -109,7 +113,7 @@ public class MemoryInfo {
/**
* get phone type.
*
*
* @return phone type
*/
public String getPhoneType() {
......
......@@ -19,8 +19,12 @@ package com.netease.qa.emmagee.utils;
import android.app.Application;
import android.view.WindowManager;
/**
* my application class
*
*/
public class MyApplication extends Application {
private WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams();
public WindowManager.LayoutParams getMywmParams() {
......
......@@ -28,12 +28,16 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.util.Log;
/**
* get information of processes
*
*/
public class ProcessInfo {
private final String LOG_TAG = "Emmagee-"
private static final String LOG_TAG = "Emmagee-"
+ ProcessInfo.class.getSimpleName();
private final String PACKAGE_NAME = "com.netease.qa.emmagee";
private static final String PACKAGE_NAME = "com.netease.qa.emmagee";
/**
* get information of all running processes,including package name ,process
......
......@@ -18,6 +18,11 @@ package com.netease.qa.emmagee.utils;
import android.graphics.drawable.Drawable;
/**
* details of installed processes ,including
* icon,packagename,pid,uid,processname
*
*/
public class Programe {
private Drawable icon;
private String processName;
......
......@@ -22,6 +22,10 @@ import java.io.RandomAccessFile;
import android.util.Log;
/**
* information of network traffic
*
*/
public class TrafficInfo {
private static final String LOG_TAG = "Emmagee-"
......@@ -72,6 +76,6 @@ public class TrafficInfo {
if (rcvTraffic == -1 || sndTraffic == -1) {
return -1;
} else
return (rcvTraffic + sndTraffic);
return rcvTraffic + sndTraffic;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册