in facebook-core/src/main/java/com/facebook/appevents/AppEventsLoggerImpl.kt [435:490]
fun initializeLib(context: Context, applicationId: String?) {
if (!FacebookSdk.getAutoLogAppEventsEnabled()) {
return
}
val logger = AppEventsLoggerImpl(context, applicationId, null)
checkNotNull(backgroundExecutor).execute {
val params = Bundle()
val classes =
arrayOf( // internal SDK Libraries
"com.facebook.core.Core",
"com.facebook.login.Login",
"com.facebook.share.Share",
"com.facebook.places.Places",
"com.facebook.messenger.Messenger",
"com.facebook.applinks.AppLinks",
"com.facebook.marketing.Marketing",
"com.facebook.gamingservices.GamingServices",
"com.facebook.all.All", // external SDK Libraries
"com.android.billingclient.api.BillingClient",
"com.android.vending.billing.IInAppBillingService")
val keys =
arrayOf( // internal SDK Libraries
"core_lib_included",
"login_lib_included",
"share_lib_included",
"places_lib_included",
"messenger_lib_included",
"applinks_lib_included",
"marketing_lib_included",
"gamingservices_lib_included",
"all_lib_included", // external SDK Libraries
"billing_client_lib_included",
"billing_service_lib_included")
if (classes.size != keys.size) {
throw FacebookException("Number of class names and key names should match")
}
var bitmask = 0
for (i in classes.indices) {
val className = classes[i]
val keyName = keys[i]
try {
Class.forName(className)
params.putInt(keyName, 1)
bitmask = bitmask or (1 shl i)
} catch (ignored: ClassNotFoundException) {
/* no op */
}
}
val preferences = context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE)
val previousBitmask = preferences.getInt("kitsBitmask", 0)
if (previousBitmask != bitmask) {
preferences.edit().putInt("kitsBitmask", bitmask).apply()
logger.logEventImplicitly(AnalyticsEvents.EVENT_SDK_INITIALIZE, null, params)
}
}
}