From 329a938bf81925a3a908c1e5f1482cdc177e84e5 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 19 Jun 2014 18:26:33 -0700 Subject: [PATCH] Hold a high performance Wi-Fi lock while streaming --- AndroidManifest.xml | 1 + src/com/limelight/Game.java | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 0bffb925..f9edd80b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -10,6 +10,7 @@ + diff --git a/src/com/limelight/Game.java b/src/com/limelight/Game.java index c55d50e0..56e143eb 100644 --- a/src/com/limelight/Game.java +++ b/src/com/limelight/Game.java @@ -19,6 +19,7 @@ import android.content.SharedPreferences; import android.graphics.Point; import android.media.AudioManager; import android.net.ConnectivityManager; +import android.net.wifi.WifiManager; import android.os.Bundle; import android.os.Handler; import android.view.Display; @@ -56,6 +57,8 @@ public class Game extends Activity implements SurfaceHolder.Callback, OnGenericM private boolean connecting = false; private boolean connected = false; + private WifiManager.WifiLock wifiLock; + private int drFlags = 0; public static final String PREFS_FILE_NAME = "gameprefs"; @@ -152,7 +155,13 @@ public class Game extends Activity implements SurfaceHolder.Callback, OnGenericM // Warn the user if they're on a metered connection checkDataConnection(); - + + // Make sure Wi-Fi is fully powered up + WifiManager wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE); + wifiLock = wifiMgr.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "Limelight"); + wifiLock.setReferenceCounted(false); + wifiLock.acquire(); + // Start the connection conn = new NvConnection(Game.this.getIntent().getStringExtra("host"), Game.this, new StreamConfiguration(width, height, refreshRate, bitrate * 1000), PlatformBinding.getCryptoProvider(this)); @@ -214,6 +223,13 @@ public class Game extends Activity implements SurfaceHolder.Callback, OnGenericM finish(); } + @Override + protected void onDestroy() { + super.onDestroy(); + + wifiLock.release(); + } + private static byte getModifierState(KeyEvent event) { byte modifier = 0; if (event.isShiftPressed()) {