Merge "Make SharedPreferences check with higher precision"
This commit is contained in:
@@ -23,16 +23,19 @@ import android.os.Looper;
|
|||||||
import android.system.ErrnoException;
|
import android.system.ErrnoException;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.system.StructStat;
|
import android.system.StructStat;
|
||||||
|
import android.system.StructTimespec;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.android.collect.Maps;
|
|
||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
import com.android.internal.util.ExponentiallyBucketedHistogram;
|
import com.android.internal.util.ExponentiallyBucketedHistogram;
|
||||||
import com.android.internal.util.XmlUtils;
|
import com.android.internal.util.XmlUtils;
|
||||||
|
|
||||||
import dalvik.system.BlockGuard;
|
import dalvik.system.BlockGuard;
|
||||||
|
|
||||||
|
import libcore.io.IoUtils;
|
||||||
|
|
||||||
|
import com.google.android.collect.Maps;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
@@ -50,8 +53,6 @@ import java.util.Set;
|
|||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
import libcore.io.IoUtils;
|
|
||||||
|
|
||||||
final class SharedPreferencesImpl implements SharedPreferences {
|
final class SharedPreferencesImpl implements SharedPreferences {
|
||||||
private static final String TAG = "SharedPreferencesImpl";
|
private static final String TAG = "SharedPreferencesImpl";
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
@@ -80,7 +81,7 @@ final class SharedPreferencesImpl implements SharedPreferences {
|
|||||||
private boolean mLoaded = false;
|
private boolean mLoaded = false;
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private long mStatTimestamp;
|
private StructTimespec mStatTimestamp;
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private long mStatSize;
|
private long mStatSize;
|
||||||
@@ -162,7 +163,7 @@ final class SharedPreferencesImpl implements SharedPreferences {
|
|||||||
mLoaded = true;
|
mLoaded = true;
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
mMap = map;
|
mMap = map;
|
||||||
mStatTimestamp = stat.st_mtime;
|
mStatTimestamp = stat.st_mtim;
|
||||||
mStatSize = stat.st_size;
|
mStatSize = stat.st_size;
|
||||||
} else {
|
} else {
|
||||||
mMap = new HashMap<>();
|
mMap = new HashMap<>();
|
||||||
@@ -209,7 +210,7 @@ final class SharedPreferencesImpl implements SharedPreferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
return mStatTimestamp != stat.st_mtime || mStatSize != stat.st_size;
|
return !stat.st_mtim.equals(mStatTimestamp) || mStatSize != stat.st_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,7 +745,7 @@ final class SharedPreferencesImpl implements SharedPreferences {
|
|||||||
try {
|
try {
|
||||||
final StructStat stat = Os.stat(mFile.getPath());
|
final StructStat stat = Os.stat(mFile.getPath());
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mStatTimestamp = stat.st_mtime;
|
mStatTimestamp = stat.st_mtim;
|
||||||
mStatSize = stat.st_size;
|
mStatSize = stat.st_size;
|
||||||
}
|
}
|
||||||
} catch (ErrnoException e) {
|
} catch (ErrnoException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user