Last active
          November 2, 2025 01:58 
        
      - 
      
 - 
        
Save benigumocom/ba24979abc15c8e960b71efb95cb4d94 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | object TestEnvironmentChecker { | |
| /** | |
| * Firebase Test Lab またはテスト環境で実行されているかを推定 | |
| */ | |
| fun isRunningInTestLab(context: Context): Boolean { | |
| return when { | |
| isFirebaseTestLab(context) -> { | |
| Log.d("EnvCheck", "Detected: Firebase Test Lab via system setting") | |
| true | |
| } | |
| isKnownTestDevice() -> { | |
| Log.d("EnvCheck", "Detected: Emulator or test device") | |
| true | |
| } | |
| isKnownTestLabNetwork() -> { | |
| Log.d("EnvCheck", "Detected: Firebase Test Lab network range") | |
| true | |
| } | |
| else -> false | |
| } | |
| } | |
| /** | |
| * firebase.test.lab = "true" で判定 | |
| */ | |
| private fun isFirebaseTestLab(context: Context): Boolean { | |
| val value = Settings.System.getString( | |
| context.contentResolver, "firebase.test.lab") | |
| return "true" == value | |
| } | |
| /** | |
| * エミュレータやCI環境の検出(補助的) | |
| */ | |
| private fun isKnownTestDevice(): Boolean { | |
| return (Build.FINGERPRINT.startsWith("generic") | |
| || Build.FINGERPRINT.lowercase().contains("vbox") | |
| || Build.MODEL.contains("Emulator") | |
| || Build.MODEL.contains("Android SDK built for x86") | |
| || Build.MANUFACTURER.contains("Genymotion") | |
| || Build.PRODUCT.contains("sdk") | |
| || Build.HARDWARE.contains("ranchu")) | |
| } | |
| /** | |
| * Firebase Test Lab のネットワーク(Google Cloud 環境)をざっくり推定 | |
| * ※厳密ではなく参考レベル | |
| */ | |
| private fun isKnownTestLabNetwork(): Boolean { | |
| return try { | |
| val interfaces = NetworkInterface.getNetworkInterfaces() | |
| interfaces.toList().any { intf -> | |
| intf.inetAddresses.toList().any { addr -> | |
| val host = addr.hostAddress ?: return@any false | |
| host.startsWith("35.") || host.startsWith("34.") // GCPのIP帯域 | |
| } | |
| } | |
| } catch (e: Exception) { | |
| false | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
“Install Error(-10)” Got You Stuck? The Hidden Trick to Beat Google Play’s Pre-launch Test
https://android.benigumo.com/20251102/install-error-10/