Close assist when launching intents from notification shade

Bug: 21035363
Change-Id: I51a6dbe5f0d93aaf81a38d1f1afacaaeaf7732e2
This commit is contained in:
Jorim Jaggi
2015-06-08 12:28:42 -07:00
parent 53b3bb072b
commit b835dd7641
6 changed files with 45 additions and 7 deletions

View File

@@ -96,6 +96,11 @@ interface IVoiceInteractionManagerService {
*/ */
void showSessionForActiveService(IVoiceInteractionSessionShowCallback showCallback); 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 * Notifies the active service that a launch was requested from the Keyguard. This will only
* be called if {@link #activeServiceSupportsLaunchFromKeyguard()} returns true. * be called if {@link #activeServiceSupportsLaunchFromKeyguard()} returns true.

View File

@@ -124,6 +124,14 @@ public class AssistManager {
startAssist(); startAssist();
} }
public void hideAssist() {
try {
mVoiceInteractionManagerService.hideCurrentSession();
} catch (RemoteException e) {
Log.w(TAG, "Failed to call hideCurrentSession", e);
}
}
private WindowManager.LayoutParams getLayoutParams() { private WindowManager.LayoutParams getLayoutParams() {
WindowManager.LayoutParams lp = new WindowManager.LayoutParams( WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,

View File

@@ -92,6 +92,7 @@ import com.android.systemui.R;
import com.android.systemui.RecentsComponent; import com.android.systemui.RecentsComponent;
import com.android.systemui.SwipeHelper; import com.android.systemui.SwipeHelper;
import com.android.systemui.SystemUI; import com.android.systemui.SystemUI;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.recents.Recents; import com.android.systemui.recents.Recents;
import com.android.systemui.statusbar.NotificationData.Entry; import com.android.systemui.statusbar.NotificationData.Entry;
import com.android.systemui.statusbar.phone.NavigationBarView; import com.android.systemui.statusbar.phone.NavigationBarView;
@@ -240,6 +241,8 @@ public abstract class BaseStatusBar extends SystemUI implements
private NotificationClicker mNotificationClicker = new NotificationClicker(); private NotificationClicker mNotificationClicker = new NotificationClicker();
protected AssistManager mAssistManager;
@Override // NotificationData.Environment @Override // NotificationData.Environment
public boolean isDeviceProvisioned() { public boolean isDeviceProvisioned() {
return mDeviceProvisioned; return mDeviceProvisioned;
@@ -1626,6 +1629,7 @@ public abstract class BaseStatusBar extends SystemUI implements
// TODO: Dismiss Keyguard. // TODO: Dismiss Keyguard.
} }
if (intent.isActivity()) { if (intent.isActivity()) {
mAssistManager.hideAssist();
overrideActivityPendingAppTransition(keyguardShowing overrideActivityPendingAppTransition(keyguardShowing
&& !afterKeyguardGone); && !afterKeyguardGone);
} }

View File

@@ -344,8 +344,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
private int mNavigationIconHints = 0; private int mNavigationIconHints = 0;
private HandlerThread mHandlerThread; private HandlerThread mHandlerThread;
private AssistManager mAssistManager;
// ensure quick settings is disabled until the current user makes it through the setup wizard // ensure quick settings is disabled until the current user makes it through the setup wizard
private boolean mUserSetup = false; private boolean mUserSetup = false;
private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) { private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) {
@@ -2753,6 +2751,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing(); final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
public void run() { public void run() {
mAssistManager.hideAssist();
intent.setFlags( intent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
int result = ActivityManager.START_CANCELED; 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, public void executeRunnableDismissingKeyguard(final Runnable runnable,

View File

@@ -49,6 +49,7 @@ import android.service.voice.VoiceInteractionServiceInfo;
import android.service.voice.VoiceInteractionSession; import android.service.voice.VoiceInteractionSession;
import android.speech.RecognitionService; import android.speech.RecognitionService;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.util.Slog; import android.util.Slog;
import com.android.internal.app.IVoiceInteractionManagerService; import com.android.internal.app.IVoiceInteractionManagerService;
@@ -475,11 +476,9 @@ public class VoiceInteractionManagerService extends SystemService {
Slog.w(TAG, "hideSessionFromSession without running voice interaction service"); Slog.w(TAG, "hideSessionFromSession without running voice interaction service");
return false; return false;
} }
final int callingPid = Binder.getCallingPid();
final int callingUid = Binder.getCallingUid();
final long caller = Binder.clearCallingIdentity(); final long caller = Binder.clearCallingIdentity();
try { try {
return mImpl.hideSessionLocked(callingPid, callingUid); return mImpl.hideSessionLocked();
} finally { } finally {
Binder.restoreCallingIdentity(caller); 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 @Override
public void launchVoiceAssistFromKeyguard() { public void launchVoiceAssistFromKeyguard() {
enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE); enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE);

View File

@@ -144,7 +144,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
return mActiveSession.showLocked(args, flags, showCallback); return mActiveSession.showLocked(args, flags, showCallback);
} }
public boolean hideSessionLocked(int callingPid, int callingUid) { public boolean hideSessionLocked() {
if (mActiveSession != null) { if (mActiveSession != null) {
return mActiveSession.hideLocked(); return mActiveSession.hideLocked();
} }