Bug 679966, part 2: Add mozVibrator() for "playing" a vibration pattern. r=bz

This commit is contained in:
Justin Lebar
2011-11-10 16:26:36 -05:00
parent e28ce2d492
commit 4ed94dfb3e
7 changed files with 354 additions and 10 deletions

View File

@@ -50,16 +50,28 @@ Vibrate(const nsTArray<uint32> &pattern, const WindowIdentifier &)
// hal_sandbox::Vibrate, and hal_impl::Vibrate all must have the same
// signature.
// Strangely enough, the Android Java API seems to treat vibrate([0]) as a
// nop. But we want to treat vibrate([0]) like CancelVibrate! (Note that we
// also need to treat vibrate([]) as a call to CancelVibrate.)
bool allZero = true;
for (uint32 i = 0; i < pattern.Length(); i++) {
if (pattern[i] != 0) {
allZero = false;
break;
}
}
if (allZero) {
hal_impl::CancelVibrate(WindowIdentifier());
return;
}
AndroidBridge* b = AndroidBridge::Bridge();
if (!b) {
return;
}
if (pattern.Length() == 0) {
b->CancelVibrate();
} else {
b->Vibrate(pattern);
}
b->Vibrate(pattern);
}
void