protected static synchronized WifiManager.WifiLock getWifiLock(Context context) { // keep wifi alive if (wifilock == null) { WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); wifilock = manager.createWifiLock(CLASS_TAG); wifilock.setReferenceCounted(true); } return wifilock; }
private synchronized void acquireWifiLockIfNecessary() { if (stream) { if (wifiLock == null) { wifiLock = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, TAG); wifiLock.setReferenceCounted(false); } wifiLock.acquire(); } }
private SipService(Context context) { if (DEBUG) Log.d(TAG, " service started!"); mContext = context; mConnectivityReceiver = new ConnectivityReceiver(); mWifiLock = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, TAG); mWifiLock.setReferenceCounted(false); mSipOnWifiOnly = SipManager.isSipWifiOnly(context); mMyWakeLock = new SipWakeLock((PowerManager) context.getSystemService(Context.POWER_SERVICE)); mTimer = new SipWakeupTimer(context, mExecutor); }
public ClientStatus(Context ctx) { this.ctx = ctx; // set up CPU Wake Lock // see documentation at http://developer.android.com/reference/android/os/PowerManager.html PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Logging.TAG); wakeLock.setReferenceCounted( false); // "one call to release() is sufficient to undo the effect of all previous calls to // acquire()" // set up Wifi wake lock WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, "MyWifiLock"); wifiLock.setReferenceCounted(false); }