diff options
23 files changed, 181 insertions, 133 deletions
diff --git a/cmds/statsd/src/anomaly/AlarmTracker.cpp b/cmds/statsd/src/anomaly/AlarmTracker.cpp index 019a9f7e5f9a..a21327b4aae0 100644 --- a/cmds/statsd/src/anomaly/AlarmTracker.cpp +++ b/cmds/statsd/src/anomaly/AlarmTracker.cpp @@ -61,11 +61,11 @@ void AlarmTracker::addSubscription(const Subscription& subscription) { } int64_t AlarmTracker::findNextAlarmSec(int64_t currentTimeSec) { - if (currentTimeSec <= mAlarmSec) { + if (currentTimeSec < mAlarmSec) { return mAlarmSec; } int64_t periodsForward = - ((currentTimeSec - mAlarmSec) * MS_PER_SEC - 1) / mAlarmConfig.period_millis() + 1; + ((currentTimeSec - mAlarmSec) * MS_PER_SEC) / mAlarmConfig.period_millis() + 1; return mAlarmSec + periodsForward * mAlarmConfig.period_millis() / MS_PER_SEC; } diff --git a/cmds/statsd/tests/anomaly/AlarmTracker_test.cpp b/cmds/statsd/tests/anomaly/AlarmTracker_test.cpp index 5e6de1cc6b91..e664023a1647 100644 --- a/cmds/statsd/tests/anomaly/AlarmTracker_test.cpp +++ b/cmds/statsd/tests/anomaly/AlarmTracker_test.cpp @@ -40,23 +40,47 @@ TEST(AlarmTrackerTest, TestTriggerTimestamp) { alarm.set_offset_millis(15 * MS_PER_SEC); alarm.set_period_millis(60 * 60 * MS_PER_SEC); // 1hr int64_t startMillis = 100000000 * MS_PER_SEC; + int64_t nextAlarmTime = startMillis / MS_PER_SEC + 15; AlarmTracker tracker(startMillis, startMillis, alarm, kConfigKey, subscriberAlarmMonitor); - EXPECT_EQ(tracker.mAlarmSec, (int64_t)(startMillis / MS_PER_SEC + 15)); + EXPECT_EQ(tracker.mAlarmSec, nextAlarmTime); uint64_t currentTimeSec = startMillis / MS_PER_SEC + 10; std::unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>> firedAlarmSet = subscriberAlarmMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec)); EXPECT_TRUE(firedAlarmSet.empty()); tracker.informAlarmsFired(currentTimeSec * NS_PER_SEC, firedAlarmSet); - EXPECT_EQ(tracker.mAlarmSec, (int64_t)(startMillis / MS_PER_SEC + 15)); + EXPECT_EQ(tracker.mAlarmSec, nextAlarmTime); + EXPECT_EQ(tracker.getAlarmTimestampSec(), nextAlarmTime); currentTimeSec = startMillis / MS_PER_SEC + 7000; + nextAlarmTime = startMillis / MS_PER_SEC + 15 + 2 * 60 * 60; firedAlarmSet = subscriberAlarmMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec)); EXPECT_EQ(firedAlarmSet.size(), 1u); tracker.informAlarmsFired(currentTimeSec * NS_PER_SEC, firedAlarmSet); EXPECT_TRUE(firedAlarmSet.empty()); - EXPECT_EQ(tracker.mAlarmSec, (int64_t)(startMillis / MS_PER_SEC + 15 + 2 * 60 * 60)); + EXPECT_EQ(tracker.mAlarmSec, nextAlarmTime); + EXPECT_EQ(tracker.getAlarmTimestampSec(), nextAlarmTime); + + // Alarm fires exactly on time. + currentTimeSec = startMillis / MS_PER_SEC + 15 + 2 * 60 * 60; + nextAlarmTime = startMillis / MS_PER_SEC + 15 + 3 * 60 * 60; + firedAlarmSet = subscriberAlarmMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec)); + ASSERT_EQ(firedAlarmSet.size(), 1u); + tracker.informAlarmsFired(currentTimeSec * NS_PER_SEC, firedAlarmSet); + EXPECT_TRUE(firedAlarmSet.empty()); + EXPECT_EQ(tracker.mAlarmSec, nextAlarmTime); + EXPECT_EQ(tracker.getAlarmTimestampSec(), nextAlarmTime); + + // Alarm fires exactly 1 period late. + currentTimeSec = startMillis / MS_PER_SEC + 15 + 4 * 60 * 60; + nextAlarmTime = startMillis / MS_PER_SEC + 15 + 5 * 60 * 60; + firedAlarmSet = subscriberAlarmMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec)); + ASSERT_EQ(firedAlarmSet.size(), 1u); + tracker.informAlarmsFired(currentTimeSec * NS_PER_SEC, firedAlarmSet); + EXPECT_TRUE(firedAlarmSet.empty()); + EXPECT_EQ(tracker.mAlarmSec, nextAlarmTime); + EXPECT_EQ(tracker.getAlarmTimestampSec(), nextAlarmTime); } } // namespace statsd diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 4f1d7f2c761c..262051d0af1e 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -215,8 +215,8 @@ import java.util.function.Consumer; * <a name="Fragments"></a> * <h3>Fragments</h3> * - * <p>The {@link android.support.v4.app.FragmentActivity} subclass - * can make use of the {@link android.support.v4.app.Fragment} class to better + * <p>The {@link androidx.fragment.app.FragmentActivity} subclass + * can make use of the {@link androidx.fragment.app.Fragment} class to better * modularize their code, build more sophisticated user interfaces for larger * screens, and help scale their application between small and large screens.</p> * @@ -1003,7 +1003,7 @@ public class Activity extends ContextThemeWrapper /** * Return the LoaderManager for this activity, creating it if needed. * - * @deprecated Use {@link android.support.v4.app.FragmentActivity#getSupportLoaderManager()} + * @deprecated Use {@link androidx.fragment.app.FragmentActivity#getSupportLoaderManager()} */ @Deprecated public LoaderManager getLoaderManager() { @@ -3022,7 +3022,7 @@ public class Activity extends ContextThemeWrapper * Return the FragmentManager for interacting with fragments associated * with this activity. * - * @deprecated Use {@link android.support.v4.app.FragmentActivity#getSupportFragmentManager()} + * @deprecated Use {@link androidx.fragment.app.FragmentActivity#getSupportFragmentManager()} */ @Deprecated public FragmentManager getFragmentManager() { @@ -3035,7 +3035,7 @@ public class Activity extends ContextThemeWrapper * method and before {@link Fragment#onCreate Fragment.onCreate()}. * * @deprecated Use {@link - * android.support.v4.app.FragmentActivity#onAttachFragment(android.support.v4.app.Fragment)} + * androidx.fragment.app.FragmentActivity#onAttachFragment(androidx.fragment.app.Fragment)} */ @Deprecated public void onAttachFragment(Fragment fragment) { @@ -5847,8 +5847,8 @@ public class Activity extends ContextThemeWrapper * @see Fragment#startActivity * @see Fragment#startActivityForResult * - * @deprecated Use {@link android.support.v4.app.FragmentActivity#startActivityFromFragment( - * android.support.v4.app.Fragment,Intent,int)} + * @deprecated Use {@link androidx.fragment.app.FragmentActivity#startActivityFromFragment( + * androidx.fragment.app.Fragment,Intent,int)} */ @Deprecated public void startActivityFromFragment(@NonNull Fragment fragment, @@ -5876,8 +5876,8 @@ public class Activity extends ContextThemeWrapper * @see Fragment#startActivity * @see Fragment#startActivityForResult * - * @deprecated Use {@link android.support.v4.app.FragmentActivity#startActivityFromFragment( - * android.support.v4.app.Fragment,Intent,int,Bundle)} + * @deprecated Use {@link androidx.fragment.app.FragmentActivity#startActivityFromFragment( + * androidx.fragment.app.Fragment,Intent,int,Bundle)} */ @Deprecated public void startActivityFromFragment(@NonNull Fragment fragment, diff --git a/core/java/android/app/AlarmManager.java b/core/java/android/app/AlarmManager.java index 647f63025cf7..febb293921cd 100644 --- a/core/java/android/app/AlarmManager.java +++ b/core/java/android/app/AlarmManager.java @@ -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; diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java index c6a0de458df0..da3bc681ed34 100644 --- a/core/java/android/app/Fragment.java +++ b/core/java/android/app/Fragment.java @@ -102,7 +102,7 @@ import java.lang.reflect.InvocationTargetException; * While the Fragment API was introduced in * {@link android.os.Build.VERSION_CODES#HONEYCOMB}, a version of the API * at is also available for use on older platforms through - * {@link android.support.v4.app.FragmentActivity}. See the blog post + * {@link androidx.fragment.app.FragmentActivity}. See the blog post * <a href="http://android-developers.blogspot.com/2011/03/fragments-for-all.html"> * Fragments For All</a> for more details. * @@ -258,8 +258,8 @@ import java.lang.reflect.InvocationTargetException; * pressing back will pop it to return the user to whatever previous state * the activity UI was in. * - * @deprecated Use the <a href="{@docRoot}tools/extras/support-library.html">Support Library</a> - * {@link android.support.v4.app.Fragment} for consistent behavior across all devices + * @deprecated Use the <a href="{@docRoot}jetpack">Jetpack Fragment Library</a> + * {@link androidx.fragment.app.Fragment} for consistent behavior across all devices * and access to <a href="{@docRoot}topic/libraries/architecture/lifecycle.html">Lifecycle</a>. */ @Deprecated @@ -432,7 +432,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene * through {@link FragmentManager#saveFragmentInstanceState(Fragment) * FragmentManager.saveFragmentInstanceState}. * - * @deprecated Use {@link android.support.v4.app.Fragment.SavedState} + * @deprecated Use {@link androidx.fragment.app.Fragment.SavedState} */ @Deprecated public static class SavedState implements Parcelable { @@ -479,7 +479,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene * Thrown by {@link Fragment#instantiate(Context, String, Bundle)} when * there is an instantiation failure. * - * @deprecated Use {@link android.support.v4.app.Fragment.InstantiationException} + * @deprecated Use {@link androidx.fragment.app.Fragment.InstantiationException} */ @Deprecated static public class InstantiationException extends AndroidRuntimeException { @@ -1055,7 +1055,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene /** * Return the LoaderManager for this fragment, creating it if needed. * - * @deprecated Use {@link android.support.v4.app.Fragment#getLoaderManager()} + * @deprecated Use {@link androidx.fragment.app.Fragment#getLoaderManager()} */ @Deprecated public LoaderManager getLoaderManager() { diff --git a/core/java/android/text/format/Time.java b/core/java/android/text/format/Time.java index 8e8409d15143..e7339380df69 100644 --- a/core/java/android/text/format/Time.java +++ b/core/java/android/text/format/Time.java @@ -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) { diff --git a/core/java/android/text/format/TimeFormatter.java b/core/java/android/text/format/TimeFormatter.java index f7fd89d7d819..cd541f2b829f 100644 --- a/core/java/android/text/format/TimeFormatter.java +++ b/core/java/android/text/format/TimeFormatter.java @@ -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 diff --git a/core/java/android/timezone/TzDataSetVersion.java b/core/java/android/timezone/TzDataSetVersion.java index f993012aeb1c..e1fb932b977d 100644 --- a/core/java/android/timezone/TzDataSetVersion.java +++ b/core/java/android/timezone/TzDataSetVersion.java @@ -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); } diff --git a/core/java/android/timezone/ZoneInfoDb.java b/core/java/android/timezone/ZoneInfoDb.java index 9354a695812d..65d6eaddf824 100644 --- a/core/java/android/timezone/ZoneInfoDb.java +++ b/core/java/android/timezone/ZoneInfoDb.java @@ -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); } diff --git a/core/java/android/util/TimeUtils.java b/core/java/android/util/TimeUtils.java index 6e41fc8017c1..b2766a44e036 100644 --- a/core/java/android/util/TimeUtils.java +++ b/core/java/android/util/TimeUtils.java @@ -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; diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index ad1f1f005baa..3d73ade33d5b 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -3064,6 +3064,11 @@ empty string is passed in --> <string name="config_wlan_data_service_package" translatable="false"></string> + <!-- Boolean indicating whether the Iwlan data service supports persistence of iwlan ipsec + tunnels across service restart. If iwlan tunnels are not persisted across restart, + Framework will clean up dangling data connections when service restarts --> + <bool name="config_wlan_data_service_conn_persistence_on_restart">true</bool> + <!-- Cellular data service class name to bind to by default. If none is specified in an overlay, an empty string is passed in --> <string name="config_wwan_data_service_class" translatable="false"></string> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index b0ee810fee41..ece65ff21487 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -298,6 +298,7 @@ <java-symbol type="string" name="config_wlan_network_service_package" /> <java-symbol type="string" name="config_wwan_network_service_class" /> <java-symbol type="string" name="config_wlan_network_service_class" /> + <java-symbol type="bool" name="config_wlan_data_service_conn_persistence_on_restart" /> <java-symbol type="string" name="config_wwan_data_service_package" /> <java-symbol type="string" name="config_wlan_data_service_package" /> <java-symbol type="string" name="config_wwan_data_service_class" /> diff --git a/media/jni/audioeffect/Visualizer.cpp b/media/jni/audioeffect/Visualizer.cpp index efeb3352d393..f4d65d0a397f 100644 --- a/media/jni/audioeffect/Visualizer.cpp +++ b/media/jni/audioeffect/Visualizer.cpp @@ -25,6 +25,7 @@ #include <limits.h> #include <audio_utils/fixedfft.h> +#include <cutils/bitops.h> #include <utils/Thread.h> #include "Visualizer.h" diff --git a/packages/Tethering/jarjar-rules.txt b/packages/Tethering/jarjar-rules.txt index 8f072e4cd217..2c4059dda9b5 100644 --- a/packages/Tethering/jarjar-rules.txt +++ b/packages/Tethering/jarjar-rules.txt @@ -12,7 +12,7 @@ rule com.android.internal.util.State* com.android.networkstack.tethering.util.St rule com.android.internal.util.StateMachine* com.android.networkstack.tethering.util.StateMachine@1 rule com.android.internal.util.TrafficStatsConstants* com.android.networkstack.tethering.util.TrafficStatsConstants@1 -rule android.net.LocalLog* com.android.networkstack.tethering.LocalLog@1 +rule android.util.LocalLog* com.android.networkstack.tethering.util.LocalLog@1 rule android.net.shared.Inet4AddressUtils* com.android.networkstack.tethering.shared.Inet4AddressUtils@1 diff --git a/packages/Tethering/tests/unit/jarjar-rules.txt b/packages/Tethering/tests/unit/jarjar-rules.txt index 1ea56cdf1a3d..ec2d2b02004e 100644 --- a/packages/Tethering/tests/unit/jarjar-rules.txt +++ b/packages/Tethering/tests/unit/jarjar-rules.txt @@ -8,4 +8,4 @@ rule com.android.internal.util.State* com.android.networkstack.tethering.util.St rule com.android.internal.util.StateMachine* com.android.networkstack.tethering.util.StateMachine@1 rule com.android.internal.util.TrafficStatsConstants* com.android.networkstack.tethering.util.TrafficStatsConstants@1 -rule android.net.LocalLog* com.android.networkstack.tethering.LocalLog@1 +rule android.util.LocalLog* com.android.networkstack.tethering.util.LocalLog@1 diff --git a/services/core/java/com/android/server/RuntimeService.java b/services/core/java/com/android/server/RuntimeService.java index bb39ccc52af2..f4249f844873 100644 --- a/services/core/java/com/android/server/RuntimeService.java +++ b/services/core/java/com/android/server/RuntimeService.java @@ -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) { diff --git a/services/core/java/com/android/server/timezone/RulesManagerService.java b/services/core/java/com/android/server/timezone/RulesManagerService.java index bbd1ae60cb62..d4a71ed27549 100644 --- a/services/core/java/com/android/server/timezone/RulesManagerService.java +++ b/services/core/java/com/android/server/timezone/RulesManagerService.java @@ -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; diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 23b1512081da..c48ee11237e9 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -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; diff --git a/services/tests/servicestests/src/com/android/server/timezone/RulesManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/timezone/RulesManagerServiceTest.java index 5c6fe0fc4cad..2c4c4d0ee91f 100644 --- a/services/tests/servicestests/src/com/android/server/timezone/RulesManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/timezone/RulesManagerServiceTest.java @@ -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; diff --git a/telephony/common/com/android/internal/telephony/SmsApplication.java b/telephony/common/com/android/internal/telephony/SmsApplication.java index 1a049e6c517e..d69282579b77 100644 --- a/telephony/common/com/android/internal/telephony/SmsApplication.java +++ b/telephony/common/com/android/internal/telephony/SmsApplication.java @@ -542,13 +542,16 @@ public final class SmsApplication { // Assign permission to special system apps assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps, - PHONE_PACKAGE_NAME); + PHONE_PACKAGE_NAME, true); assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps, - BLUETOOTH_PACKAGE_NAME); + BLUETOOTH_PACKAGE_NAME, true); assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps, - MMS_SERVICE_PACKAGE_NAME); + MMS_SERVICE_PACKAGE_NAME, true); assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps, - TELEPHONY_PROVIDER_PACKAGE_NAME); + TELEPHONY_PROVIDER_PACKAGE_NAME, true); + // CellbroadcastReceiver is a mainline module thus skip signature match. + assignExclusiveSmsPermissionsToSystemApp(context, packageManager, appOps, + CellBroadcastUtils.getDefaultCellBroadcastReceiverPackageName(context), false); // Give AppOps permission to UID 1001 which contains multiple // apps, all of them should be able to write to telephony provider. @@ -738,17 +741,23 @@ public final class SmsApplication { * @param packageManager The package manager instance * @param appOps The AppOps manager instance * @param packageName The package name of the system app + * @param sigatureMatch whether to check signature match */ private static void assignExclusiveSmsPermissionsToSystemApp(Context context, - PackageManager packageManager, AppOpsManager appOps, String packageName) { + PackageManager packageManager, AppOpsManager appOps, String packageName, + boolean sigatureMatch) { // First check package signature matches the caller's package signature. // Since this class is only used internally by the system, this check makes sure // the package signature matches system signature. - final int result = packageManager.checkSignatures(context.getPackageName(), packageName); - if (result != PackageManager.SIGNATURE_MATCH) { - Log.e(LOG_TAG, packageName + " does not have system signature"); - return; + if (sigatureMatch) { + final int result = packageManager.checkSignatures(context.getPackageName(), + packageName); + if (result != PackageManager.SIGNATURE_MATCH) { + Log.e(LOG_TAG, packageName + " does not have system signature"); + return; + } } + try { PackageInfo info = packageManager.getPackageInfo(packageName, 0); int mode = appOps.unsafeCheckOp(AppOpsManager.OPSTR_WRITE_SMS, info.applicationInfo.uid, diff --git a/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java b/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java index 7069e0ab9b1e..2cdf70e6cf4c 100644 --- a/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java +++ b/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java @@ -29,6 +29,7 @@ import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.util.RemoteCallbackListExt; +import com.android.internal.util.ArrayUtils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -105,6 +106,11 @@ public class ImsRegistrationImplBase { // Locked on mLock, create unspecified disconnect cause. private ImsReasonInfo mLastDisconnectCause = new ImsReasonInfo(); + // We hold onto the uris each time they change so that we can send it to a callback when its + // first added. + private Uri[] mUris = new Uri[0]; + private boolean mUrisSet = false; + /** * @hide */ @@ -208,19 +214,27 @@ public class ImsRegistrationImplBase { } /** - * The this device's subscriber associated {@link Uri}s have changed, which are used to filter - * out this device's {@link Uri}s during conference calling. - * @param uris + * Invoked when the {@link Uri}s associated to this device's subscriber have changed. + * These {@link Uri}s' are filtered out during conference calls. + * + * The {@link Uri}s are not guaranteed to be different between subsequent calls. + * @param uris changed uris */ public final void onSubscriberAssociatedUriChanged(Uri[] uris) { - mCallbacks.broadcastAction((c) -> { - try { - c.onSubscriberAssociatedUriChanged(uris); - } catch (RemoteException e) { - Log.w(LOG_TAG, e + " " + "onSubscriberAssociatedUriChanged() - Skipping " + - "callback."); - } - }); + synchronized (mLock) { + mUris = ArrayUtils.cloneOrNull(uris); + mUrisSet = true; + } + mCallbacks.broadcastAction((c) -> onSubscriberAssociatedUriChanged(c, uris)); + } + + private void onSubscriberAssociatedUriChanged(IImsRegistrationCallback callback, Uri[] uris) { + try { + callback.onSubscriberAssociatedUriChanged(uris); + } catch (RemoteException e) { + Log.w(LOG_TAG, e + " " + "onSubscriberAssociatedUriChanged() - Skipping " + + "callback."); + } } private void updateToState(@ImsRegistrationTech int connType, int newState) { @@ -233,6 +247,10 @@ public class ImsRegistrationImplBase { private void updateToDisconnectedState(ImsReasonInfo info) { synchronized (mLock) { + //We don't want to send this info over if we are disconnected + mUrisSet = false; + mUris = null; + updateToState(REGISTRATION_TECH_NONE, RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED); if (info != null) { @@ -260,12 +278,17 @@ public class ImsRegistrationImplBase { * @param c the newly registered callback that will be updated with the current registration * state. */ - private void updateNewCallbackWithState(IImsRegistrationCallback c) throws RemoteException { + private void updateNewCallbackWithState(IImsRegistrationCallback c) + throws RemoteException { int state; ImsReasonInfo disconnectInfo; + boolean urisSet; + Uri[] uris; synchronized (mLock) { state = mRegistrationState; disconnectInfo = mLastDisconnectCause; + urisSet = mUrisSet; + uris = mUris; } switch (state) { case RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED: { @@ -285,5 +308,8 @@ public class ImsRegistrationImplBase { break; } } + if (urisSet) { + onSubscriberAssociatedUriChanged(c, uris); + } } } diff --git a/tests/net/java/android/net/ipmemorystore/ParcelableTests.java b/tests/net/java/android/net/ipmemorystore/ParcelableTests.java index 1d3635709ec5..02f5286506a8 100644 --- a/tests/net/java/android/net/ipmemorystore/ParcelableTests.java +++ b/tests/net/java/android/net/ipmemorystore/ParcelableTests.java @@ -19,8 +19,6 @@ package android.net.ipmemorystore; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import android.net.quirks.IPv6ProvisioningLossQuirk; -import android.net.quirks.IPv6ProvisioningLossQuirkParcelable; import android.os.Parcel; import android.os.Parcelable; @@ -48,7 +46,7 @@ public class ParcelableTests { builder.setAssignedV4Address((Inet4Address) Inet4Address.getByName("1.2.3.4")); // lease will expire in two hours builder.setAssignedV4AddressExpiry(System.currentTimeMillis() + 7_200_000); - // cluster stays null this time around + // groupHint stays null this time around builder.setDnsAddresses(Collections.emptyList()); builder.setMtu(18); in = builder.build(); @@ -71,7 +69,7 @@ public class ParcelableTests { // Verify that this test does not miss any new field added later. // If any field is added to NetworkAttributes it must be tested here for parceling // roundtrip. - assertEquals(6, Arrays.stream(NetworkAttributes.class.getDeclaredFields()) + assertEquals(5, Arrays.stream(NetworkAttributes.class.getDeclaredFields()) .filter(f -> !Modifier.isStatic(f.getModifiers())).count()); } @@ -106,22 +104,6 @@ public class ParcelableTests { assertEquals(in.confidence, out.confidence, 0.01f /* delta */); } - @Test - public void testIPv6ProvisioningLossQuirkParceling() throws Exception { - final NetworkAttributes.Builder builder = new NetworkAttributes.Builder(); - final IPv6ProvisioningLossQuirkParcelable parcelable = - new IPv6ProvisioningLossQuirkParcelable(); - final long expiry = System.currentTimeMillis() + 7_200_000; - - parcelable.detectionCount = 3; - parcelable.quirkExpiry = expiry; // quirk info will expire in two hours - builder.setIpv6ProvLossQuirk(IPv6ProvisioningLossQuirk.fromStableParcelable(parcelable)); - final NetworkAttributes in = builder.build(); - - final NetworkAttributes out = new NetworkAttributes(parcelingRoundTrip(in.toParcelable())); - assertEquals(out.ipv6ProvLossQuirk, in.ipv6ProvLossQuirk); - } - private <T extends Parcelable> T parcelingRoundTrip(final T in) throws Exception { final Parcel p = Parcel.obtain(); in.writeToParcel(p, /* flags */ 0); diff --git a/tests/net/java/com/android/server/net/ipmemorystore/NetworkAttributesTest.java b/tests/net/java/com/android/server/net/ipmemorystore/NetworkAttributesTest.java index cdf4b3f94fa2..fb84611cb662 100644 --- a/tests/net/java/com/android/server/net/ipmemorystore/NetworkAttributesTest.java +++ b/tests/net/java/com/android/server/net/ipmemorystore/NetworkAttributesTest.java @@ -19,7 +19,6 @@ package com.android.server.net.ipmemorystore; import static org.junit.Assert.assertEquals; import android.net.ipmemorystore.NetworkAttributes; -import android.net.quirks.IPv6ProvisioningLossQuirk; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -53,8 +52,6 @@ public class NetworkAttributesTest { } assertEquals(sum, NetworkAttributes.TOTAL_WEIGHT, EPSILON); - final IPv6ProvisioningLossQuirk ipv6ProvLossQuirk = - new IPv6ProvisioningLossQuirk(3, System.currentTimeMillis() + 7_200_000); // Use directly the constructor with all attributes, and make sure that when compared // to itself the score is a clean 1.0f. final NetworkAttributes na = @@ -64,7 +61,7 @@ public class NetworkAttributesTest { "some hint", Arrays.asList(Inet4Address.getByAddress(new byte[] {5, 6, 7, 8}), Inet4Address.getByAddress(new byte[] {9, 0, 1, 2})), - 98, ipv6ProvLossQuirk); + 98); assertEquals(1.0f, na.getNetworkGroupSamenessConfidence(na), EPSILON); } } |