Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ccf51bef authored by Jeff Brown's avatar Jeff Brown Committed by Android Git Automerger
Browse files

am 2d9b513d: Merge "I\'m feeling the good vibrations." into klp-modular-dev

* commit '2d9b513d':
  I'm feeling the good vibrations.
parents 8f120dd6 2d9b513d
Loading
Loading
Loading
Loading
+24 −7
Original line number Diff line number Diff line
@@ -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) {
                    // 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();

                    int size = mVibrations.size();
                    for(int i = 0; i < size; i++) {
                        unlinkVibration(mVibrations.get(i));
                    }

                    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();
                        }
                    }
                }
            }
        }