<commit_before>package io.taig.android.system_service

import android.app._
import android.app.job.JobScheduler
import android.app.usage.NetworkStatsManager
import android.content.Context
import android.content.Context._
import android.hardware.SensorManager
import android.location.LocationManager
import android.media.{ AudioManager, MediaRouter }
import android.net.ConnectivityManager
import android.net.wifi.WifiManager
import android.os.storage.StorageManager
import android.os.{ BatteryManager, PowerManager, Vibrator }
import android.telephony.{ CarrierConfigManager, SubscriptionManager, TelephonyManager }
import android.view.inputmethod.InputMethodManager
import android.view.{ LayoutInflater, WindowManager }

trait SystemServiceResolver[T] {
    def resolve( context: Context ): T
}

object SystemServiceResolver {
    def apply[T: SystemServiceResolver]: SystemServiceResolver[T] = implicitly[SystemServiceResolver[T]]

    def instance[T]( f: Context ⇒ T ): SystemServiceResolver[T] = new SystemServiceResolver[T] {
        override def resolve( context: Context ) = f( context )
    }

    private def load[T]( name: String )( implicit c: Context ): T = {
        c.getSystemService( name ).asInstanceOf[T]
    }

    implicit val systemServiceResolver_ActivityManager: SystemServiceResolver[ActivityManager] = {
        instance { implicit context ⇒
            load( ACTIVITY_SERVICE )
        }
    }

    implicit val systemServiceResolver_AlarmManager: SystemServiceResolver[AlarmManager] = {
        instance { implicit context ⇒
            load( ALARM_SERVICE )
        }
    }

    implicit val systemServiceResolver_AudioManager: SystemServiceResolver[AudioManager] = {
        instance { implicit context ⇒
            load( AUDIO_SERVICE )
        }
    }

    implicit val systemServiceResolver_BatteryManager: SystemServiceResolver[BatteryManager] = {
        instance { implicit context ⇒
            load( BATTERY_SERVICE )
        }
    }

    implicit val systemServiceResolver_CarrierConfigManager: SystemServiceResolver[CarrierConfigManager] = {
        instance { implicit context ⇒
            load( CARRIER_CONFIG_SERVICE )
        }
    }

    implicit val systemServiceResolver_ConnectivityManager: SystemServiceResolver[ConnectivityManager] = {
        instance { implicit context ⇒
            load( CONNECTIVITY_SERVICE )
        }
    }

    implicit val systemServiceResolver_DownloadManager: SystemServiceResolver[DownloadManager] = {
        instance { implicit context ⇒
            load( DOWNLOAD_SERVICE )
        }
    }

    implicit val systemServiceResolver_InputMethodManager: SystemServiceResolver[InputMethodManager] = {
        instance { implicit context ⇒
            load( INPUT_METHOD_SERVICE )
        }
    }

    implicit val systemServiceResolver_JobScheduler: SystemServiceResolver[JobScheduler] = {
        instance { implicit context ⇒
            load( JOB_SCHEDULER_SERVICE )
        }
    }

    implicit val systemServiceResolver_KeyguardManager: SystemServiceResolver[KeyguardManager] = {
        instance { implicit context ⇒
            load( KEYGUARD_SERVICE )
        }
    }

    implicit val systemServiceResolver_LayoutInflater: SystemServiceResolver[LayoutInflater] = {
        instance { implicit context ⇒
            load( LAYOUT_INFLATER_SERVICE )
        }
    }

    implicit val systemServiceResolver_LocationManager: SystemServiceResolver[LocationManager] = {
        instance { implicit context ⇒
            load( LOCATION_SERVICE )
        }
    }

    implicit val systemServiceResolver_MediaRouter: SystemServiceResolver[MediaRouter] = {
        instance { implicit context ⇒
            load( MEDIA_ROUTER_SERVICE )
        }
    }

    implicit val systemServiceResolver_NetworkStatsManager: SystemServiceResolver[NetworkStatsManager] = {
        instance { implicit context ⇒
            load( NETWORK_STATS_SERVICE )
        }
    }

    implicit val systemServiceResolver_NotificationManager: SystemServiceResolver[NotificationManager] = {
        instance { implicit context ⇒
            load( NOTIFICATION_SERVICE )
        }
    }

    implicit val systemServiceResolver_PowerManager: SystemServiceResolver[PowerManager] = {
        instance { implicit context ⇒
            load( POWER_SERVICE )
        }
    }

    implicit val systemServiceResolver_SearchManager: SystemServiceResolver[SearchManager] = {
        instance { implicit context ⇒
            load( SEARCH_SERVICE )
        }
    }

    implicit val systemServiceResolver_SensorManager: SystemServiceResolver[SensorManager] = {
        instance { implicit context ⇒
            load( SENSOR_SERVICE )
        }
    }

    implicit val systemServiceResolver_StorageManager: SystemServiceResolver[StorageManager] = {
        instance { implicit context ⇒
            load( STORAGE_SERVICE )
        }
    }

    implicit val systemServiceResolver_SubscriptionManager: SystemServiceResolver[SubscriptionManager] = {
        instance { implicit context ⇒
            load( TELEPHONY_SUBSCRIPTION_SERVICE )
        }
    }

    implicit val systemServiceResolver_TelephonyManager: SystemServiceResolver[TelephonyManager] = {
        instance { implicit context ⇒
            load( TELEPHONY_SERVICE )
        }
    }

    implicit val systemServiceResolver_UiModeManager: SystemServiceResolver[UiModeManager] = {
        instance { implicit context ⇒
            load( UI_MODE_SERVICE )
        }
    }

    implicit val systemServiceResolver_Vibrator: SystemServiceResolver[Vibrator] = {
        instance { implicit context ⇒
            load( VIBRATOR_SERVICE )
        }
    }

    implicit val systemServiceResolver_WifiManager: SystemServiceResolver[WifiManager] = {
        instance { implicit context ⇒
            load( WIFI_SERVICE )
        }
    }

    implicit val systemServiceResolver_WindowManager: SystemServiceResolver[WindowManager] = {
        instance { implicit context ⇒
            load( WINDOW_SERVICE )
        }
    }
}<commit_msg>Explicitly state type arguments because scala will infer Nothing otherwise<commit_after>package io.taig.android.system_service

import android.app._
import android.app.job.JobScheduler
import android.app.usage.NetworkStatsManager
import android.content.Context
import android.content.Context._
import android.hardware.SensorManager
import android.location.LocationManager
import android.media.{ AudioManager, MediaRouter }
import android.net.ConnectivityManager
import android.net.wifi.WifiManager
import android.os.storage.StorageManager
import android.os.{ BatteryManager, PowerManager, Vibrator }
import android.telephony.{ CarrierConfigManager, SubscriptionManager, TelephonyManager }
import android.view.inputmethod.InputMethodManager
import android.view.{ LayoutInflater, WindowManager }

trait SystemServiceResolver[T] {
    def resolve( context: Context ): T
}

object SystemServiceResolver {
    def apply[T: SystemServiceResolver]: SystemServiceResolver[T] = implicitly[SystemServiceResolver[T]]

    def instance[T]( f: Context ⇒ T ): SystemServiceResolver[T] = new SystemServiceResolver[T] {
        override def resolve( context: Context ) = f( context )
    }

    private def load[T]( name: String )( implicit c: Context ): T = {
        c.getSystemService( name ).asInstanceOf[T]
    }

    implicit val systemServiceResolver_ActivityManager: SystemServiceResolver[ActivityManager] = {
        instance { implicit context ⇒
            load[ActivityManager]( ACTIVITY_SERVICE )
        }
    }

    implicit val systemServiceResolver_AlarmManager: SystemServiceResolver[AlarmManager] = {
        instance { implicit context ⇒
            load[AlarmManager]( ALARM_SERVICE )
        }
    }

    implicit val systemServiceResolver_AudioManager: SystemServiceResolver[AudioManager] = {
        instance { implicit context ⇒
            load[AudioManager]( AUDIO_SERVICE )
        }
    }

    implicit val systemServiceResolver_BatteryManager: SystemServiceResolver[BatteryManager] = {
        instance { implicit context ⇒
            load[BatteryManager]( BATTERY_SERVICE )
        }
    }

    implicit val systemServiceResolver_CarrierConfigManager: SystemServiceResolver[CarrierConfigManager] = {
        instance { implicit context ⇒
            load[CarrierConfigManager]( CARRIER_CONFIG_SERVICE )
        }
    }

    implicit val systemServiceResolver_ConnectivityManager: SystemServiceResolver[ConnectivityManager] = {
        instance { implicit context ⇒
            load[ConnectivityManager]( CONNECTIVITY_SERVICE )
        }
    }

    implicit val systemServiceResolver_DownloadManager: SystemServiceResolver[DownloadManager] = {
        instance { implicit context ⇒
            load[DownloadManager]( DOWNLOAD_SERVICE )
        }
    }

    implicit val systemServiceResolver_InputMethodManager: SystemServiceResolver[InputMethodManager] = {
        instance { implicit context ⇒
            load[InputMethodManager]( INPUT_METHOD_SERVICE )
        }
    }

    implicit val systemServiceResolver_JobScheduler: SystemServiceResolver[JobScheduler] = {
        instance { implicit context ⇒
            load[JobScheduler]( JOB_SCHEDULER_SERVICE )
        }
    }

    implicit val systemServiceResolver_KeyguardManager: SystemServiceResolver[KeyguardManager] = {
        instance { implicit context ⇒
            load[KeyguardManager]( KEYGUARD_SERVICE )
        }
    }

    implicit val systemServiceResolver_LayoutInflater: SystemServiceResolver[LayoutInflater] = {
        instance { implicit context ⇒
            load[LayoutInflater]( LAYOUT_INFLATER_SERVICE )
        }
    }

    implicit val systemServiceResolver_LocationManager: SystemServiceResolver[LocationManager] = {
        instance { implicit context ⇒
            load[LocationManager]( LOCATION_SERVICE )
        }
    }

    implicit val systemServiceResolver_MediaRouter: SystemServiceResolver[MediaRouter] = {
        instance { implicit context ⇒
            load[MediaRouter]( MEDIA_ROUTER_SERVICE )
        }
    }

    implicit val systemServiceResolver_NetworkStatsManager: SystemServiceResolver[NetworkStatsManager] = {
        instance { implicit context ⇒
            load[NetworkStatsManager]( NETWORK_STATS_SERVICE )
        }
    }

    implicit val systemServiceResolver_NotificationManager: SystemServiceResolver[NotificationManager] = {
        instance { implicit context ⇒
            load[NotificationManager]( NOTIFICATION_SERVICE )
        }
    }

    implicit val systemServiceResolver_PowerManager: SystemServiceResolver[PowerManager] = {
        instance { implicit context ⇒
            load[PowerManager]( POWER_SERVICE )
        }
    }

    implicit val systemServiceResolver_SearchManager: SystemServiceResolver[SearchManager] = {
        instance { implicit context ⇒
            load[SearchManager]( SEARCH_SERVICE )
        }
    }

    implicit val systemServiceResolver_SensorManager: SystemServiceResolver[SensorManager] = {
        instance { implicit context ⇒
            load[SensorManager]( SENSOR_SERVICE )
        }
    }

    implicit val systemServiceResolver_StorageManager: SystemServiceResolver[StorageManager] = {
        instance { implicit context ⇒
            load[StorageManager]( STORAGE_SERVICE )
        }
    }

    implicit val systemServiceResolver_SubscriptionManager: SystemServiceResolver[SubscriptionManager] = {
        instance { implicit context ⇒
            load[SubscriptionManager]( TELEPHONY_SUBSCRIPTION_SERVICE )
        }
    }

    implicit val systemServiceResolver_TelephonyManager: SystemServiceResolver[TelephonyManager] = {
        instance { implicit context ⇒
            load[TelephonyManager]( TELEPHONY_SERVICE )
        }
    }

    implicit val systemServiceResolver_UiModeManager: SystemServiceResolver[UiModeManager] = {
        instance { implicit context ⇒
            load[UiModeManager]( UI_MODE_SERVICE )
        }
    }

    implicit val systemServiceResolver_Vibrator: SystemServiceResolver[Vibrator] = {
        instance { implicit context ⇒
            load[Vibrator]( VIBRATOR_SERVICE )
        }
    }

    implicit val systemServiceResolver_WifiManager: SystemServiceResolver[WifiManager] = {
        instance { implicit context ⇒
            load[WifiManager]( WIFI_SERVICE )
        }
    }

    implicit val systemServiceResolver_WindowManager: SystemServiceResolver[WindowManager] = {
        instance { implicit context ⇒
            load[WindowManager]( WINDOW_SERVICE )
        }
    }
}
{'fraction_non_alphanumeric': 0.06629922517772985, 'fraction_numerical': 0.0, 'mean_word_length': 3.1157133464825773, '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': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3145331', 'n_tokens_mistral': 3141, 'n_tokens_neox': 3221, 'n_words': 677}