From 0cac01d92a0a3e9a420047a30e4bc5e5a4f69c3d Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Tue, 28 Sep 2010 06:47:15 -0500 Subject: Remove WAKE_LOCK permission; yay Use window flags instead of a wake lock to keep the screen on. This allows us to make the WindowManager do all the wake lockey things that are annoying and error prone. --- src/org/connectbot/ConsoleActivity.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/org') diff --git a/src/org/connectbot/ConsoleActivity.java b/src/org/connectbot/ConsoleActivity.java index 2b5cbb4..f0d930f 100644 --- a/src/org/connectbot/ConsoleActivity.java +++ b/src/org/connectbot/ConsoleActivity.java @@ -44,7 +44,6 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; -import android.os.PowerManager; import android.preference.PreferenceManager; import android.text.ClipboardManager; import android.util.Log; @@ -99,8 +98,6 @@ public class ConsoleActivity extends Activity { private SharedPreferences prefs = null; - private PowerManager.WakeLock wakelock = null; - protected Uri requested; protected ClipboardManager clipboard; @@ -278,9 +275,6 @@ public class ConsoleActivity extends Activity { // TODO find proper way to disable volume key beep if it exists. setVolumeControlStream(AudioManager.STREAM_MUSIC); - PowerManager manager = (PowerManager)getSystemService(Context.POWER_SERVICE); - wakelock = manager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG); - // handle requested console from incoming intent requested = getIntent().getData(); @@ -817,10 +811,6 @@ public class ConsoleActivity extends Activity { super.onPause(); Log.d(TAG, "onPause called"); - // Allow the screen to dim and fall asleep. - if (wakelock != null && wakelock.isHeld()) - wakelock.release(); - if (forcedOrientation && bound != null) bound.setResizeAllowed(false); } @@ -832,8 +822,11 @@ public class ConsoleActivity extends Activity { // Make sure we don't let the screen fall asleep. // This also keeps the Wi-Fi chipset from disconnecting us. - if (wakelock != null && prefs.getBoolean(PreferenceConstants.KEEP_ALIVE, true)) - wakelock.acquire(); + if (prefs.getBoolean(PreferenceConstants.KEEP_ALIVE, true)) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } else { + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } configureOrientation(); -- cgit v1.2.3