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

Commit 441af3fb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Disable the legacy TV VIS launch path" into rvc-dev am: 5108508c am:...

Merge "Disable the legacy TV VIS launch path" into rvc-dev am: 5108508c am: 77a643d0 am: 24e2e0cf

Change-Id: I64e5846bd7909c6cc4c889a3e9be9d1be7acd1dc
parents bf65966f 24e2e0cf
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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);
    }
}
+4 −60
Original line number Diff line number Diff line
@@ -266,68 +266,12 @@ 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);
        }
    }
    }

    // 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) {