• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package com.android.car.settings.enterprise;
17 
18 import android.annotation.Nullable;
19 import android.app.AppGlobals;
20 import android.car.drivingstate.CarUxRestrictions;
21 import android.content.Context;
22 
23 import androidx.preference.Preference;
24 
25 import com.android.car.settings.common.FragmentController;
26 import com.android.car.settingslib.applications.ApplicationFeatureProvider;
27 import com.android.car.settingslib.applications.ApplicationFeatureProviderImpl;
28 import com.android.car.settingslib.enterprise.EnterprisePrivacyFeatureProvider;
29 import com.android.car.settingslib.enterprise.EnterprisePrivacyFeatureProviderImpl;
30 
31 /**
32  * Base class for controllers in the Enterprise Privacy / Managed Device Info screen.
33  */
34 abstract class BaseEnterprisePrivacyPreferenceController<P extends Preference>
35         extends BaseEnterprisePreferenceController<P> {
36 
37     protected final EnterprisePrivacyFeatureProvider mEnterprisePrivacyFeatureProvider;
38     protected final ApplicationFeatureProvider mApplicationFeatureProvider;
39 
BaseEnterprisePrivacyPreferenceController(Context context, String preferenceKey, FragmentController fragmentController, CarUxRestrictions uxRestrictions)40     protected BaseEnterprisePrivacyPreferenceController(Context context,
41             String preferenceKey, FragmentController fragmentController,
42             CarUxRestrictions uxRestrictions) {
43         this(context, preferenceKey, fragmentController, uxRestrictions,
44                 /* enterprisePrivacyFeatureProvider= */ null,
45                 /* applicationFeatureProvider= */ null);
46     }
47 
48     // Only used by subclasses on tests.
BaseEnterprisePrivacyPreferenceController(Context context, String preferenceKey, FragmentController fragmentController, CarUxRestrictions uxRestrictions, @Nullable EnterprisePrivacyFeatureProvider enterprisePrivacyFeatureProvider, @Nullable ApplicationFeatureProvider applicationFeatureProvider)49     protected BaseEnterprisePrivacyPreferenceController(Context context, String preferenceKey,
50             FragmentController fragmentController, CarUxRestrictions uxRestrictions,
51             @Nullable EnterprisePrivacyFeatureProvider enterprisePrivacyFeatureProvider,
52             @Nullable ApplicationFeatureProvider applicationFeatureProvider) {
53         super(context, preferenceKey, fragmentController, uxRestrictions);
54 
55         // providers are only non-null on unit tests
56         mEnterprisePrivacyFeatureProvider = enterprisePrivacyFeatureProvider != null
57                 ? enterprisePrivacyFeatureProvider
58                 : new EnterprisePrivacyFeatureProviderImpl(context, mDpm, mPm);
59         mApplicationFeatureProvider = applicationFeatureProvider != null
60                 ? applicationFeatureProvider
61                 : new ApplicationFeatureProviderImpl(context, mPm, AppGlobals.getPackageManager(),
62                         mDpm);
63     }
64 }
65