public Dictionary<string, string> GetDeviceInfo() { Dictionary<string, string> deviceInfo = new Dictionary<string, string>(); if (Application.platform == RuntimePlatform.IPhonePlayer) { // Fill in device system info deviceInfo["ManufacturerCode"] = _getManufacturerCode(); deviceInfo["DeviceSoftwareVersion"] = _getDeviceSoftwareVersion(); deviceInfo["DeviceModel"] = _getDeviceModel(); deviceInfo["OperatingSystem"] = _getOperatingSystem(); // Fill in carrier/ISO info CarrierInfoClass carrierInfo = new CarrierInfoClass(); deviceInfo["SimOperatorName"] = carrierInfo.GetCurrentCarrierName(); deviceInfo["SimCountryCodeIso"] = carrierInfo.GetISOCountryCodeFromCarrier(); } return deviceInfo; }
public PlatformIntegration() { // Target Device Network Interfaces. This is not known until compile time: #if UNITY_ANDROID NetworkInterfaceName = new AndroidNetworkInterfaceName(); #elif UNITY_IOS NetworkInterfaceName = new IOSNetworkInterfaceName(); #else Logger.LogWarning("Unknown or unsupported platform. Please create WiFi and Cellular interface name Object for your platform"); #endif // Editor or Player network management (overrides target device platform): switch (Application.platform) { case RuntimePlatform.OSXPlayer: case RuntimePlatform.OSXEditor: NetworkInterfaceName = new MacNetworkInterfaceName(); CarrierInfo = new TestCarrierInfoClass(); UniqueID = new TestUniqueIDClass(); DeviceInfo = new TestDeviceInfo(); break; case RuntimePlatform.LinuxPlayer: case RuntimePlatform.LinuxEditor: NetworkInterfaceName = new LinuxNetworkInterfaceName(); CarrierInfo = new TestCarrierInfoClass(); UniqueID = new TestUniqueIDClass(); DeviceInfo = new TestDeviceInfo(); break; case RuntimePlatform.WindowsPlayer: case RuntimePlatform.WindowsEditor: NetworkInterfaceName = new Windows10NetworkInterfaceName(); CarrierInfo = new TestCarrierInfoClass(); UniqueID = new TestUniqueIDClass(); DeviceInfo = new TestDeviceInfo(); break; default: CarrierInfo = new CarrierInfoClass(); UniqueID = new UniqueIDClass(); DeviceInfo = new DeviceInfoIntegration(); break; } NetInterface = new NetInterfaceClass(NetworkInterfaceName); }
public Dictionary <string, string> GetDeviceInfo() { CarrierInfo carrierInfo = overrideCarrierInfo; if (carrierInfo == null) { carrierInfo = new CarrierInfoClass(); } Dictionary <string, string> deviceInfo = new Dictionary <string, string>(); deviceInfo["DataNetworkPath"] = carrierInfo.GetDataNetworkPath(); deviceInfo["CarrierName"] = carrierInfo.GetCurrentCarrierName(); deviceInfo["SignalStrength"] = carrierInfo.GetSignalStrength().ToString(); deviceInfo["DeviceOS"] = SystemInfo.operatingSystem; deviceInfo["DeviceModel"] = SystemInfo.deviceModel; Debug.Log("deviceInfo count: " + deviceInfo.Count); return(deviceInfo); }
/// <summary> /// Function for IOS that checks if device is in different country from carrier network /// </summary> /// <returns>bool</returns> public async Task <bool> IsRoaming() { #if !UNITY_EDITOR // 0,0 is fine in Unity Editor if (location.longitude == 0 && location.latitude == 0) { Debug.LogError("Invalid location: (0,0). Please wait for valid location information before checking roaming status."); throw new CarrierInfoException("Invalid location: (0,0). Please wait for valid location information before checking roaming status."); } #endif try { CarrierInfoClass carrierInfoClass = new CarrierInfoClass(); return(await carrierInfoClass.IsRoaming(location.longitude, location.latitude)); } catch (CarrierInfoException cie) { Debug.LogError("Unable to get Roaming status. CarrierInfoException: " + cie.Message + ". Assuming device is not roaming"); return(false); } }
// Placeholder, if available, just use the Unity version #if UNITY_ANDROID public Dictionary<string, string> GetDeviceInfo() { CarrierInfoClass carrierInfo = new CarrierInfoClass(); Dictionary<string, string> map = new Dictionary<string, string>(); int sdk_int = carrierInfo.getAndroidSDKVers(); map["Build.VERSION.SDK_INT"] = sdk_int.ToString(); if (UnityEngine.XR.XRSettings.loadedDeviceName.Contains("oculus")) { return map; } AndroidJavaObject telephonyManager = carrierInfo.GetTelephonyManager(); if (telephonyManager == null) { Logger.Log("No TelephonyManager!"); return map; } const string readPhoneStatePermissionString = "android.permission.READ_PHONE_STATE"; try { if (Permission.HasUserAuthorizedPermission(readPhoneStatePermissionString)) { string ver = PlatformIntegrationUtil.Call<string>(telephonyManager, "getDeviceSoftwareVersion"); if (ver != null) { map["DeviceSoftwareVersion"] = ver.ToString(); } } } catch (Exception e) { Logger.LogWarning("Exception retrieving properties: " + e.GetBaseException() + ", " + e.Message); } try { if (Permission.HasUserAuthorizedPermission(readPhoneStatePermissionString)) { int nType = PlatformIntegrationUtil.Call<int>(telephonyManager, "getDataNetworkType"); NetworkDataType datatype = (NetworkDataType)nType; map["DataNetworkType"] = datatype.ToString(); } } catch (Exception e) { Logger.LogWarning("Exception retrieving properties: " + e.GetBaseException() + ", " + e.Message); } AndroidJavaClass versionCodesClass = new AndroidJavaClass("android.os.Build$VERSION_CODES"); int versionCode = PlatformIntegrationUtil.GetStatic<int>(versionCodesClass, "Q"); if (sdk_int > versionCode) { string mc = PlatformIntegrationUtil.Call<string>(telephonyManager, "getManufacturerCode"); if (mc != null) { map["ManufacturerCode"] = mc; } } string niso = PlatformIntegrationUtil.Call<string>(telephonyManager, "getNetworkCountryIso"); if (niso != null) { map["NetworkCountryIso"] = niso; } string siso = PlatformIntegrationUtil.Call<string>(telephonyManager, "getSimCountryIso"); if (siso != null) { map["SimCountryCodeIso"] = siso; } int phoneType = PlatformIntegrationUtil.Call<int>(telephonyManager, "getPhoneType"); map["PhoneType"] = phoneType.ToString(); // Default one. string simOperatorName = PlatformIntegrationUtil.Call<string>(telephonyManager, "getSimOperatorName"); if (simOperatorName != null) { map["SimOperatorName"] = simOperatorName; } // Default one. string networkOperator = PlatformIntegrationUtil.Call<string>(telephonyManager, "getNetworkOperatorName"); if (networkOperator != null) { map["NetworkOperatorName"] = networkOperator; } return map; }