Refactor/Move isTestModeEnabled to frameworks/base
ActionDisabledByAdminControllerFactory is also in frameworks/base, and should take test mode into consideration. Bug: 188847063 Test: atest ParentalControlsUtilsTest Change-Id: I0195478606361aa8b6406376d96b2fc219d9cc4d
This commit is contained in:
@@ -20,7 +20,10 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
|
||||
/**
|
||||
* "Base" functionality. For settings-specific functionality (which may rely on this base
|
||||
@@ -29,6 +32,27 @@ import android.os.UserHandle;
|
||||
*/
|
||||
public class ParentalControlsUtilsInternal {
|
||||
|
||||
private static final String TEST_ALWAYS_REQUIRE_CONSENT =
|
||||
"android.hardware.biometrics.ParentalControlsUtilsInternal.always_require_consent";
|
||||
|
||||
public static boolean isTestModeEnabled(@NonNull Context context) {
|
||||
if (Build.IS_USERDEBUG || Build.IS_ENG) {
|
||||
return Settings.Secure.getInt(context.getContentResolver(),
|
||||
TEST_ALWAYS_REQUIRE_CONSENT, 0) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean parentConsentRequired(@NonNull Context context,
|
||||
@NonNull DevicePolicyManager dpm, @BiometricAuthenticator.Modality int modality,
|
||||
@NonNull UserHandle userHandle) {
|
||||
if (isTestModeEnabled(context)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return parentConsentRequired(dpm, modality, userHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if parental consent is required in order for biometric sensors to be used.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user