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.settingslib.enterprise;
18 
19 import android.content.Context;
20 import android.content.DialogInterface;
21 import android.content.Intent;
22 import android.net.Uri;
23 import android.provider.Settings;
24 import android.util.Log;
25 
26 import androidx.annotation.NonNull;
27 import androidx.annotation.Nullable;
28 
29 import com.android.settingslib.RestrictedLockUtils;
30 
31 public class BiometricActionDisabledByAdminController extends BaseActionDisabledByAdminController {
32 
33     private static final String TAG = "BiometricActionDisabledByAdminController";
34 
BiometricActionDisabledByAdminController( DeviceAdminStringProvider stringProvider)35     BiometricActionDisabledByAdminController(
36             DeviceAdminStringProvider stringProvider) {
37         super(stringProvider);
38     }
39 
40     @Override
setupLearnMoreButton(Context context)41     public void setupLearnMoreButton(Context context) {
42 
43     }
44 
45     @Override
getAdminSupportTitle(@ullable String restriction)46     public String getAdminSupportTitle(@Nullable String restriction) {
47         return mStringProvider.getDisabledBiometricsParentConsentTitle();
48     }
49 
50     @Override
getAdminSupportContentString(Context context, @Nullable CharSequence supportMessage)51     public CharSequence getAdminSupportContentString(Context context,
52             @Nullable CharSequence supportMessage) {
53         return mStringProvider.getDisabledBiometricsParentConsentContent();
54     }
55 
56     @Override
getPositiveButtonListener(@onNull Context context, @NonNull RestrictedLockUtils.EnforcedAdmin enforcedAdmin)57     public DialogInterface.OnClickListener getPositiveButtonListener(@NonNull Context context,
58             @NonNull RestrictedLockUtils.EnforcedAdmin enforcedAdmin) {
59         return (dialog, which) -> {
60             Log.d(TAG, "Positive button clicked, component: " + enforcedAdmin.component);
61             final Intent intent = new Intent(Settings.ACTION_MANAGE_SUPERVISOR_RESTRICTED_SETTING)
62                     .putExtra(Settings.EXTRA_SUPERVISOR_RESTRICTED_SETTING_KEY,
63                             Settings.SUPERVISOR_VERIFICATION_SETTING_BIOMETRICS)
64                     .setData(new Uri.Builder()
65                             .scheme("policy")
66                             .appendPath("biometric")
67                             .build())
68                     .setPackage(enforcedAdmin.component.getPackageName());
69             context.startActivity(intent);
70         };
71     }
72 }
73