1 /*
2  * Copyright (C) 2018 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 
17 package com.android.server.wm;
18 
19 import android.util.proto.ProtoOutputStream;
20 import android.view.IRemoteAnimationRunner;
21 import android.view.RemoteAnimationAdapter;
22 
23 /**
24  * Interface used by the owner/creator of a process that owns windows to listen to changes from the
25  * WM side.
26  * @see WindowProcessController
27  */
28 public interface WindowProcessListener {
29 
30     /** Clear the profiler record if we are currently profiling this process. */
clearProfilerIfNeeded()31     void clearProfilerIfNeeded();
32 
33     /** Update the service connection for this process based on activities it might have. */
updateServiceConnectionActivities()34     void updateServiceConnectionActivities();
35 
36     /** Set or clear flag that we would like to clean-up UI resources for this process. */
setPendingUiClean(boolean pendingUiClean)37     void setPendingUiClean(boolean pendingUiClean);
38 
39     /**
40      * Set flag that we would like to clean-up UI resources for this process and force new process
41      * state.
42      */
setPendingUiCleanAndForceProcessStateUpTo(int newState)43     void setPendingUiCleanAndForceProcessStateUpTo(int newState);
44 
45     /** Update the process information. */
updateProcessInfo(boolean updateServiceConnectionActivities, boolean activityChange, boolean updateOomAdj)46     void updateProcessInfo(boolean updateServiceConnectionActivities, boolean activityChange,
47             boolean updateOomAdj);
48 
49     /**
50      * Returns true if the process is removed and we should completely clean up the related records
51      * belonging to this process.
52      */
isRemoved()53     boolean isRemoved();
54 
55     /** Returns the total time (in milliseconds) spent executing in both user and system code. */
getCpuTime()56     long getCpuTime();
57 
58     /** Called when we are in the process on starting an activity. */
onStartActivity(int topProcessState, boolean setProfileProc, String packageName, long versionCode)59     void onStartActivity(int topProcessState, boolean setProfileProc, String packageName,
60             long versionCode);
61 
62     /** App died :(...oh well */
appDied()63     void appDied();
writeToProto(ProtoOutputStream proto, long fieldId)64     void writeToProto(ProtoOutputStream proto, long fieldId);
65 
66     /**
67      * Sets if the process is currently running a remote animation, which is taken a signal for
68      * determining oom adjustment and scheduling behavior.
69      *
70      * @param runningRemoteAnimation True if the process is running a remote animation, false
71      *                               otherwise.
72      * @see RemoteAnimationAdapter
73      */
setRunningRemoteAnimation(boolean runningRemoteAnimation)74     void setRunningRemoteAnimation(boolean runningRemoteAnimation);
75 }
76