• 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 
17 package com.android.settings.privacy;
18 
19 import android.content.Context;
20 import android.content.Intent;
21 import android.provider.DeviceConfig;
22 
23 import androidx.annotation.NonNull;
24 import androidx.preference.Preference;
25 import androidx.preference.PreferenceScreen;
26 
27 import com.android.settings.core.BasePreferenceController;
28 
29 /**
30  * The preference controller for privacy hub top level preference.
31  */
32 public final class PrivacyHubPreferenceController extends BasePreferenceController {
33     public static final String PROPERTY_PRIVACY_HUB_ENABLED = "privacy_hub_enabled";
34 
PrivacyHubPreferenceController(@onNull Context context, @NonNull String key)35     public PrivacyHubPreferenceController(@NonNull Context context, @NonNull String key) {
36         super(context, key);
37     }
38 
39     @Override
getAvailabilityStatus()40     public int getAvailabilityStatus() {
41         return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
42                 PROPERTY_PRIVACY_HUB_ENABLED, true) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
43     }
44 
45     @Override
displayPreference(@onNull PreferenceScreen screen)46     public void displayPreference(@NonNull PreferenceScreen screen) {
47         super.displayPreference(screen);
48 
49         Preference pref = screen.findPreference(getPreferenceKey());
50         if (pref != null) {
51             pref.setIntent(new Intent(Intent.ACTION_REVIEW_PERMISSION_USAGE)
52                     .setPackage(mContext.getPackageManager().getPermissionControllerPackageName()));
53         }
54     }
55 }
56