diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-05-21 02:38:11 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-21 02:38:11 +0000 |
commit | ccf51bef288652cb618a566a376173e252b84af0 (patch) | |
tree | 5b8dc8df4ca657abba9835f9099dd1c39536f41d /services/core | |
parent | 8f120dd6d631ac632d3356b81403a53f958021f0 (diff) | |
parent | 2d9b513dab78242281bca125b4abc6b8235089a6 (diff) | |
download | frameworks_base-ccf51bef288652cb618a566a376173e252b84af0.zip frameworks_base-ccf51bef288652cb618a566a376173e252b84af0.tar.gz frameworks_base-ccf51bef288652cb618a566a376173e252b84af0.tar.bz2 |
am 2d9b513d: Merge "I\'m feeling the good vibrations." into klp-modular-dev
* commit '2d9b513dab78242281bca125b4abc6b8235089a6':
I'm feeling the good vibrations.
Diffstat (limited to 'services/core')
-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 28eb948..09828fb 100644 --- a/services/core/java/com/android/server/VibratorService.java +++ b/services/core/java/com/android/server/VibratorService.java @@ -46,6 +46,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; @@ -130,6 +131,10 @@ public class VibratorService extends IVibratorService.Stub } return true; } + + public boolean isSystemHapticFeedback() { + return (mUid == Process.SYSTEM_UID || mUid == 0) && mRepeat < 0; + } } VibratorService(Context context) { @@ -592,20 +597,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(); + } + } } } } |