summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2021-09-01 12:17:04 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-09-01 12:17:04 +0000
commit73f898f900216bd01772cd048dd769c015dfd5be (patch)
tree4c4714a50a8c3f7db19691f625741f4a02cc4f9a /core/java/android
parent40743c0cb055644eb0bf241c4ca28aa9f6e65c8a (diff)
parent81b893734f05d01bed829f25948c826d118a627d (diff)
Merge "Allow blocking transaction to IExternalVibrationController"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/os/ExternalVibration.java29
1 files changed, 21 insertions, 8 deletions
diff --git a/core/java/android/os/ExternalVibration.java b/core/java/android/os/ExternalVibration.java
index 7fd02116814b..0686dd689499 100644
--- a/core/java/android/os/ExternalVibration.java
+++ b/core/java/android/os/ExternalVibration.java
@@ -42,25 +42,38 @@ public class ExternalVibration implements Parcelable {
// boundaries.
@NonNull
private IBinder mToken;
-
public ExternalVibration(int uid, @NonNull String pkg, @NonNull AudioAttributes attrs,
@NonNull IExternalVibrationController controller) {
+ this(uid, pkg, attrs, controller, new Binder());
+ }
+
+ private ExternalVibration(int uid, @NonNull String pkg, @NonNull AudioAttributes attrs,
+ @NonNull IExternalVibrationController controller, @NonNull IBinder token) {
mUid = uid;
mPkg = Preconditions.checkNotNull(pkg);
mAttrs = Preconditions.checkNotNull(attrs);
mController = Preconditions.checkNotNull(controller);
- mToken = new Binder();
+ mToken = Preconditions.checkNotNull(token);
+
+ // IExternalVibrationController is a hidden AIDL interface with implementation provided by
+ // the audio framework to allow mute/unmute control over the external vibration.
+ //
+ // Transactions are locked in audioflinger, and should be blocking to avoid racing
+ // conditions on multiple audio playback.
+ //
+ // They can also be triggered before starting a new external vibration in
+ // IExternalVibratorService, as the ongoing external vibration needs to be muted before the
+ // new one can start, which also requires blocking calls to mute.
+ Binder.allowBlocking(mController.asBinder());
}
private ExternalVibration(Parcel in) {
- mUid = in.readInt();
- mPkg = in.readString();
- mAttrs = readAudioAttributes(in);
- mController = IExternalVibrationController.Stub.asInterface(in.readStrongBinder());
- mToken = in.readStrongBinder();
+ this(in.readInt(), in.readString(), readAudioAttributes(in),
+ IExternalVibrationController.Stub.asInterface(in.readStrongBinder()),
+ in.readStrongBinder());
}
- private AudioAttributes readAudioAttributes(Parcel in) {
+ private static AudioAttributes readAudioAttributes(Parcel in) {
int usage = in.readInt();
int contentType = in.readInt();
int capturePreset = in.readInt();