Add getPackageName to VoiceInteractor
Adds a new API to VoiceInteractor to allow apps to query the package name of the Voice Interactor associated with this the current voice interaction BUG: 192061561 CTS-Coverage-Bug: 218687104 Test: Manual validation from personal and work profiles Change-Id: If381c38498535bf94d13c0b5ad5f6c4fa5495117
This commit is contained in:
committed by
Reema Bajwa
parent
b2134e69f7
commit
99589ebc0f
@@ -7039,6 +7039,7 @@ package android.app {
|
||||
public final class VoiceInteractor {
|
||||
method public android.app.VoiceInteractor.Request getActiveRequest(String);
|
||||
method public android.app.VoiceInteractor.Request[] getActiveRequests();
|
||||
method @NonNull public String getPackageName();
|
||||
method public boolean isDestroyed();
|
||||
method public void notifyDirectActionsChanged();
|
||||
method public boolean registerOnDestroyedCallback(@NonNull java.util.concurrent.Executor, @NonNull Runnable);
|
||||
|
||||
@@ -128,6 +128,7 @@ interface IActivityTaskManager {
|
||||
int callingUid, in Intent intent, in String resolvedType,
|
||||
in IVoiceInteractionSession session, in IVoiceInteractor interactor, int flags,
|
||||
in ProfilerInfo profilerInfo, in Bundle options, int userId);
|
||||
String getVoiceInteractorPackageName(in IBinder callingVoiceInteractor);
|
||||
int startAssistantActivity(in String callingPackage, in String callingFeatureId, int callingPid,
|
||||
int callingUid, in Intent intent, in String resolvedType, in Bundle options, int userId);
|
||||
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MANAGE_GAME_ACTIVITY)")
|
||||
|
||||
@@ -1168,6 +1168,23 @@ public final class VoiceInteractor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the package name of the service providing the VoiceInteractionService.
|
||||
*/
|
||||
@NonNull
|
||||
public String getPackageName() {
|
||||
String packageName = null;
|
||||
if (mActivity != null && mInteractor != null) {
|
||||
try {
|
||||
packageName = ActivityTaskManager.getService()
|
||||
.getVoiceInteractorPackageName(mInteractor.asBinder());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
return packageName == null ? "" : packageName;
|
||||
}
|
||||
|
||||
void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
|
||||
String innerPrefix = prefix + " ";
|
||||
if (mActiveRequests.size() > 0) {
|
||||
|
||||
@@ -49,6 +49,13 @@ public abstract class VoiceInteractionManagerInternal {
|
||||
*/
|
||||
public abstract boolean hasActiveSession(String packageName);
|
||||
|
||||
/**
|
||||
* Returns the package name of the active session.
|
||||
*
|
||||
* @param callingVoiceInteractor the voice interactor binder from the calling VoiceInteractor.
|
||||
*/
|
||||
public abstract String getVoiceInteractorPackageName(IBinder callingVoiceInteractor);
|
||||
|
||||
/**
|
||||
* Gets the identity of the currently active HotwordDetectionService.
|
||||
*
|
||||
@@ -82,4 +89,4 @@ public abstract class VoiceInteractionManagerInternal {
|
||||
return mOwnerUid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1694,6 +1694,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVoiceInteractorPackageName(IBinder callingVoiceInteractor) {
|
||||
return LocalServices.getService(VoiceInteractionManagerInternal.class)
|
||||
.getVoiceInteractorPackageName(callingVoiceInteractor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int startAssistantActivity(String callingPackage, @NonNull String callingFeatureId,
|
||||
int callingPid, int callingUid, Intent intent, String resolvedType, Bundle bOptions,
|
||||
|
||||
@@ -262,6 +262,25 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
return TextUtils.equals(packageName, session.mSessionComponentName.getPackageName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVoiceInteractorPackageName(IBinder callingVoiceInteractor) {
|
||||
VoiceInteractionManagerServiceImpl impl =
|
||||
VoiceInteractionManagerService.this.mServiceStub.mImpl;
|
||||
if (impl == null) {
|
||||
return null;
|
||||
}
|
||||
VoiceInteractionSessionConnection session =
|
||||
impl.mActiveSession;
|
||||
if (session == null) {
|
||||
return null;
|
||||
}
|
||||
IVoiceInteractor voiceInteractor = session.mInteractor;
|
||||
if (voiceInteractor == null || voiceInteractor.asBinder() != callingVoiceInteractor) {
|
||||
return null;
|
||||
}
|
||||
return session.mSessionComponentName.getPackageName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HotwordDetectionServiceIdentity getHotwordDetectionServiceIdentity() {
|
||||
// IMPORTANT: This is called when performing permission checks; do not lock!
|
||||
|
||||
Reference in New Issue
Block a user