Loading services/core/java/com/android/server/VibratorService.java +26 −1 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ public class VibratorService extends IVibratorService.Stub private final SparseArray<ScaleLevel> mScaleLevels; private final LinkedList<VibrationInfo> mPreviousRingVibrations; private final LinkedList<VibrationInfo> mPreviousNotificationVibrations; private final LinkedList<VibrationInfo> mPreviousAlarmVibrations; private final LinkedList<VibrationInfo> mPreviousVibrations; private final int mPreviousVibrationsLimit; private final boolean mAllowPriorityVibrationsInLowPowerMode; Loading Loading @@ -259,6 +260,10 @@ public class VibratorService extends IVibratorService.Stub return VibratorService.this.isRingtone(usageHint); } public boolean isAlarm() { return VibratorService.this.isAlarm(usageHint); } public boolean isFromSystem() { return uid == Process.SYSTEM_UID || uid == 0 || SYSTEM_UI_PACKAGE.equals(opPkg); } Loading Loading @@ -359,6 +364,7 @@ public class VibratorService extends IVibratorService.Stub mPreviousRingVibrations = new LinkedList<>(); mPreviousNotificationVibrations = new LinkedList<>(); mPreviousAlarmVibrations = new LinkedList<>(); mPreviousVibrations = new LinkedList<>(); IntentFilter filter = new IntentFilter(); Loading Loading @@ -601,7 +607,7 @@ public class VibratorService extends IVibratorService.Stub Vibration vib = new Vibration(token, effect, usageHint, uid, opPkg, reason); if (mProcStatesCache.get(uid, ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND) > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND && !vib.isNotification() && !vib.isRingtone()) { && !vib.isNotification() && !vib.isRingtone() && !vib.isAlarm()) { Slog.e(TAG, "Ignoring incoming vibration as process with" + " uid = " + uid + " is background," + " usage = " + AudioAttributes.usageToString(vib.usageHint)); Loading Loading @@ -633,6 +639,8 @@ public class VibratorService extends IVibratorService.Stub previousVibrations = mPreviousRingVibrations; } else if (vib.isNotification()) { previousVibrations = mPreviousNotificationVibrations; } else if (vib.isAlarm()) { previousVibrations = mPreviousAlarmVibrations; } else { previousVibrations = mPreviousVibrations; } Loading Loading @@ -797,6 +805,8 @@ public class VibratorService extends IVibratorService.Stub return mNotificationIntensity; } else if (vib.isHapticFeedback()) { return mHapticFeedbackIntensity; } else if (vib.isAlarm()) { return Vibrator.VIBRATION_INTENSITY_HIGH; } else { return Vibrator.VIBRATION_INTENSITY_MEDIUM; } Loading @@ -821,6 +831,8 @@ public class VibratorService extends IVibratorService.Stub defaultIntensity = mVibrator.getDefaultNotificationVibrationIntensity(); } else if (vib.isHapticFeedback()) { defaultIntensity = mVibrator.getDefaultHapticFeedbackIntensity(); } else if (vib.isAlarm()) { defaultIntensity = Vibrator.VIBRATION_INTENSITY_HIGH; } else { // If we don't know what kind of vibration we're playing then just skip scaling for // now. Loading Loading @@ -1153,6 +1165,10 @@ public class VibratorService extends IVibratorService.Stub return usageHint == AudioAttributes.USAGE_ASSISTANCE_SONIFICATION; } private static boolean isAlarm(int usageHint) { return usageHint == AudioAttributes.USAGE_ALARM; } private void noteVibratorOnLocked(int uid, long millis) { try { mBatteryStatsService.noteVibratorOn(uid, millis); Loading Loading @@ -1384,6 +1400,12 @@ public class VibratorService extends IVibratorService.Stub pw.println(info.toString()); } pw.println(" Previous alarm vibrations:"); for (VibrationInfo info : mPreviousAlarmVibrations) { pw.print(" "); pw.println(info.toString()); } pw.println(" Previous vibrations:"); for (VibrationInfo info : mPreviousVibrations) { pw.print(" "); Loading Loading @@ -1449,6 +1471,9 @@ public class VibratorService extends IVibratorService.Stub } else if (isHapticFeedback(usage)) { defaultIntensity = mVibrator.getDefaultHapticFeedbackIntensity(); currentIntensity = mHapticFeedbackIntensity; } else if (isAlarm(usage)) { defaultIntensity = Vibrator.VIBRATION_INTENSITY_HIGH; currentIntensity = Vibrator.VIBRATION_INTENSITY_HIGH; } else { defaultIntensity = 0; currentIntensity = 0; Loading Loading
services/core/java/com/android/server/VibratorService.java +26 −1 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ public class VibratorService extends IVibratorService.Stub private final SparseArray<ScaleLevel> mScaleLevels; private final LinkedList<VibrationInfo> mPreviousRingVibrations; private final LinkedList<VibrationInfo> mPreviousNotificationVibrations; private final LinkedList<VibrationInfo> mPreviousAlarmVibrations; private final LinkedList<VibrationInfo> mPreviousVibrations; private final int mPreviousVibrationsLimit; private final boolean mAllowPriorityVibrationsInLowPowerMode; Loading Loading @@ -259,6 +260,10 @@ public class VibratorService extends IVibratorService.Stub return VibratorService.this.isRingtone(usageHint); } public boolean isAlarm() { return VibratorService.this.isAlarm(usageHint); } public boolean isFromSystem() { return uid == Process.SYSTEM_UID || uid == 0 || SYSTEM_UI_PACKAGE.equals(opPkg); } Loading Loading @@ -359,6 +364,7 @@ public class VibratorService extends IVibratorService.Stub mPreviousRingVibrations = new LinkedList<>(); mPreviousNotificationVibrations = new LinkedList<>(); mPreviousAlarmVibrations = new LinkedList<>(); mPreviousVibrations = new LinkedList<>(); IntentFilter filter = new IntentFilter(); Loading Loading @@ -601,7 +607,7 @@ public class VibratorService extends IVibratorService.Stub Vibration vib = new Vibration(token, effect, usageHint, uid, opPkg, reason); if (mProcStatesCache.get(uid, ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND) > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND && !vib.isNotification() && !vib.isRingtone()) { && !vib.isNotification() && !vib.isRingtone() && !vib.isAlarm()) { Slog.e(TAG, "Ignoring incoming vibration as process with" + " uid = " + uid + " is background," + " usage = " + AudioAttributes.usageToString(vib.usageHint)); Loading Loading @@ -633,6 +639,8 @@ public class VibratorService extends IVibratorService.Stub previousVibrations = mPreviousRingVibrations; } else if (vib.isNotification()) { previousVibrations = mPreviousNotificationVibrations; } else if (vib.isAlarm()) { previousVibrations = mPreviousAlarmVibrations; } else { previousVibrations = mPreviousVibrations; } Loading Loading @@ -797,6 +805,8 @@ public class VibratorService extends IVibratorService.Stub return mNotificationIntensity; } else if (vib.isHapticFeedback()) { return mHapticFeedbackIntensity; } else if (vib.isAlarm()) { return Vibrator.VIBRATION_INTENSITY_HIGH; } else { return Vibrator.VIBRATION_INTENSITY_MEDIUM; } Loading @@ -821,6 +831,8 @@ public class VibratorService extends IVibratorService.Stub defaultIntensity = mVibrator.getDefaultNotificationVibrationIntensity(); } else if (vib.isHapticFeedback()) { defaultIntensity = mVibrator.getDefaultHapticFeedbackIntensity(); } else if (vib.isAlarm()) { defaultIntensity = Vibrator.VIBRATION_INTENSITY_HIGH; } else { // If we don't know what kind of vibration we're playing then just skip scaling for // now. Loading Loading @@ -1153,6 +1165,10 @@ public class VibratorService extends IVibratorService.Stub return usageHint == AudioAttributes.USAGE_ASSISTANCE_SONIFICATION; } private static boolean isAlarm(int usageHint) { return usageHint == AudioAttributes.USAGE_ALARM; } private void noteVibratorOnLocked(int uid, long millis) { try { mBatteryStatsService.noteVibratorOn(uid, millis); Loading Loading @@ -1384,6 +1400,12 @@ public class VibratorService extends IVibratorService.Stub pw.println(info.toString()); } pw.println(" Previous alarm vibrations:"); for (VibrationInfo info : mPreviousAlarmVibrations) { pw.print(" "); pw.println(info.toString()); } pw.println(" Previous vibrations:"); for (VibrationInfo info : mPreviousVibrations) { pw.print(" "); Loading Loading @@ -1449,6 +1471,9 @@ public class VibratorService extends IVibratorService.Stub } else if (isHapticFeedback(usage)) { defaultIntensity = mVibrator.getDefaultHapticFeedbackIntensity(); currentIntensity = mHapticFeedbackIntensity; } else if (isAlarm(usage)) { defaultIntensity = Vibrator.VIBRATION_INTENSITY_HIGH; currentIntensity = Vibrator.VIBRATION_INTENSITY_HIGH; } else { defaultIntensity = 0; currentIntensity = 0; Loading