• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.server.location.injector;
18 
19 import android.util.SparseBooleanArray;
20 
21 /**
22  * Version of AppForegroundHelper to be used for testing. All apps are treated as foreground until
23  * notified otherwise.
24  */
25 public class FakeAppForegroundHelper extends AppForegroundHelper {
26 
27     private final SparseBooleanArray mForegroundUids;
28 
FakeAppForegroundHelper()29     public FakeAppForegroundHelper() {
30         mForegroundUids = new SparseBooleanArray();
31     }
32 
setAppForeground(int uid, boolean foreground)33     public void setAppForeground(int uid, boolean foreground) {
34         mForegroundUids.put(uid, foreground);
35         notifyAppForeground(uid, foreground);
36     }
37 
38     @Override
isAppForeground(int uid)39     public boolean isAppForeground(int uid) {
40         return mForegroundUids.get(uid, true);
41     }
42 }
43