提交 def4df80 编写于 作者: A andrewleo

Fixed: cpu name of arm and refine fps

上级 a24e18d7
......@@ -141,19 +141,14 @@ public class CpuInfo {
try {
RandomAccessFile cpuStat = new RandomAccessFile(CPU_INFO_PATH, "r");
// check cpu type
if (Build.CPU_ABI.equalsIgnoreCase(CPU_X86)) {
String line;
while (null != (line = cpuStat.readLine())) {
String[] values = line.split(":");
if (values[0].contains(INTEL_CPU_NAME)) {
cpuStat.close();
return values[1];
}
String line;
while (null != (line = cpuStat.readLine())) {
String[] values = line.split(":");
if (values[0].contains(INTEL_CPU_NAME) || values[0].contains("Processor")) {
cpuStat.close();
Log.d(LOG_TAG, "CPU name="+values[1]);
return values[1];
}
} else {
String[] cpu = cpuStat.readLine().split(":"); // cpu信息的前一段是含有processor字符串,此处替换为不显示
cpuStat.close();
return cpu[1];
}
} catch (IOException e) {
Log.e(LOG_TAG, "IOException: " + e.getMessage());
......
......@@ -12,19 +12,27 @@ public class FpsInfo {
private static DataOutputStream os = null;
private static long startTime = 0L;
private static int lastFrameNum = 0;
private static boolean ok = true;
/**
* 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;
if (ok) {
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;
} else {
return -1;
}
}
/**
......@@ -43,19 +51,18 @@ public class FpsInfo {
os.writeBytes("service call SurfaceFlinger 1013" + "\n");
os.flush();
String str1 = ir.readLine();
if (str1 == null) {
return -1;
if (str1 != null) {
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);
}
}
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;
}
ok = false;
return -1;
}
}
......@@ -97,6 +97,7 @@ public class ProcessInfo {
Log.i(LOG_TAG, "start getLaunchedPid");
ActivityManager am = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
// Note: getRunningAppProcesses return itself in API 22
if (Build.VERSION.SDK_INT < ANDROID_M) {
List<RunningAppProcessInfo> run = am.getRunningAppProcesses();
for (RunningAppProcessInfo runningProcess : run) {
......@@ -208,6 +209,7 @@ public class ProcessInfo {
public static String getTopActivity(Context context) {
ActivityManager manager = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
// Note: getRunningTasks is deprecated in API 21(Official)
List<RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1);
if (runningTaskInfos != null)
return (runningTaskInfos.get(0).topActivity).toString();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册