1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.quickstep.util;
17 
18 import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_ASSISTANT;
19 
20 import android.annotation.TargetApi;
21 import android.app.TaskInfo;
22 import android.content.Intent;
23 import android.os.Build;
24 
25 import com.android.systemui.shared.system.ActivityManagerWrapper;
26 import com.android.systemui.shared.system.TaskInfoCompat;
27 
28 /**
29  * Utility class for interacting with the Assistant.
30  */
31 @TargetApi(Build.VERSION_CODES.Q)
32 public final class AssistantUtilities {
33 
34     /** Returns true if an Assistant activity that is excluded from recents is running. */
isExcludedAssistantRunning()35     public static boolean isExcludedAssistantRunning() {
36         return isExcludedAssistant(ActivityManagerWrapper.getInstance().getRunningTask());
37     }
38 
39     /** Returns true if the given task holds an Assistant activity that is excluded from recents. */
isExcludedAssistant(TaskInfo info)40     public static boolean isExcludedAssistant(TaskInfo info) {
41         return info != null
42             && TaskInfoCompat.getActivityType(info) == ACTIVITY_TYPE_ASSISTANT
43             && (info.baseIntent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
44     }
45 
AssistantUtilities()46     private AssistantUtilities() {}
47 }
48