blob: b36e3c7b9e3548ceb36f7ac07b2701527eb5b09d [file] [log] [blame]
Wale Ogunwale9de19442018-10-18 19:05:03 -07001/*
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
17package com.android.server.am;
18
19import android.util.SparseArray;
20
21/** Whitelists of uids to temporarily bypass Power Save mode. */
22final class PendingTempWhitelists {
23
24 private ActivityManagerService mService;
25
26 private final SparseArray<ActivityManagerService.PendingTempWhitelist> mPendingTempWhitelist =
27 new SparseArray<>();
28
29 PendingTempWhitelists(ActivityManagerService service) {
30 mService = service;
31 }
32
33 void put(int uid, ActivityManagerService.PendingTempWhitelist value) {
34 mPendingTempWhitelist.put(uid, value);
35 mService.mAtmInternal.onUidAddedToPendingTempWhitelist(uid, value.tag);
36 }
37
38 void removeAt(int index) {
39 final int uid = mPendingTempWhitelist.keyAt(index);
40 mPendingTempWhitelist.removeAt(index);
41 mService.mAtmInternal.onUidRemovedFromPendingTempWhitelist(uid);
42 }
43
44 ActivityManagerService.PendingTempWhitelist get(int uid) {
45 return mPendingTempWhitelist.get(uid);
46 }
47
48 int size() {
49 return mPendingTempWhitelist.size();
50 }
51
52 ActivityManagerService.PendingTempWhitelist valueAt(int index) {
53 return mPendingTempWhitelist.valueAt(index);
54 }
55
56 int indexOfKey(int key) {
57 return mPendingTempWhitelist.indexOfKey(key);
58 }
59}