Skip to content

Commit 9ac0631

Browse files
authored
Merge 23a841c into cf708bd
2 parents cf708bd + 23a841c commit 9ac0631

File tree

5 files changed

+18
-25
lines changed

5 files changed

+18
-25
lines changed

sentry-android-distribution/api/sentry-android-distribution.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
public final class io/sentry/android/distribution/DistributionIntegration : io/sentry/IDistributionApi, io/sentry/Integration {
22
public fun <init> (Landroid/content/Context;)V
3-
public fun checkForUpdate (Lio/sentry/IDistributionApi$UpdateCallback;)V
3+
public fun checkForUpdate ()Ljava/util/concurrent/Future;
44
public fun checkForUpdateBlocking ()Lio/sentry/UpdateStatus;
55
public fun downloadUpdate (Lio/sentry/UpdateInfo;)V
66
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V

sentry-android-distribution/src/main/java/io/sentry/android/distribution/DistributionIntegration.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,12 @@ public class DistributionIntegration(context: Context) : Integration, IDistribut
8484
}
8585

8686
/**
87-
* Check for available updates asynchronously using a callback.
87+
* Check for available updates asynchronously.
8888
*
89-
* @param onResult Callback that will be called with the UpdateStatus result
89+
* @return Future that will resolve to an UpdateStatus result
9090
*/
91-
public override fun checkForUpdate(onResult: IDistributionApi.UpdateCallback) {
92-
// TODO implement this in a async way
93-
val result = checkForUpdateBlocking()
94-
onResult.onResult(result)
91+
public override fun checkForUpdate(): java.util.concurrent.Future<UpdateStatus> {
92+
return sentryOptions.executorService.submit<UpdateStatus> { checkForUpdateBlocking() }
9593
}
9694

9795
/**

sentry/api/sentry.api

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -776,15 +776,11 @@ public abstract interface class io/sentry/IContinuousProfiler {
776776
}
777777

778778
public abstract interface class io/sentry/IDistributionApi {
779-
public abstract fun checkForUpdate (Lio/sentry/IDistributionApi$UpdateCallback;)V
779+
public abstract fun checkForUpdate ()Ljava/util/concurrent/Future;
780780
public abstract fun checkForUpdateBlocking ()Lio/sentry/UpdateStatus;
781781
public abstract fun downloadUpdate (Lio/sentry/UpdateInfo;)V
782782
}
783783

784-
public abstract interface class io/sentry/IDistributionApi$UpdateCallback {
785-
public abstract fun onResult (Lio/sentry/UpdateStatus;)V
786-
}
787-
788784
public abstract interface class io/sentry/IEnvelopeReader {
789785
public abstract fun read (Ljava/io/InputStream;)Lio/sentry/SentryEnvelope;
790786
}
@@ -1493,7 +1489,7 @@ public final class io/sentry/NoOpContinuousProfiler : io/sentry/IContinuousProfi
14931489
}
14941490

14951491
public final class io/sentry/NoOpDistributionApi : io/sentry/IDistributionApi {
1496-
public fun checkForUpdate (Lio/sentry/IDistributionApi$UpdateCallback;)V
1492+
public fun checkForUpdate ()Ljava/util/concurrent/Future;
14971493
public fun checkForUpdateBlocking ()Lio/sentry/UpdateStatus;
14981494
public fun downloadUpdate (Lio/sentry/UpdateInfo;)V
14991495
public static fun getInstance ()Lio/sentry/NoOpDistributionApi;
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sentry;
22

3+
import java.util.concurrent.Future;
34
import org.jetbrains.annotations.ApiStatus;
45
import org.jetbrains.annotations.NotNull;
56

@@ -14,20 +15,21 @@ public interface IDistributionApi {
1415

1516
/**
1617
* Check for available updates synchronously (blocking call). This method will block the calling
17-
* thread while making the network request. Consider using checkForUpdate with callback for
18-
* non-blocking behavior.
18+
* thread while making the network request. Consider using checkForUpdate for non-blocking
19+
* behavior.
1920
*
2021
* @return UpdateStatus indicating if an update is available, up to date, or error
2122
*/
2223
@NotNull
2324
UpdateStatus checkForUpdateBlocking();
2425

2526
/**
26-
* Check for available updates asynchronously using a callback.
27+
* Check for available updates asynchronously.
2728
*
28-
* @param onResult Callback that will be called with the UpdateStatus result
29+
* @return Future that will resolve to an UpdateStatus result
2930
*/
30-
void checkForUpdate(@NotNull UpdateCallback onResult);
31+
@NotNull
32+
Future<UpdateStatus> checkForUpdate();
3133

3234
/**
3335
* Download and install the provided update by opening the download URL in the default browser or
@@ -36,9 +38,4 @@ public interface IDistributionApi {
3638
* @param info Information about the update to download
3739
*/
3840
void downloadUpdate(@NotNull UpdateInfo info);
39-
40-
/** Callback interface for receiving async update check results. */
41-
interface UpdateCallback {
42-
void onResult(@NotNull UpdateStatus status);
43-
}
4441
}

sentry/src/main/java/io/sentry/NoOpDistributionApi.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.sentry;
22

3+
import java.util.concurrent.CompletableFuture;
4+
import java.util.concurrent.Future;
35
import org.jetbrains.annotations.ApiStatus;
46
import org.jetbrains.annotations.NotNull;
57

@@ -21,8 +23,8 @@ public static NoOpDistributionApi getInstance() {
2123
}
2224

2325
@Override
24-
public void checkForUpdate(@NotNull UpdateCallback onResult) {
25-
// No-op implementation - do nothing
26+
public @NotNull Future<UpdateStatus> checkForUpdate() {
27+
return CompletableFuture.completedFuture(UpdateStatus.UpToDate.getInstance());
2628
}
2729

2830
@Override

0 commit comments

Comments
 (0)