Merge "Disable the legacy TV VIS launch path" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5108508cba
@@ -20,18 +20,21 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
|
||||||
import com.android.internal.statusbar.IStatusBarService;
|
import com.android.internal.statusbar.IStatusBarService;
|
||||||
import com.android.systemui.SystemUI;
|
import com.android.systemui.SystemUI;
|
||||||
|
import com.android.systemui.assist.AssistManager;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
import com.android.systemui.statusbar.tv.micdisclosure.AudioRecordingDisclosureBar;
|
import com.android.systemui.statusbar.tv.micdisclosure.AudioRecordingDisclosureBar;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.Lazy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status bar implementation for "large screen" products that mostly present no on-screen nav.
|
* 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";
|
"com.android.tv.action.OPEN_NOTIFICATIONS_PANEL";
|
||||||
|
|
||||||
private final CommandQueue mCommandQueue;
|
private final CommandQueue mCommandQueue;
|
||||||
|
private final Lazy<AssistManager> mAssistManagerLazy;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TvStatusBar(Context context, CommandQueue commandQueue) {
|
public TvStatusBar(Context context, CommandQueue commandQueue,
|
||||||
|
Lazy<AssistManager> assistManagerLazy) {
|
||||||
super(context);
|
super(context);
|
||||||
mCommandQueue = commandQueue;
|
mCommandQueue = commandQueue;
|
||||||
|
mAssistManagerLazy = assistManagerLazy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,4 +90,9 @@ public class TvStatusBar extends SystemUI implements CommandQueue.Callbacks {
|
|||||||
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
|
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startAssist(Bundle args) {
|
||||||
|
mAssistManagerLazy.get().startAssist(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,69 +266,13 @@ public class SearchManagerService extends ISearchManager.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void launchAssist(int userHandle, Bundle args) {
|
public void launchAssist(int userHandle, Bundle args) {
|
||||||
if ((mContext.getResources().getConfiguration().uiMode
|
StatusBarManagerInternal statusBarManager =
|
||||||
& Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) {
|
LocalServices.getService(StatusBarManagerInternal.class);
|
||||||
// On TV, use legacy handling until assistants are implemented in the proper way.
|
if (statusBarManager != null) {
|
||||||
launchLegacyAssist(null, userHandle, args);
|
statusBarManager.startAssist(args);
|
||||||
} else {
|
|
||||||
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
|
@Override
|
||||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user