當前位置: 首頁>>代碼示例>>Java>>正文


Java WifiManager.WIFI_MODE_FULL屬性代碼示例

本文整理匯總了Java中android.net.wifi.WifiManager.WIFI_MODE_FULL屬性的典型用法代碼示例。如果您正苦於以下問題:Java WifiManager.WIFI_MODE_FULL屬性的具體用法?Java WifiManager.WIFI_MODE_FULL怎麽用?Java WifiManager.WIFI_MODE_FULL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.net.wifi.WifiManager的用法示例。


在下文中一共展示了WifiManager.WIFI_MODE_FULL屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: acquireResources

/**
 * 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;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:47,代碼來源:SipService.java

示例2: getWifiLockMode

@SuppressLint("InlinedApi")
private static int getWifiLockMode() {
  return Util.SDK_INT < 12 ? WifiManager.WIFI_MODE_FULL : WifiManager.WIFI_MODE_FULL_HIGH_PERF;
}
 
開發者ID:ashwanijanghu,項目名稱:ExoPlayer-Offline,代碼行數:4,代碼來源:HostActivity.java


注:本文中的android.net.wifi.WifiManager.WIFI_MODE_FULL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。