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.car.settings.applications.specialaccess;
18 
19 import static android.Manifest.permission.SCHEDULE_EXACT_ALARM;
20 
21 import android.app.AppOpsManager;
22 import android.content.Context;
23 
24 import com.android.car.settings.R;
25 import com.android.car.settings.applications.AppListFragment;
26 
27 /**
28  * Displays a list of apps which have declared in their Manifest the permission
29  * #{@link android.Manifest.permission#SCHEDULE_EXACT_ALARM} and allows the users to grant or revoke
30  * the permission from those apps.
31  */
32 public class AlarmsAndReminderFragment extends AppListFragment {
33 
34     @Override
getPreferenceScreenResId()35     protected int getPreferenceScreenResId() {
36         return R.xml.alarms_and_reminders_fragment;
37     }
38 
39     @Override
onAttach(Context context)40     public void onAttach(Context context) {
41         super.onAttach(context);
42         use(AppOpsPreferenceController.class, R.string.pk_alarms_and_reminders).init(
43                 AppOpsManager.OP_SCHEDULE_EXACT_ALARM,
44                 SCHEDULE_EXACT_ALARM,
45                 AppOpsManager.MODE_ERRORED);
46     }
47 
48     @Override
onToggleShowSystemApps(boolean showSystem)49     protected void onToggleShowSystemApps(boolean showSystem) {
50         use(AppOpsPreferenceController.class, R.string.pk_alarms_and_reminders).setShowSystem(
51                 showSystem);
52     }
53 }
54