• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package android.media;
18 
19 import android.media.IResourceManagerClient;
20 import android.media.MediaResourceParcel;
21 import android.media.MediaResourcePolicyParcel;
22 import android.media.ClientInfoParcel;
23 import android.media.ClientConfigParcel;
24 
25 /**
26  * ResourceManagerService interface that keeps track of media resource
27  * owned by clients, and reclaims resources based on configured policies
28  * when necessary.
29  *
30  * {@hide}
31  */
32 interface IResourceManagerService {
33     const @utf8InCpp String kPolicySupportsMultipleSecureCodecs
34             = "supports-multiple-secure-codecs";
35     const @utf8InCpp String kPolicySupportsSecureWithNonSecureCodec
36             = "supports-secure-with-non-secure-codec";
37 
38     /**
39      * Configure the ResourceManagerService to adopted particular policies when
40      * managing the resources.
41      *
42      * @param policies an array of policies to be adopted.
43      */
config(in MediaResourcePolicyParcel[] policies)44     void config(in MediaResourcePolicyParcel[] policies);
45 
46     /**
47      * Add a client to a process with a list of resources.
48      *
49      * @param clientInfo info of the calling client.
50      * @param client interface for the ResourceManagerService to call the client.
51      * @param resources an array of resources to be added.
52      */
addResource( in ClientInfoParcel clientInfo, IResourceManagerClient client, in MediaResourceParcel[] resources)53     void addResource(
54             in ClientInfoParcel clientInfo,
55             IResourceManagerClient client,
56             in MediaResourceParcel[] resources);
57 
58     /**
59      * Remove the listed resources from a client.
60      *
61      * @param clientInfo info of the calling client.
62      * @param resources an array of resources to be removed from the client.
63      */
removeResource(in ClientInfoParcel clientInfo, in MediaResourceParcel[] resources)64     void removeResource(in ClientInfoParcel clientInfo, in MediaResourceParcel[] resources);
65 
66     /**
67      * Remove all resources from a client.
68      *
69      * @param clientInfo info of the calling client.
70      */
removeClient(in ClientInfoParcel clientInfo)71     void removeClient(in ClientInfoParcel clientInfo);
72 
73     /**
74      * Tries to reclaim resource from processes with lower priority than the
75      * calling process according to the requested resources.
76      *
77      * @param clientInfo info of the calling client.
78      * @param resources an array of resources to be reclaimed.
79      *
80      * @return true if the reclaim was successful and false otherwise.
81      */
reclaimResource(in ClientInfoParcel clientInfo, in MediaResourceParcel[] resources)82     boolean reclaimResource(in ClientInfoParcel clientInfo, in MediaResourceParcel[] resources);
83 
84     /**
85      * Override the pid of original calling process with the pid of the process
86      * who actually use the requested resources.
87      *
88      * @param originalPid pid of the original calling process.
89      * @param newPid pid of the actual process who use the resources.
90      *        remove existing override on originalPid if newPid is -1.
91      */
overridePid(int originalPid, int newPid)92     void overridePid(int originalPid, int newPid);
93 
94     /**
95      * Override the process state and OOM score of the calling process with the
96      * the specified values. This is used by native service processes to specify
97      * these values for ResourceManagerService to use. ResourceManagerService usually
98      * gets these values from ActivityManagerService, however, ActivityManagerService
99      * doesn't track native service processes.
100      *
101      * @param client a token for the ResourceManagerService to link to the caller and
102      *              receive notification if it goes away. This is needed for clearing
103      *              the overrides.
104      * @param pid pid of the calling process.
105      * @param procState the process state value that ResourceManagerService should
106      *                  use for this pid.
107      * @param oomScore the oom score value that ResourceManagerService should
108      *                  use for this pid.
109      */
overrideProcessInfo( IResourceManagerClient client, int pid, int procState, int oomScore)110     void overrideProcessInfo(
111             IResourceManagerClient client,
112             int pid,
113             int procState,
114             int oomScore);
115 
116     /**
117      * Mark a client for pending removal
118      *
119      * @param clientInfo info of the calling client.
120      */
markClientForPendingRemoval(in ClientInfoParcel clientInfo)121     void markClientForPendingRemoval(in ClientInfoParcel clientInfo);
122 
123     /**
124      * Reclaim resources from clients pending removal, if any.
125      *
126      * @param pid pid from which resources will be reclaimed.
127      */
reclaimResourcesFromClientsPendingRemoval(int pid)128     void reclaimResourcesFromClientsPendingRemoval(int pid);
129 
130     /**
131      * Notify that the client has been created.
132      *
133      * This call is made to collect the (concurrent) metrics about the
134      * resources associated with the Codec (and also DRM sessions).
135      *
136      * @param clientInfo Information of the client.
137      */
notifyClientCreated(in ClientInfoParcel clientInfo)138     void notifyClientCreated(in ClientInfoParcel clientInfo);
139 
140     /**
141      * Notify that the client has been started.
142      *
143      * This call is made to collect the (concurrent) metrics about the
144      * resources associated with the Codec (and also DRM sessions).
145      *
146      * @param clientConfig Configuration information of the client.
147      */
notifyClientStarted(in ClientConfigParcel clientConfig)148     void notifyClientStarted(in ClientConfigParcel clientConfig);
149 
150     /**
151      * Notify that the client has been stopped.
152      *
153      * This call is made to collect the (concurrent) metrics about the
154      * resources associated with the Codec (and also DRM sessions).
155      *
156      * @param clientConfig Configuration information of the client.
157      */
notifyClientStopped(in ClientConfigParcel clientConfig)158     void notifyClientStopped(in ClientConfigParcel clientConfig);
159 
160     /**
161      * Notify that the client's configuration has changed.
162      *
163      * This call is made to collect the (concurrent) metrics about the
164      * resources associated with the Codec (and also DRM sessions).
165      * This is called after notifyClientStarted (and before notifyClientStopped)
166      * to make changes to some of the configurations associated with the client.
167      *
168      * @param clientConfig Configuration information of the client.
169      */
notifyClientConfigChanged(in ClientConfigParcel clientConfig)170     void notifyClientConfigChanged(in ClientConfigParcel clientConfig);
171 }
172