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.Manifest; 19 20 import com.android.car.settings.R; 21 import com.android.car.settings.common.SettingsFragment; 22 23 /** 24 * Base fragment for displaying a list of applications on a device. 25 * 26 * <p>Inner static classes are concrete implementations. 27 */ 28 public abstract class ApplicationListFragment extends SettingsFragment { 29 30 private abstract static class AdminGrantedPermission extends ApplicationListFragment { 31 private final String[] mPermissions; 32 AdminGrantedPermission(String[] permissions)33 AdminGrantedPermission(String[] permissions) { 34 mPermissions = permissions; 35 } 36 } 37 38 /** 39 * Fragment for camera permissions. 40 */ 41 public static class AdminGrantedCameraPermission extends AdminGrantedPermission { AdminGrantedCameraPermission()42 public AdminGrantedCameraPermission() { 43 super(new String[] {Manifest.permission.CAMERA}); 44 } 45 46 @Override getPreferenceScreenResId()47 protected int getPreferenceScreenResId() { 48 return R.xml.enterprise_privacy_granted_camera_permission_apps_fragment; 49 } 50 } 51 52 /** 53 * Fragment for location permissions. 54 */ 55 public static class AdminGrantedLocationPermissions extends AdminGrantedPermission { AdminGrantedLocationPermissions()56 public AdminGrantedLocationPermissions() { 57 super(new String[] {Manifest.permission.ACCESS_COARSE_LOCATION, 58 Manifest.permission.ACCESS_FINE_LOCATION}); 59 } 60 61 @Override getPreferenceScreenResId()62 protected int getPreferenceScreenResId() { 63 return R.xml.enterprise_privacy_granted_location_permissions_apps_fragment; 64 } 65 } 66 67 /** 68 * Fragment for microphone permissions. 69 */ 70 public static class AdminGrantedMicrophonePermission extends AdminGrantedPermission { AdminGrantedMicrophonePermission()71 public AdminGrantedMicrophonePermission() { 72 super(new String[] {Manifest.permission.RECORD_AUDIO}); 73 } 74 75 @Override getPreferenceScreenResId()76 protected int getPreferenceScreenResId() { 77 return R.xml.enterprise_privacy_granted_microphone_permission_apps_fragment; 78 } 79 } 80 81 /** 82 * Fragment for application list installed by enterprise. 83 */ 84 public static class EnterpriseInstalledPackages extends ApplicationListFragment { 85 @Override getPreferenceScreenResId()86 protected int getPreferenceScreenResId() { 87 return R.xml.enterprise_privacy_installed_packages_fragment; 88 } 89 } 90 } 91