Merge "Disable the legacy TV VIS launch path" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-05-29 10:19:39 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 61 deletions

View File

@@ -20,18 +20,21 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.SystemUI;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.tv.micdisclosure.AudioRecordingDisclosureBar;
import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.Lazy;
/**
* Status bar implementation for "large screen" products that mostly present no on-screen nav.
@@ -49,11 +52,14 @@ public class TvStatusBar extends SystemUI implements CommandQueue.Callbacks {
"com.android.tv.action.OPEN_NOTIFICATIONS_PANEL";
private final CommandQueue mCommandQueue;
private final Lazy<AssistManager> mAssistManagerLazy;
@Inject
public TvStatusBar(Context context, CommandQueue commandQueue) {
public TvStatusBar(Context context, CommandQueue commandQueue,
Lazy<AssistManager> assistManagerLazy) {
super(context);
mCommandQueue = commandQueue;
mAssistManagerLazy = assistManagerLazy;
}
@Override
@@ -84,4 +90,9 @@ public class TvStatusBar extends SystemUI implements CommandQueue.Callbacks {
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
}
}
@Override
public void startAssist(Bundle args) {
mAssistManagerLazy.get().startAssist(args);
}
}

View File

@@ -266,69 +266,13 @@ public class SearchManagerService extends ISearchManager.Stub {
@Override
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);
}
StatusBarManagerInternal statusBarManager =
LocalServices.getService(StatusBarManagerInternal.class);
if (statusBarManager != null) {
statusBarManager.startAssist(args);
}
}
// Check and return VIS component
private ComponentName getLegacyAssistComponent(int userHandle) {
try {
userHandle = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
Binder.getCallingUid(), userHandle, true, false, "getLegacyAssistComponent",
null);
PackageManager pm = mContext.getPackageManager();
Intent intentAssistProbe = new Intent(VoiceInteractionService.SERVICE_INTERFACE);
List<ResolveInfo> infoListVis = pm.queryIntentServicesAsUser(intentAssistProbe,
PackageManager.MATCH_SYSTEM_ONLY, userHandle);
if (infoListVis == null || infoListVis.isEmpty()) {
return null;
} else {
ResolveInfo rInfo = infoListVis.get(0);
return new ComponentName(
rInfo.serviceInfo.applicationInfo.packageName,
rInfo.serviceInfo.name);
}
} catch (Exception e) {
Log.e(TAG, "Exception in getLegacyAssistComponent: " + e);
}
return null;
}
private boolean launchLegacyAssist(String hint, int userHandle, Bundle args) {
ComponentName comp = getLegacyAssistComponent(userHandle);
if (comp == null) {
return false;
}
long ident = Binder.clearCallingIdentity();
try {
Intent intent = new Intent(VoiceInteractionService.SERVICE_INTERFACE);
intent.setComponent(comp);
IActivityTaskManager am = ActivityTaskManager.getService();
if (args != null) {
args.putInt(Intent.EXTRA_KEY_EVENT, android.view.KeyEvent.KEYCODE_ASSIST);
}
intent.putExtras(args);
return am.launchAssistIntent(intent, ActivityManager.ASSIST_CONTEXT_BASIC, hint,
userHandle, args);
} catch (RemoteException e) {
} finally {
Binder.restoreCallingIdentity(ident);
}
return true;
}
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;