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.annotation.NonNull; 20 import android.content.Context; 21 import android.content.DialogInterface; 22 import android.content.Intent; 23 import android.util.Log; 24 25 import androidx.annotation.Nullable; 26 27 import com.android.settingslib.RestrictedLockUtils; 28 29 public class BiometricActionDisabledByAdminController extends BaseActionDisabledByAdminController { 30 31 private static final String TAG = "BiometricActionDisabledByAdminController"; 32 33 // These MUST not change, as they are the stable API between here and device admin specified 34 // by the component below. 35 private static final String ACTION_LEARN_MORE = 36 "android.intent.action.MANAGE_RESTRICTED_SETTING"; 37 private static final String EXTRA_SETTING_KEY = "extra_setting"; 38 private static final String EXTRA_SETTING_VALUE = "biometric_disabled_by_admin_controller"; 39 BiometricActionDisabledByAdminController( DeviceAdminStringProvider stringProvider)40 BiometricActionDisabledByAdminController( 41 DeviceAdminStringProvider stringProvider) { 42 super(stringProvider); 43 } 44 45 @Override setupLearnMoreButton(Context context)46 public void setupLearnMoreButton(Context context) { 47 48 } 49 50 @Override getAdminSupportTitle(@ullable String restriction)51 public String getAdminSupportTitle(@Nullable String restriction) { 52 return mStringProvider.getDisabledBiometricsParentConsentTitle(); 53 } 54 55 @Override getAdminSupportContentString(Context context, @Nullable CharSequence supportMessage)56 public CharSequence getAdminSupportContentString(Context context, 57 @Nullable CharSequence supportMessage) { 58 return mStringProvider.getDisabledBiometricsParentConsentContent(); 59 } 60 61 @Override getPositiveButtonListener(@onNull Context context, @NonNull RestrictedLockUtils.EnforcedAdmin enforcedAdmin)62 public DialogInterface.OnClickListener getPositiveButtonListener(@NonNull Context context, 63 @NonNull RestrictedLockUtils.EnforcedAdmin enforcedAdmin) { 64 return (dialog, which) -> { 65 Log.d(TAG, "Positive button clicked, component: " + enforcedAdmin.component); 66 final Intent intent = new Intent(ACTION_LEARN_MORE) 67 .putExtra(EXTRA_SETTING_KEY, EXTRA_SETTING_VALUE) 68 .setPackage(enforcedAdmin.component.getPackageName()); 69 context.startActivity(intent); 70 }; 71 } 72 } 73