Permalink
Browse files

refine code

  • Loading branch information...
andrewleo committed Feb 18, 2013
1 parent bc8f673 commit 48d4cdf97b6887af8a62575e3e38a3c9cd32ea0f
@@ -62,7 +62,7 @@
private List<Programe> processList;
private ProcessInfo processInfo;
private Intent MonitorService;
private Intent monitorService;
private ListView lstViProgramme;
private Button btnTest;
private boolean isTesting = true;
@@ -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) {
@@ -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 {
@@ -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");
@@ -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) {
@@ -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) {
@@ -197,7 +201,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
/**
* trigger menu options.
*
*
* @return false
*/
public boolean onOptionsItemSelected(MenuItem item) {
@@ -219,7 +223,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
/**
* create a dialog.
*
*
* @return a dialog
*/
protected Dialog onCreateDialog(int id) {
@@ -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();
@@ -250,7 +254,7 @@ public void onClick(DialogInterface dialog,
/**
* customizing adapter.
*
*
*/
private class ListAdapter extends BaseAdapter {
List<Programe> programe;
@@ -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");
@@ -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);
@@ -135,7 +134,7 @@ protected void onDestroy() {
/**
* is input a number.
*
*
* @param inputStr
* input string
* @return true is numeric
@@ -157,7 +157,7 @@ private void readSettingInfo(Intent intent) {
time = "5";
isFloating = true;
Log.e(LOG_TAG, e.getMessage());
}
}
}
/**
@@ -300,9 +300,9 @@ public void run() {
/**
* refresh the performance data showing in floating window.
*
*
* @throws FileNotFoundException
*
*
* @throws IOException
*/
private void dataRefresh() {
@@ -148,7 +148,7 @@ public String getCpuName() {
String mDateTime2 = formatterFile.format(cal.getTime().getTime()
+ 8 * 60 * 60 * 1000);
if (isInitialStatics == true) {
if (isInitialStatics) {
initialTraffic = trafficInfo.getTrafficInfo();
isInitialStatics = false;
} else {
@@ -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();
@@ -100,7 +100,7 @@ public int getPidMemorySize(int pid, Context context) {
/**
* get the sdk version of phone.
*
*
* @return sdk version
*/
public String getSDKVersion() {
@@ -109,7 +109,7 @@ public String getSDKVersion() {
/**
* get phone type.
*
*
* @return phone type
*/
public String getPhoneType() {
@@ -38,7 +38,7 @@
/**
* get information of all running processes,including package name ,process
* name ,icon ,pid and uid.
*
*
* @param context
* context of activity
* @return running processes list
@@ -83,7 +83,7 @@
/**
* get information of all applications.
*
*
* @param context
* context of activity
* @return packages information of all applications
@@ -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() {

0 comments on commit 48d4cdf

Please sign in to comment.