diff options
author | Suchi Amalapurapu <asuchitra@google.com> | 2009-12-04 12:31:13 -0800 |
---|---|---|
committer | Suchi Amalapurapu <asuchitra@google.com> | 2009-12-04 13:59:38 -0800 |
commit | be1c422a73cf70e1478a13463de5ab929991c619 (patch) | |
tree | 6c698859af0d0f744aed03edb41ac557524923c5 /services/java | |
parent | 48a65d99cba33db3af2e05982a6825b883be2030 (diff) | |
download | frameworks_base-be1c422a73cf70e1478a13463de5ab929991c619.zip frameworks_base-be1c422a73cf70e1478a13463de5ab929991c619.tar.gz frameworks_base-be1c422a73cf70e1478a13463de5ab929991c619.tar.bz2 |
If the usage stats file doesn't exist in the first place there is no need to
backup and short return.
Diffstat (limited to 'services/java')
-rw-r--r-- | services/java/com/android/server/am/UsageStatsService.java | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/services/java/com/android/server/am/UsageStatsService.java b/services/java/com/android/server/am/UsageStatsService.java index 373b44e..f99ca96 100644 --- a/services/java/com/android/server/am/UsageStatsService.java +++ b/services/java/com/android/server/am/UsageStatsService.java @@ -380,11 +380,15 @@ public final class UsageStatsService extends IUsageStats.Stub { // Get the most recent file mFileLeaf = getCurrentDateStr(FILE_PREFIX); // Copy current file to back up - File backupFile = new File(mFile.getPath() + ".bak"); - if (!mFile.renameTo(backupFile)) { - Log.w(TAG, "Failed to persist new stats"); - return; + File backupFile = null; + if (mFile != null && mFile.exists()) { + backupFile = new File(mFile.getPath() + ".bak"); + if (!mFile.renameTo(backupFile)) { + Log.w(TAG, "Failed to persist new stats"); + return; + } } + try { // Write mStats to file writeStatsFLOCK(); @@ -468,16 +472,10 @@ public final class UsageStatsService extends IUsageStats.Stub { final boolean samePackage = pkgName.equals(mLastResumedPkg); if (mIsResumed) { - if (samePackage) { - Log.w(TAG, "Something wrong here, didn't expect " - + pkgName + " to be resumed"); - return; - } - if (mLastResumedPkg != null) { // We last resumed some other package... just pause it now // to recover. - Log.w(TAG, "Unexpected resume of " + pkgName + Log.i(TAG, "Unexpected resume of " + pkgName + " while already resumed in " + mLastResumedPkg); PkgUsageStatsExtended pus = mStats.get(mLastResumedPkg); if (pus != null) { @@ -516,7 +514,7 @@ public final class UsageStatsService extends IUsageStats.Stub { return; } if (!mIsResumed) { - Log.w(TAG, "Something wrong here, didn't expect " + Log.i(TAG, "Something wrong here, didn't expect " + pkgName + " to be paused"); return; } @@ -527,7 +525,7 @@ public final class UsageStatsService extends IUsageStats.Stub { PkgUsageStatsExtended pus = mStats.get(pkgName); if (pus == null) { // Weird some error here - Log.w(TAG, "No package stats for pkg:"+pkgName); + Log.i(TAG, "No package stats for pkg:"+pkgName); return; } pus.updatePause(); |