Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99589ebc authored by Lee Campbell's avatar Lee Campbell Committed by Reema Bajwa
Browse files

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
parent b2134e69
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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)")
+17 −0
Original line number Diff line number Diff line
@@ -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) {
+8 −1
Original line number Diff line number Diff line
@@ -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.
     *
+6 −0
Original line number Diff line number Diff line
@@ -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,
Loading