Skip to content

Commit

Permalink
add lockscreen PIN input layout scrambling toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
muhomorr committed Aug 12, 2024
1 parent 3e06418 commit 0ad2312
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions res/values/strings_ext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<string name="app_exploit_protection_category">App exploit protection</string>

<string name="scramble_pin_title">Scramble PIN input layout</string>

<string name="auto_grant_OTHER_SENSORS_permission_title">Allow Sensors permission to apps by default</string>
<string name="auto_grant_OTHER_SENSORS_permission_summary_on">Sensors is a non-standard permission, apps may malfunction if it’s denied.</string>
Expand Down
5 changes: 5 additions & 0 deletions res/xml/screen_lock_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
android:title="@string/lock_screen_auto_pin_confirm_title"
android:summary="@string/lock_screen_auto_pin_confirm_summary" />

<SwitchPreferenceCompat
android:key="scramble_pin_layout"
android:title="@string/scramble_pin_title"
settings:controller="com.android.settings.security.screenlock.PinScramblingPrefController" />

<SwitchPreferenceCompat
android:key="enhancedPinPrivacy"
android:title="@string/lockpattern_settings_enhanced_pin_privacy_title"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.android.settings.security.screenlock;

import android.content.Context;
import android.ext.settings.ExtSettings;

import com.android.internal.widget.LockPatternUtils;
import com.android.settings.ext.BoolSettingPrefController;
import com.android.settings.overlay.FeatureFactory;

public class PinScramblingPrefController extends BoolSettingPrefController {

private final LockPatternUtils lockPatternUtils;

public PinScramblingPrefController(Context ctx, String key) {
super(ctx, key, ExtSettings.SCRAMBLE_LOCKSCREEN_PIN_LAYOUT);

lockPatternUtils = FeatureFactory.getFeatureFactory()
.getSecurityFeatureProvider()
.getLockPatternUtils(ctx);
}

@Override
public int getAvailabilityStatus() {
int res = super.getAvailabilityStatus();
if (res == AVAILABLE) {
if (lockPatternUtils.getCredentialTypeForUser(mContext.getUserId())
!= LockPatternUtils.CREDENTIAL_TYPE_PIN) {
return CONDITIONALLY_UNAVAILABLE;
}
}
return res;
}
}

0 comments on commit 0ad2312

Please sign in to comment.