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

Commit 25b0f41e authored by skill's avatar skill
Browse files

Delete SearchManager.launchAssistService and convert

SearchManager.launchAssist into @SystemApi method that handles both phone
and TV devices.

That allows apps to start Assistant.

Bug: 128538467
Test: manual
Change-Id: Ie05c910768062c00717df66e35b4118805458999
parent f8a28911
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -593,6 +593,10 @@ package android.app {
    method public void setNotificationAssistantAccessGranted(@Nullable android.content.ComponentName, boolean);
  }
  public class SearchManager implements android.content.DialogInterface.OnCancelListener android.content.DialogInterface.OnDismissListener {
    method public void launchAssist(@Nullable android.os.Bundle);
  }
  public final class StatsManager {
    method @RequiresPermission(allOf={android.Manifest.permission.DUMP, android.Manifest.permission.PACKAGE_USAGE_STATS}) public void addConfig(long, byte[]) throws android.app.StatsManager.StatsUnavailableException;
    method @Deprecated @RequiresPermission(allOf={android.Manifest.permission.DUMP, android.Manifest.permission.PACKAGE_USAGE_STATS}) public boolean addConfiguration(long, byte[]);
+1 −2
Original line number Diff line number Diff line
@@ -31,6 +31,5 @@ interface ISearchManager {
   @UnsupportedAppUsage
   ComponentName getGlobalSearchActivity();
   ComponentName getWebSearchActivity();
   void launchAssist(in Bundle args);
   boolean launchLegacyAssist(String hint, int userHandle, in Bundle args);
   void launchAssist(int userHandle, in Bundle args);
}
+10 −23
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.app;

import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.UnsupportedAppUsage;
import android.content.ActivityNotFoundException;
@@ -973,37 +975,22 @@ public class SearchManager
    }

    /**
     * Starts the assistant.
     * Starts the {@link android.provider.Settings.Secure#ASSISTANT assistant}.
     *
     * @param args the args to pass to the assistant
     * @param args a {@code Bundle} that will be passed to the assistant's
     *         {@link android.service.voice.VoiceInteractionSession#onShow VoiceInteractionSession}
     *         (or as {@link Intent#getExtras() extras} along
     *         {@link Intent#ACTION_ASSIST ACTION_ASSIST} for legacy assistants)
     *
     * @hide
     */
    @UnsupportedAppUsage
    public void launchAssist(Bundle args) {
    @SystemApi
    public void launchAssist(@Nullable Bundle args) {
        try {
            if (mService == null) {
                return;
            }
            mService.launchAssist(args);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Starts the legacy assistant (i.e. the {@link Intent#ACTION_ASSIST}).
     *
     * @param args the args to pass to the assistant
     *
     * @hide
     */
    public boolean launchLegacyAssist(String hint, int userHandle, Bundle args) {
        try {
            if (mService == null) {
                return false;
            }
            return mService.launchLegacyAssist(hint, userHandle, args);
            mService.launchAssist(mContext.getUserId(), args);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
+3 −2
Original line number Diff line number Diff line
@@ -3192,8 +3192,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            // On TVs, if the app doesn't implement search, we want to launch assist.
            Bundle args = new Bundle();
            args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, event.getDeviceId());
            return ((SearchManager)getContext().getSystemService(Context.SEARCH_SERVICE))
                    .launchLegacyAssist(null, getContext().getUserId(), args);
            ((SearchManager) getContext().getSystemService(Context.SEARCH_SERVICE))
                    .launchAssist(args);
            return true;
        }
        return result;
    }
+6 −16
Original line number Diff line number Diff line
@@ -3334,27 +3334,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return;
        }
        Bundle args = null;
        if (deviceId > Integer.MIN_VALUE) {
        if (deviceId > Integer.MIN_VALUE || hint != null) {
            args = new Bundle();
            if (deviceId > Integer.MIN_VALUE) {
                args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, deviceId);
            }
        if ((mContext.getResources().getConfiguration().uiMode
                & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) {
            // On TV, use legacy handling until assistants are implemented in the proper way.
            ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
                    .launchLegacyAssist(hint, mCurrentUserId, args);
        } else {
            if (hint != null) {
                if (args == null) {
                    args = new Bundle();
                }
                args.putBoolean(hint, true);
            }
            StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
            if (statusbar != null) {
                statusbar.startAssist(args);
            }
        }
        ((SearchManager) mContext.createContextAsUser(UserHandle.of(mCurrentUserId), 0)
                .getSystemService(Context.SEARCH_SERVICE)).launchAssist(args);
    }

    /** Launches ACTION_VOICE_ASSIST. Does nothing on keyguard. */
Loading