Merge changes from topic "hds_identity" into udc-dev am: 8fc7d8d1ab
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22672862 Change-Id: Id288dfa2e80d73389060ced23e557951e03f5450 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -381,51 +381,21 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
@NonNull Identity originatorIdentity, IBinder client,
|
||||
ModuleProperties moduleProperties) {
|
||||
Objects.requireNonNull(originatorIdentity);
|
||||
boolean forHotwordDetectionService;
|
||||
boolean forHotwordDetectionService = false;
|
||||
synchronized (VoiceInteractionManagerServiceStub.this) {
|
||||
enforceIsCurrentVoiceInteractionService();
|
||||
forHotwordDetectionService =
|
||||
mImpl != null && mImpl.mHotwordDetectionConnection != null;
|
||||
}
|
||||
IVoiceInteractionSoundTriggerSession session;
|
||||
if (forHotwordDetectionService) {
|
||||
// Use our own identity and handle the permission checks ourselves. This allows
|
||||
// properly checking/noting against the voice interactor or hotword detection
|
||||
// service as needed.
|
||||
if (HotwordDetectionConnection.DEBUG) {
|
||||
Slog.d(TAG, "Creating a SoundTriggerSession for a HotwordDetectionService");
|
||||
}
|
||||
originatorIdentity.uid = Binder.getCallingUid();
|
||||
originatorIdentity.pid = Binder.getCallingPid();
|
||||
session = new SoundTriggerSessionPermissionsDecorator(
|
||||
createSoundTriggerSessionForSelfIdentity(client, moduleProperties),
|
||||
mContext,
|
||||
originatorIdentity);
|
||||
} else {
|
||||
if (HotwordDetectionConnection.DEBUG) {
|
||||
Slog.d(TAG, "Creating a SoundTriggerSession");
|
||||
}
|
||||
try (SafeCloseable ignored = PermissionUtil.establishIdentityDirect(
|
||||
originatorIdentity)) {
|
||||
session = new SoundTriggerSession(mSoundTriggerInternal.attach(client,
|
||||
moduleProperties, false));
|
||||
}
|
||||
if (HotwordDetectionConnection.DEBUG) {
|
||||
Slog.d(TAG, "Creating a SoundTriggerSession, for HDS: "
|
||||
+ forHotwordDetectionService);
|
||||
}
|
||||
try (SafeCloseable ignored = PermissionUtil.establishIdentityDirect(
|
||||
originatorIdentity)) {
|
||||
return new SoundTriggerSession(mSoundTriggerInternal.attach(client,
|
||||
moduleProperties, forHotwordDetectionService));
|
||||
}
|
||||
return new SoundTriggerSessionBinderProxy(session);
|
||||
}
|
||||
|
||||
private IVoiceInteractionSoundTriggerSession createSoundTriggerSessionForSelfIdentity(
|
||||
IBinder client, ModuleProperties moduleProperties) {
|
||||
Identity identity = new Identity();
|
||||
identity.uid = Process.myUid();
|
||||
identity.pid = Process.myPid();
|
||||
identity.packageName = ActivityThread.currentOpPackageName();
|
||||
return Binder.withCleanCallingIdentity(() -> {
|
||||
try (SafeCloseable ignored = IdentityContext.create(identity)) {
|
||||
return new SoundTriggerSession(
|
||||
mSoundTriggerInternal.attach(client, moduleProperties, false));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1700,11 +1670,7 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of SoundTriggerSession. Does not implement {@link #asBinder()} as it's
|
||||
* intended to be wrapped by an {@link IVoiceInteractionSoundTriggerSession.Stub} object.
|
||||
*/
|
||||
private class SoundTriggerSession implements IVoiceInteractionSoundTriggerSession {
|
||||
private class SoundTriggerSession extends IVoiceInteractionSoundTriggerSession.Stub {
|
||||
final SoundTriggerInternal.Session mSession;
|
||||
private IHotwordRecognitionStatusCallback mSessionExternalCallback;
|
||||
private IRecognitionStatusCallback mSessionInternalCallback;
|
||||
@@ -1850,12 +1816,6 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder asBinder() {
|
||||
throw new UnsupportedOperationException(
|
||||
"This object isn't intended to be used as a Binder.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
mSession.detach();
|
||||
|
||||
Reference in New Issue
Block a user