SystemVibratorpublic class SystemVibrator extends Vibrator Vibrator implementation that controls the main system vibrator. |
Fields Summary |
---|
private static final String | TAG | private final IVibratorService | mService | private final Binder | mToken |
Constructors Summary |
---|
public SystemVibrator()
mService = IVibratorService.Stub.asInterface(
ServiceManager.getService("vibrator"));
| public SystemVibrator(android.content.Context context)
super(context);
mService = IVibratorService.Stub.asInterface(
ServiceManager.getService("vibrator"));
|
Methods Summary |
---|
public void | cancel()
if (mService == null) {
return;
}
try {
mService.cancelVibrate(mToken);
} catch (RemoteException e) {
Log.w(TAG, "Failed to cancel vibration.", e);
}
| public boolean | hasVibrator()
if (mService == null) {
Log.w(TAG, "Failed to vibrate; no vibrator service.");
return false;
}
try {
return mService.hasVibrator();
} catch (RemoteException e) {
}
return false;
| private static int | usageForAttributes(android.media.AudioAttributes attributes)
return attributes != null ? attributes.getUsage() : AudioAttributes.USAGE_UNKNOWN;
| public void | vibrate(int uid, java.lang.String opPkg, long milliseconds, android.media.AudioAttributes attributes)
if (mService == null) {
Log.w(TAG, "Failed to vibrate; no vibrator service.");
return;
}
try {
mService.vibrate(uid, opPkg, milliseconds, usageForAttributes(attributes), mToken);
} catch (RemoteException e) {
Log.w(TAG, "Failed to vibrate.", e);
}
| public void | vibrate(int uid, java.lang.String opPkg, long[] pattern, int repeat, android.media.AudioAttributes attributes)
if (mService == null) {
Log.w(TAG, "Failed to vibrate; no vibrator service.");
return;
}
// catch this here because the server will do nothing. pattern may
// not be null, let that be checked, because the server will drop it
// anyway
if (repeat < pattern.length) {
try {
mService.vibratePattern(uid, opPkg, pattern, repeat, usageForAttributes(attributes),
mToken);
} catch (RemoteException e) {
Log.w(TAG, "Failed to vibrate.", e);
}
} else {
throw new ArrayIndexOutOfBoundsException();
}
|
|