summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Atneya Nair <atneya@google.com> 2023-04-01 01:52:02 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-04-01 01:52:02 +0000
commit3fb19e904328c299a62ea3dbf0c1879cdd396b9f (patch)
tree75ca2f5468aa47395ad84d511620d47bba34eebc
parente7d9a12327ed2a0496986a5bd9dd5d4795338ec1 (diff)
parent147d90ed7e49c1ac14f95c06efd764ac7bb0f0f6 (diff)
Merge "Add triggerOnResourceAvailable to fake STHAL" into udc-dev
-rw-r--r--media/aidl/android/media/soundtrigger_middleware/IInjectGlobalEvent.aidl13
-rw-r--r--services/voiceinteraction/java/com/android/server/soundtrigger_middleware/FakeSoundTriggerHal.java29
2 files changed, 30 insertions, 12 deletions
diff --git a/media/aidl/android/media/soundtrigger_middleware/IInjectGlobalEvent.aidl b/media/aidl/android/media/soundtrigger_middleware/IInjectGlobalEvent.aidl
index dcf39458b261..47d84264a9cd 100644
--- a/media/aidl/android/media/soundtrigger_middleware/IInjectGlobalEvent.aidl
+++ b/media/aidl/android/media/soundtrigger_middleware/IInjectGlobalEvent.aidl
@@ -25,14 +25,14 @@ import android.media.soundtrigger_middleware.IAcknowledgeEvent;
oneway interface IInjectGlobalEvent {
/**
- * Request a fake STHAL restart.
+ * Trigger a fake STHAL restart.
* This invalidates the {@link IInjectGlobalEvent}.
*/
void triggerRestart();
/**
- * Triggers global resource contention into the fake STHAL. Loads/startRecognition
- * will fail with RESOURCE_CONTENTION.
+ * Set global resource contention within the fake STHAL. Loads/startRecognition
+ * will fail with {@code RESOURCE_CONTENTION} until unset.
* @param isContended - true to enable resource contention. false to disable resource contention
* and resume normal functionality.
* @param callback - Call {@link IAcknowledgeEvent#eventReceived()} on this interface once
@@ -40,4 +40,11 @@ oneway interface IInjectGlobalEvent {
*/
void setResourceContention(boolean isContended, IAcknowledgeEvent callback);
+ /**
+ * Trigger an
+ * {@link android.hardware.soundtrigger3.ISoundTriggerHwGlobalCallback#onResourcesAvailable}
+ * callback from the fake STHAL. This callback is used to signal to the framework that
+ * previous operations which failed may now succeed.
+ */
+ void triggerOnResourcesAvailable();
}
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger_middleware/FakeSoundTriggerHal.java b/services/voiceinteraction/java/com/android/server/soundtrigger_middleware/FakeSoundTriggerHal.java
index b76e3e90fade..37a325e09e56 100644
--- a/services/voiceinteraction/java/com/android/server/soundtrigger_middleware/FakeSoundTriggerHal.java
+++ b/services/voiceinteraction/java/com/android/server/soundtrigger_middleware/FakeSoundTriggerHal.java
@@ -276,16 +276,15 @@ public class FakeSoundTriggerHal extends ISoundTriggerHw.Stub {
// for our clients.
mGlobalEventSession = new IInjectGlobalEvent.Stub() {
/**
- * Overrides IInjectGlobalEvent method.
* Simulate a HAL process restart. This method is not included in regular HAL interface,
* since the entire process is restarted by sending a signal.
* Since we run in-proc, we must offer an explicit restart method.
* oneway
*/
@Override
- public void triggerRestart() throws RemoteException {
+ public void triggerRestart() {
synchronized (FakeSoundTriggerHal.this.mLock) {
- if (mIsDead) throw new DeadObjectException();
+ if (mIsDead) return;
mIsDead = true;
mInjectionDispatcher.wrap((ISoundTriggerInjection cb) ->
cb.onRestarted(this));
@@ -305,15 +304,15 @@ public class FakeSoundTriggerHal extends ISoundTriggerHw.Stub {
}
}
- /**
- * Overrides IInjectGlobalEvent method.
- * oneway
- */
+ // oneway
@Override
public void setResourceContention(boolean isResourcesContended,
- IAcknowledgeEvent callback) throws RemoteException {
+ IAcknowledgeEvent callback) {
synchronized (FakeSoundTriggerHal.this.mLock) {
- if (mIsDead) throw new DeadObjectException();
+ // oneway, so don't throw on death
+ if (mIsDead || mIsResourceContended == isResourcesContended) {
+ return;
+ }
mIsResourceContended = isResourcesContended;
// Introducing contention is the only injection which can't be
// observed by the ST client.
@@ -325,7 +324,19 @@ public class FakeSoundTriggerHal extends ISoundTriggerHw.Stub {
}
}
}
+
+ // oneway
+ @Override
+ public void triggerOnResourcesAvailable() {
+ synchronized (FakeSoundTriggerHal.this.mLock) {
+ // oneway, so don't throw on death
+ if (mIsDead) return;
+ mGlobalCallbackDispatcher.wrap((ISoundTriggerHwGlobalCallback cb) ->
+ cb.onResourcesAvailable());
+ }
+ }
};
+
// Register the global event injection interface
mInjectionDispatcher.wrap((ISoundTriggerInjection cb)
-> cb.registerGlobalEventInjection(mGlobalEventSession));