Skip to content

Commit cf7c9dd

Browse files
committed
ref(android): Deprecate AndroidDateUtils.getCurrentSentryDateTime (JAVA-571)
Its own javadoc already told callers to prefer options.getDateProvider(); this makes the compiler say so. The static holder cannot be configured or stubbed, which is the whole reason the note was there. Annotated on the method rather than the class, for the same import reason as the current-date providers.
1 parent 545c4c3 commit cf7c9dd

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎sentry-android-core/src/main/java/io/sentry/android/core/ActivityLifecycleIntegration.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@ private void finishTransaction(
549549
}
550550
}
551551

552+
// TODO [MAJOR]: replace AndroidDateUtils.getCurrentSentryDateTime() with
553+
// options.getDateProvider().now()
554+
@SuppressWarnings("deprecation")
552555
@Override
553556
public void onActivityPreCreated(
554557
final @NotNull Activity activity, final @Nullable Bundle savedInstanceState) {
@@ -604,6 +607,9 @@ public void onActivityPostCreated(
604607
}
605608
}
606609

610+
// TODO [MAJOR]: replace AndroidDateUtils.getCurrentSentryDateTime() with
611+
// options.getDateProvider().now()
612+
@SuppressWarnings("deprecation")
607613
@Override
608614
public void onActivityPreStarted(final @NotNull Activity activity) {
609615
final ActivityLifecycleSpanHelper helper = activitySpanHelpers.get(activity);
@@ -672,6 +678,9 @@ public void onActivityPostResumed(@NotNull Activity activity) {
672678
// empty override, required to avoid a api-level breaking super.onActivityPostResumed() calls
673679
}
674680

681+
// TODO [MAJOR]: replace AndroidDateUtils.getCurrentSentryDateTime() with
682+
// options.getDateProvider().now()
683+
@SuppressWarnings("deprecation")
675684
@Override
676685
public void onActivityPrePaused(@NotNull Activity activity) {
677686
// only executed if API >= 29 otherwise it happens on onActivityPaused
@@ -1094,6 +1103,9 @@ private void onHeadlessAppStart() {
10941103
* Standalone-only: this is only registered as a listener when standalone app start tracing is
10951104
* enabled.
10961105
*/
1106+
// TODO [MAJOR]: replace AndroidDateUtils.getCurrentSentryDateTime() with
1107+
// options.getDateProvider().now()
1108+
@SuppressWarnings("deprecation")
10971109
private @Nullable AppStartExtension.ExtendedAppStart onExtendAppStartRequested() {
10981110
if (scopes == null
10991111
|| options == null

‎sentry-android-core/src/main/java/io/sentry/android/core/AndroidDateUtils.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ public final class AndroidDateUtils {
1717
* invocations.
1818
*
1919
* @return the UTC SentryDate
20+
* @deprecated use {@code options.getDateProvider()}. This static holder cannot be configured or
21+
* stubbed, which is why the note above already asked callers to prefer the options.
2022
*/
23+
@Deprecated
2124
public static @NotNull SentryDate getCurrentSentryDateTime() {
2225
return dateProvider.now();
2326
}

‎sentry-android-core/src/main/java/io/sentry/android/core/performance/ActivityLifecycleSpanHelper.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public void createAndStopOnStartSpan(final @Nullable ISpan parentSpan) {
6969
return onStartStartTimestamp;
7070
}
7171

72+
// TODO [MAJOR]: replace AndroidDateUtils.getCurrentSentryDateTime() with
73+
// options.getDateProvider().now()
74+
@SuppressWarnings("deprecation")
7275
public void saveSpanToAppStartMetrics() {
7376
if (onCreateSpan == null || onStartSpan == null) {
7477
return;

0 commit comments

Comments
 (0)