Merge "Link to death of external vibrations" into qt-dev
am: 192b61833d
Change-Id: I48d2e57e9e9a0e6f75981a0d33d4c3c38c2b6cbe
This commit is contained in:
@@ -114,6 +114,24 @@ public class ExternalVibration implements Parcelable {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Links a recipient to death against this external vibration token
|
||||
*/
|
||||
public void linkToDeath(IBinder.DeathRecipient recipient) {
|
||||
try {
|
||||
mToken.linkToDeath(recipient, 0);
|
||||
} catch (RemoteException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlinks a recipient to death against this external vibration token
|
||||
*/
|
||||
public void unlinkToDeath(IBinder.DeathRecipient recipient) {
|
||||
mToken.unlinkToDeath(recipient, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || !(o instanceof ExternalVibration)) {
|
||||
|
||||
@@ -620,7 +620,6 @@ public class VibratorService extends IVibratorService.Stub
|
||||
linkVibration(vib);
|
||||
long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
|
||||
doCancelVibrateLocked();
|
||||
startVibrationLocked(vib);
|
||||
addToPreviousVibrationsLocked(vib);
|
||||
@@ -1437,6 +1436,8 @@ public class VibratorService extends IVibratorService.Stub
|
||||
}
|
||||
|
||||
final class ExternalVibratorService extends IExternalVibratorService.Stub {
|
||||
ExternalVibrationDeathRecipient mCurrentExternalDeathRecipient;
|
||||
|
||||
@Override
|
||||
public int onExternalVibrationStart(ExternalVibration vib) {
|
||||
if (!mSupportsExternalControl) {
|
||||
@@ -1470,6 +1471,8 @@ public class VibratorService extends IVibratorService.Stub
|
||||
// Note that this doesn't support multiple concurrent external controls, as we
|
||||
// would need to mute the old one still if it came from a different controller.
|
||||
mCurrentExternalVibration = vib;
|
||||
mCurrentExternalDeathRecipient = new ExternalVibrationDeathRecipient();
|
||||
mCurrentExternalVibration.linkToDeath(mCurrentExternalDeathRecipient);
|
||||
if (mPreviousExternalVibrations.size() > mPreviousVibrationsLimit) {
|
||||
mPreviousExternalVibrations.removeFirst();
|
||||
}
|
||||
@@ -1514,6 +1517,8 @@ public class VibratorService extends IVibratorService.Stub
|
||||
public void onExternalVibrationStop(ExternalVibration vib) {
|
||||
synchronized (mLock) {
|
||||
if (vib.equals(mCurrentExternalVibration)) {
|
||||
mCurrentExternalVibration.unlinkToDeath(mCurrentExternalDeathRecipient);
|
||||
mCurrentExternalDeathRecipient = null;
|
||||
mCurrentExternalVibration = null;
|
||||
setVibratorUnderExternalControl(false);
|
||||
if (DEBUG) {
|
||||
@@ -1522,6 +1527,14 @@ public class VibratorService extends IVibratorService.Stub
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ExternalVibrationDeathRecipient implements IBinder.DeathRecipient {
|
||||
public void binderDied() {
|
||||
synchronized (mLock) {
|
||||
onExternalVibrationStop(mCurrentExternalVibration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class VibratorShellCommand extends ShellCommand {
|
||||
|
||||
Reference in New Issue
Block a user