Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facebook SDK is not adding necessary manifest queries/intents for results from PackageManager.getActivityInfo. #1247

Open
5 tasks done
AndreiGorbaich opened this issue May 28, 2024 · 0 comments

Comments

@AndreiGorbaich
Copy link

Checklist before submitting a bug report

Java version

1.8

Android version

Android 14

Android SDK version

17.0.0

Installation platform & version

Gradle 8.7

Package

Core & AppEvents

Goals

Ensure a complete list of intents in queryIntentActivities in Validate.kt

Expected results

The Facebook SDK automatically adds the necessary queries/intents in AndroidManifest.xml, which ensures Validate.kt's hasCustomTabRedirectActivity returns valid results, taking into account other packages.

Actual results

Validate.kt function hasCustomTabRedirectActivity() returns incomplete results due to Android package manager restrictions. (See: Android Package Visibility)

Steps to reproduce

No response

Code samples & details

https://github.com/facebook/facebook-android-sdk/blob/main/facebook-core/src/main/java/com/facebook/internal/Validate.kt

  @JvmStatic
  fun hasCustomTabRedirectActivity(context: Context, redirectURI: String): Boolean {
    val pm = context.packageManager
    var infos: List<ResolveInfo>? = null
    if (pm != null) {
      val intent = Intent()
      intent.action = Intent.ACTION_VIEW
      intent.addCategory(Intent.CATEGORY_DEFAULT)
      intent.addCategory(Intent.CATEGORY_BROWSABLE)
      intent.data = Uri.parse(redirectURI)
      infos = pm.queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER)
    }
    var hasActivity = false
    if (infos != null) {
      for (info in infos) {
        val activityInfo = info.activityInfo
        if (activityInfo.name == "com.facebook.CustomTabActivity" &&
            activityInfo.packageName == context.packageName) {
          hasActivity = true
        } else {
          // another application is listening for this url scheme, don't open
          // Custom Tab for security reasons
          return false
        }
      }
    }
    return hasActivity
  }

To get info about another packages in queryIntentActivities intent filter should be declared in AndroidManifest.xml 

</queries> 
   <intent>
      <data android:host="cct.${applicationId}" android:scheme="fbconnect" />
   </intent>
</queries>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant