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 * Update the client with given list of resources. 60 * This is used to update the existing resource values with an updated value. 61 * 62 * @param clientInfo info of the calling client. 63 * @param resources an array of resources to be updated. 64 */ updateResource( in ClientInfoParcel clientInfo, in MediaResourceParcel[] resources)65 void updateResource( 66 in ClientInfoParcel clientInfo, 67 in MediaResourceParcel[] resources); 68 69 /** 70 * Remove the listed resources from a client. 71 * 72 * @param clientInfo info of the calling client. 73 * @param resources an array of resources to be removed from the client. 74 */ removeResource(in ClientInfoParcel clientInfo, in MediaResourceParcel[] resources)75 void removeResource(in ClientInfoParcel clientInfo, in MediaResourceParcel[] resources); 76 77 /** 78 * Remove all resources from a client. 79 * 80 * @param clientInfo info of the calling client. 81 */ removeClient(in ClientInfoParcel clientInfo)82 void removeClient(in ClientInfoParcel clientInfo); 83 84 /** 85 * Tries to reclaim resource from processes with lower priority than the 86 * calling process according to the requested resources. 87 * 88 * @param clientInfo info of the calling client. 89 * @param resources an array of resources to be reclaimed. 90 * 91 * @return true if the reclaim was successful and false otherwise. 92 */ reclaimResource(in ClientInfoParcel clientInfo, in MediaResourceParcel[] resources)93 boolean reclaimResource(in ClientInfoParcel clientInfo, in MediaResourceParcel[] resources); 94 95 /** 96 * Override the pid of original calling process with the pid of the process 97 * who actually use the requested resources. 98 * 99 * @param originalPid pid of the original calling process. 100 * @param newPid pid of the actual process who use the resources. 101 * remove existing override on originalPid if newPid is -1. 102 */ overridePid(int originalPid, int newPid)103 void overridePid(int originalPid, int newPid); 104 105 /** 106 * Override the process state and OOM score of the calling process with the 107 * the specified values. This is used by native service processes to specify 108 * these values for ResourceManagerService to use. ResourceManagerService usually 109 * gets these values from ActivityManagerService, however, ActivityManagerService 110 * doesn't track native service processes. 111 * 112 * @param client a token for the ResourceManagerService to link to the caller and 113 * receive notification if it goes away. This is needed for clearing 114 * the overrides. 115 * @param pid pid of the calling process. 116 * @param procState the process state value that ResourceManagerService should 117 * use for this pid. 118 * @param oomScore the oom score value that ResourceManagerService should 119 * use for this pid. 120 */ overrideProcessInfo( IResourceManagerClient client, int pid, int procState, int oomScore)121 void overrideProcessInfo( 122 IResourceManagerClient client, 123 int pid, 124 int procState, 125 int oomScore); 126 127 /** 128 * Mark a client for pending removal 129 * 130 * @param clientInfo info of the calling client. 131 */ markClientForPendingRemoval(in ClientInfoParcel clientInfo)132 void markClientForPendingRemoval(in ClientInfoParcel clientInfo); 133 134 /** 135 * Reclaim resources from clients pending removal, if any. 136 * 137 * @param pid pid from which resources will be reclaimed. 138 */ reclaimResourcesFromClientsPendingRemoval(int pid)139 void reclaimResourcesFromClientsPendingRemoval(int pid); 140 141 /** 142 * Notify that the client has been created. 143 * 144 * This call is made to collect the (concurrent) metrics about the 145 * resources associated with the Codec (and also DRM sessions). 146 * 147 * @param clientInfo Information of the client. 148 */ notifyClientCreated(in ClientInfoParcel clientInfo)149 void notifyClientCreated(in ClientInfoParcel clientInfo); 150 151 /** 152 * Notify that the client has been started. 153 * 154 * This call is made to collect the (concurrent) metrics about the 155 * resources associated with the Codec (and also DRM sessions). 156 * 157 * @param clientConfig Configuration information of the client. 158 */ notifyClientStarted(in ClientConfigParcel clientConfig)159 void notifyClientStarted(in ClientConfigParcel clientConfig); 160 161 /** 162 * Notify that the client has been stopped. 163 * 164 * This call is made to collect the (concurrent) metrics about the 165 * resources associated with the Codec (and also DRM sessions). 166 * 167 * @param clientConfig Configuration information of the client. 168 */ notifyClientStopped(in ClientConfigParcel clientConfig)169 void notifyClientStopped(in ClientConfigParcel clientConfig); 170 171 /** 172 * Notify that the client's configuration has changed. 173 * 174 * This call is made to collect the (concurrent) metrics about the 175 * resources associated with the Codec (and also DRM sessions). 176 * This is called after notifyClientStarted (and before notifyClientStopped) 177 * to make changes to some of the configurations associated with the client. 178 * 179 * @param clientConfig Configuration information of the client. 180 */ notifyClientConfigChanged(in ClientConfigParcel clientConfig)181 void notifyClientConfigChanged(in ClientConfigParcel clientConfig); 182 183 /** 184 * Get a list of all the MediaResources currently being used. 185 * 186 * This provides information on current resource usage by the system. 187 * 188 * @param resources List of resources being used when this call is made. 189 */ getMediaResourceUsageReport(out MediaResourceParcel[] resources)190 void getMediaResourceUsageReport(out MediaResourceParcel[] resources); 191 } 192