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

Commit 1de1186d authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Implement issue #22403908: Enable assistant to refuse context sharing

New APIs allow the voice interaction service to set/retrieve a filter
for which of the show flags are allowed.

Change-Id: I588cbe55afee0548ad3afa22d3a7d3bc43cb54a6
parent 1d4247c4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -28785,11 +28785,13 @@ package android.service.voice {
  public class VoiceInteractionService extends android.app.Service {
    ctor public VoiceInteractionService();
    method public final android.service.voice.AlwaysOnHotwordDetector createAlwaysOnHotwordDetector(java.lang.String, java.util.Locale, android.service.voice.AlwaysOnHotwordDetector.Callback);
    method public int getDisabledShowContext();
    method public static boolean isActiveService(android.content.Context, android.content.ComponentName);
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onLaunchVoiceAssistFromKeyguard();
    method public void onReady();
    method public void onShutdown();
    method public void setDisabledShowContext(int);
    method public void showSession(android.os.Bundle, int);
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.voice.VoiceInteractionService";
    field public static final java.lang.String SERVICE_META_DATA = "android.voice_interaction";
@@ -28801,6 +28803,7 @@ package android.service.voice {
    method public void closeSystemDialogs();
    method public void finish();
    method public android.content.Context getContext();
    method public int getDisabledShowContext();
    method public android.view.LayoutInflater getLayoutInflater();
    method public android.app.Dialog getWindow();
    method public void hide();
@@ -28832,6 +28835,7 @@ package android.service.voice {
    method public void onTaskStarted(android.content.Intent, int);
    method public void onTrimMemory(int);
    method public void setContentView(android.view.View);
    method public void setDisabledShowContext(int);
    method public void setKeepAwake(boolean);
    method public void setTheme(int);
    method public void show(android.os.Bundle, int);
+4 −0
Original line number Diff line number Diff line
@@ -30934,11 +30934,13 @@ package android.service.voice {
  public class VoiceInteractionService extends android.app.Service {
    ctor public VoiceInteractionService();
    method public final android.service.voice.AlwaysOnHotwordDetector createAlwaysOnHotwordDetector(java.lang.String, java.util.Locale, android.service.voice.AlwaysOnHotwordDetector.Callback);
    method public int getDisabledShowContext();
    method public static boolean isActiveService(android.content.Context, android.content.ComponentName);
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onLaunchVoiceAssistFromKeyguard();
    method public void onReady();
    method public void onShutdown();
    method public void setDisabledShowContext(int);
    method public void showSession(android.os.Bundle, int);
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.voice.VoiceInteractionService";
    field public static final java.lang.String SERVICE_META_DATA = "android.voice_interaction";
@@ -30950,6 +30952,7 @@ package android.service.voice {
    method public void closeSystemDialogs();
    method public void finish();
    method public android.content.Context getContext();
    method public int getDisabledShowContext();
    method public android.view.LayoutInflater getLayoutInflater();
    method public android.app.Dialog getWindow();
    method public void hide();
@@ -30981,6 +30984,7 @@ package android.service.voice {
    method public void onTaskStarted(android.content.Intent, int);
    method public void onTrimMemory(int);
    method public void setContentView(android.view.View);
    method public void setDisabledShowContext(int);
    method public void setKeepAwake(boolean);
    method public void setTheme(int);
    method public void show(android.os.Bundle, int);
+29 −2
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Locale;


/**
 * Top-level service of the current global voice interactor, which is providing
 * support for hotwording, the back-end of a {@link android.app.VoiceInteractor}, etc.
@@ -153,12 +152,40 @@ public class VoiceInteractionService extends Service {
        return curComp.equals(service);
    }

    /**
     * Set contextual options you would always like to have disabled when a session
     * is shown.  The flags may be any combination of
     * {@link VoiceInteractionSession#SHOW_WITH_ASSIST VoiceInteractionSession.SHOW_WITH_ASSIST} and
     * {@link VoiceInteractionSession#SHOW_WITH_SCREENSHOT
     * VoiceInteractionSession.SHOW_WITH_SCREENSHOT}.
     */
    public void setDisabledShowContext(int flags) {
        try {
            mSystemService.setDisabledShowContext(flags);
        } catch (RemoteException e) {
        }
    }

    /**
     * Return the value set by {@link #setDisabledShowContext}.
     */
    public int getDisabledShowContext() {
        try {
            return mSystemService.getDisabledShowContext();
        } catch (RemoteException e) {
            return 0;
        }
    }

    /**
     * Request that the associated {@link android.service.voice.VoiceInteractionSession} be
     * shown to the user, starting it if necessary.
     * @param args Arbitrary arguments that will be propagated to the session.
     * @param flags Indicates additional optional behavior that should be performed.  May
     * be {@link VoiceInteractionSession#SHOW_WITH_ASSIST VoiceInteractionSession.SHOW_WITH_ASSIST}
     * be any combination of
     * {@link VoiceInteractionSession#SHOW_WITH_ASSIST VoiceInteractionSession.SHOW_WITH_ASSIST} and
     * {@link VoiceInteractionSession#SHOW_WITH_SCREENSHOT
      * VoiceInteractionSession.SHOW_WITH_SCREENSHOT}
     * to request that the system generate and deliver assist data on the current foreground
     * app as part of showing the session UI.
     */
+27 −1
Original line number Diff line number Diff line
@@ -907,13 +907,39 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
        mContentFrame = (FrameLayout)mRootView.findViewById(android.R.id.content);
    }

    /**
     * Equivalent to {@link VoiceInteractionService#setDisabledShowContext
     * VoiceInteractionService.setDisabledShowContext(int)}.
     */
    public void setDisabledShowContext(int flags) {
        try {
            mSystemService.setDisabledShowContext(flags);
        } catch (RemoteException e) {
        }
    }

    /**
     * Equivalent to {@link VoiceInteractionService#getDisabledShowContext
     * VoiceInteractionService.getDisabledShowContext}.
     */
    public int getDisabledShowContext() {
        try {
            return mSystemService.getDisabledShowContext();
        } catch (RemoteException e) {
            return 0;
        }
    }

    /**
     * Show the UI for this session.  This asks the system to go through the process of showing
     * your UI, which will eventually culminate in {@link #onShow}.  This is similar to calling
     * {@link VoiceInteractionService#showSession VoiceInteractionService.showSession}.
     * @param args Arbitrary arguments that will be propagated {@link #onShow}.
     * @param flags Indicates additional optional behavior that should be performed.  May
     * be {@link VoiceInteractionSession#SHOW_WITH_ASSIST VoiceInteractionSession.SHOW_WITH_ASSIST}
     * be any combination of
     * {@link VoiceInteractionSession#SHOW_WITH_ASSIST VoiceInteractionSession.SHOW_WITH_ASSIST} and
     * {@link VoiceInteractionSession#SHOW_WITH_SCREENSHOT
     * VoiceInteractionSession.SHOW_WITH_SCREENSHOT}
     * to request that the system generate and deliver assist data on the current foreground
     * app as part of showing the session UI.
     */
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ interface IVoiceInteractionManagerService {
    void setKeepAwake(IBinder token, boolean keepAwake);
    void closeSystemDialogs(IBinder token);
    void finish(IBinder token);
    void setDisabledShowContext(int flags);
    int getDisabledShowContext();

    /**
     * Gets the registered Sound model for keyphrase detection for the current user.
Loading