Merge "Be more defensive around invalid tzids" am: f60c302dad am: 96c57398b4

Change-Id: If8695ee257155eaedc901aa797f1939eab0c721e
This commit is contained in:
Neil Fuller
2020-05-26 10:54:50 +00:00
committed by Automerger Merge Worker
3 changed files with 19 additions and 22 deletions

View File

@@ -180,6 +180,8 @@ 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 com.google.android.startop.iorap.IorapForwardingService;
@@ -438,8 +440,9 @@ public final class SystemServer {
// Default the timezone property to GMT if not set.
//
String timezoneProperty = SystemProperties.get("persist.sys.timezone");
if (timezoneProperty == null || timezoneProperty.isEmpty()) {
Slog.w(TAG, "Timezone not set; setting to GMT.");
if (!isValidTimeZoneId(timezoneProperty)) {
Slog.w(TAG, "persist.sys.timezone is not valid (" + timezoneProperty
+ "); setting to GMT.");
SystemProperties.set("persist.sys.timezone", "GMT");
}
@@ -617,6 +620,12 @@ public final class SystemServer {
throw new RuntimeException("Main thread loop unexpectedly exited");
}
private static boolean isValidTimeZoneId(String timezoneProperty) {
return timezoneProperty != null
&& !timezoneProperty.isEmpty()
&& ZoneInfoDb.getInstance().hasTimeZone(timezoneProperty);
}
private boolean isFirstBootOrUpgrade() {
return mPackageManagerService.isFirstBoot() || mPackageManagerService.isDeviceUpgrading();
}