• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.powermodel;
18 
19 /**
20  * Identifiers for well-known apps that have unique characteristics.
21  *
22  * @more
23  * This includes three categories:
24  * <ul>
25  *   <li><b>Built-in system components</b> – These have predefined UIDs that are
26  *   always the same. For example, the system UID is always 1000.</li>
27  *   <li><b>Well known apps with shared UIDs</b> – These do not have predefined
28  *   UIDs (i.e. are different on each device), but since they have shared UIDs
29  *   with varying sets of package names (GmsCore is the canonical example), we
30  *   have special logic to capture these into a single entity with a well defined
31  *   key. These have the {@link #uid uid} field set to
32  *   {@link Uid#UID_VARIES Uid.UID_VARIES}.</li>
33  *   <li><b>Synthetic remainder app</b> – The {@link #REMAINDER REMAINDER} app doesn't
34  *   represent a real app. It contains accounting for usage which is not attributed
35  *   to any UID. This app has the {@link #uid uid} field set to
36  *   {@link Uid#UID_SYNTHETIC Uid.UID_SYNTHETIC}.</li>
37  * </ul>
38  */
39 public enum SpecialApp {
40 
41     /**
42      * Synthetic app that accounts for the remaining amount of resources used
43      * that is unaccounted for by apps, or overcounted because of inaccuracies
44      * in the model.
45      */
46     REMAINDER(Uid.UID_SYNTHETIC),
47 
48     /**
49      * Synthetic app that holds system-wide numbers, for example the total amount
50      * of various resources used, device-wide.
51      */
52     GLOBAL(Uid.UID_SYNTHETIC),
53 
54     SYSTEM(1000),
55 
56     GOOGLE_SERVICES(Uid.UID_VARIES);
57 
58     /**
59      * Constants for SpecialApps where the uid is not actually a UID.
60      */
61     public static class Uid {
62         /**
63          * Constant to indicate that this special app does not have a fixed UID.
64          */
65         public static final int UID_VARIES = -1;
66 
67         /**
68          * Constant to indicate that this special app is not actually an app with a UID.
69          *
70          * @see SpecialApp#REMAINDER
71          * @see SpecialApp#GLOBAL
72          */
73         public static final int UID_SYNTHETIC = -2;
74     }
75 
76     /**
77      * The fixed UID value of this special app, or {@link #UID_VARIES} if there
78      * isn't one.
79      */
80     public final int uid;
81 
SpecialApp(int uid)82     private SpecialApp(int uid) {
83         this.uid = uid;
84     }
85 }
86