From d0cb9890caeb0bdfff2bf1fe85c5f5e2a18d342d Mon Sep 17 00:00:00 2001 From: andrewleo2013 Date: Tue, 12 Mar 2013 11:55:27 +0800 Subject: [PATCH] fix bug --- src/com/netease/qa/emmagee/utils/CpuInfo.java | 14 ++++++++++---- src/com/netease/qa/emmagee/utils/TrafficInfo.java | 11 +++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/com/netease/qa/emmagee/utils/CpuInfo.java b/src/com/netease/qa/emmagee/utils/CpuInfo.java index 3064e7a..62e67bc 100644 --- a/src/com/netease/qa/emmagee/utils/CpuInfo.java +++ b/src/com/netease/qa/emmagee/utils/CpuInfo.java @@ -27,6 +27,7 @@ import com.netease.qa.emmagee.service.EmmageeService; import android.content.Context; +import android.os.Build; import android.util.Log; /** @@ -148,9 +149,14 @@ public ArrayList getCpuRatioInfo() { cpuUsedRatio.clear(); try { + String mDateTime2; Calendar cal = Calendar.getInstance(); - String mDateTime2 = formatterFile.format(cal.getTime().getTime() - + 8 * 60 * 60 * 1000); +// if ((Build.MODEL.equals("sdk")) +// || (Build.MODEL.equals("google_sdk"))) { +// mDateTime2 = formatterFile.format(cal.getTime().getTime() + 8 +// * 60 * 60 * 1000); +// } else + mDateTime2 = formatterFile.format(cal.getTime().getTime()); if (isInitialStatics) { initialTraffic = trafficInfo.getTrafficInfo(); @@ -164,8 +170,8 @@ public ArrayList getCpuRatioInfo() { processCpuRatio = fomart .format(100 * ((double) (processCpu - processCpu2) / (double) (totalCpu - totalCpu2))); totalCpuRatio = fomart - .format(100 * ((double) ((totalCpu - idleCpu) - (totalCpu2 - idleCpu2)) - / (double) (totalCpu - totalCpu2))); + .format(100 * ((double) ((totalCpu - idleCpu) - + (totalCpu2 - idleCpu2)) / (double) (totalCpu - totalCpu2))); long pidMemory = mi.getPidMemorySize(pid, context); String pMemory = fomart.format((double) pidMemory / 1024); long freeMemory = mi.getFreeMemorySize(context); diff --git a/src/com/netease/qa/emmagee/utils/TrafficInfo.java b/src/com/netease/qa/emmagee/utils/TrafficInfo.java index add49be..3fb72a6 100644 --- a/src/com/netease/qa/emmagee/utils/TrafficInfo.java +++ b/src/com/netease/qa/emmagee/utils/TrafficInfo.java @@ -24,7 +24,7 @@ /** * information of network traffic - * + * */ public class TrafficInfo { @@ -40,7 +40,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() { @@ -66,8 +66,11 @@ public long getTrafficInfo() { e.printStackTrace(); } finally { try { - rafRcv.close(); - rafSnd.close(); + if (rafRcv != null) { + rafRcv.close(); + } + if (rafSnd != null) + rafSnd.close(); } catch (IOException e) { Log.i(LOG_TAG, "close randomAccessFile exception: " + e.getMessage());