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

Commit f2c2a1b5 authored by Sergej Salnikov's avatar Sergej Salnikov Committed by Android (Google) Code Review
Browse files

Merge "Delete SearchManager.launchAssistService and convert...

Merge "Delete SearchManager.launchAssistService and convert SearchManager.launchAssist into @SystemApi method that handles both phone and TV devices."
parents 7d72e1ea 25b0f41e
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -604,6 +604,10 @@ package android.app {
    method public void setNotificationAssistantAccessGranted(@Nullable android.content.ComponentName, boolean);
    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 {
  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 @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[]);
    method @Deprecated @RequiresPermission(allOf={android.Manifest.permission.DUMP, android.Manifest.permission.PACKAGE_USAGE_STATS}) public boolean addConfiguration(long, byte[]);
+1 −2
Original line number Original line Diff line number Diff line
@@ -31,6 +31,5 @@ interface ISearchManager {
   @UnsupportedAppUsage
   @UnsupportedAppUsage
   ComponentName getGlobalSearchActivity();
   ComponentName getGlobalSearchActivity();
   ComponentName getWebSearchActivity();
   ComponentName getWebSearchActivity();
   void launchAssist(in Bundle args);
   void launchAssist(int userHandle, in Bundle args);
   boolean launchLegacyAssist(String hint, int userHandle, in Bundle args);
}
}
+10 −23
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.app;
package android.app;


import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.SystemService;
import android.annotation.UnsupportedAppUsage;
import android.annotation.UnsupportedAppUsage;
import android.content.ActivityNotFoundException;
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
     * @hide
     */
     */
    @UnsupportedAppUsage
    @SystemApi
    public void launchAssist(Bundle args) {
    public void launchAssist(@Nullable Bundle args) {
        try {
        try {
            if (mService == null) {
            if (mService == null) {
                return;
                return;
            }
            }
            mService.launchAssist(args);
            mService.launchAssist(mContext.getUserId(), 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);
        } catch (RemoteException re) {
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
            throw re.rethrowFromSystemServer();
        }
        }
+3 −2
Original line number Original line Diff line number Diff line
@@ -3109,8 +3109,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            // On TVs, if the app doesn't implement search, we want to launch assist.
            // On TVs, if the app doesn't implement search, we want to launch assist.
            Bundle args = new Bundle();
            Bundle args = new Bundle();
            args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, event.getDeviceId());
            args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, event.getDeviceId());
            return ((SearchManager)getContext().getSystemService(Context.SEARCH_SERVICE))
            ((SearchManager) getContext().getSystemService(Context.SEARCH_SERVICE))
                    .launchLegacyAssist(null, getContext().getUserId(), args);
                    .launchAssist(args);
            return true;
        }
        }
        return result;
        return result;
    }
    }
+6 −16
Original line number Original line Diff line number Diff line
@@ -3334,27 +3334,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return;
            return;
        }
        }
        Bundle args = null;
        Bundle args = null;
        if (deviceId > Integer.MIN_VALUE) {
        if (deviceId > Integer.MIN_VALUE || hint != null) {
            args = new Bundle();
            args = new Bundle();
            if (deviceId > Integer.MIN_VALUE) {
                args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, deviceId);
                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 (hint != null) {
                if (args == null) {
                    args = new Bundle();
                }
                args.putBoolean(hint, true);
                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. */
    /** Launches ACTION_VOICE_ASSIST. Does nothing on keyguard. */
Loading