Skip to content

Commit

Permalink
Added: add ftp to csv
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewleo committed Jul 31, 2015
1 parent 2d2a44f commit 669de8a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 4 deletions.
1 change: 1 addition & 0 deletions res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<string name="current">电流(mA)</string>
<string name="temperature">温度(C)</string>
<string name="voltage">电压(V)</string>
<string name="fps">帧率</string>
<string name="stat_error">统计出错</string>

<string name="comment1">注释:已知部分不支持的机型可在此查阅:https://github.com/NetEase/Emmagee/wiki/Some-devices-are-not-supported</string>
Expand Down
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<string name="current">Current(mA)</string>
<string name="temperature">Temperature(C)</string>
<string name="voltage">Voltage(V)</string>
<string name="fps">FPS</string>
<string name="stat_error">Stat Error</string>

<string name="comment1">Note: for unsupported devices refer to: https://github.com/NetEase/Emmagee/wiki/Some-devices-are-not-supported</string>
Expand Down
7 changes: 5 additions & 2 deletions src/com/netease/qa/emmagee/service/EmmageeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import com.netease.qa.emmagee.utils.CpuInfo;
import com.netease.qa.emmagee.utils.CurrentInfo;
import com.netease.qa.emmagee.utils.EncryptData;
import com.netease.qa.emmagee.utils.FpsInfo;
import com.netease.qa.emmagee.utils.MailSender;
import com.netease.qa.emmagee.utils.MemoryInfo;
import com.netease.qa.emmagee.utils.MyApplication;
Expand Down Expand Up @@ -122,6 +123,7 @@ public class EmmageeService extends Service {
private String temperature;
private String voltage;
private CurrentInfo currentInfo;
private FpsInfo fpsInfo;
private BatteryInfoBroadcastReceiver batteryBroadcast = null;

// get start time
Expand All @@ -139,6 +141,7 @@ public void onCreate() {
super.onCreate();
isServiceStop = false;
isStop = false;
fpsInfo = new FpsInfo();
memoryInfo = new MemoryInfo();
procInfo = new ProcessInfo();
fomart = new DecimalFormat();
Expand Down Expand Up @@ -300,7 +303,7 @@ private void createResultCsv() {
+ getString(R.string.mobile_free_mem) + Constants.COMMA + getString(R.string.app_used_cpu_ratio) + Constants.COMMA
+ getString(R.string.total_used_cpu_ratio) + multiCpuTitle + Constants.COMMA + getString(R.string.traffic) + Constants.COMMA
+ getString(R.string.battery) + Constants.COMMA + getString(R.string.current) + Constants.COMMA + getString(R.string.temperature)
+ Constants.COMMA + getString(R.string.voltage) + Constants.LINE_END);
+ Constants.COMMA + getString(R.string.voltage) + Constants.COMMA + getString(R.string.fps) + Constants.LINE_END);
} catch (IOException e) {
Log.e(LOG_TAG, e.getMessage());
}
Expand Down Expand Up @@ -457,7 +460,7 @@ private void dataRefresh() {
} catch (Exception e) {
currentBatt = Constants.NA;
}
ArrayList<String> processInfo = cpuInfo.getCpuRatioInfo(totalBatt, currentBatt, temperature, voltage, isRoot);
ArrayList<String> processInfo = cpuInfo.getCpuRatioInfo(totalBatt, currentBatt, temperature, voltage, String.valueOf(fpsInfo.fps()), isRoot);
if (isFloating) {
String processCpuRatio = "0.00";
String totalCpuRatio = "0.00";
Expand Down
4 changes: 2 additions & 2 deletions src/com/netease/qa/emmagee/utils/CpuInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public ArrayList<String> getCpuList() {
* @return network traffic ,used ratio of process CPU and total CPU in
* certain interval
*/
public ArrayList<String> getCpuRatioInfo(String totalBatt, String currentBatt, String temperature, String voltage,boolean isRoot) {
public ArrayList<String> getCpuRatioInfo(String totalBatt, String currentBatt, String temperature, String voltage, String fps, boolean isRoot) {

String heapData = "";
DecimalFormat fomart = new DecimalFormat();
Expand Down Expand Up @@ -315,7 +315,7 @@ public ArrayList<String> getCpuRatioInfo(String totalBatt, String currentBatt, S
EmmageeService.bw.write(mDateTime2 + Constants.COMMA + ProcessInfo.getTopActivity(context) + Constants.COMMA +heapData+ pMemory
+ Constants.COMMA + percent + Constants.COMMA + fMemory + Constants.COMMA + processCpuRatio + Constants.COMMA
+ totalCpuBuffer.toString() + trafValue + Constants.COMMA + totalBatt + Constants.COMMA + currentBatt + Constants.COMMA
+ temperature + Constants.COMMA + voltage + Constants.LINE_END);
+ temperature + Constants.COMMA + voltage + Constants.COMMA + fps + Constants.LINE_END);
totalCpu2 = (ArrayList<Long>) totalCpu.clone();
processCpu2 = processCpu;
idleCpu2 = (ArrayList<Long>) idleCpu.clone();
Expand Down
61 changes: 61 additions & 0 deletions src/com/netease/qa/emmagee/utils/FpsInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.netease.qa.emmagee.utils;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class FpsInfo {

private static Process process;
private static BufferedReader ir;
private static DataOutputStream os = null;
private static long startTime = 0L;
private static int lastFrameNum = 0;

/**
* get frame per second
* @return frame per second
*/
public static float fps() {
long nowTime = System.nanoTime();
float f = (float) (nowTime - startTime) / 1000000.0F;
startTime = nowTime;
int nowFrameNum = getFrameNum();
final float fps = Math.round((nowFrameNum - lastFrameNum) * 1000 / f);
lastFrameNum = nowFrameNum;
return fps;
}

/**
* get frame value
*
* @return frame value
*/
public static final int getFrameNum() {
try {
if (process == null) {
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
ir = new BufferedReader(new InputStreamReader(
process.getInputStream()));
}
os.writeBytes("service call SurfaceFlinger 1013" + "\n");
os.flush();
String str1 = ir.readLine();
if (str1 == null) {
return -1;
}
int start = str1.indexOf("(");
int end = str1.indexOf(" ");
if ((start != -1) & (end > start)) {
String str2 = str1.substring(start + 1, end);
return Integer.parseInt((String) str2, 16);
}
return -1;
} catch (IOException e) {
e.printStackTrace();
return -1;
}
}
}

0 comments on commit 669de8a

Please sign in to comment.