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.tv.settings.enterprise;
18 
19 import android.content.Context;
20 
21 import com.android.internal.annotations.VisibleForTesting;
22 import com.android.settingslib.core.AbstractPreferenceController;
23 import com.android.tv.settings.PreferenceControllerFragment;
24 import com.android.tv.settings.overlay.FlavorUtils;
25 
26 import java.util.List;
27 
28 public class EnterprisePrivacySettingsFragment extends PreferenceControllerFragment {
29 
30     static final String TAG = "EnterprisePrivacySettings";
31 
32     @VisibleForTesting
33     PrivacySettingsPreference mPrivacySettingsPreference;
34 
newInstance()35     public static EnterprisePrivacySettingsFragment newInstance() {
36         return new EnterprisePrivacySettingsFragment();
37     }
38 
39     @Override
getPreferenceScreenResId()40     protected int getPreferenceScreenResId() {
41         return mPrivacySettingsPreference.getPreferenceScreenResId();
42     }
43 
44     @Override
onCreatePreferenceControllers(Context context)45     protected List<AbstractPreferenceController> onCreatePreferenceControllers(Context context) {
46         return mPrivacySettingsPreference.createPreferenceControllers(true /* async */);
47     }
48 
getPageId()49     protected int getPageId() {
50         //TODO: get proper pageId
51         return super.getPageId();
52     }
53 
54     @Override
onAttach(Context context)55     public void onAttach(Context context) {
56         mPrivacySettingsPreference = new PrivacySettingsEnterprisePreference(context);
57         super.onAttach(context);
58     }
59 
60     @Override
onDetach()61     public void onDetach() {
62         mPrivacySettingsPreference = null;
63         super.onDetach();
64     }
65 
isPageEnabled(Context context)66     public static boolean isPageEnabled(Context context) {
67         return FlavorUtils.getFeatureFactory(context).getEnterprisePrivacyFeatureProvider(
68                 context).hasDeviceOwner();
69     }
70 
71 }
72