Permalink
Browse files

front: Use a wake lock while emulating to attempt to prevent devices …

…from

under clocking.
  • Loading branch information...
fzurita committed Jan 24, 2016
1 parent 5d22b6e commit ae0c33447f754ee7791bd8c2774c410c6e3b32d9
Showing with 11 additions and 0 deletions.
  1. +1 −0 AndroidManifest.xml
  2. +10 −0 src/paulscode/android/mupen64plusae/game/GameActivity.java
View
@@ -21,6 +21,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name="paulscode.android.mupen64plusae.AppMupen64Plus"
@@ -71,6 +71,8 @@
import android.hardware.SensorManager;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.Vibrator;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
@@ -162,6 +164,7 @@
private GameAutoSaveManager mAutoSaveManager;
private boolean mFirstStart;
private boolean mWaitingOnConfirmation = false;
WakeLock mWakeLock = null;
@Override
protected void onCreate( Bundle savedInstanceState )
@@ -179,6 +182,11 @@ protected void onCreate( Bundle savedInstanceState )
setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
//Attempt to use a wake lock to prevent devices from under clocking
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"MyWakelockTag");
mControllers = new ArrayList<AbstractController>();
mMogaController = Controller.getInstance( this );
@@ -361,6 +369,7 @@ protected void onResume()
mGlobalPrefs.displayActionBarTransparency));
mMogaController.onResume();
mWakeLock.acquire();
}
@Override
@@ -377,6 +386,7 @@ protected void onPause()
}
mMogaController.onPause();
mWakeLock.release();
}
@Override

0 comments on commit ae0c334

Please sign in to comment.