<commit_before>package com.garpr.android.wrappers

import android.app.Activity
import android.app.Application
import android.content.DialogInterface.OnCancelListener
import android.content.pm.PackageInfo
import android.content.pm.PackageManager

import com.garpr.android.R
import com.garpr.android.misc.CrashlyticsWrapper
import com.garpr.android.misc.Timber
import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability

class GoogleApiWrapperImpl(
        private val application: Application,
        private val crashlyticsWrapper: CrashlyticsWrapper,
        private val timber: Timber
) : GoogleApiWrapper {

    companion object {
        private const val TAG = "GoogleApiWrapperImpl"
        private const val PLAY_SERVICES_RESOLUTION_REQUEST = 9000
    }

    init {
        checkPlayServicesInstallationInfo()
    }

    private fun checkPlayServicesInstallationInfo() {
        val libraryVersion = application.resources.getInteger(R.integer.google_play_services_version)
        crashlyticsWrapper.setInt("gms_library_version", libraryVersion)

        var pi: PackageInfo? = null

        try {
            pi = application.packageManager.getPackageInfo("com.google.android.gms", 0)
        } catch (e: PackageManager.NameNotFoundException) {
            timber.w(TAG, "Error occurred when retrieving Google Play Services package info", e)
        }

        val versionCode = if (pi == null) "n/a" else pi.versionCode.toString()
        crashlyticsWrapper.setString("gms_version_code", versionCode)

        val versionName = if (pi == null) "n/a" else pi.versionName
        crashlyticsWrapper.setString("gms_version_name", versionName)<commit_msg>some Kotlin cleanup<commit_after>package com.garpr.android.wrappers

import android.app.Activity
import android.app.Application
import android.content.DialogInterface.OnCancelListener
import android.content.pm.PackageInfo
import android.content.pm.PackageManager

import com.garpr.android.R
import com.garpr.android.misc.CrashlyticsWrapper
import com.garpr.android.misc.Timber
import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability

class GoogleApiWrapperImpl(
        private val application: Application,
        private val crashlyticsWrapper: CrashlyticsWrapper,
        private val timber: Timber
) : GoogleApiWrapper {

    companion object {
        private const val TAG = "GoogleApiWrapperImpl"
        private const val PLAY_SERVICES_RESOLUTION_REQUEST = 9000
    }

    init {
        checkPlayServicesInstallationInfo()
    }

    private fun checkPlayServicesInstallationInfo() {
        val libraryVersion = application.resources.getInteger(R.integer.google_play_services_version)
        crashlyticsWrapper.setInt("gms_library_version", libraryVersion)

        var pi: PackageInfo? = null

        try {
            pi = application.packageManager.getPackageInfo("com.google.android.gms", 0)
        } catch (e: PackageManager.NameNotFoundException) {
            timber.w(TAG, "Error occurred when retrieving Google Play Services package info", e)
        }

        val versionCode = pi?.versionCode?.toString() ?: "n/a"
        crashlyticsWrapper.setString("gms_version_code", versionCode)

        val versionName = pi?.versionName ?: "n/a"
        crashlyticsWrapper.setString("gms_version_name", versionName)
{'fraction_non_alphanumeric': 0.08022333235380547, 'fraction_numerical': 0.0029385836027034967, 'mean_word_length': 3.774193548387097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5662401', 'n_tokens_mistral': 964, 'n_tokens_neox': 920, 'n_words': 195}