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