• 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 
23 /**
24  * ResourceManagerService interface that keeps track of media resource
25  * owned by clients, and reclaims resources based on configured policies
26  * when necessary.
27  *
28  * {@hide}
29  */
30 interface IResourceManagerService {
31     const @utf8InCpp String kPolicySupportsMultipleSecureCodecs
32             = "supports-multiple-secure-codecs";
33     const @utf8InCpp String kPolicySupportsSecureWithNonSecureCodec
34             = "supports-secure-with-non-secure-codec";
35 
36     /**
37      * Configure the ResourceManagerService to adopted particular policies when
38      * managing the resources.
39      *
40      * @param policies an array of policies to be adopted.
41      */
config(in MediaResourcePolicyParcel[] policies)42     void config(in MediaResourcePolicyParcel[] policies);
43 
44     /**
45      * Add a client to a process with a list of resources.
46      *
47      * @param pid pid of the client.
48      * @param uid uid of the client.
49      * @param clientId an identifier that uniquely identifies the client within the pid.
50      * @param client interface for the ResourceManagerService to call the client.
51      * @param resources an array of resources to be added.
52      */
addResource( int pid, int uid, long clientId, IResourceManagerClient client, in MediaResourceParcel[] resources)53     void addResource(
54             int pid,
55             int uid,
56             long clientId,
57             IResourceManagerClient client,
58             in MediaResourceParcel[] resources);
59 
60     /**
61      * Remove the listed resources from a client.
62      *
63      * @param pid pid from which the list of resources will be removed.
64      * @param clientId clientId within the pid from which the list of resources will be removed.
65      * @param resources an array of resources to be removed from the client.
66      */
removeResource(int pid, long clientId, in MediaResourceParcel[] resources)67     void removeResource(int pid, long clientId, in MediaResourceParcel[] resources);
68 
69     /**
70      * Remove all resources from a client.
71      *
72      * @param pid pid from which the client's resources will be removed.
73      * @param clientId clientId within the pid that will be removed.
74      */
removeClient(int pid, long clientId)75     void removeClient(int pid, long clientId);
76 
77     /**
78      * Tries to reclaim resource from processes with lower priority than the
79      * calling process according to the requested resources.
80      *
81      * @param callingPid pid of the calling process.
82      * @param resources an array of resources to be reclaimed.
83      *
84      * @return true if the reclaim was successful and false otherwise.
85      */
reclaimResource(int callingPid, in MediaResourceParcel[] resources)86     boolean reclaimResource(int callingPid, in MediaResourceParcel[] resources);
87 
88     /**
89      * Override the pid of original calling process with the pid of the process
90      * who actually use the requested resources.
91      *
92      * @param originalPid pid of the original calling process.
93      * @param newPid pid of the actual process who use the resources.
94      *        remove existing override on originalPid if newPid is -1.
95      */
overridePid(int originalPid, int newPid)96     void overridePid(int originalPid, int newPid);
97 
98     /**
99      * Override the process state and OOM score of the calling process with the
100      * the specified values. This is used by native service processes to specify
101      * these values for ResourceManagerService to use. ResourceManagerService usually
102      * gets these values from ActivityManagerService, however, ActivityManagerService
103      * doesn't track native service processes.
104      *
105      * @param client a token for the ResourceManagerService to link to the caller and
106      *              receive notification if it goes away. This is needed for clearing
107      *              the overrides.
108      * @param pid pid of the calling process.
109      * @param procState the process state value that ResourceManagerService should
110      *                  use for this pid.
111      * @param oomScore the oom score value that ResourceManagerService should
112      *                  use for this pid.
113      */
overrideProcessInfo( IResourceManagerClient client, int pid, int procState, int oomScore)114     void overrideProcessInfo(
115             IResourceManagerClient client,
116             int pid,
117             int procState,
118             int oomScore);
119 
120     /**
121      * Mark a client for pending removal
122      *
123      * @param pid pid from which the client's resources will be removed.
124      * @param clientId clientId within the pid that will be removed.
125      */
markClientForPendingRemoval(int pid, long clientId)126     void markClientForPendingRemoval(int pid, long clientId);
127 
128     /**
129      * Reclaim resources from clients pending removal, if any.
130      *
131      * @param pid pid from which resources will be reclaimed.
132      */
reclaimResourcesFromClientsPendingRemoval(int pid)133     void reclaimResourcesFromClientsPendingRemoval(int pid);
134 }
135