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.enterprise; 18 19 import static android.app.admin.DevicePolicyResources.Strings.Settings.CONTACT_YOUR_IT_ADMIN; 20 import static android.app.admin.DevicePolicyResources.Strings.Settings.DISABLED_BY_IT_ADMIN_TITLE; 21 import static android.app.admin.DevicePolicyResources.Strings.Settings.IT_ADMIN_POLICY_DISABLING_INFO_URL; 22 23 import static java.util.Objects.requireNonNull; 24 25 import android.app.admin.DevicePolicyManager; 26 import android.content.Context; 27 28 import com.android.settings.R; 29 import com.android.settingslib.enterprise.DeviceAdminStringProvider; 30 31 class DeviceAdminStringProviderImpl implements DeviceAdminStringProvider { 32 private final Context mContext; 33 private final DevicePolicyManager mDevicePolicyManager; 34 DeviceAdminStringProviderImpl(Context context)35 DeviceAdminStringProviderImpl(Context context) { 36 mContext = requireNonNull(context); 37 mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class); 38 } 39 40 @Override getDefaultDisabledByPolicyTitle()41 public String getDefaultDisabledByPolicyTitle() { 42 return mDevicePolicyManager.getResources().getString(DISABLED_BY_IT_ADMIN_TITLE, 43 () -> mContext.getString(R.string.disabled_by_policy_title)); 44 } 45 46 @Override getDisallowAdjustVolumeTitle()47 public String getDisallowAdjustVolumeTitle() { 48 return mContext.getString(R.string.disabled_by_policy_title_adjust_volume); 49 } 50 51 @Override getDisallowOutgoingCallsTitle()52 public String getDisallowOutgoingCallsTitle() { 53 return mContext.getString(R.string.disabled_by_policy_title_outgoing_calls); 54 } 55 56 @Override getDisallowSmsTitle()57 public String getDisallowSmsTitle() { 58 return mContext.getString(R.string.disabled_by_policy_title_sms); 59 } 60 61 @Override getDisableCameraTitle()62 public String getDisableCameraTitle() { 63 return mContext.getString(R.string.disabled_by_policy_title_camera); 64 } 65 66 @Override getDisableScreenCaptureTitle()67 public String getDisableScreenCaptureTitle() { 68 return mContext.getString(R.string.disabled_by_policy_title_screen_capture); 69 } 70 71 @Override getSuspendPackagesTitle()72 public String getSuspendPackagesTitle() { 73 return mContext.getString(R.string.disabled_by_policy_title_suspend_packages); 74 } 75 76 @Override getDefaultDisabledByPolicyContent()77 public String getDefaultDisabledByPolicyContent() { 78 return mDevicePolicyManager.getResources().getString(CONTACT_YOUR_IT_ADMIN, 79 () -> mContext.getString(R.string.default_admin_support_msg)); 80 } 81 82 @Override getLearnMoreHelpPageUrl()83 public String getLearnMoreHelpPageUrl() { 84 return mDevicePolicyManager.getResources().getString(IT_ADMIN_POLICY_DISABLING_INFO_URL, 85 () -> mContext.getString(R.string.help_url_action_disabled_by_it_admin)); 86 } 87 88 @Override getDisabledByPolicyTitleForFinancedDevice()89 public String getDisabledByPolicyTitleForFinancedDevice() { 90 return mContext.getString(R.string.disabled_by_policy_title_financed_device); 91 } 92 93 @Override getDisabledBiometricsParentConsentTitle()94 public String getDisabledBiometricsParentConsentTitle() { 95 return mContext.getString(R.string.disabled_by_policy_title_biometric_parental_consent); 96 } 97 98 @Override getDisabledByParentContent()99 public String getDisabledByParentContent() { 100 return mContext.getString(R.string.disabled_by_policy_parental_consent); 101 } 102 103 @Override getDisabledBiometricsParentConsentContent()104 public String getDisabledBiometricsParentConsentContent() { 105 return mContext.getString(R.string.disabled_by_policy_content_biometric_parental_consent); 106 } 107 } 108