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

Commit b835dd76 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Close assist when launching intents from notification shade

Bug: 21035363
Change-Id: I51a6dbe5f0d93aaf81a38d1f1afacaaeaf7732e2
parent 53b3bb07
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -96,6 +96,11 @@ interface IVoiceInteractionManagerService {
     */
    void showSessionForActiveService(IVoiceInteractionSessionShowCallback showCallback);

    /**
     * Hides the session from the active service, if it is showing.
     */
    void hideCurrentSession();

    /**
     * Notifies the active service that a launch was requested from the Keyguard. This will only
     * be called if {@link #activeServiceSupportsLaunchFromKeyguard()} returns true.
+8 −0
Original line number Diff line number Diff line
@@ -124,6 +124,14 @@ public class AssistManager {
        startAssist();
    }

    public void hideAssist() {
        try {
            mVoiceInteractionManagerService.hideCurrentSession();
        } catch (RemoteException e) {
            Log.w(TAG, "Failed to call hideCurrentSession", e);
        }
    }

    private WindowManager.LayoutParams getLayoutParams() {
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
+4 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.SwipeHelper;
import com.android.systemui.SystemUI;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.recents.Recents;
import com.android.systemui.statusbar.NotificationData.Entry;
import com.android.systemui.statusbar.phone.NavigationBarView;
@@ -240,6 +241,8 @@ public abstract class BaseStatusBar extends SystemUI implements

    private NotificationClicker mNotificationClicker = new NotificationClicker();

    protected AssistManager mAssistManager;

    @Override  // NotificationData.Environment
    public boolean isDeviceProvisioned() {
        return mDeviceProvisioned;
@@ -1626,6 +1629,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                                    // TODO: Dismiss Keyguard.
                                }
                                if (intent.isActivity()) {
                                    mAssistManager.hideAssist();
                                    overrideActivityPendingAppTransition(keyguardShowing
                                            && !afterKeyguardGone);
                                }
+3 −3
Original line number Diff line number Diff line
@@ -344,8 +344,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private int mNavigationIconHints = 0;
    private HandlerThread mHandlerThread;

    private AssistManager mAssistManager;

    // ensure quick settings is disabled until the current user makes it through the setup wizard
    private boolean mUserSetup = false;
    private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) {
@@ -2753,6 +2751,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
        Runnable runnable = new Runnable() {
            public void run() {
                mAssistManager.hideAssist();
                intent.setFlags(
                        Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                int result = ActivityManager.START_CANCELED;
@@ -2781,7 +2780,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                }
            }
        };
        executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShade, afterKeyguardGone);
        executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShade,
                afterKeyguardGone);
    }

    public void executeRunnableDismissingKeyguard(final Runnable runnable,
+24 −3
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.service.voice.VoiceInteractionServiceInfo;
import android.service.voice.VoiceInteractionSession;
import android.speech.RecognitionService;
import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;

import com.android.internal.app.IVoiceInteractionManagerService;
@@ -475,11 +476,9 @@ public class VoiceInteractionManagerService extends SystemService {
                    Slog.w(TAG, "hideSessionFromSession without running voice interaction service");
                    return false;
                }
                final int callingPid = Binder.getCallingPid();
                final int callingUid = Binder.getCallingUid();
                final long caller = Binder.clearCallingIdentity();
                try {
                    return mImpl.hideSessionLocked(callingPid, callingUid);
                    return mImpl.hideSessionLocked();
                } finally {
                    Binder.restoreCallingIdentity(caller);
                }
@@ -743,6 +742,28 @@ public class VoiceInteractionManagerService extends SystemService {
            }
        }

        @Override
        public void hideCurrentSession() throws RemoteException {
            enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE);
            synchronized (this) {
                if (mImpl == null) {
                    return;
                }
                final long caller = Binder.clearCallingIdentity();
                try {
                    if (mImpl.mActiveSession != null && mImpl.mActiveSession.mSession != null) {
                        try {
                            mImpl.mActiveSession.mSession.closeSystemDialogs();
                        } catch (RemoteException e) {
                            Log.w(TAG, "Failed to call closeSystemDialogs", e);
                        }
                    }
                } finally {
                    Binder.restoreCallingIdentity(caller);
                }
            }
        }

        @Override
        public void launchVoiceAssistFromKeyguard() {
            enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE);
Loading