Use currentTimeMillis instead of epoch seconds
Bug: 179215598 Test: N/A Change-Id: I1fc16750c42b0ce5a2206b928fcf153109d56cb4
This commit is contained in:
@@ -172,7 +172,7 @@ public class Typeface {
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public long native_instance;
|
||||
public final long native_instance;
|
||||
|
||||
private Runnable mCleaner;
|
||||
|
||||
@@ -207,6 +207,7 @@ public class Typeface {
|
||||
private static final int STYLE_NORMAL = 0;
|
||||
private static final int STYLE_ITALIC = 1;
|
||||
|
||||
@GuardedBy("this")
|
||||
private int[] mSupportedAxes;
|
||||
private static final int[] EMPTY_AXES = {};
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ import java.util.Set;
|
||||
private static final String ATTR_VALUE = "value";
|
||||
|
||||
/* package */ static class Config {
|
||||
public long lastModifiedDate;
|
||||
public long lastModifiedMillis;
|
||||
public final Set<String> updatedFontDirs = new ArraySet<>();
|
||||
public final List<FontConfig.FontFamily> fontFamilies = new ArrayList<>();
|
||||
}
|
||||
@@ -73,7 +73,7 @@ import java.util.Set;
|
||||
} else if (depth == 2) {
|
||||
switch (tag) {
|
||||
case TAG_LAST_MODIFIED_DATE:
|
||||
out.lastModifiedDate = parseLongAttribute(parser, ATTR_VALUE, 0);
|
||||
out.lastModifiedMillis = parseLongAttribute(parser, ATTR_VALUE, 0);
|
||||
break;
|
||||
case TAG_UPDATED_FONT_DIR:
|
||||
out.updatedFontDirs.add(getAttribute(parser, ATTR_VALUE));
|
||||
@@ -101,7 +101,7 @@ import java.util.Set;
|
||||
|
||||
out.startTag(null, TAG_ROOT);
|
||||
out.startTag(null, TAG_LAST_MODIFIED_DATE);
|
||||
out.attribute(null, ATTR_VALUE, Long.toString(config.lastModifiedDate));
|
||||
out.attribute(null, ATTR_VALUE, Long.toString(config.lastModifiedMillis));
|
||||
out.endTag(null, TAG_LAST_MODIFIED_DATE);
|
||||
for (String dir : config.updatedFontDirs) {
|
||||
out.startTag(null, TAG_UPDATED_FONT_DIR);
|
||||
|
||||
@@ -112,7 +112,7 @@ final class UpdatableFontDir {
|
||||
private final File mConfigFile;
|
||||
private final File mTmpConfigFile;
|
||||
|
||||
private long mLastModifiedDate;
|
||||
private long mLastModifiedMillis;
|
||||
private int mConfigVersion = 1;
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ final class UpdatableFontDir {
|
||||
/* package */ void loadFontFileMap() {
|
||||
mFontFileInfoMap.clear();
|
||||
mFontFamilyMap.clear();
|
||||
mLastModifiedDate = 0;
|
||||
mLastModifiedMillis = 0;
|
||||
boolean success = false;
|
||||
try {
|
||||
PersistentSystemFontConfig.Config config = new PersistentSystemFontConfig.Config();
|
||||
@@ -157,7 +157,7 @@ final class UpdatableFontDir {
|
||||
Slog.e(TAG, "Failed to load config xml file", e);
|
||||
return;
|
||||
}
|
||||
mLastModifiedDate = config.lastModifiedDate;
|
||||
mLastModifiedMillis = config.lastModifiedMillis;
|
||||
|
||||
File[] dirs = mFilesDir.listFiles();
|
||||
if (dirs == null) return;
|
||||
@@ -200,7 +200,7 @@ final class UpdatableFontDir {
|
||||
if (!success) {
|
||||
mFontFileInfoMap.clear();
|
||||
mFontFamilyMap.clear();
|
||||
mLastModifiedDate = 0;
|
||||
mLastModifiedMillis = 0;
|
||||
FileUtils.deleteContents(mFilesDir);
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ final class UpdatableFontDir {
|
||||
FileUtils.deleteContents(mFilesDir);
|
||||
mFontFamilyMap.clear();
|
||||
|
||||
mLastModifiedDate = Instant.now().getEpochSecond();
|
||||
mLastModifiedMillis = System.currentTimeMillis();
|
||||
try (FileOutputStream fos = new FileOutputStream(mConfigFile)) {
|
||||
PersistentSystemFontConfig.writeToXml(fos, createPersistentConfig());
|
||||
} catch (Exception e) {
|
||||
@@ -231,7 +231,7 @@ final class UpdatableFontDir {
|
||||
// Backup the mapping for rollback.
|
||||
ArrayMap<String, FontFileInfo> backupMap = new ArrayMap<>(mFontFileInfoMap);
|
||||
ArrayMap<String, FontConfig.FontFamily> backupFamilies = new ArrayMap<>(mFontFamilyMap);
|
||||
long backupLastModifiedDate = mLastModifiedDate;
|
||||
long backupLastModifiedDate = mLastModifiedMillis;
|
||||
boolean success = false;
|
||||
try {
|
||||
for (FontUpdateRequest request : requests) {
|
||||
@@ -247,7 +247,7 @@ final class UpdatableFontDir {
|
||||
}
|
||||
|
||||
// Write config file.
|
||||
mLastModifiedDate = Instant.now().getEpochSecond();
|
||||
mLastModifiedMillis = Instant.now().getEpochSecond();
|
||||
try (FileOutputStream fos = new FileOutputStream(mTmpConfigFile)) {
|
||||
PersistentSystemFontConfig.writeToXml(fos, createPersistentConfig());
|
||||
} catch (Exception e) {
|
||||
@@ -269,7 +269,7 @@ final class UpdatableFontDir {
|
||||
mFontFileInfoMap.putAll(backupMap);
|
||||
mFontFamilyMap.clear();
|
||||
mFontFamilyMap.putAll(backupFamilies);
|
||||
mLastModifiedDate = backupLastModifiedDate;
|
||||
mLastModifiedMillis = backupLastModifiedDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -527,7 +527,7 @@ final class UpdatableFontDir {
|
||||
|
||||
private PersistentSystemFontConfig.Config createPersistentConfig() {
|
||||
PersistentSystemFontConfig.Config config = new PersistentSystemFontConfig.Config();
|
||||
config.lastModifiedDate = mLastModifiedDate;
|
||||
config.lastModifiedMillis = mLastModifiedMillis;
|
||||
for (FontFileInfo info : mFontFileInfoMap.values()) {
|
||||
config.updatedFontDirs.add(info.getRandomizedFontDir().getName());
|
||||
}
|
||||
@@ -560,7 +560,7 @@ final class UpdatableFontDir {
|
||||
// which will be used as a fallback font without being overridden.
|
||||
mergedFamilies.addAll(mFontFamilyMap.values());
|
||||
return new FontConfig(
|
||||
mergedFamilies, config.getAliases(), mLastModifiedDate, mConfigVersion);
|
||||
mergedFamilies, config.getAliases(), mLastModifiedMillis, mConfigVersion);
|
||||
}
|
||||
|
||||
/* package */ int getConfigVersion() {
|
||||
|
||||
@@ -45,7 +45,7 @@ public final class PersistentSystemFontConfigTest {
|
||||
public void testWriteRead() throws Exception {
|
||||
long expectedModifiedDate = 1234567890;
|
||||
PersistentSystemFontConfig.Config config = new PersistentSystemFontConfig.Config();
|
||||
config.lastModifiedDate = expectedModifiedDate;
|
||||
config.lastModifiedMillis = expectedModifiedDate;
|
||||
config.updatedFontDirs.add("~~abc");
|
||||
config.updatedFontDirs.add("~~def");
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class PersistentSystemFontConfigTest {
|
||||
PersistentSystemFontConfig.Config another = new PersistentSystemFontConfig.Config();
|
||||
PersistentSystemFontConfig.loadFromXml(bais, another);
|
||||
|
||||
assertThat(another.lastModifiedDate).isEqualTo(expectedModifiedDate);
|
||||
assertThat(another.lastModifiedMillis).isEqualTo(expectedModifiedDate);
|
||||
assertThat(another.updatedFontDirs).containsExactly("~~abc", "~~def");
|
||||
assertThat(another.fontFamilies).containsExactly(fontFamily);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public final class PersistentSystemFontConfigTest {
|
||||
new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))) {
|
||||
PersistentSystemFontConfig.Config config = new PersistentSystemFontConfig.Config();
|
||||
PersistentSystemFontConfig.loadFromXml(bais, config);
|
||||
assertThat(config.lastModifiedDate).isEqualTo(0);
|
||||
assertThat(config.lastModifiedMillis).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ public final class UpdatableFontDirTest {
|
||||
FakeFontFileParser parser = new FakeFontFileParser();
|
||||
FakeFsverityUtil fakeFsverityUtil = new FakeFsverityUtil();
|
||||
PersistentSystemFontConfig.Config config = new PersistentSystemFontConfig.Config();
|
||||
config.lastModifiedDate = expectedModifiedDate;
|
||||
config.lastModifiedMillis = expectedModifiedDate;
|
||||
writeConfig(config, mConfigFile);
|
||||
UpdatableFontDir dirForPreparation = new UpdatableFontDir(
|
||||
mUpdatableFontFilesDir, mPreinstalledFontDirs, parser, fakeFsverityUtil,
|
||||
@@ -507,7 +507,7 @@ public final class UpdatableFontDirTest {
|
||||
File readonlyFile = new File(readonlyDir, "readonly_config.xml");
|
||||
|
||||
PersistentSystemFontConfig.Config config = new PersistentSystemFontConfig.Config();
|
||||
config.lastModifiedDate = expectedModifiedDate;
|
||||
config.lastModifiedMillis = expectedModifiedDate;
|
||||
writeConfig(config, readonlyFile);
|
||||
|
||||
assertThat(readonlyDir.setWritable(false, false)).isTrue();
|
||||
|
||||
Reference in New Issue
Block a user