Skip to content

Commit b2dd6dd

Browse files
runningcodeclaude
andcommitted
feat(android-distribution): Address PR feedback
- Fix ActivityNotFoundException in downloadUpdate method - Update AndroidManifest provider to use shorter naming convention - Add EmptySecureContentProvider for security - Convert DistributionOptions from data class to regular class - Add initOrder comment explaining initialization sequence 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b60f232 commit b2dd6dd

File tree

4 files changed

+33
-42
lines changed

4 files changed

+33
-42
lines changed

sentry-android-distribution/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
<uses-permission android:name="android.permission.INTERNET" />
44

55
<application>
6+
<!-- Lower initOrder than SentryPerformanceProvider (200) to ensure initialization happens before performance monitoring -->
67
<provider
7-
android:name="io.sentry.android.distribution.DistributionContentProvider"
8-
android:authorities="${applicationId}.sentry-distribution-provider"
8+
android:name=".SentryDistributionProvider"
9+
android:authorities="${applicationId}.SentryDistributionProvider"
910
android:exported="false"
1011
android:initOrder="100" />
1112
</application>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ public object Distribution {
6565
public fun downloadUpdate(context: Context, info: UpdateInfo) {
6666
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(info.downloadUrl))
6767
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
68-
context.startActivity(browserIntent)
68+
69+
try {
70+
context.startActivity(browserIntent)
71+
} catch (e: android.content.ActivityNotFoundException) {
72+
// No application can handle the HTTP/HTTPS URL, typically no browser installed
73+
// Silently fail as this is expected behavior in some environments
74+
}
6975
}
7076
}
Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package io.sentry.android.distribution
22

3-
import android.content.ContentProvider
4-
import android.content.ContentValues
5-
import android.database.Cursor
6-
import android.net.Uri
3+
import io.sentry.android.core.EmptySecureContentProvider
74

85
/**
96
* ContentProvider that automatically initializes the Sentry Distribution SDK.
@@ -12,31 +9,9 @@ import android.net.Uri
129
* the Distribution SDK is available without requiring manual initialization in
1310
* Application.onCreate().
1411
*/
15-
public class DistributionContentProvider : ContentProvider() {
12+
public class SentryDistributionProvider : EmptySecureContentProvider() {
1613
override fun onCreate(): Boolean {
1714
// TODO: Automatic initialization will be implemented in future PR
1815
return true
1916
}
20-
21-
// Required ContentProvider methods (not used for initialization)
22-
override fun query(
23-
uri: Uri,
24-
projection: Array<String>?,
25-
selection: String?,
26-
selectionArgs: Array<String>?,
27-
sortOrder: String?,
28-
): Cursor? = null
29-
30-
override fun getType(uri: Uri): String? = null
31-
32-
override fun insert(uri: Uri, values: ContentValues?): Uri? = null
33-
34-
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<String>?): Int = 0
35-
36-
override fun update(
37-
uri: Uri,
38-
values: ContentValues?,
39-
selection: String?,
40-
selectionArgs: Array<String>?,
41-
): Int = 0
4217
}

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,26 @@ package io.sentry.android.distribution
22

33
/**
44
* Configuration options for Sentry Build Distribution.
5-
*
6-
* @param orgAuthToken Organization authentication token for API access
7-
* @param organizationSlug Sentry organization slug
8-
* @param projectSlug Sentry project slug
9-
* @param sentryBaseUrl Base URL for Sentry API (defaults to https://sentry.io)
10-
* @param buildConfiguration Optional build configuration name for filtering
115
*/
12-
public data class DistributionOptions(
13-
val orgAuthToken: String,
14-
val organizationSlug: String,
15-
val projectSlug: String,
16-
val sentryBaseUrl: String = "https://sentry.io",
17-
val buildConfiguration: String? = null,
6+
public class DistributionOptions(
7+
/**
8+
* Organization authentication token for API access
9+
*/
10+
public val orgAuthToken: String,
11+
/**
12+
* Sentry organization slug
13+
*/
14+
public val organizationSlug: String,
15+
/**
16+
* Sentry project slug
17+
*/
18+
public val projectSlug: String,
19+
/**
20+
* Base URL for Sentry API (defaults to https://sentry.io)
21+
*/
22+
public val sentryBaseUrl: String = "https://sentry.io",
23+
/**
24+
* Optional build configuration name for filtering
25+
*/
26+
public val buildConfiguration: String? = null,
1827
)

0 commit comments

Comments
 (0)