Merge "Allow IVoiceInteractionSessionListener to listen for window vis changes" into tm-dev am: 44e14e72b6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17211290 Change-Id: I0ef34055a82eca0d2f2efcefae2aeb99eb0640e9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1095,7 +1095,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
if (!mWindowVisible) {
|
if (!mWindowVisible) {
|
||||||
mWindowVisible = true;
|
mWindowVisible = true;
|
||||||
if (mUiEnabled) {
|
if (mUiEnabled) {
|
||||||
mWindow.show();
|
showWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (showCallback != null) {
|
if (showCallback != null) {
|
||||||
@@ -1284,9 +1284,25 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showWindow() {
|
||||||
|
if (mWindow != null) {
|
||||||
|
mWindow.show();
|
||||||
|
try {
|
||||||
|
mSystemService.setSessionWindowVisible(mToken, true);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.w(TAG, "Failed to notify session window shown", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ensureWindowHidden() {
|
void ensureWindowHidden() {
|
||||||
if (mWindow != null) {
|
if (mWindow != null) {
|
||||||
mWindow.hide();
|
mWindow.hide();
|
||||||
|
try {
|
||||||
|
mSystemService.setSessionWindowVisible(mToken, false);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.w(TAG, "Failed to notify session window hidden", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1377,7 +1393,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
if (mWindowVisible) {
|
if (mWindowVisible) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
ensureWindowAdded();
|
ensureWindowAdded();
|
||||||
mWindow.show();
|
showWindow();
|
||||||
} else {
|
} else {
|
||||||
ensureWindowHidden();
|
ensureWindowHidden();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,4 +284,9 @@ interface IVoiceInteractionManagerService {
|
|||||||
* Stops to listen the status of visible activity.
|
* Stops to listen the status of visible activity.
|
||||||
*/
|
*/
|
||||||
void stopListeningVisibleActivityChanged(in IBinder token);
|
void stopListeningVisibleActivityChanged(in IBinder token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies when the session window is shown or hidden.
|
||||||
|
*/
|
||||||
|
void setSessionWindowVisible(in IBinder token, boolean visible);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,11 @@
|
|||||||
*/
|
*/
|
||||||
void onVoiceSessionHidden();
|
void onVoiceSessionHidden();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a voice session window is shown/hidden.
|
||||||
|
*/
|
||||||
|
void onVoiceSessionWindowVisibilityChanged(boolean visible);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when UI hints were received.
|
* Called when UI hints were received.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -186,6 +186,14 @@ public class AssistManager {
|
|||||||
AssistantSessionEvent.ASSISTANT_SESSION_CLOSE);
|
AssistantSessionEvent.ASSISTANT_SESSION_CLOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVoiceSessionWindowVisibilityChanged(boolean visible)
|
||||||
|
throws RemoteException {
|
||||||
|
if (VERBOSE) {
|
||||||
|
Log.v(TAG, "Window visibility changed: " + visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetUiHints(Bundle hints) {
|
public void onSetUiHints(Bundle hints) {
|
||||||
if (VERBOSE) {
|
if (VERBOSE) {
|
||||||
|
|||||||
@@ -1824,6 +1824,32 @@ public class VoiceInteractionManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSessionWindowVisible(IBinder token, boolean visible) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (mImpl == null) {
|
||||||
|
Slog.w(TAG, "setSessionWindowVisible called without running voice interaction "
|
||||||
|
+ "service");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mImpl.mActiveSession == null || token != mImpl.mActiveSession.mToken) {
|
||||||
|
Slog.w(TAG, "setSessionWindowVisible does not match active session");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final long caller = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
mVoiceInteractionSessionListeners.broadcast(listener -> {
|
||||||
|
try {
|
||||||
|
listener.onVoiceSessionWindowVisibilityChanged(visible);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Slog.e(TAG, "Error delivering window visibility event to listener.", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(caller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@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