Bug 1356698 - Use application context in AndroidGamepadManager; r=snorp

Use application context in AndroidGamepadManager to avoid crash when
trying to use GeckoAppShell.getContext() in content process.
This commit is contained in:
Jim Chen 2017-05-11 16:39:30 -04:00
parent 7785e0c15b
commit 18c0a5d9ca

View File

@ -407,7 +407,10 @@ public class AndroidGamepadManager {
public void onInputDeviceChanged(int deviceId) {
}
};
((InputManager) GeckoAppShell.getContext().getSystemService(Context.INPUT_SERVICE)).registerInputDeviceListener(sListener, ThreadUtils.getUiHandler());
final InputManager im = (InputManager)
GeckoAppShell.getApplicationContext()
.getSystemService(Context.INPUT_SERVICE);
im.registerInputDeviceListener(sListener, ThreadUtils.getUiHandler());
}
}
@ -418,7 +421,10 @@ public class AndroidGamepadManager {
sPollTimer = null;
}
} else {
((InputManager) GeckoAppShell.getContext().getSystemService(Context.INPUT_SERVICE)).unregisterInputDeviceListener(sListener);
final InputManager im = (InputManager)
GeckoAppShell.getApplicationContext()
.getSystemService(Context.INPUT_SERVICE);
im.unregisterInputDeviceListener(sListener);
sListener = null;
}
}