Bug 1289208 - Move gamepad methods out of GeckoAppShell; r=snorp

Move gamepad methods called by native code out of GeckoAppShell and into
AndroidGamepadManager.
This commit is contained in:
Jim Chen 2016-08-04 09:16:05 -04:00
Родитель 56e79ec2bc
Коммит e5eac1e286
4 изменённых файлов: 36 добавлений и 36 удалений

Просмотреть файл

@ -11,12 +11,12 @@ namespace dom {
void StartGamepadMonitoring()
{
java::GeckoAppShell::StartMonitoringGamepad();
java::AndroidGamepadManager::Start();
}
void StopGamepadMonitoring()
{
java::GeckoAppShell::StopMonitoringGamepad();
java::AndroidGamepadManager::Stop();
}
} // namespace dom

Просмотреть файл

@ -137,7 +137,17 @@ public class AndroidGamepadManager {
private AndroidGamepadManager() {
}
public static void startup() {
@WrapForJNI(allowMultithread = true)
private static void start() {
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
doStart();
}
});
}
/* package */ static void doStart() {
ThreadUtils.assertOnUiThread();
if (!sStarted) {
scanForGamepads();
@ -146,7 +156,17 @@ public class AndroidGamepadManager {
}
}
public static void shutdown() {
@WrapForJNI(allowMultithread = true)
private static void stop() {
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
doStop();
}
});
}
/* package */ static void doStop() {
ThreadUtils.assertOnUiThread();
if (sStarted) {
removeDeviceListener();
@ -156,7 +176,17 @@ public class AndroidGamepadManager {
}
}
public static void gamepadAdded(int deviceId, int serviceId) {
@WrapForJNI
private static void onGamepadAdded(final int device_id, final int service_id) {
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
handleGamepadAdded(device_id, service_id);
}
});
}
/* package */ static void handleGamepadAdded(int deviceId, int serviceId) {
ThreadUtils.assertOnUiThread();
if (!sStarted) {
return;

Просмотреть файл

@ -860,36 +860,6 @@ public class GeckoAppShell
}
}
@WrapForJNI
public static void startMonitoringGamepad() {
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
AndroidGamepadManager.startup();
}
});
}
@WrapForJNI
public static void stopMonitoringGamepad() {
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
AndroidGamepadManager.shutdown();
}
});
}
@WrapForJNI
public static void gamepadAdded(final int device_id, final int service_id) {
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
AndroidGamepadManager.gamepadAdded(device_id, service_id);
}
});
}
@WrapForJNI
public static void moveTaskToBack() {
if (getGeckoInterface() != null)

Просмотреть файл

@ -706,7 +706,7 @@ nsAppShell::LegacyGeckoEvent::Run()
dom::GamepadMappingType::Standard,
dom::kStandardGamepadButtons,
dom::kStandardGamepadAxes);
java::GeckoAppShell::GamepadAdded(curEvent->ID(), svc_id);
java::AndroidGamepadManager::OnGamepadAdded(curEvent->ID(), svc_id);
} else if (curEvent->Action() == AndroidGeckoEvent::ACTION_GAMEPAD_REMOVED) {
service->RemoveGamepad(curEvent->ID());
}