Merge "Fix issue #20672970: Notifications are not dismissed on hot word detection" into mnc-dev

This commit is contained in:
Dianne Hackborn
2015-07-01 22:31:15 +00:00
committed by Android (Google) Code Review
7 changed files with 58 additions and 7 deletions

View File

@@ -28805,6 +28805,7 @@ package android.service.voice {
public class VoiceInteractionSession implements android.content.ComponentCallbacks2 android.view.KeyEvent.Callback {
ctor public VoiceInteractionSession(android.content.Context);
ctor public VoiceInteractionSession(android.content.Context, android.os.Handler);
method public void closeSystemDialogs();
method public void finish();
method public android.content.Context getContext();
method public android.view.LayoutInflater getLayoutInflater();

View File

@@ -30959,6 +30959,7 @@ package android.service.voice {
public class VoiceInteractionSession implements android.content.ComponentCallbacks2 android.view.KeyEvent.Callback {
ctor public VoiceInteractionSession(android.content.Context);
ctor public VoiceInteractionSession(android.content.Context, android.os.Handler);
method public void closeSystemDialogs();
method public void finish();
method public android.content.Context getContext();
method public android.view.LayoutInflater getLayoutInflater();

View File

@@ -1000,6 +1000,21 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
}
}
/**
* Request that all system dialogs (and status bar shade etc) be closed, allowing
* access to the session's UI. This will <em>not</em> cause the lock screen to be
* dismissed.
*/
public void closeSystemDialogs() {
if (mToken == null) {
throw new IllegalStateException("Can't call before onCreate()");
}
try {
mSystemService.closeSystemDialogs(mToken);
} catch (RemoteException e) {
}
}
/**
* Convenience for inflating views.
*/

View File

@@ -35,6 +35,7 @@ interface IVoiceInteractionManagerService {
boolean hideSessionFromSession(IBinder token);
int startVoiceActivity(IBinder token, in Intent intent, String resolvedType);
void setKeepAwake(IBinder token, boolean keepAwake);
void closeSystemDialogs(IBinder token);
void finish(IBinder token);
/**

View File

@@ -18,9 +18,7 @@ package com.android.server.am;
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static com.android.internal.util.XmlUtils.readBooleanAttribute;
import static com.android.internal.util.XmlUtils.readIntAttribute;

View File

@@ -544,6 +544,24 @@ public class VoiceInteractionManagerService extends SystemService {
}
}
@Override
public void closeSystemDialogs(IBinder token) {
synchronized (this) {
if (mImpl == null) {
Slog.w(TAG, "closeSystemDialogs without running voice interaction service");
return;
}
final int callingPid = Binder.getCallingPid();
final int callingUid = Binder.getCallingUid();
final long caller = Binder.clearCallingIdentity();
try {
mImpl.closeSystemDialogsLocked(callingPid, callingUid, token);
} finally {
Binder.restoreCallingIdentity(caller);
}
}
}
@Override
public void finish(IBinder token) {
synchronized (this) {

View File

@@ -48,6 +48,8 @@ import java.io.PrintWriter;
class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConnection.Callback {
final static String TAG = "VoiceInteractionServiceManager";
final static String CLOSE_REASON_VOICE_INTERACTION = "voiceinteraction";
final boolean mValid;
final Context mContext;
@@ -68,11 +70,14 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) {
synchronized (mLock) {
if (mActiveSession != null && mActiveSession.mSession != null) {
try {
mActiveSession.mSession.closeSystemDialogs();
} catch (RemoteException e) {
String reason = intent.getStringExtra("reason");
if (!CLOSE_REASON_VOICE_INTERACTION.equals(reason)) {
synchronized (mLock) {
if (mActiveSession != null && mActiveSession.mSession != null) {
try {
mActiveSession.mSession.closeSystemDialogs();
} catch (RemoteException e) {
}
}
}
}
@@ -196,6 +201,18 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
}
}
public void closeSystemDialogsLocked(int callingPid, int callingUid, IBinder token) {
try {
if (mActiveSession == null || token != mActiveSession.mToken) {
Slog.w(TAG, "closeSystemDialogs does not match active session");
return;
}
mAm.closeSystemDialogs(CLOSE_REASON_VOICE_INTERACTION);
} catch (RemoteException e) {
throw new IllegalStateException("Unexpected remote error", e);
}
}
public void finishLocked(IBinder token) {
if (mActiveSession == null || token != mActiveSession.mToken) {
Slog.w(TAG, "finish does not match active session");