1 /*
2  * Copyright (C) 2021 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.wifitrackerlib;
18 
19 import android.content.Context;
20 import android.os.UserManager;
21 import android.util.ArraySet;
22 
23 import androidx.annotation.NonNull;
24 
25 import java.util.Set;
26 
27 /**
28  * Wrapper class for commonly referenced objects and static data.
29  */
30 public class WifiTrackerInjector {
31     private final boolean mIsDemoMode;
32     @NonNull private final Set<String> mNoAttributionAnnotationPackages;
33 
34     // TODO(b/201571677): Migrate the rest of the common objects to WifiTrackerInjector.
WifiTrackerInjector(@onNull Context context)35     public WifiTrackerInjector(@NonNull Context context) {
36         mIsDemoMode = UserManager.isDeviceInDemoMode(context);
37         mNoAttributionAnnotationPackages = new ArraySet<>();
38         String[] noAttributionAnnotationPackages = context.getString(
39                 R.string.wifitrackerlib_no_attribution_annotation_packages).split(",");
40         for (int i = 0; i < noAttributionAnnotationPackages.length; i++) {
41             mNoAttributionAnnotationPackages.add(noAttributionAnnotationPackages[i]);
42         }
43     }
44 
isDemoMode()45     public boolean isDemoMode() {
46         return mIsDemoMode;
47     }
48 
49     /**
50      * Returns the set of package names which we should not show attribution annotations for.
51      */
getNoAttributionAnnotationPackages()52     @NonNull public Set<String> getNoAttributionAnnotationPackages() {
53         return mNoAttributionAnnotationPackages;
54     }
55 }
56