Skip to content

Commit

Permalink
refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewleo committed Feb 18, 2013
1 parent bc8f673 commit 48d4cdf
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 31 deletions.
40 changes: 22 additions & 18 deletions src/com/netease/qa/emmagee/activity/MainPageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class MainPageActivity extends Activity {

private List<Programe> processList;
private ProcessInfo processInfo;
private Intent MonitorService;
private Intent monitorService;
private ListView lstViProgramme;
private Button btnTest;
private boolean isTesting = true;
Expand All @@ -86,8 +86,8 @@ public void onCreate(Bundle savedInstanceState) {
btnTest.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MonitorService = new Intent();
MonitorService.setClass(MainPageActivity.this,
monitorService = new Intent();
monitorService.setClass(MainPageActivity.this,
EmmageeService.class);
if (isTesting) {
if (isRadioChecked) {
Expand All @@ -96,13 +96,13 @@ public void onClick(View v) {
Log.d(LOG_TAG, packageName);
startActivity(intent);
waitForAppStart(packageName);
MonitorService.putExtra("processName", processName);
MonitorService.putExtra("pid", pid);
MonitorService.putExtra("uid", uid);
MonitorService.putExtra("packageName", packageName);
MonitorService.putExtra("settingTempFile",
monitorService.putExtra("processName", processName);
monitorService.putExtra("pid", pid);
monitorService.putExtra("uid", uid);
monitorService.putExtra("packageName", packageName);
monitorService.putExtra("settingTempFile",
settingTempFile);
startService(MonitorService);
startService(monitorService);
btnTest.setText("停止测试");
isTesting = false;
} else {
Expand All @@ -115,14 +115,14 @@ public void onClick(View v) {
Toast.makeText(MainPageActivity.this,
"测试结果文件:" + EmmageeService.resultFilePath,
Toast.LENGTH_LONG).show();
stopService(MonitorService);
stopService(monitorService);
}
}
});
}

/**
* create new file to reserve setting data
* create new file to reserve setting data.
*/
private void createNewFile() {
Log.i(LOG_TAG, "create new file to save setting data");
Expand Down Expand Up @@ -174,6 +174,10 @@ private void waitForAppStart(String packageName) {

/**
* show a dialog when click return key.
*
* @return Return true to prevent this event from being propagated further,
* or false to indicate that you have not handled this event and it
* should continue to be propagated.
*/
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
Expand All @@ -183,8 +187,8 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
}

/**
* set menu options.
*
* set menu options,including cancel and setting options.
*
* @return true
*/
public boolean onCreateOptionsMenu(Menu menu) {
Expand All @@ -197,7 +201,7 @@ public boolean onCreateOptionsMenu(Menu menu) {

/**
* trigger menu options.
*
*
* @return false
*/
public boolean onOptionsItemSelected(MenuItem item) {
Expand All @@ -219,7 +223,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

/**
* create a dialog.
*
*
* @return a dialog
*/
protected Dialog onCreateDialog(int id) {
Expand All @@ -233,9 +237,9 @@ protected Dialog onCreateDialog(int id) {
@Override
public void onClick(DialogInterface dialog,
int which) {
if (MonitorService != null) {
if (monitorService != null) {
Log.d(LOG_TAG, "stop service");
stopService(MonitorService);
stopService(monitorService);
}
Log.d(LOG_TAG, "exit Emmagee");
EmmageeService.closeOpenedStream();
Expand All @@ -250,7 +254,7 @@ public void onClick(DialogInterface dialog,

/**
* customizing adapter.
*
*
*/
private class ListAdapter extends BaseAdapter {
List<Programe> programe;
Expand Down
5 changes: 2 additions & 3 deletions src/com/netease/qa/emmagee/activity/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void onCreate(Bundle savedInstanceState) {
edtTime = (EditText) findViewById(R.id.time);
Button btnSave = (Button) findViewById(R.id.save);
boolean floatingTag = true;
RandomAccessFile raf ;
RandomAccessFile raf;

try {
raf = new RandomAccessFile(settingTempFile, "r");
Expand All @@ -81,7 +81,6 @@ public void onCreate(Bundle savedInstanceState) {
Log.e(LOG_TAG, "IOException: " + e.getMessage());
e.printStackTrace();
}

edtTime.setText(time);
chkFloat.setChecked(floatingTag);
// edtTime.setInputType(InputType.TYPE_CLASS_NUMBER);
Expand Down Expand Up @@ -135,7 +134,7 @@ protected void onDestroy() {

/**
* is input a number.
*
*
* @param inputStr
* input string
* @return true is numeric
Expand Down
6 changes: 3 additions & 3 deletions src/com/netease/qa/emmagee/service/EmmageeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void readSettingInfo(Intent intent) {
time = "5";
isFloating = true;
Log.e(LOG_TAG, e.getMessage());
}
}
}

/**
Expand Down Expand Up @@ -300,9 +300,9 @@ public void run() {

/**
* refresh the performance data showing in floating window.
*
*
* @throws FileNotFoundException
*
*
* @throws IOException
*/
private void dataRefresh() {
Expand Down
2 changes: 1 addition & 1 deletion src/com/netease/qa/emmagee/utils/CpuInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public ArrayList<String> getCpuRatioInfo() {
String mDateTime2 = formatterFile.format(cal.getTime().getTime()
+ 8 * 60 * 60 * 1000);

if (isInitialStatics == true) {
if (isInitialStatics) {
initialTraffic = trafficInfo.getTrafficInfo();
isInitialStatics = false;
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/com/netease/qa/emmagee/utils/MemoryInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public int getPidMemorySize(int pid, Context context) {
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();
Expand All @@ -100,7 +100,7 @@ public int getPidMemorySize(int pid, Context context) {

/**
* get the sdk version of phone.
*
*
* @return sdk version
*/
public String getSDKVersion() {
Expand All @@ -109,7 +109,7 @@ public String getSDKVersion() {

/**
* get phone type.
*
*
* @return phone type
*/
public String getPhoneType() {
Expand Down
4 changes: 2 additions & 2 deletions src/com/netease/qa/emmagee/utils/ProcessInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ProcessInfo {
/**
* get information of all running processes,including package name ,process
* name ,icon ,pid and uid.
*
*
* @param context
* context of activity
* @return running processes list
Expand Down Expand Up @@ -83,7 +83,7 @@ public List<Programe> getRunningProcess(Context context) {

/**
* get information of all applications.
*
*
* @param context
* context of activity
* @return packages information of all applications
Expand Down
2 changes: 1 addition & 1 deletion src/com/netease/qa/emmagee/utils/TrafficInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public TrafficInfo(String uid) {
/**
* get total network traffic, which is the sum of upload and download
* traffic.
*
*
* @return total traffic include received and send traffic
*/
public long getTrafficInfo() {
Expand Down

0 comments on commit 48d4cdf

Please sign in to comment.