Loading core/java/android/service/voice/VoiceInteractionSession.java +16 −9 Original line number Original line Diff line number Diff line Loading @@ -1645,7 +1645,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall /** /** * Called to receive data from the application that the user was currently viewing when * Called to receive data from the application that the user was currently viewing when * an assist session is started. If the original show request did not specify - * an assist session is started. If the original show request did not specify * {@link #SHOW_WITH_ASSIST}, this method will not be called. * {@link #SHOW_WITH_ASSIST}, this method will not be called. * * * @param data Arbitrary data supplied by the app through * @param data Arbitrary data supplied by the app through Loading @@ -1671,7 +1671,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall /** /** * Called to receive data from the application that the user was currently viewing when * Called to receive data from the application that the user was currently viewing when * an assist session is started. If the original show request did not specify * an assist session is started. If the original show request did not specify * {@link #SHOW_WITH_ASSIST}, this method will not be called. * {@link #SHOW_WITH_ASSIST}, {@link AssistState} parameter will only provide * {@link ActivityId}. * * * <p>This method is called for all activities along with an index and count that indicates * <p>This method is called for all activities along with an index and count that indicates * which activity the data is for. {@code index} will be between 0 and {@code count}-1 and * which activity the data is for. {@code index} will be between 0 and {@code count}-1 and Loading @@ -1685,7 +1686,10 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall * @param state The state object capturing the state of an activity. * @param state The state object capturing the state of an activity. */ */ public void onHandleAssist(@NonNull AssistState state) { public void onHandleAssist(@NonNull AssistState state) { if (state.getIndex() == 0) { if (state.getAssistData() == null && state.getAssistStructure() == null && state.getAssistContent() == null) { return; } else if (state.getIndex() == 0) { onHandleAssist(state.getAssistData(), state.getAssistStructure(), onHandleAssist(state.getAssistData(), state.getAssistStructure(), state.getAssistContent()); state.getAssistContent()); } else { } else { Loading Loading @@ -2028,7 +2032,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall /** /** * @return Arbitrary data supplied by the app through * @return Arbitrary data supplied by the app through * {@link android.app.Activity#onProvideAssistData Activity.onProvideAssistData}. * {@link android.app.Activity#onProvideAssistData Activity.onProvideAssistData}. * May be null if assist data has been disabled by the user or device policy. * May be null if assist data has been disabled by the user or device policy; will be null * if the original show request did not specify {@link #SHOW_WITH_ASSIST}. */ */ public @Nullable Bundle getAssistData() { public @Nullable Bundle getAssistData() { return mData; return mData; Loading @@ -2037,7 +2042,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall /** /** * @return If available, the structure definition of all windows currently * @return If available, the structure definition of all windows currently * displayed by the app. May be null if assist data has been disabled by the user * displayed by the app. May be null if assist data has been disabled by the user * or device policy; will be an empty stub if the application has disabled assist * or device policy; will be null if the original show request did not specify * {@link #SHOW_WITH_ASSIST}; will be an empty stub if the application has disabled assist * by marking its window as secure. * by marking its window as secure. */ */ public @Nullable AssistStructure getAssistStructure() { public @Nullable AssistStructure getAssistStructure() { Loading @@ -2047,9 +2053,10 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall /** /** * @return Additional content data supplied by the app through * @return Additional content data supplied by the app through * {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}. * {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}. * May be null if assist data has been disabled by the user or device policy; will * May be null if assist data has been disabled by the user or device policy; will be null * not be automatically filled in with data from the app if the app has marked its * if the original show request did not specify {@link #SHOW_WITH_ASSIST}. Will not be * window as secure. * automatically filled in with data from the app if the app has marked its window as * secure. */ */ public @Nullable AssistContent getAssistContent() { public @Nullable AssistContent getAssistContent() { return mContent; return mContent; Loading services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +4 −3 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.IBinder; import android.os.RemoteException; import android.os.RemoteException; import android.service.voice.IVoiceInteractionSession; import android.service.voice.IVoiceInteractionSession; import android.util.Pair; import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream; import android.window.TaskSnapshot; import android.window.TaskSnapshot; Loading Loading @@ -162,10 +163,10 @@ public abstract class ActivityTaskManagerInternal { IVoiceInteractor mInteractor); IVoiceInteractor mInteractor); /** /** * Returns the top activity from each of the currently visible root tasks. The first entry * Returns the top activity from each of the currently visible root tasks, and the related task * will be the focused activity. * id. The first entry will be the focused activity. */ */ public abstract List<IBinder> getTopVisibleActivities(); public abstract List<Pair<IBinder, Integer>> getTopVisibleActivities(); /** /** * Returns whether {@code uid} has any resumed activity. * Returns whether {@code uid} has any resumed activity. Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -215,6 +215,7 @@ import android.text.format.TimeMigrationUtils; import android.util.ArrayMap; import android.util.ArrayMap; import android.util.ArraySet; import android.util.ArraySet; import android.util.Log; import android.util.Log; import android.util.Pair; import android.util.Slog; import android.util.Slog; import android.util.SparseArray; import android.util.SparseArray; import android.util.TimeUtils; import android.util.TimeUtils; Loading Loading @@ -5074,7 +5075,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } @Override @Override public List<IBinder> getTopVisibleActivities() { public List<Pair<IBinder, Integer>> getTopVisibleActivities() { synchronized (mGlobalLock) { synchronized (mGlobalLock) { return mRootWindowContainer.getTopVisibleActivities(); return mRootWindowContainer.getTopVisibleActivities(); } } Loading services/core/java/com/android/server/wm/RootWindowContainer.java +9 −7 Original line number Original line Diff line number Diff line Loading @@ -1814,11 +1814,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } /** /** * @return a list of activities which are the top ones in each visible root task. The first * @return a list of pairs, containing activities and their task id which are the top ones in * entry will be the focused activity. * each visible root task. The first entry will be the focused activity. */ */ List<IBinder> getTopVisibleActivities() { List<Pair<IBinder, Integer>> getTopVisibleActivities() { final ArrayList<IBinder> topActivityTokens = new ArrayList<>(); final ArrayList<Pair<IBinder, Integer>> topVisibleActivities = new ArrayList<>(); final Task topFocusedRootTask = getTopDisplayFocusedRootTask(); final Task topFocusedRootTask = getTopDisplayFocusedRootTask(); // Traverse all displays. // Traverse all displays. forAllRootTasks(rootTask -> { forAllRootTasks(rootTask -> { Loading @@ -1826,15 +1826,17 @@ class RootWindowContainer extends WindowContainer<DisplayContent> if (rootTask.shouldBeVisible(null /* starting */)) { if (rootTask.shouldBeVisible(null /* starting */)) { final ActivityRecord top = rootTask.getTopNonFinishingActivity(); final ActivityRecord top = rootTask.getTopNonFinishingActivity(); if (top != null) { if (top != null) { Pair<IBinder, Integer> visibleActivity = new Pair<>(top.appToken, top.getTask().mTaskId); if (rootTask == topFocusedRootTask) { if (rootTask == topFocusedRootTask) { topActivityTokens.add(0, top.appToken); topVisibleActivities.add(0, visibleActivity); } else { } else { topActivityTokens.add(top.appToken); topVisibleActivities.add(visibleActivity); } } } } } } }); }); return topActivityTokens; return topVisibleActivities; } } @Nullable @Nullable Loading services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +17 −6 Original line number Original line Diff line number Diff line Loading @@ -50,6 +50,7 @@ import android.service.voice.IVoiceInteractionSession; import android.service.voice.VoiceInteractionService; import android.service.voice.VoiceInteractionService; import android.service.voice.VoiceInteractionServiceInfo; import android.service.voice.VoiceInteractionServiceInfo; import android.system.OsConstants; import android.system.OsConstants; import android.util.Pair; import android.util.PrintWriterPrinter; import android.util.PrintWriterPrinter; import android.util.Slog; import android.util.Slog; import android.view.IWindowManager; import android.view.IWindowManager; Loading Loading @@ -186,17 +187,27 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne mSessionComponentName, mUser, mContext, this, mSessionComponentName, mUser, mContext, this, mInfo.getServiceInfo().applicationInfo.uid, mHandler); mInfo.getServiceInfo().applicationInfo.uid, mHandler); } } List<IBinder> activityTokens = null; List<Pair<IBinder, Integer>> allVisibleActivities = LocalServices.getService(ActivityTaskManagerInternal.class) .getTopVisibleActivities(); List<Pair<IBinder, Integer>> visibleActivities = null; if (activityToken != null) { if (activityToken != null) { activityTokens = new ArrayList<>(); visibleActivities = new ArrayList(); activityTokens.add(activityToken); int activitiesCount = allVisibleActivities.size(); for (int i = 0; i < activitiesCount; i++) { if (allVisibleActivities.get(i).first == activityToken) { visibleActivities.add( new Pair<>(activityToken, allVisibleActivities.get(i).second)); break; } } } else { } else { // Let's get top activities from all visible stacks visibleActivities = LocalServices.getService(ActivityTaskManagerInternal.class) activityTokens = LocalServices.getService(ActivityTaskManagerInternal.class) .getTopVisibleActivities(); .getTopVisibleActivities(); } } return mActiveSession.showLocked(args, flags, mDisabledShowContext, showCallback, return mActiveSession.showLocked(args, flags, mDisabledShowContext, showCallback, activityTokens); visibleActivities); } } public void getActiveServiceSupportedActions(List<String> commands, public void getActiveServiceSupportedActions(List<String> commands, Loading Loading
core/java/android/service/voice/VoiceInteractionSession.java +16 −9 Original line number Original line Diff line number Diff line Loading @@ -1645,7 +1645,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall /** /** * Called to receive data from the application that the user was currently viewing when * Called to receive data from the application that the user was currently viewing when * an assist session is started. If the original show request did not specify - * an assist session is started. If the original show request did not specify * {@link #SHOW_WITH_ASSIST}, this method will not be called. * {@link #SHOW_WITH_ASSIST}, this method will not be called. * * * @param data Arbitrary data supplied by the app through * @param data Arbitrary data supplied by the app through Loading @@ -1671,7 +1671,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall /** /** * Called to receive data from the application that the user was currently viewing when * Called to receive data from the application that the user was currently viewing when * an assist session is started. If the original show request did not specify * an assist session is started. If the original show request did not specify * {@link #SHOW_WITH_ASSIST}, this method will not be called. * {@link #SHOW_WITH_ASSIST}, {@link AssistState} parameter will only provide * {@link ActivityId}. * * * <p>This method is called for all activities along with an index and count that indicates * <p>This method is called for all activities along with an index and count that indicates * which activity the data is for. {@code index} will be between 0 and {@code count}-1 and * which activity the data is for. {@code index} will be between 0 and {@code count}-1 and Loading @@ -1685,7 +1686,10 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall * @param state The state object capturing the state of an activity. * @param state The state object capturing the state of an activity. */ */ public void onHandleAssist(@NonNull AssistState state) { public void onHandleAssist(@NonNull AssistState state) { if (state.getIndex() == 0) { if (state.getAssistData() == null && state.getAssistStructure() == null && state.getAssistContent() == null) { return; } else if (state.getIndex() == 0) { onHandleAssist(state.getAssistData(), state.getAssistStructure(), onHandleAssist(state.getAssistData(), state.getAssistStructure(), state.getAssistContent()); state.getAssistContent()); } else { } else { Loading Loading @@ -2028,7 +2032,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall /** /** * @return Arbitrary data supplied by the app through * @return Arbitrary data supplied by the app through * {@link android.app.Activity#onProvideAssistData Activity.onProvideAssistData}. * {@link android.app.Activity#onProvideAssistData Activity.onProvideAssistData}. * May be null if assist data has been disabled by the user or device policy. * May be null if assist data has been disabled by the user or device policy; will be null * if the original show request did not specify {@link #SHOW_WITH_ASSIST}. */ */ public @Nullable Bundle getAssistData() { public @Nullable Bundle getAssistData() { return mData; return mData; Loading @@ -2037,7 +2042,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall /** /** * @return If available, the structure definition of all windows currently * @return If available, the structure definition of all windows currently * displayed by the app. May be null if assist data has been disabled by the user * displayed by the app. May be null if assist data has been disabled by the user * or device policy; will be an empty stub if the application has disabled assist * or device policy; will be null if the original show request did not specify * {@link #SHOW_WITH_ASSIST}; will be an empty stub if the application has disabled assist * by marking its window as secure. * by marking its window as secure. */ */ public @Nullable AssistStructure getAssistStructure() { public @Nullable AssistStructure getAssistStructure() { Loading @@ -2047,9 +2053,10 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall /** /** * @return Additional content data supplied by the app through * @return Additional content data supplied by the app through * {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}. * {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}. * May be null if assist data has been disabled by the user or device policy; will * May be null if assist data has been disabled by the user or device policy; will be null * not be automatically filled in with data from the app if the app has marked its * if the original show request did not specify {@link #SHOW_WITH_ASSIST}. Will not be * window as secure. * automatically filled in with data from the app if the app has marked its window as * secure. */ */ public @Nullable AssistContent getAssistContent() { public @Nullable AssistContent getAssistContent() { return mContent; return mContent; Loading
services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +4 −3 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.IBinder; import android.os.RemoteException; import android.os.RemoteException; import android.service.voice.IVoiceInteractionSession; import android.service.voice.IVoiceInteractionSession; import android.util.Pair; import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream; import android.window.TaskSnapshot; import android.window.TaskSnapshot; Loading Loading @@ -162,10 +163,10 @@ public abstract class ActivityTaskManagerInternal { IVoiceInteractor mInteractor); IVoiceInteractor mInteractor); /** /** * Returns the top activity from each of the currently visible root tasks. The first entry * Returns the top activity from each of the currently visible root tasks, and the related task * will be the focused activity. * id. The first entry will be the focused activity. */ */ public abstract List<IBinder> getTopVisibleActivities(); public abstract List<Pair<IBinder, Integer>> getTopVisibleActivities(); /** /** * Returns whether {@code uid} has any resumed activity. * Returns whether {@code uid} has any resumed activity. Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -215,6 +215,7 @@ import android.text.format.TimeMigrationUtils; import android.util.ArrayMap; import android.util.ArrayMap; import android.util.ArraySet; import android.util.ArraySet; import android.util.Log; import android.util.Log; import android.util.Pair; import android.util.Slog; import android.util.Slog; import android.util.SparseArray; import android.util.SparseArray; import android.util.TimeUtils; import android.util.TimeUtils; Loading Loading @@ -5074,7 +5075,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } @Override @Override public List<IBinder> getTopVisibleActivities() { public List<Pair<IBinder, Integer>> getTopVisibleActivities() { synchronized (mGlobalLock) { synchronized (mGlobalLock) { return mRootWindowContainer.getTopVisibleActivities(); return mRootWindowContainer.getTopVisibleActivities(); } } Loading
services/core/java/com/android/server/wm/RootWindowContainer.java +9 −7 Original line number Original line Diff line number Diff line Loading @@ -1814,11 +1814,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } /** /** * @return a list of activities which are the top ones in each visible root task. The first * @return a list of pairs, containing activities and their task id which are the top ones in * entry will be the focused activity. * each visible root task. The first entry will be the focused activity. */ */ List<IBinder> getTopVisibleActivities() { List<Pair<IBinder, Integer>> getTopVisibleActivities() { final ArrayList<IBinder> topActivityTokens = new ArrayList<>(); final ArrayList<Pair<IBinder, Integer>> topVisibleActivities = new ArrayList<>(); final Task topFocusedRootTask = getTopDisplayFocusedRootTask(); final Task topFocusedRootTask = getTopDisplayFocusedRootTask(); // Traverse all displays. // Traverse all displays. forAllRootTasks(rootTask -> { forAllRootTasks(rootTask -> { Loading @@ -1826,15 +1826,17 @@ class RootWindowContainer extends WindowContainer<DisplayContent> if (rootTask.shouldBeVisible(null /* starting */)) { if (rootTask.shouldBeVisible(null /* starting */)) { final ActivityRecord top = rootTask.getTopNonFinishingActivity(); final ActivityRecord top = rootTask.getTopNonFinishingActivity(); if (top != null) { if (top != null) { Pair<IBinder, Integer> visibleActivity = new Pair<>(top.appToken, top.getTask().mTaskId); if (rootTask == topFocusedRootTask) { if (rootTask == topFocusedRootTask) { topActivityTokens.add(0, top.appToken); topVisibleActivities.add(0, visibleActivity); } else { } else { topActivityTokens.add(top.appToken); topVisibleActivities.add(visibleActivity); } } } } } } }); }); return topActivityTokens; return topVisibleActivities; } } @Nullable @Nullable Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +17 −6 Original line number Original line Diff line number Diff line Loading @@ -50,6 +50,7 @@ import android.service.voice.IVoiceInteractionSession; import android.service.voice.VoiceInteractionService; import android.service.voice.VoiceInteractionService; import android.service.voice.VoiceInteractionServiceInfo; import android.service.voice.VoiceInteractionServiceInfo; import android.system.OsConstants; import android.system.OsConstants; import android.util.Pair; import android.util.PrintWriterPrinter; import android.util.PrintWriterPrinter; import android.util.Slog; import android.util.Slog; import android.view.IWindowManager; import android.view.IWindowManager; Loading Loading @@ -186,17 +187,27 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne mSessionComponentName, mUser, mContext, this, mSessionComponentName, mUser, mContext, this, mInfo.getServiceInfo().applicationInfo.uid, mHandler); mInfo.getServiceInfo().applicationInfo.uid, mHandler); } } List<IBinder> activityTokens = null; List<Pair<IBinder, Integer>> allVisibleActivities = LocalServices.getService(ActivityTaskManagerInternal.class) .getTopVisibleActivities(); List<Pair<IBinder, Integer>> visibleActivities = null; if (activityToken != null) { if (activityToken != null) { activityTokens = new ArrayList<>(); visibleActivities = new ArrayList(); activityTokens.add(activityToken); int activitiesCount = allVisibleActivities.size(); for (int i = 0; i < activitiesCount; i++) { if (allVisibleActivities.get(i).first == activityToken) { visibleActivities.add( new Pair<>(activityToken, allVisibleActivities.get(i).second)); break; } } } else { } else { // Let's get top activities from all visible stacks visibleActivities = LocalServices.getService(ActivityTaskManagerInternal.class) activityTokens = LocalServices.getService(ActivityTaskManagerInternal.class) .getTopVisibleActivities(); .getTopVisibleActivities(); } } return mActiveSession.showLocked(args, flags, mDisabledShowContext, showCallback, return mActiveSession.showLocked(args, flags, mDisabledShowContext, showCallback, activityTokens); visibleActivities); } } public void getActiveServiceSupportedActions(List<String> commands, public void getActiveServiceSupportedActions(List<String> commands, Loading