Search in sources :

Example 11 with Vibrator

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);
}
Also used : SystemVibrator(android.os.SystemVibrator) Vibrator(android.os.Vibrator) SystemVibrator(android.os.SystemVibrator) RemoteException(android.os.RemoteException) ErrnoException(android.system.ErrnoException) IOException(java.io.IOException)

Example 12 with Vibrator

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);
}
Also used : Vibrator(android.os.Vibrator)

Example 13 with Vibrator

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);
    }
}
Also used : Vibrator(android.os.Vibrator)

Example 14 with Vibrator

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);
        }
    }
}
Also used : Ringtone(android.media.Ringtone) Vibrator(android.os.Vibrator) ContentResolver(android.content.ContentResolver)

Example 15 with Vibrator

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);
    }
}
Also used : Vibrator(android.os.Vibrator)

Aggregations

Vibrator (android.os.Vibrator)159 Intent (android.content.Intent)15 IOException (java.io.IOException)14 Uri (android.net.Uri)12 Context (android.content.Context)10 Handler (android.os.Handler)10 View (android.view.View)10 NotificationManager (android.app.NotificationManager)8 RemoteException (android.os.RemoteException)8 ImageView (android.widget.ImageView)8 AudioManager (android.media.AudioManager)7 SettingNotFoundException (android.provider.Settings.SettingNotFoundException)6 InputDevice (android.view.InputDevice)6 TextView (android.widget.TextView)6 Activity (android.app.Activity)5 Bitmap (android.graphics.Bitmap)5 FileOutputStream (java.io.FileOutputStream)5 ExecutionException (java.util.concurrent.ExecutionException)5 ListenableFuture (org.thoughtcrime.securesms.util.concurrent.ListenableFuture)5 SuppressLint (android.annotation.SuppressLint)4