VWOUtils { public static String getDeviceCountryCode(Context context) { try { TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (manager != null) { final String simCountry = manager.getSimCountryIso(); if (simCountry != null && simCountry.length() == 2) { return simCountry; } else if (manager.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { String countryCode = manager.getNetworkCountryIso(); if (countryCode != null && countryCode.length() == 2) { return countryCode; } } } } catch (Exception exception) { VWOLog.e(VWOLog.CONFIG_LOGS, exception, true, false); } return Locale.getDefault().getCountry(); }  static boolean isValidVwoAppKey(String appKey); static String getDeviceUUID(VWOPreference vwoPreference); static String androidVersion(); static boolean isTablet(@NonNull Context context); static int applicationVersion(Context context); static double getRandomNumber(); static boolean checkForInternetPermissions(Context context); static Calendar getCalendar(); static boolean checkIfClassExists(String className); static String getDeviceName(); static boolean isApplicationDebuggable(@NonNull Context context); static int getScreenWidth(); static int getScreenHeight(); static double getScale(Context context); static String getDeviceCountryCode(Context context); @Nullable static String toMD5Hash(String message);  }
@Test @Config(qualifiers = "en-rIN") public void countryCodeTestIndia() { Assert.assertEquals("IN", VWOUtils.getDeviceCountryCode(RuntimeEnvironment.application.getApplicationContext())); Assert.assertNotSame("US", VWOUtils.getDeviceCountryCode(RuntimeEnvironment.application.getApplicationContext())); }
@Test @Config(qualifiers = "ar-rAE-ldrtl") public void countryCodeTestUnitedArab() { Assert.assertEquals("AE", VWOUtils.getDeviceCountryCode(RuntimeEnvironment.application.getApplicationContext())); Assert.assertNotSame("US", VWOUtils.getDeviceCountryCode(RuntimeEnvironment.application.getApplicationContext())); }