Java Code Examples for android.net.wifi.WifiManager#WIFI_MODE_FULL
The following examples show how to use
android.net.wifi.WifiManager#WIFI_MODE_FULL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NodeMainExecutorService.java From rosjava_android_template with Apache License 2.0 | 6 votes |
@Override public void onCreate() { handler = new Handler(); PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); wakeLock.acquire(); int wifiLockType = WifiManager.WIFI_MODE_FULL; try { wifiLockType = WifiManager.class.getField("WIFI_MODE_FULL_HIGH_PERF").getInt(null); } catch (Exception e) { // We must be running on a pre-Honeycomb device. Log.w(TAG, "Unable to acquire high performance wifi lock."); } WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE); wifiLock = wifiManager.createWifiLock(wifiLockType, TAG); wifiLock.acquire(); }
Example 2
Source File: AndroidRouter.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
protected WifiManager.WifiLock createWiFiLock() { int wifiMode = WifiManager.WIFI_MODE_FULL; try { // TODO: What's this? Field f = WifiManager.class.getField("WIFI_MODE_FULL_HIGH_PERF"); wifiMode = f.getInt(null); } catch (Exception e) { // Ignore } WifiManager.WifiLock wifiLock = wifiManager.createWifiLock(wifiMode, getClass().getSimpleName()); log.info("Created WiFi lock, mode: " + wifiMode); return wifiLock; }
Example 3
Source File: AndroidRouter.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
protected WifiManager.WifiLock createWiFiLock() { int wifiMode = WifiManager.WIFI_MODE_FULL; try { // TODO: What's this? Field f = WifiManager.class.getField("WIFI_MODE_FULL_HIGH_PERF"); wifiMode = f.getInt(null); } catch (Exception e) { // Ignore } WifiManager.WifiLock wifiLock = wifiManager.createWifiLock(wifiMode, getClass().getSimpleName()); log.info("Created WiFi lock, mode: " + wifiMode); return wifiLock; }
Example 4
Source File: Util.java From Popeens-DSub with GNU General Public License v3.0 | 5 votes |
public static WifiManager.WifiLock createWifiLock(Context context, String tag) { WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); int lockType = WifiManager.WIFI_MODE_FULL; if (Build.VERSION.SDK_INT >= 12) { lockType = 3; } return wm.createWifiLock(lockType, tag); }
Example 5
Source File: SipService.java From CSipSimple with GNU General Public License v3.0 | 4 votes |
/** * Ask to take the control of the wifi and the partial wake lock if * configured */ private synchronized void acquireResources() { if(holdResources) { return; } // Add a wake lock for CPU if necessary if (prefsWrapper.getPreferenceBooleanValue(SipConfigManager.USE_PARTIAL_WAKE_LOCK)) { PowerManager pman = (PowerManager) getSystemService(Context.POWER_SERVICE); if (wakeLock == null) { wakeLock = pman.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "com.csipsimple.SipService"); wakeLock.setReferenceCounted(false); } // Extra check if set reference counted is false ??? if (!wakeLock.isHeld()) { wakeLock.acquire(); } } // Add a lock for WIFI if necessary WifiManager wman = (WifiManager) getSystemService(Context.WIFI_SERVICE); if (wifiLock == null) { int mode = WifiManager.WIFI_MODE_FULL; if(Compatibility.isCompatible(9) && prefsWrapper.getPreferenceBooleanValue(SipConfigManager.LOCK_WIFI_PERFS)) { mode = 0x3; // WIFI_MODE_FULL_HIGH_PERF } wifiLock = wman.createWifiLock(mode, "com.csipsimple.SipService"); wifiLock.setReferenceCounted(false); } if (prefsWrapper.getPreferenceBooleanValue(SipConfigManager.LOCK_WIFI) && !wifiLock.isHeld()) { WifiInfo winfo = wman.getConnectionInfo(); if (winfo != null) { DetailedState dstate = WifiInfo.getDetailedStateOf(winfo.getSupplicantState()); // We assume that if obtaining ip addr, we are almost connected // so can keep wifi lock if (dstate == DetailedState.OBTAINING_IPADDR || dstate == DetailedState.CONNECTED) { if (!wifiLock.isHeld()) { wifiLock.acquire(); } } } } holdResources = true; }
Example 6
Source File: HostActivity.java From ExoPlayer-Offline with Apache License 2.0 | 4 votes |
@SuppressLint("InlinedApi") private static int getWifiLockMode() { return Util.SDK_INT < 12 ? WifiManager.WIFI_MODE_FULL : WifiManager.WIFI_MODE_FULL_HIGH_PERF; }