diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-05-21 02:41:06 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-21 02:41:06 +0000 |
commit | 7a32533c62fc7ac5d38f40de7372bc4314f7f2e5 (patch) | |
tree | fd275a49d41f2fb4d04c28cf8719ff3fc40a67d9 /services | |
parent | df3bad37d2e3b52a86b18e0d9c84ede4d5098f92 (diff) | |
parent | ccf51bef288652cb618a566a376173e252b84af0 (diff) | |
download | frameworks_base-7a32533c62fc7ac5d38f40de7372bc4314f7f2e5.zip frameworks_base-7a32533c62fc7ac5d38f40de7372bc4314f7f2e5.tar.gz frameworks_base-7a32533c62fc7ac5d38f40de7372bc4314f7f2e5.tar.bz2 |
am ccf51bef: am 2d9b513d: Merge "I\'m feeling the good vibrations." into klp-modular-dev
* commit 'ccf51bef288652cb618a566a376173e252b84af0':
I'm feeling the good vibrations.
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/VibratorService.java | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/VibratorService.java b/services/core/java/com/android/server/VibratorService.java index 82c13e0..06dd3ed 100644 --- a/services/core/java/com/android/server/VibratorService.java +++ b/services/core/java/com/android/server/VibratorService.java @@ -47,6 +47,7 @@ import com.android.internal.app.IAppOpsService; import com.android.internal.app.IBatteryStats; import java.util.ArrayList; +import java.util.Iterator; import java.util.LinkedList; import java.util.ListIterator; @@ -136,6 +137,10 @@ public class VibratorService extends IVibratorService.Stub } return true; } + + public boolean isSystemHapticFeedback() { + return (mUid == Process.SYSTEM_UID || mUid == 0) && mRepeat < 0; + } } VibratorService(Context context) { @@ -622,20 +627,32 @@ public class VibratorService extends IVibratorService.Stub } } } - }; + } BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { + @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { synchronized (mVibrations) { - doCancelVibrateLocked(); - - int size = mVibrations.size(); - for(int i = 0; i < size; i++) { - unlinkVibration(mVibrations.get(i)); + // When the system is entering a non-interactive state, we want + // to cancel vibrations in case a misbehaving app has abandoned + // them. However it may happen that the system is currently playing + // haptic feedback as part of the transition. So we don't cancel + // system vibrations. + if (mCurrentVibration != null + && !mCurrentVibration.isSystemHapticFeedback()) { + doCancelVibrateLocked(); } - mVibrations.clear(); + // Clear all remaining vibrations. + Iterator<Vibration> it = mVibrations.iterator(); + while (it.hasNext()) { + Vibration vibration = it.next(); + if (vibration != mCurrentVibration) { + unlinkVibration(vibration); + it.remove(); + } + } } } } |