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

Commit b9d173ce authored by Brad Fitzpatrick's avatar Brad Fitzpatrick Committed by Android Git Automerger
Browse files

am f6809853: am 7a84a60d: am 1a5a2379: Merge "Unregister callback from binder...

am f6809853: am 7a84a60d: am 1a5a2379: Merge "Unregister callback from binder when vibration is removed"

* commit 'f6809853':
  Unregister callback from binder when vibration is removed
parents d0b4e961 f6809853
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -247,6 +247,7 @@ public class VibratorService extends IVibratorService.Stub {
    // Lock held on mVibrations
    private void startNextVibrationLocked() {
        if (mVibrations.size() <= 0) {
            mCurrentVibration = null;
            return;
        }
        mCurrentVibration = mVibrations.getFirst();
@@ -273,17 +274,27 @@ public class VibratorService extends IVibratorService.Stub {
            Vibration vib = iter.next();
            if (vib.mToken == token) {
                iter.remove();
                unlinkVibration(vib);
                return vib;
            }
        }
        // We might be looking for a simple vibration which is only stored in
        // mCurrentVibration.
        if (mCurrentVibration != null && mCurrentVibration.mToken == token) {
            unlinkVibration(mCurrentVibration);
            return mCurrentVibration;
        }
        return null;
    }

    private void unlinkVibration(Vibration vib) {
        if (vib.mPattern != null) {
            // If Vibration object has a pattern,
            // the Vibration object has also been linkedToDeath.
            vib.mToken.unlinkToDeath(vib, 0);
        }
    }

    private class VibrateThread extends Thread {
        final Vibration mVibration;
        boolean mDone;
@@ -360,6 +371,7 @@ public class VibratorService extends IVibratorService.Stub {
                    // If this vibration finished naturally, start the next
                    // vibration.
                    mVibrations.remove(mVibration);
                    unlinkVibration(mVibration);
                    startNextVibrationLocked();
                }
            }