blob: 3359a41369d7d0ea50e1d77940314e1ffd8279a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
* 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 android.window;
import android.annotation.NonNull;
import android.content.ComponentName;
import android.content.pm.ActivityInfo;
import android.util.ArraySet;
import java.io.PrintWriter;
import java.util.List;
/**
* Abstract class to control the policies of the windows that can be displayed on the virtual
* display.
*
* @hide
*/
public abstract class DisplayWindowPolicyController {
/**
* The window flags that we are interested in.
* @see android.view.WindowManager.LayoutParams
* @see #keepActivityOnWindowFlagsChanged
*/
private int mWindowFlags;
/**
* The system window flags that we are interested in.
* @see android.view.WindowManager.LayoutParams
* @see #keepActivityOnWindowFlagsChanged
*/
private int mSystemWindowFlags;
/**
* Returns {@code true} if the given window flags contain the flags that we're interested in.
*/
public final boolean isInterestedWindowFlags(int windowFlags, int systemWindowFlags) {
return (mWindowFlags & windowFlags) != 0 || (mSystemWindowFlags & systemWindowFlags) != 0;
}
/**
* Sets the window flags that we’re interested in and expected
* #keepActivityOnWindowFlagsChanged to be called if any changes.
*/
public final void setInterestedWindowFlags(int windowFlags, int systemWindowFlags) {
mWindowFlags = windowFlags;
mSystemWindowFlags = systemWindowFlags;
}
/**
* Returns {@code true} if the given activities can be displayed on this virtual display.
*/
public abstract boolean canContainActivities(@NonNull List<ActivityInfo> activities);
/**
* Called when an Activity window is layouted with the new changes where contains the
* window flags that we’re interested in.
* Returns {@code false} if the Activity cannot remain on the display and the activity task will
* be moved back to default display.
*/
public abstract boolean keepActivityOnWindowFlagsChanged(
ActivityInfo activityInfo, int windowFlags, int systemWindowFlags);
/**
* This is called when the top activity of the display is changed.
*/
public void onTopActivityChanged(ComponentName topActivity, int uid) {}
/**
* This is called when the apps that contains running activities on the display has changed.
* The running activities refer to the non-finishing activities regardless of they are running
* in a process.
*/
public void onRunningAppsChanged(ArraySet<Integer> runningUids) {}
/** Dump debug data */
public void dump(String prefix, final PrintWriter pw) {
pw.println(prefix + "DisplayWindowPolicyController{" + super.toString() + "}");
pw.println(prefix + " mWindowFlags=" + mWindowFlags);
pw.println(prefix + " mSystemWindowFlags=" + mSystemWindowFlags);
}
}
|