mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1168175 - Follow-up: Guard against null contexts. r=bustage
On a CLOSED TREE. So, apparently we race to have a non-null application context from the target context. No matter, we can use the target context directly.
This commit is contained in:
parent
685025dfb0
commit
2f4cc4cba4
@ -40,8 +40,8 @@ public class FennecInstrumentationTestRunner extends InstrumentationTestRunner {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
final Context app = getTargetContext().getApplicationContext();
|
||||
|
||||
final Context app = getTargetContext();
|
||||
if (app != null) {
|
||||
final String name = FennecInstrumentationTestRunner.class.getSimpleName();
|
||||
// Unlock the device so that the tests can input keystrokes.
|
||||
final KeyguardManager keyguard = (KeyguardManager) app.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
@ -53,6 +53,9 @@ public class FennecInstrumentationTestRunner extends InstrumentationTestRunner {
|
||||
final PowerManager power = (PowerManager) app.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = power.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE, name);
|
||||
wakeLock.acquire();
|
||||
} else {
|
||||
Log.e("GeckoInstTestRunner", "Application target context is null: not disabling keyguard and not taking wakelock.");
|
||||
}
|
||||
|
||||
super.onStart();
|
||||
}
|
||||
@ -61,8 +64,12 @@ public class FennecInstrumentationTestRunner extends InstrumentationTestRunner {
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (wakeLock != null) {
|
||||
wakeLock.release();
|
||||
}
|
||||
if (keyguardLock != null) {
|
||||
// Deprecated in favour of window flags, which aren't appropriate here.
|
||||
keyguardLock.reenableKeyguard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user