Add a method to clear the cached default timezone.

Adds clearCacheDefault() method that clears the cached timezone. This
method is hidden from the public API and will only be used by
java.util.TimeZone to ensure that ICU has the same view of what the
default timezone is as java.util.TimeZone.

This (together with the corresponding change in libcore) means that the
calling android.icu.util.TimeZone.setDefault() with a value foo does not
guarantee that the ICU default timezone after the call is equal to foo
since the value will be conferted to a JDK-equivalent in ICU
TimeZone.setDefault() and back to a ICU equivalent in ICU
TimeZone.getDefault(). Both of these processes are potentially lossy.

Background:

When java.util.TimeZone.setDefault() is called (either by client code or
from ActivityThread.updateTimeZone due to ACTION_TIMEZONE_CHANGED) we
need to notify android.icu.util.TimeZone of this change, as it keeps a
cached android.icu.util.TimeZone object to represent that default value.

android.icu.util.TimeZone.setTimeZone would be the obvious candidate
here. Unfortunately that method was hidden to have a single consistent
way to set the timezone and tries to do some extra work that is
undesireable on Android.

Bug: 28949992
Change-Id: Id9edb80ff255bfac39e2fadcba829474352e4620
5 files changed