Skip to content

[Android] Fail fast when CCT callback URI scheme is missing from AndroidManifest - #3009

Merged
wmathurin merged 3 commits into
forcedotcom:devfrom
wmathurin:android-cct-manifest-preflight
Aug 26, 2026
Merged

[Android] Fail fast when CCT callback URI scheme is missing from AndroidManifest#3009
wmathurin merged 3 commits into
forcedotcom:devfrom
wmathurin:android-cct-manifest-preflight

Conversation

@wmathurin

Copy link
Copy Markdown
Contributor

Summary

  • Adds a isCallbackSchemeRegistered() preflight check in LoginActivity.loadLoginPageInCustomTab() that probes PackageManager for a matching intent-filter before launching the Chrome Custom Tab (CCT).
  • When the redirect URI scheme is unregistered: logs an ERROR naming the missing scheme; in debug builds shows a localizable AlertDialog with remediation instructions and aborts the CCT launch cleanly.
  • Adds two localizable strings to sf__strings.xml (sf__advanced_auth_manifest_error_title, sf__advanced_auth_manifest_error_message).
  • Two new instrumented unit tests in LoginActivityTest verify the registered and unregistered cases.

Fixes the silent blank-screen hang that occurs when an app enables advanced auth but omits the callback URI <intent-filter> from its AndroidManifest.xml.

GUS: W-24000206

Test plan

  • ./gradlew :libs:SalesforceSDK:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.salesforce.androidsdk.ui.LoginActivityTest#test_givenRegisteredScheme_whenIsCallbackSchemeRegistered_thenReturnsTrue passes
  • ./gradlew :libs:SalesforceSDK:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.salesforce.androidsdk.ui.LoginActivityTest#test_givenUnregisteredScheme_whenIsCallbackSchemeRegistered_thenReturnsFalse passes
  • In a debug build with an app that has no CCT callback intent-filter, starting the login flow shows the AlertDialog before any CCT is opened
  • In the same scenario, logcat shows the ERROR line naming the missing scheme
  • Apps that already have the correct intent-filter registered see no change in behavior (happy path)

When advanced auth (Chrome Custom Tab) is enabled, a missing
intent-filter for the redirect URI scheme causes the CCT redirect to be
silently dropped by Android, leaving the user on a blank screen at the
end of the login flow with no diagnostic output.

Before launching the CCT, LoginActivity now calls
isCallbackSchemeRegistered() to probe the app's PackageManager for a
matching intent-filter. If none is found:
- An ERROR log line names the missing scheme and the required fix.
- In debug builds, a localizable AlertDialog surfaces the issue and
  aborts the CCT launch.

New strings added to sf__strings.xml:
  sf__advanced_auth_manifest_error_title
  sf__advanced_auth_manifest_error_message

Two instrumented unit tests added to LoginActivityTest.
@wmathurin
wmathurin requested a review from brandonpage August 26, 2026 17:59
- Use String.toUri() KTX extension instead of Uri.parse() (two sites)
- Add setPackage(packageName) to the probe intent to scope the
  queryIntentActivities call to the current app only, removing the
  need for a <queries> manifest declaration (package visibility)
setPackage(packageName) // scope to this app; avoids <queries> requirement
}
return packageManager
?.queryIntentActivities(probeIntent, MATCH_DEFAULT_ONLY)

@github-actions github-actions Bot Aug 26, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Consider adding a <queries> declaration to your manifest when calling this method; see https://g.co/dev/packagevisibility for details

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setPackage(packageName) is already set on the probe intent, which restricts the query to this app's own package. Android's package visibility restrictions (<queries>) only apply when probing external apps — querying your own package is always permitted without a manifest declaration. This warning is a false positive.

@brandonpage brandonpage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!


/**
* Returns true if the app's manifest contains an intent-filter that handles [redirectUri],
* false otherwise. A missing registration causes the CCT redirect to be silently dropped by

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extremely NIT: CCT implies we only support Chrome. Agents tend to propagate this misinformation.

… KDoc

The SDK supports any custom tab browser, not only Chrome.
@wmathurin
wmathurin merged commit 821bd74 into forcedotcom:dev Aug 26, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants