Merge "Use new package name for ZoneInfo and libcore.timezone"
This commit is contained in:
@@ -35,7 +35,7 @@ import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import libcore.timezone.ZoneInfoDb;
|
||||
import com.android.i18n.timezone.ZoneInfoDb;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@@ -18,8 +18,8 @@ package android.text.format;
|
||||
|
||||
import android.util.TimeFormatException;
|
||||
|
||||
import libcore.timezone.ZoneInfoDb;
|
||||
import libcore.util.ZoneInfo;
|
||||
import com.android.i18n.timezone.ZoneInfoData;
|
||||
import com.android.i18n.timezone.ZoneInfoDb;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
@@ -1059,15 +1059,15 @@ public class Time {
|
||||
* to the enclosing object, but others do not: thus separate state is retained.
|
||||
*/
|
||||
private static class TimeCalculator {
|
||||
public final ZoneInfo.WallTime wallTime;
|
||||
public final ZoneInfoData.WallTime wallTime;
|
||||
public String timezone;
|
||||
|
||||
// Information about the current timezone.
|
||||
private ZoneInfo zoneInfo;
|
||||
private ZoneInfoData mZoneInfoData;
|
||||
|
||||
public TimeCalculator(String timezoneId) {
|
||||
this.zoneInfo = lookupZoneInfo(timezoneId);
|
||||
this.wallTime = new ZoneInfo.WallTime();
|
||||
this.mZoneInfoData = lookupZoneInfoData(timezoneId);
|
||||
this.wallTime = new ZoneInfoData.WallTime();
|
||||
}
|
||||
|
||||
public long toMillis(boolean ignoreDst) {
|
||||
@@ -1075,7 +1075,7 @@ public class Time {
|
||||
wallTime.setIsDst(-1);
|
||||
}
|
||||
|
||||
int r = wallTime.mktime(zoneInfo);
|
||||
int r = wallTime.mktime(mZoneInfoData);
|
||||
if (r == -1) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1087,7 +1087,7 @@ public class Time {
|
||||
int intSeconds = (int) (millis / 1000);
|
||||
|
||||
updateZoneInfoFromTimeZone();
|
||||
wallTime.localtime(intSeconds, zoneInfo);
|
||||
wallTime.localtime(intSeconds, mZoneInfoData);
|
||||
}
|
||||
|
||||
public String format(String format) {
|
||||
@@ -1095,31 +1095,31 @@ public class Time {
|
||||
format = "%c";
|
||||
}
|
||||
TimeFormatter formatter = new TimeFormatter();
|
||||
return formatter.format(format, wallTime, zoneInfo);
|
||||
return formatter.format(format, wallTime, mZoneInfoData);
|
||||
}
|
||||
|
||||
private void updateZoneInfoFromTimeZone() {
|
||||
if (!zoneInfo.getID().equals(timezone)) {
|
||||
this.zoneInfo = lookupZoneInfo(timezone);
|
||||
if (!mZoneInfoData.getID().equals(timezone)) {
|
||||
this.mZoneInfoData = lookupZoneInfoData(timezone);
|
||||
}
|
||||
}
|
||||
|
||||
private static ZoneInfo lookupZoneInfo(String timezoneId) {
|
||||
ZoneInfo zoneInfo = ZoneInfoDb.getInstance().makeTimeZone(timezoneId);
|
||||
if (zoneInfo == null) {
|
||||
zoneInfo = ZoneInfoDb.getInstance().makeTimeZone("GMT");
|
||||
private static ZoneInfoData lookupZoneInfoData(String timezoneId) {
|
||||
ZoneInfoData zoneInfoData = ZoneInfoDb.getInstance().makeZoneInfoData(timezoneId);
|
||||
if (zoneInfoData == null) {
|
||||
zoneInfoData = ZoneInfoDb.getInstance().makeZoneInfoData("GMT");
|
||||
}
|
||||
if (zoneInfo == null) {
|
||||
if (zoneInfoData == null) {
|
||||
throw new AssertionError("GMT not found: \"" + timezoneId + "\"");
|
||||
}
|
||||
return zoneInfo;
|
||||
return zoneInfoData;
|
||||
}
|
||||
|
||||
public void switchTimeZone(String timezone) {
|
||||
int seconds = wallTime.mktime(zoneInfo);
|
||||
int seconds = wallTime.mktime(mZoneInfoData);
|
||||
this.timezone = timezone;
|
||||
updateZoneInfoFromTimeZone();
|
||||
wallTime.localtime(seconds, zoneInfo);
|
||||
wallTime.localtime(seconds, mZoneInfoData);
|
||||
}
|
||||
|
||||
public String format2445(boolean hasTime) {
|
||||
|
||||
@@ -22,8 +22,9 @@ package android.text.format;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.android.i18n.timezone.ZoneInfoData;
|
||||
|
||||
import libcore.icu.LocaleData;
|
||||
import libcore.util.ZoneInfo;
|
||||
|
||||
import java.nio.CharBuffer;
|
||||
import java.time.Instant;
|
||||
@@ -94,8 +95,8 @@ class TimeFormatter {
|
||||
* incorrect digit localization behavior.
|
||||
*/
|
||||
String formatMillisWithFixedFormat(long timeMillis) {
|
||||
// This method is deliberately not a general purpose replacement for
|
||||
// format(String, ZoneInfo.WallTime, ZoneInfo): It hard-codes the pattern used; many of the
|
||||
// This method is deliberately not a general purpose replacement for format(String,
|
||||
// ZoneInfoData.WallTime, ZoneInfoData): It hard-codes the pattern used; many of the
|
||||
// pattern characters supported by Time.format() have unusual behavior which would make
|
||||
// using java.time.format or similar packages difficult. It would be a lot of work to share
|
||||
// behavior and many internal Android usecases can be covered by this common pattern
|
||||
@@ -144,7 +145,8 @@ class TimeFormatter {
|
||||
/**
|
||||
* Format the specified {@code wallTime} using {@code pattern}. The output is returned.
|
||||
*/
|
||||
public String format(String pattern, ZoneInfo.WallTime wallTime, ZoneInfo zoneInfo) {
|
||||
public String format(String pattern, ZoneInfoData.WallTime wallTime,
|
||||
ZoneInfoData zoneInfoData) {
|
||||
try {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
@@ -153,7 +155,7 @@ class TimeFormatter {
|
||||
// and locale sensitive strings are output directly using outputBuilder.
|
||||
numberFormatter = new Formatter(stringBuilder, Locale.US);
|
||||
|
||||
formatInternal(pattern, wallTime, zoneInfo);
|
||||
formatInternal(pattern, wallTime, zoneInfoData);
|
||||
String result = stringBuilder.toString();
|
||||
// The localizeDigits() behavior is the source of a bug since some formats are defined
|
||||
// as being in ASCII and not localized.
|
||||
@@ -186,13 +188,14 @@ class TimeFormatter {
|
||||
* Format the specified {@code wallTime} using {@code pattern}. The output is written to
|
||||
* {@link #outputBuilder}.
|
||||
*/
|
||||
private void formatInternal(String pattern, ZoneInfo.WallTime wallTime, ZoneInfo zoneInfo) {
|
||||
private void formatInternal(String pattern, ZoneInfoData.WallTime wallTime,
|
||||
ZoneInfoData zoneInfoData) {
|
||||
CharBuffer formatBuffer = CharBuffer.wrap(pattern);
|
||||
while (formatBuffer.remaining() > 0) {
|
||||
boolean outputCurrentChar = true;
|
||||
char currentChar = formatBuffer.get(formatBuffer.position());
|
||||
if (currentChar == '%') {
|
||||
outputCurrentChar = handleToken(formatBuffer, wallTime, zoneInfo);
|
||||
outputCurrentChar = handleToken(formatBuffer, wallTime, zoneInfoData);
|
||||
}
|
||||
if (outputCurrentChar) {
|
||||
outputBuilder.append(formatBuffer.get(formatBuffer.position()));
|
||||
@@ -201,8 +204,8 @@ class TimeFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleToken(CharBuffer formatBuffer, ZoneInfo.WallTime wallTime,
|
||||
ZoneInfo zoneInfo) {
|
||||
private boolean handleToken(CharBuffer formatBuffer, ZoneInfoData.WallTime wallTime,
|
||||
ZoneInfoData zoneInfoData) {
|
||||
|
||||
// The char at formatBuffer.position() is expected to be '%' at this point.
|
||||
int modifier = 0;
|
||||
@@ -247,10 +250,10 @@ class TimeFormatter {
|
||||
outputYear(wallTime.getYear(), true, false, modifier);
|
||||
return false;
|
||||
case 'c':
|
||||
formatInternal(dateTimeFormat, wallTime, zoneInfo);
|
||||
formatInternal(dateTimeFormat, wallTime, zoneInfoData);
|
||||
return false;
|
||||
case 'D':
|
||||
formatInternal("%m/%d/%y", wallTime, zoneInfo);
|
||||
formatInternal("%m/%d/%y", wallTime, zoneInfoData);
|
||||
return false;
|
||||
case 'd':
|
||||
numberFormatter.format(getFormat(modifier, "%02d", "%2d", "%d", "%02d"),
|
||||
@@ -272,7 +275,7 @@ class TimeFormatter {
|
||||
wallTime.getMonthDay());
|
||||
return false;
|
||||
case 'F':
|
||||
formatInternal("%Y-%m-%d", wallTime, zoneInfo);
|
||||
formatInternal("%Y-%m-%d", wallTime, zoneInfoData);
|
||||
return false;
|
||||
case 'H':
|
||||
numberFormatter.format(getFormat(modifier, "%02d", "%2d", "%d", "%02d"),
|
||||
@@ -315,21 +318,21 @@ class TimeFormatter {
|
||||
: localeData.amPm[0], FORCE_LOWER_CASE);
|
||||
return false;
|
||||
case 'R':
|
||||
formatInternal("%H:%M", wallTime, zoneInfo);
|
||||
formatInternal("%H:%M", wallTime, zoneInfoData);
|
||||
return false;
|
||||
case 'r':
|
||||
formatInternal("%I:%M:%S %p", wallTime, zoneInfo);
|
||||
formatInternal("%I:%M:%S %p", wallTime, zoneInfoData);
|
||||
return false;
|
||||
case 'S':
|
||||
numberFormatter.format(getFormat(modifier, "%02d", "%2d", "%d", "%02d"),
|
||||
wallTime.getSecond());
|
||||
return false;
|
||||
case 's':
|
||||
int timeInSeconds = wallTime.mktime(zoneInfo);
|
||||
int timeInSeconds = wallTime.mktime(zoneInfoData);
|
||||
outputBuilder.append(Integer.toString(timeInSeconds));
|
||||
return false;
|
||||
case 'T':
|
||||
formatInternal("%H:%M:%S", wallTime, zoneInfo);
|
||||
formatInternal("%H:%M:%S", wallTime, zoneInfoData);
|
||||
return false;
|
||||
case 't':
|
||||
outputBuilder.append('\t');
|
||||
@@ -383,7 +386,7 @@ class TimeFormatter {
|
||||
return false;
|
||||
}
|
||||
case 'v':
|
||||
formatInternal("%e-%b-%Y", wallTime, zoneInfo);
|
||||
formatInternal("%e-%b-%Y", wallTime, zoneInfoData);
|
||||
return false;
|
||||
case 'W':
|
||||
int n = (wallTime.getYearDay() + DAYSPERWEEK - (
|
||||
@@ -395,10 +398,10 @@ class TimeFormatter {
|
||||
numberFormatter.format("%d", wallTime.getWeekDay());
|
||||
return false;
|
||||
case 'X':
|
||||
formatInternal(timeOnlyFormat, wallTime, zoneInfo);
|
||||
formatInternal(timeOnlyFormat, wallTime, zoneInfoData);
|
||||
return false;
|
||||
case 'x':
|
||||
formatInternal(dateOnlyFormat, wallTime, zoneInfo);
|
||||
formatInternal(dateOnlyFormat, wallTime, zoneInfoData);
|
||||
return false;
|
||||
case 'y':
|
||||
outputYear(wallTime.getYear(), false, true, modifier);
|
||||
@@ -411,7 +414,8 @@ class TimeFormatter {
|
||||
return false;
|
||||
}
|
||||
boolean isDst = wallTime.getIsDst() != 0;
|
||||
modifyAndAppend(zoneInfo.getDisplayName(isDst, TimeZone.SHORT), modifier);
|
||||
modifyAndAppend(TimeZone.getTimeZone(zoneInfoData.getID())
|
||||
.getDisplayName(isDst, TimeZone.SHORT), modifier);
|
||||
return false;
|
||||
case 'z': {
|
||||
if (wallTime.getIsDst() < 0) {
|
||||
@@ -432,7 +436,7 @@ class TimeFormatter {
|
||||
return false;
|
||||
}
|
||||
case '+':
|
||||
formatInternal("%a %b %e %H:%M:%S %Z %Y", wallTime, zoneInfo);
|
||||
formatInternal("%a %b %e %H:%M:%S %Z %Y", wallTime, zoneInfoData);
|
||||
return false;
|
||||
case '%':
|
||||
// If conversion char is undefined, behavior is undefined. Print out the
|
||||
|
||||
@@ -50,14 +50,14 @@ public final class TzDataSetVersion {
|
||||
* Returns the major tz data format version supported by this device.
|
||||
*/
|
||||
public static int currentFormatMajorVersion() {
|
||||
return libcore.timezone.TzDataSetVersion.currentFormatMajorVersion();
|
||||
return com.android.i18n.timezone.TzDataSetVersion.currentFormatMajorVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minor tz data format version supported by this device.
|
||||
*/
|
||||
public static int currentFormatMinorVersion() {
|
||||
return libcore.timezone.TzDataSetVersion.currentFormatMinorVersion();
|
||||
return com.android.i18n.timezone.TzDataSetVersion.currentFormatMinorVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ public final class TzDataSetVersion {
|
||||
* with the current system image, and set of active modules.
|
||||
*/
|
||||
public static boolean isCompatibleWithThisDevice(TzDataSetVersion tzDataSetVersion) {
|
||||
return libcore.timezone.TzDataSetVersion.isCompatibleWithThisDevice(
|
||||
return com.android.i18n.timezone.TzDataSetVersion.isCompatibleWithThisDevice(
|
||||
tzDataSetVersion.mDelegate);
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ public final class TzDataSetVersion {
|
||||
public static TzDataSetVersion read() throws IOException, TzDataSetException {
|
||||
try {
|
||||
return new TzDataSetVersion(
|
||||
libcore.timezone.TzDataSetVersion.readTimeZoneModuleVersion());
|
||||
} catch (libcore.timezone.TzDataSetVersion.TzDataSetException e) {
|
||||
com.android.i18n.timezone.TzDataSetVersion.readTimeZoneModuleVersion());
|
||||
} catch (com.android.i18n.timezone.TzDataSetVersion.TzDataSetException e) {
|
||||
throw new TzDataSetException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
@@ -100,9 +100,9 @@ public final class TzDataSetVersion {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private final libcore.timezone.TzDataSetVersion mDelegate;
|
||||
private final com.android.i18n.timezone.TzDataSetVersion mDelegate;
|
||||
|
||||
private TzDataSetVersion(@NonNull libcore.timezone.TzDataSetVersion delegate) {
|
||||
private TzDataSetVersion(@NonNull com.android.i18n.timezone.TzDataSetVersion delegate) {
|
||||
mDelegate = Objects.requireNonNull(delegate);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,16 +41,16 @@ public final class ZoneInfoDb {
|
||||
public static ZoneInfoDb getInstance() {
|
||||
synchronized (sLock) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new ZoneInfoDb(libcore.timezone.ZoneInfoDb.getInstance());
|
||||
sInstance = new ZoneInfoDb(com.android.i18n.timezone.ZoneInfoDb.getInstance());
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private final libcore.timezone.ZoneInfoDb mDelegate;
|
||||
private final com.android.i18n.timezone.ZoneInfoDb mDelegate;
|
||||
|
||||
private ZoneInfoDb(libcore.timezone.ZoneInfoDb delegate) {
|
||||
private ZoneInfoDb(com.android.i18n.timezone.ZoneInfoDb delegate) {
|
||||
mDelegate = Objects.requireNonNull(delegate);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,11 @@ import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.android.i18n.timezone.ZoneInfoDb;
|
||||
|
||||
import libcore.timezone.CountryTimeZones;
|
||||
import libcore.timezone.CountryTimeZones.TimeZoneMapping;
|
||||
import libcore.timezone.TimeZoneFinder;
|
||||
import libcore.timezone.ZoneInfoDb;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
@@ -23,10 +23,9 @@ import android.service.runtime.RuntimeServiceInfoProto;
|
||||
import android.util.Slog;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import libcore.timezone.TimeZoneDataFiles;
|
||||
import libcore.util.CoreLibraryDebug;
|
||||
import libcore.util.DebugInfo;
|
||||
|
||||
import com.android.i18n.timezone.DebugInfo;
|
||||
import com.android.i18n.timezone.I18nModuleDebug;
|
||||
import com.android.i18n.timezone.TimeZoneDataFiles;
|
||||
import com.android.internal.util.DumpUtils;
|
||||
import com.android.timezone.distro.DistroException;
|
||||
import com.android.timezone.distro.DistroVersion;
|
||||
@@ -61,14 +60,14 @@ public class RuntimeService extends Binder {
|
||||
boolean protoFormat = hasOption(args, "--proto");
|
||||
ProtoOutputStream proto = null;
|
||||
|
||||
DebugInfo coreLibraryDebugInfo = CoreLibraryDebug.getDebugInfo();
|
||||
addTimeZoneApkDebugInfo(coreLibraryDebugInfo);
|
||||
DebugInfo i18nLibraryDebugInfo = I18nModuleDebug.getDebugInfo();
|
||||
addTimeZoneApkDebugInfo(i18nLibraryDebugInfo);
|
||||
|
||||
if (protoFormat) {
|
||||
proto = new ProtoOutputStream(fd);
|
||||
reportTimeZoneInfoProto(coreLibraryDebugInfo, proto);
|
||||
reportTimeZoneInfoProto(i18nLibraryDebugInfo, proto);
|
||||
} else {
|
||||
reportTimeZoneInfo(coreLibraryDebugInfo, pw);
|
||||
reportTimeZoneInfo(i18nLibraryDebugInfo, pw);
|
||||
}
|
||||
|
||||
if (protoFormat) {
|
||||
|
||||
@@ -37,6 +37,9 @@ import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.i18n.timezone.TimeZoneDataFiles;
|
||||
import com.android.i18n.timezone.TzDataSetVersion;
|
||||
import com.android.i18n.timezone.ZoneInfoDb;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.server.EventLogTags;
|
||||
import com.android.server.SystemService;
|
||||
@@ -46,10 +49,7 @@ import com.android.timezone.distro.StagedDistroOperation;
|
||||
import com.android.timezone.distro.TimeZoneDistro;
|
||||
import com.android.timezone.distro.installer.TimeZoneDistroInstaller;
|
||||
|
||||
import libcore.timezone.TimeZoneDataFiles;
|
||||
import libcore.timezone.TimeZoneFinder;
|
||||
import libcore.timezone.TzDataSetVersion;
|
||||
import libcore.timezone.ZoneInfoDb;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
|
||||
@@ -74,6 +74,7 @@ import android.view.WindowManager;
|
||||
import android.view.contentcapture.ContentCaptureManager;
|
||||
import android.view.inputmethod.InputMethodSystemProperty;
|
||||
|
||||
import com.android.i18n.timezone.ZoneInfoDb;
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.notification.SystemNotificationChannels;
|
||||
@@ -165,8 +166,6 @@ import com.android.server.wm.ActivityTaskManagerService;
|
||||
import com.android.server.wm.WindowManagerGlobalLock;
|
||||
import com.android.server.wm.WindowManagerService;
|
||||
|
||||
import libcore.timezone.ZoneInfoDb;
|
||||
|
||||
import dalvik.system.VMRuntime;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -43,13 +43,13 @@ import android.app.timezone.RulesManager;
|
||||
import android.app.timezone.RulesState;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
|
||||
import com.android.i18n.timezone.TzDataSetVersion;
|
||||
import com.android.timezone.distro.DistroVersion;
|
||||
import com.android.timezone.distro.StagedDistroOperation;
|
||||
import com.android.timezone.distro.TimeZoneDistro;
|
||||
import com.android.timezone.distro.installer.TimeZoneDistroInstaller;
|
||||
|
||||
import libcore.io.IoUtils;
|
||||
import libcore.timezone.TzDataSetVersion;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
Reference in New Issue
Block a user