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

Commit 745af612 authored by Nicolò Mazzucato's avatar Nicolò Mazzucato Committed by Android (Google) Code Review
Browse files

Merge "Fix onHandleAssist behaviour when showSession is called with flags = 0" into sc-dev

parents 91d9eaa2 d4e6ec0e
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wm;

import android.os.IBinder;

/**
 * Class needed to expose some {@link ActivityRecord} fields in order to provide
 * {@link android.service.voice.VoiceInteractionSession#onHandleAssist(AssistState)}
 *
 * @hide
 */
public class ActivityAssistInfo {
    private final IBinder mActivityToken;
    private final IBinder mAssistToken;
    private final int mTaskId;

    public ActivityAssistInfo(ActivityRecord activityRecord) {
        this.mActivityToken = activityRecord.appToken;
        this.mAssistToken = activityRecord.assistToken;
        this.mTaskId = activityRecord.getTask().mTaskId;
    }

    /** @hide */
    public IBinder getActivityToken() {
        return mActivityToken;
    }

    /** @hide */
    public IBinder getAssistToken() {
        return mAssistToken;
    }

    /** @hide */
    public int getTaskId() {
        return mTaskId;
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.service.voice.IVoiceInteractionSession;
import android.util.Pair;
import android.util.proto.ProtoOutputStream;
import android.window.TaskSnapshot;

@@ -166,7 +165,7 @@ public abstract class ActivityTaskManagerInternal {
     * Returns the top activity from each of the currently visible root tasks, and the related task
     * id. The first entry will be the focused activity.
     */
    public abstract List<Pair<IBinder, Integer>> getTopVisibleActivities();
    public abstract List<ActivityAssistInfo> getTopVisibleActivities();

    /**
     * Returns whether {@code uid} has any resumed activity.
+1 −2
Original line number Diff line number Diff line
@@ -215,7 +215,6 @@ import android.text.format.TimeMigrationUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
import android.util.TimeUtils;
@@ -5112,7 +5111,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }

        @Override
        public List<Pair<IBinder, Integer>> getTopVisibleActivities() {
        public List<ActivityAssistInfo> getTopVisibleActivities() {
            synchronized (mGlobalLock) {
                return mRootWindowContainer.getTopVisibleActivities();
            }
+3 −4
Original line number Diff line number Diff line
@@ -1817,8 +1817,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
     * @return a list of pairs, containing activities and their task id which are the top ones in
     * each visible root task. The first entry will be the focused activity.
     */
    List<Pair<IBinder, Integer>> getTopVisibleActivities() {
        final ArrayList<Pair<IBinder, Integer>> topVisibleActivities = new ArrayList<>();
    List<ActivityAssistInfo> getTopVisibleActivities() {
        final ArrayList<ActivityAssistInfo> topVisibleActivities = new ArrayList<>();
        final Task topFocusedRootTask = getTopDisplayFocusedRootTask();
        // Traverse all displays.
        forAllRootTasks(rootTask -> {
@@ -1826,8 +1826,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            if (rootTask.shouldBeVisible(null /* starting */)) {
                final ActivityRecord top = rootTask.getTopNonFinishingActivity();
                if (top != null) {
                    Pair<IBinder, Integer> visibleActivity = new Pair<>(top.appToken,
                            top.getTask().mTaskId);
                    ActivityAssistInfo visibleActivity = new ActivityAssistInfo(top);
                    if (rootTask == topFocusedRootTask) {
                        topVisibleActivities.add(0, visibleActivity);
                    } else {
+8 −0
Original line number Diff line number Diff line
@@ -7,6 +7,14 @@
          "exclude-annotation": "androidx.test.filters.FlakyTest"
        }
      ]
    },
    {
      "name": "CtsAssistTestCases",
      "options": [
        {
          "exclude-annotation": "androidx.test.filters.FlakyTest"
        }
      ]
    }
  ]
}
Loading