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
This commit is contained in:
@@ -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[]);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
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 (deviceId > Integer.MIN_VALUE) {
|
||||
args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, deviceId);
|
||||
}
|
||||
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. */
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.server.search;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityTaskManager;
|
||||
import android.app.IActivityManager;
|
||||
import android.app.IActivityTaskManager;
|
||||
import android.app.ISearchManager;
|
||||
import android.app.SearchManager;
|
||||
@@ -29,6 +28,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.ContentObserver;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
@@ -265,11 +265,17 @@ public class SearchManagerService extends ISearchManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchAssist(Bundle args) {
|
||||
StatusBarManagerInternal statusBarManager =
|
||||
LocalServices.getService(StatusBarManagerInternal.class);
|
||||
if (statusBarManager != null) {
|
||||
statusBarManager.startAssist(args);
|
||||
public void launchAssist(int userHandle, Bundle args) {
|
||||
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.
|
||||
launchLegacyAssist(null, userHandle, args);
|
||||
} else {
|
||||
StatusBarManagerInternal statusBarManager =
|
||||
LocalServices.getService(StatusBarManagerInternal.class);
|
||||
if (statusBarManager != null) {
|
||||
statusBarManager.startAssist(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,8 +304,7 @@ public class SearchManagerService extends ISearchManager.Stub {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean launchLegacyAssist(String hint, int userHandle, Bundle args) {
|
||||
private boolean launchLegacyAssist(String hint, int userHandle, Bundle args) {
|
||||
ComponentName comp = getLegacyAssistComponent(userHandle);
|
||||
if (comp == null) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user