Merge change Ibe1c422a into eclair
* changes: If the usage stats file doesn't exist in the first place there is no need to backup and short return.
This commit is contained in:
@ -380,11 +380,15 @@ public final class UsageStatsService extends IUsageStats.Stub {
|
|||||||
// Get the most recent file
|
// Get the most recent file
|
||||||
mFileLeaf = getCurrentDateStr(FILE_PREFIX);
|
mFileLeaf = getCurrentDateStr(FILE_PREFIX);
|
||||||
// Copy current file to back up
|
// Copy current file to back up
|
||||||
File backupFile = new File(mFile.getPath() + ".bak");
|
File backupFile = null;
|
||||||
if (!mFile.renameTo(backupFile)) {
|
if (mFile != null && mFile.exists()) {
|
||||||
Log.w(TAG, "Failed to persist new stats");
|
backupFile = new File(mFile.getPath() + ".bak");
|
||||||
return;
|
if (!mFile.renameTo(backupFile)) {
|
||||||
|
Log.w(TAG, "Failed to persist new stats");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Write mStats to file
|
// Write mStats to file
|
||||||
writeStatsFLOCK();
|
writeStatsFLOCK();
|
||||||
@ -468,16 +472,10 @@ public final class UsageStatsService extends IUsageStats.Stub {
|
|||||||
|
|
||||||
final boolean samePackage = pkgName.equals(mLastResumedPkg);
|
final boolean samePackage = pkgName.equals(mLastResumedPkg);
|
||||||
if (mIsResumed) {
|
if (mIsResumed) {
|
||||||
if (samePackage) {
|
|
||||||
Log.w(TAG, "Something wrong here, didn't expect "
|
|
||||||
+ pkgName + " to be resumed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mLastResumedPkg != null) {
|
if (mLastResumedPkg != null) {
|
||||||
// We last resumed some other package... just pause it now
|
// We last resumed some other package... just pause it now
|
||||||
// to recover.
|
// to recover.
|
||||||
Log.w(TAG, "Unexpected resume of " + pkgName
|
Log.i(TAG, "Unexpected resume of " + pkgName
|
||||||
+ " while already resumed in " + mLastResumedPkg);
|
+ " while already resumed in " + mLastResumedPkg);
|
||||||
PkgUsageStatsExtended pus = mStats.get(mLastResumedPkg);
|
PkgUsageStatsExtended pus = mStats.get(mLastResumedPkg);
|
||||||
if (pus != null) {
|
if (pus != null) {
|
||||||
@ -516,7 +514,7 @@ public final class UsageStatsService extends IUsageStats.Stub {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mIsResumed) {
|
if (!mIsResumed) {
|
||||||
Log.w(TAG, "Something wrong here, didn't expect "
|
Log.i(TAG, "Something wrong here, didn't expect "
|
||||||
+ pkgName + " to be paused");
|
+ pkgName + " to be paused");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -527,7 +525,7 @@ public final class UsageStatsService extends IUsageStats.Stub {
|
|||||||
PkgUsageStatsExtended pus = mStats.get(pkgName);
|
PkgUsageStatsExtended pus = mStats.get(pkgName);
|
||||||
if (pus == null) {
|
if (pus == null) {
|
||||||
// Weird some error here
|
// Weird some error here
|
||||||
Log.w(TAG, "No package stats for pkg:"+pkgName);
|
Log.i(TAG, "No package stats for pkg:"+pkgName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pus.updatePause();
|
pus.updatePause();
|
||||||
|
Reference in New Issue
Block a user