1 /* 2 * Copyright (C) 2024 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 22 import androidx.annotation.NonNull; 23 import androidx.preference.Preference; 24 import androidx.preference.PreferenceScreen; 25 26 import com.android.settings.core.BasePreferenceController; 27 28 /** 29 * The preference controller for managing permissions 30 */ 31 public class ManagePermissionsPreferenceController extends BasePreferenceController { 32 ManagePermissionsPreferenceController(@onNull Context context, @NonNull String preferenceKey)33 public ManagePermissionsPreferenceController(@NonNull Context context, 34 @NonNull String preferenceKey) { 35 super(context, preferenceKey); 36 } 37 38 @Override displayPreference(@onNull PreferenceScreen screen)39 public void displayPreference(@NonNull PreferenceScreen screen) { 40 super.displayPreference(screen); 41 42 Preference pref = screen.findPreference(getPreferenceKey()); 43 if (pref != null) { 44 pref.setIntent(new Intent(Intent.ACTION_MANAGE_PERMISSIONS) 45 .setPackage(mContext.getPackageManager().getPermissionControllerPackageName())); 46 } 47 } 48 49 @Override getAvailabilityStatus()50 public int getAvailabilityStatus() { 51 return AVAILABLE; 52 } 53 } 54