use of android.os.Vibrator in project android_frameworks_base by ResurrectionRemix.
the class ShutdownThread method rebootOrShutdown.
/**
* Do not call this directly. Use {@link #reboot(Context, String, boolean)}
* or {@link #shutdown(Context, boolean)} instead.
*
* @param context Context used to vibrate or null without vibration
* @param reboot true to reboot or false to shutdown
* @param reason reason for reboot/shutdown
*/
public static void rebootOrShutdown(final Context context, boolean reboot, String reason) {
// Call oem shutdown handler
deviceRebootOrShutdown(reboot, reason);
if (reboot) {
Log.i(TAG, "Rebooting, reason: " + reason);
PowerManagerService.lowLevelReboot(reason);
Log.e(TAG, "Reboot failed, will attempt shutdown instead");
reason = null;
} else if (SHUTDOWN_VIBRATE_MS > 0 && context != null) {
// vibrate before shutting down
Vibrator vibrator = new SystemVibrator(context);
try {
vibrator.vibrate(SHUTDOWN_VIBRATE_MS, VIBRATION_ATTRIBUTES);
} catch (Exception e) {
// Failure to vibrate shouldn't interrupt shutdown. Just log it.
Log.w(TAG, "Failed to vibrate during shutdown.", e);
}
// vibrator is asynchronous so we need to wait to avoid shutting down too soon.
try {
Thread.sleep(SHUTDOWN_VIBRATE_MS);
} catch (InterruptedException unused) {
}
}
// Shutdown power
Log.i(TAG, "Performing low-level shutdown...");
PowerManagerService.lowLevelShutdown(reason);
}
use of android.os.Vibrator in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VibratorIntensity method testVibration.
private void testVibration() {
final Vibrator vib = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
vib.vibrate(200);
}
use of android.os.Vibrator in project zxing by zxing.
the class BeepManager method playBeepSoundAndVibrate.
synchronized void playBeepSoundAndVibrate() {
if (playBeep && mediaPlayer != null) {
mediaPlayer.start();
}
if (vibrate) {
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}
use of android.os.Vibrator in project android_frameworks_base by DirtyUnicorns.
the class PowerUI method playPowerNotificationSound.
void playPowerNotificationSound() {
final ContentResolver cr = mContext.getContentResolver();
final boolean customSound = Settings.Global.getInt(cr, Settings.Global.POWER_NOTIFICATION_CUSTOM_RINGTONE, 0) != 0;
final String soundPath = customSound ? Settings.Global.getString(cr, Settings.Global.POWER_NOTIFICATIONS_RINGTONE) : Settings.Global.getString(cr, Settings.Global.WIRELESS_CHARGING_STARTED_SOUND);
if (soundPath != null && !soundPath.equals(POWER_NOTIFICATIONS_SILENT_URI)) {
Ringtone powerRingtone = RingtoneManager.getRingtone(mContext, Uri.parse(soundPath));
if (powerRingtone != null) {
powerRingtone.play();
}
}
if (Settings.Global.getInt(cr, Settings.Global.POWER_NOTIFICATIONS_VIBRATE, 0) == 1) {
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
if (vibrator != null) {
vibrator.vibrate(250);
}
}
}
use of android.os.Vibrator in project android_frameworks_base by DirtyUnicorns.
the class FingerprintUtils method vibrateFingerprintSuccess.
public static void vibrateFingerprintSuccess(Context context) {
Vibrator vibrator = context.getSystemService(Vibrator.class);
boolean FingerprintVib = Settings.System.getIntForUser(context.getContentResolver(), Settings.System.FINGERPRINT_SUCCESS_VIB, 1, UserHandle.USER_CURRENT) == 1;
if (vibrator != null && FingerprintVib) {
vibrator.vibrate(FP_SUCCESS_VIBRATE_PATTERN, -1);
}
}
Aggregations