diff --git a/src/com/netease/qa/emmagee/utils/CpuInfo.java b/src/com/netease/qa/emmagee/utils/CpuInfo.java index 6134518770c5e4312f07a4793576e729a1a40e37..c7f7f21fd75e9f66474757886f1a8048954cac45 100644 --- a/src/com/netease/qa/emmagee/utils/CpuInfo.java +++ b/src/com/netease/qa/emmagee/utils/CpuInfo.java @@ -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()); diff --git a/src/com/netease/qa/emmagee/utils/FpsInfo.java b/src/com/netease/qa/emmagee/utils/FpsInfo.java index 23acbba08d03f5984babce7f0af0e7647938f76b..dc0068d0661509bf0752228def56c3b7f24c5e2c 100644 --- a/src/com/netease/qa/emmagee/utils/FpsInfo.java +++ b/src/com/netease/qa/emmagee/utils/FpsInfo.java @@ -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; } } diff --git a/src/com/netease/qa/emmagee/utils/ProcessInfo.java b/src/com/netease/qa/emmagee/utils/ProcessInfo.java index feede827f5a18dbc60997d1232dcc96db9c78f50..16f5a087dd90c52d0ca56fd29ec1c6f301951c9c 100644 --- a/src/com/netease/qa/emmagee/utils/ProcessInfo.java +++ b/src/com/netease/qa/emmagee/utils/ProcessInfo.java @@ -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 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 runningTaskInfos = manager.getRunningTasks(1); if (runningTaskInfos != null) return (runningTaskInfos.get(0).topActivity).toString();