/// <summary> /// Determines whether a connectivity type is usually considered to be metered or not. /// </summary> /// <remarks> /// Wi-Fi and ethernet are considered unmetered. /// </remarks> private static bool IsNetworkTypeMetered(ConnectivityType connectivityType) { return( connectivityType == ConnectivityType.Wifi || connectivityType == ConnectivityType.Ethernet ); }
internal static ConnectionProfile GetConnectionType(ConnectivityType connectivityType, string typeName) { switch (connectivityType) { case ConnectivityType.Ethernet: return(ConnectionProfile.Ethernet); case ConnectivityType.Wimax: return(ConnectionProfile.WiMAX); case ConnectivityType.Wifi: return(ConnectionProfile.WiFi); case ConnectivityType.Bluetooth: return(ConnectionProfile.Bluetooth); case ConnectivityType.Mobile: case ConnectivityType.MobileDun: case ConnectivityType.MobileHipri: case ConnectivityType.MobileMms: return(ConnectionProfile.Cellular); case ConnectivityType.Dummy: return(ConnectionProfile.Other); default: if (string.IsNullOrWhiteSpace(typeName)) { return(ConnectionProfile.Other); } var typeNameLower = typeName.ToLowerInvariant(); if (typeNameLower.Contains("mobile")) { return(ConnectionProfile.Cellular); } if (typeNameLower.Contains("wifi")) { return(ConnectionProfile.WiFi); } if (typeNameLower.Contains("wimax")) { return(ConnectionProfile.WiMAX); } if (typeNameLower.Contains("ethernet")) { return(ConnectionProfile.Ethernet); } if (typeNameLower.Contains("bluetooth")) { return(ConnectionProfile.Bluetooth); } return(ConnectionProfile.Other); } }
public override bool WifiState(Activity _) { try { var cm = (ConnectivityManager)_.GetSystemService(Context.ConnectivityService); if (null == _ || cm == null) { return(false); } if (cm.ActiveNetworkInfo != null) { if (cm.ActiveNetworkInfo.IsAvailable) { if (ActiveInternetConnectionType != cm.ActiveNetworkInfo.Type) { ActiveInternetConnectionType = cm.ActiveNetworkInfo.Type; cms.NetWorkType = ActiveInternetConnectionType.ToString(); } wifistatesarray = cm.ActiveNetworkInfo.IsConnected; } else { wifistatesarray = false; } } } catch (Exception ex) { } return(wifistatesarray); }
// Prepare shards. Set bounds, set neibs public static List <RFShard> GetShards(List <RayfireRigid> rigidList, ConnectivityType connectivity) { List <RFShard> shardList = new List <RFShard>(); for (int i = 0; i < rigidList.Count; i++) { // Get mesh filter MeshFilter mf = rigidList[i].GetComponent <MeshFilter>(); // Child has no mesh if (mf == null) { continue; } // Create new shard RFShard shard = new RFShard(rigidList[i].transform, i); shard.rigid = rigidList[i]; // Set faces data for connectivity if (connectivity == ConnectivityType.ByMesh) { shard.tris = RFTriangle.SetTriangles(shard.tm, mf); } // Collect shard shardList.Add(shard); } return(shardList); }
private ConnectivityType GetConnTypeFromSelectedConnType() { ConnectivityType xoConnType = ConnectivityType.Unknown; if (drpConnType.SelectedIndex >= 0) { if (OleDbSelected()) { xoConnType = ConnectivityType.OleDB; } else { if (OdbcSelected()) { xoConnType = ConnectivityType.ODBC; } else { if (SqlSelected()) { xoConnType = ConnectivityType.DotNet; } } } } return(xoConnType); }
private ConnectivityType GetSelectedConnType() { ConnectivityType xeType = ConnectivityType.Unknown; if (OleDbSelected()) { xeType = ConnectivityType.OleDB; } else { if (OdbcSelected()) { xeType = ConnectivityType.ODBC; } else { if (SqlSelected()) { xeType = ConnectivityType.DotNet; } } } return(xeType); }
// Set up main cluster and set shards RFCluster SetupMainCluster(ConnectivityType connect) { // Create Base cluster RFCluster cluster = new RFCluster(); cluster.tm = transform; cluster.depth = 0; cluster.pos = transform.position; // Set cluster id cluster.id = 0; // Set shards for main cluster RFShard.SetShards(cluster, connectivity); clusterId = 0; // Collect all shards allShards.Clear(); allShards.AddRange(cluster.shards); // TODO set bound return(cluster); }
public static ConnectionType GetConnectionType(ConnectivityType connectivityType) { switch (connectivityType) { case ConnectivityType.Ethernet: return(ConnectionType.Desktop); case ConnectivityType.Wimax: return(ConnectionType.Wimax); case ConnectivityType.Wifi: return(ConnectionType.WiFi); case ConnectivityType.Bluetooth: return(ConnectionType.Bluetooth); case ConnectivityType.Mobile: case ConnectivityType.MobileDun: case ConnectivityType.MobileHipri: return(ConnectionType.Cellular); case ConnectivityType.Dummy: return(ConnectionType.Other); default: return(ConnectionType.Other); } }
public TwoPassCCAlgorithm(UnifyingFeature feature, ConnectivityType connectivityType) { this.Feature = feature; this.ConnectivityType = connectivityType; this.RegionsEquivalents = new List<List<int>>();// Dictionary<int, List<int>>(); this.Regions = new Dictionary<int, Region>(); }
private void OnConnectivityGot(ConnectivityType ty) { Log.Debug(TAG, "OnConnectivityGot " + ty); UnregisterNetworkCallback(); type = ty; if (type == ConnectivityType.Wifi) { if (settings.AutoStopWifi.Count == 0) { Log.Debug(TAG, "settings.AutoStopWifi.Count == 0"); JobFinished(jobParam, true); return; } if (!File.Exists(TrojanPlusMainActivity.RunningConfigPath)) { Log.Debug(TAG, "RunningConfigPath file is not exist, VPN is not running"); JobFinished(jobParam, true); return; } } else if (type == ConnectivityType.Cellur) { if (!settings.AutoStartCellur) { Log.Debug(TAG, "settings.AutoStartCellur == false"); JobFinished(jobParam, true); return; } if (!File.Exists(TrojanPlusMainActivity.PrepareConfigPath)) { Log.Debug(TAG, "PrepareConfig file is not exist"); JobFinished(jobParam, false); return; } if (File.Exists(TrojanPlusMainActivity.RunningConfigPath)) { Log.Debug(TAG, "RunningConfigPath file is exist, VPN is running"); JobFinished(jobParam, true); return; } } else { JobFinished(jobParam, true); return; } if (starter == null) { starter = new TrojanPlusStarter(this, this); } starter.OnJobServiceStart(); }
// Copy from public void CopyFrom(RFDemolitionCluster demolition) { meshDemolition = demolition.meshDemolition; connectivity = demolition.connectivity; contactRadius = demolition.contactRadius; Reset(); }
/// ///////////////////////////////////////////////////////// /// Constructor /// ///////////////////////////////////////////////////////// // Constructor public RFDemolitionCluster() { meshDemolition = false; connectivity = ConnectivityType.ByBoundingBox; contactRadius = 15; cluster = null; Reset(); }
private static bool IsConnectionWwan(ConnectivityType connectivityType) { return (connectivityType == ConnectivityType.Wimax || connectivityType == ConnectivityType.Mobile || connectivityType == ConnectivityType.MobileDun || connectivityType == ConnectivityType.MobileHipri || connectivityType == ConnectivityType.MobileMms || connectivityType == ConnectivityType.MobileSupl); }
private void OnConnectivityStateChange(object sender, EventArgs e) { ConnectivityType state = cm.State; cm.CheckConnectivity(); if (state != cm.State) { GetIsp(); } }
private async void GetNetworks() { ConnectivityType ct = cm.State; if (ct == ConnectivityType.Data || ct == ConnectivityType.Wifi) { var client = new HttpClient(); client.DefaultRequestHeaders.Add("Accept", "application/json"); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://dev.socsuite.com/api-ss/networks/"); var response = await client.SendAsync(request); if (response != null && response.IsSuccessStatusCode) { string json = await response.Content.ReadAsStringAsync(); List <NetworkDto> dtoList = JsonConvert.DeserializeObject <List <NetworkDto> >(json); if (dtoList != null) { RunOnUiThread(() => { int networkIndex = 0; bool ssidMatched = false; string ssid; StringBuilder networks = new StringBuilder(); dtoList.ForEach(l => { if (networkIndex > 0) { networks.AppendLine(); } ++networkIndex; ssid = l.NetworkSsid; if (ssid == null) { networks.Append(l.FriendlyName); } else { networks.AppendFormat("{0} ({1})", l.FriendlyName, ssid); if (!ssidMatched) { if (ssid.Equals(cm.NetworkSsid, StringComparison.OrdinalIgnoreCase)) { ssidMatched = true; networks.Append(" ***"); } } } }); TextNetworks.Text = networks.ToString(); }); } } } }
/// ///////////////////////////////////////////////////////// /// Shards /// ///////////////////////////////////////////////////////// // Prepare shards. Set bounds, set neibs public static List <RFShard> GetShards(Transform tm, ConnectivityType connectivity) { // Get all children tms List <Transform> tmList = new List <Transform>(); for (int i = 0; i < tm.childCount; i++) { tmList.Add(tm.GetChild(i)); } return(GetShards(tmList, connectivity)); }
/// ///////////////////////////////////////////////////////// /// Shards /// ///////////////////////////////////////////////////////// // Prepare shards. Set bounds, set neibs public static void SetShards(RFCluster cluster, ConnectivityType connectivity, bool setRigid = false) { // Get all children tms List <Transform> tmList = new List <Transform>(); for (int i = 0; i < cluster.tm.childCount; i++) { tmList.Add(cluster.tm.GetChild(i)); } // Get child shards SetShardsByTransforms(cluster, tmList, connectivity, setRigid); }
// Set up main cluster and set shards RFCluster SetupMainCluster(ConnectivityType connect) { // Create Base cluster RFCluster cluster = RFCluster.SetCluster(transform, connect); clusterId = 0; // Collect all shards allShards.Clear(); allShards.AddRange(cluster.shards); // TODO set bound return(cluster); }
private string CheckForConnStrMatch() { string xsErrMsg = ""; if (!chkManual.Checked) { if (drpProv.SelectedIndex >= 0) { DatabaseProvider xoProv = moProviders[drpProv.SelectedIndex]; if (drpConnType.SelectedIndex >= 0) { ConnectivityType xeConnType = GetConnTypeFromSelectedConnType(); string xs = ""; switch (xeConnType) { case ConnectivityType.DotNet: xs = xoProv.DotNetConnStr.Trim() + xoProv.DotNetConnStrTrusted.Trim(); if (xs.Length == 0) { xsErrMsg = "Connection type is SQL, but a connection string has not been provided for the selected provider."; } break; case ConnectivityType.ODBC: xs = xoProv.OdbcConnStr.Trim() + xoProv.OdbcConnStrTrusted.Trim(); if (xs.Length == 0) { xsErrMsg = "Connection type is ODBC, but a connection string has not been provided for the selected provider."; } break; case ConnectivityType.OleDB: xs = xoProv.OleDbConnStr.Trim() + xoProv.OleDbConnStrTrusted.Trim(); if (xs.Length == 0) { xsErrMsg = "Connection type is OLEDB, but a connection string has not been provided for the selected provider."; } break; default: break; } } } } return(xsErrMsg); }
private void MatchConnType(ConnectivityType piConnType) { switch (piConnType) { case ConnectivityType.OleDB: MatchConnType2("ole"); break; case ConnectivityType.ODBC: MatchConnType2("odbc"); break; default: MatchConnType2("sql"); break; } }
/// ///////////////////////////////////////////////////////// /// Collider /// ///////////////////////////////////////////////////////// // Create base cluster with children as shards public static RFCluster SetCluster(Transform transform, ConnectivityType connectivity) { // Create Base cluster RFCluster cluster = new RFCluster(); cluster.tm = transform; cluster.rootParent = null; cluster.depth = 0; cluster.pos = transform.position; // Set cluster id cluster.id = 0; // Set shards for main cluster cluster.shards = RFShard.GetShards(cluster.tm, connectivity); return(cluster); }
internal ConnectionType GetConnectionType(ConnectivityType connectivityType) { switch (connectivityType) { case ConnectivityType.Ethernet: case ConnectivityType.Wimax: case ConnectivityType.Wifi: case ConnectivityType.Bluetooth: return(ConnectionType.WiFi); case ConnectivityType.Mobile: case ConnectivityType.MobileDun: case ConnectivityType.MobileHipri: case ConnectivityType.MobileMms: case ConnectivityType.Dummy: return(ConnectionType.Cellular); default: return(ConnectionType.Cellular); } }
private void drpProv_SelectedIndexChanged(object sender, EventArgs e) { if (!mbUserChangeConnType) // only do this if user has not yet manually changed the connection type { if (drpProv.SelectedIndex >= 0) { if (drpProv.Enabled) { // let's select "preferred" type string xsID = ""; ConnectivityType xeConnType = moProviders[drpProv.SelectedIndex].PreferredConnectionType; switch (xeConnType) { case ConnectivityType.OleDB: xsID = "OLE"; break; case ConnectivityType.ODBC: xsID = "ODBC"; break; case ConnectivityType.DotNet: xsID = "SQL"; break; default: xsID = SingleConnType(moProviders[drpProv.SelectedIndex]); // if selected provide only has one conn type, we'll choose it for them break; } if (xsID.Length > 0) { MatchConnType2(xsID); } } } } UpdateControlsAvails(); }
private async void GetIsp() { ConnectivityType ct = cm.State; if (ct == ConnectivityType.Data || ct == ConnectivityType.Wifi) { var client = new HttpClient(); client.DefaultRequestHeaders.Add("Accept", "application/json"); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://dev.socsuite.com/api-ss/netLocation/"); var response = await client.SendAsync(request); if (response != null && response.IsSuccessStatusCode) { string json = await response.Content.ReadAsStringAsync(); NetworkLocationDto dto = JsonConvert.DeserializeObject <NetworkLocationDto>(json); RunOnUiThread(() => { TextIsp.Text = dto.Isp; }); } } }
/** * Check if the connection is fast */ public static bool IsConnectionFast(ConnectivityType type, NetworkType subType) { if (type == ConnectivityType.Wifi) { return(true); } else if (type == ConnectivityType.Mobile) { switch (subType) { /* * Check for all kind of network that the oparetor provide */ case NetworkType.OneXrtt: return(false); case NetworkType.Cdma: return(false); case NetworkType.Edge: return(false); case NetworkType.Evdo0: return(true); case NetworkType.EvdoA: return(true); case NetworkType.Gprs: return(false); case NetworkType.Hsdpa: return(true); case NetworkType.Hspa: return(true); case NetworkType.Hsupa: return(true); case NetworkType.Umts: return(true); /* * Above API level 7, make sure to set android:targetSdkVersion * to appropriate level to use these */ case NetworkType.Ehrpd: return(true); case NetworkType.EvdoB: return(true); case NetworkType.Hspap: return(true); case NetworkType.Iden: return(false); case NetworkType.Lte: return(true); case NetworkType.Unknown: return(false); default: return(false); } } else { return(false); } }
// Prepare shards. Set bounds, set neibs public static void SetShardsByTransforms(RFCluster cluster, List <Transform> tmList, ConnectivityType connectivity, bool setRigid = false) { cluster.shards = new List <RFShard>(); for (int i = 0; i < tmList.Count; i++) { // Get mesh filter MeshFilter mf = tmList[i].GetComponent <MeshFilter>(); // Child has no mesh if (mf == null) { continue; } // Has no mesh if (mf.sharedMesh == null) { continue; } // Create new shard RFShard shard = new RFShard(tmList[i], i); shard.cluster = cluster; // Set faces data for connectivity if (connectivity == ConnectivityType.ByMesh || connectivity == ConnectivityType.ByBoundingBoxAndMesh) { RFTriangle.SetTriangles(shard, mf); } // Collect shard cluster.shards.Add(shard); } // Set rigid component if (setRigid == true) { for (int i = 0; i < cluster.shards.Count; i++) { cluster.shards[i].rigid = cluster.shards[i].tm.GetComponent <RayfireRigid>(); } } }
// Set shard neibs public static void SetShardNeibs(List <RFShard> shards, ConnectivityType type, float minArea = 0, float minSize = 0, int perc = 0, int seed = 0) { // Set list for (int i = 0; i < shards.Count; i++) { shards[i].neibShards = new List <RFShard>(); shards[i].nArea = new List <float>(); shards[i].nIds = new List <int>(); shards[i].nAm = 0; } // Set neib and area info for (int i = 0; i < shards.Count; i++) { // Skip by size if (minSize > 0 && shards[i].sz < minSize) { continue; } for (int s = 0; s < shards.Count; s++) { // Skip itself if (s != i) { // Skip by size if (minSize > 0 && shards[s].sz < minSize) { continue; } // Set random state for same pair if (perc > 0) { Random.InitState(shards[i].id + shards[s].id + seed); if (Random.Range(0, 100) < perc) { continue; } } // Check if shard was not added as neib before if (shards[s].nIds.Contains(shards[i].id) == false) { // Bounding box intersection check if (shards[i].bnd.Intersects(shards[s].bnd) == true) { // Get areas float area = 0; if (type != ConnectivityType.ByBoundingBox) { area = shards[i].NeibArea(shards[s]); } if (type != ConnectivityType.ByMesh) { area = (shards[i].sz + shards[s].sz) / 4f; } // Skip low area neibs TODO filter after all connected, leave one biggest ?? if (minArea > 0 && area < minArea) { continue; } // Collect if (area > 0) { shards[i].neibShards.Add(shards[s]); shards[i].nArea.Add(area); shards[i].nIds.Add(shards[s].id); shards[s].neibShards.Add(shards[i]); shards[s].nArea.Add(area); shards[s].nIds.Add(shards[i].id); } } } } } // Set original neib amount to know if neibs was removed shards[i].nAm = shards[i].nIds.Count; } // Clear triangles data if (type == ConnectivityType.ByMesh) { for (int i = 0; i < shards.Count; i++) { RFTriangle.Clear(shards[i]); } } }
// Set shard neibs public static void SetShardNeibs(List <RFShard> shards, ConnectivityType connectivity) { // Set list foreach (RFShard shard in shards) { shard.neibShards = new List <RFShard>(); shard.neibArea = new List <float>(); shard.neibPerc = new List <float>(); } // Set neib and area info for (int i = 0; i < shards.Count; i++) { for (int s = 0; s < shards.Count; s++) { if (s != i) { // Check if shard was not added as neib before if (shards[s].neibShards.Contains(shards[i]) == false) { // Bounding box intersection check if (shards[i].bound.Intersects(shards[s].bound) == true) { // No need in face check connectivity if (connectivity == ConnectivityType.ByBoundingBox) { float size = shards[i].bound.size.magnitude; shards[i].neibShards.Add(shards[s]); shards[i].neibArea.Add(size); shards[s].neibShards.Add(shards[i]); shards[s].neibArea.Add(size); } // Face to face connectivity check else { // Check for shared faces and collect neibs and areas if (shards[i].TrisNeib(shards[s]) == true) { float area = shards[i].NeibArea(shards[s]); shards[i].neibShards.Add(shards[s]); shards[i].neibArea.Add(area); shards[s].neibShards.Add(shards[i]); shards[s].neibArea.Add(area); } } } } } } float maxArea = Mathf.Max(shards[i].neibArea.ToArray()); foreach (float area in shards[i].neibArea) { if (maxArea > 0) { shards[i].neibPerc.Add(area / maxArea); } else { shards[i].neibPerc.Add(0f); } } } }
// Prepare shards. Set bounds, set neibs static void SetShardsByRigids(RFCluster cluster, List <RayfireRigid> rigidList, ConnectivityType connectivity) { for (int i = 0; i < rigidList.Count; i++) { // Get mesh filter MeshFilter mf = rigidList[i].GetComponent <MeshFilter>(); // Child has no mesh if (mf == null) { continue; } // Create new shard RFShard shard = new RFShard(rigidList[i].transform, i); shard.cluster = cluster; shard.rigid = rigidList[i]; shard.uny = rigidList[i].activation.unyielding; shard.col = rigidList[i].physics.meshCollider; // Set faces data for connectivity if (connectivity == ConnectivityType.ByMesh) { RFTriangle.SetTriangles(shard, mf); } // Collect shard cluster.shards.Add(shard); } }
private static bool IsConnectionWlan(ConnectivityType connectivityType) { return(connectivityType == ConnectivityType.Wifi); }
/** * Check if the connection is fast * @param type * @param subType * @return */ public static bool IsConnectionFast(ConnectivityType type, NetworkType subType) { if (type == ConnectivityType.Wifi) { return(true); } else if (type == ConnectivityType.Mobile) { switch (subType) { //case TelephonyManager.NETWORK_TYPE_1xRTT: case NetworkType.OneXrtt: return(false); // ~ 50-100 kbps //case TelephonyManager.NETWORK_TYPE_CDMA: case NetworkType.Cdma: return(false); // ~ 14-64 kbps //case TelephonyManager.NETWORK_TYPE_EDGE: case NetworkType.Edge: return(false); // ~ 50-100 kbps //case TelephonyManager.NETWORK_TYPE_EVDO_0: case NetworkType.Evdo0: return(true); // ~ 400-1000 kbps //case TelephonyManager.NETWORK_TYPE_EVDO_A: case NetworkType.EvdoA: return(true); // ~ 600-1400 kbps //case TelephonyManager.NETWORK_TYPE_GPRS: case NetworkType.Gprs: return(false); // ~ 100 kbps //case TelephonyManager.NETWORK_TYPE_HSDPA: case NetworkType.Hsdpa: return(true); // ~ 2-14 Mbps //case TelephonyManager.NETWORK_TYPE_HSPA: case NetworkType.Hspa: return(true); // ~ 700-1700 kbps //case TelephonyManager.NETWORK_TYPE_HSUPA: case NetworkType.Hsupa: return(true); // ~ 1-23 Mbps //case TelephonyManager.NETWORK_TYPE_UMTS: case NetworkType.Umts: return(true); // ~ 400-7000 kbps /* * Above API level 7, make sure to set android:targetSdkVersion * to appropriate level to use these */ //case TelephonyManager.NETWORK_TYPE_EHRPD: // API level 11 case NetworkType.Ehrpd: return(true); // ~ 1-2 Mbps //case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9 case NetworkType.EvdoB: return(true); // ~ 5 Mbps //case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13 case NetworkType.Hspap: return(true); // ~ 10-20 Mbps //case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8 case NetworkType.Iden: return(false); // ~25 kbps //case TelephonyManager.NETWORK_TYPE_LTE: // API level 11 case NetworkType.Lte: return(true); // ~ 10+ Mbps // Unknown //case TelephonyManager.NETWORK_TYPE_UNKNOWN: case NetworkType.Unknown: return(false); default: return(false); } } else { return(false); } }