Skip to content

Commit fd12f05

Browse files
committed
Don’t require strong auth on regular time interval
This disables the need to provide strong authentication except when booting the device. The idea behind this is that you are no longer forced to enter your strong authentication credentials in random locations where it might be easy to snoop your strong authentication credentials allowing an adversary to boot and decrypt your device against your will. Changing DEFAULT_STRONG_AUTH_TIMEOUT_MS is not enough. Rather, it has the opposite effect. In my tests, it caused the strong auth to be required every hour rather than a 42 d interval. Ref: frameworks/base/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java In my tests, dpm.getRequiredStrongAuthTimeout(null, userId)) returned 3600000. Note that this patch circumvents the values that DeviceAdmin may provide. In other words, it ignores whatever a MDM would request for the strong auth timeout! To be clear, this patch is a practical approach, in an ideal world, we would properly use the DeviceAdmin feature. Confirmed working on: * Android 9 * Android 10 Submitted to: * hashbang/os#32 * RattlesnakeOS/community_patches#9 * https://github.com/ypid/ypid-android-patches
1 parent 86a9704 commit fd12f05

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

core/java/android/app/admin/DevicePolicyManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ protected int myUserId() {
534534
*
535535
* @hide
536536
*/
537-
public static final long DEFAULT_STRONG_AUTH_TIMEOUT_MS = 72 * 60 * 60 * 1000; // 72h
537+
public static final long DEFAULT_STRONG_AUTH_TIMEOUT_MS = 42 * 24 * 60 * 60 * 1000; // 42d
538538

539539
/**
540540
* A {@link android.os.Parcelable} extra of type {@link android.os.PersistableBundle} that

services/core/java/com/android/server/locksettings/LockSettingsStrongAuth.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,7 @@ private void handleRemoveUser(int userId) {
120120
private void handleScheduleStrongAuthTimeout(int userId) {
121121
final DevicePolicyManager dpm =
122122
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
123-
long when = SystemClock.elapsedRealtime() + dpm.getRequiredStrongAuthTimeout(null, userId);
124-
// cancel current alarm listener for the user (if there was one)
125-
StrongAuthTimeoutAlarmListener alarm = mStrongAuthTimeoutAlarmListenerForUser.get(userId);
126-
if (alarm != null) {
127-
mAlarmManager.cancel(alarm);
128-
} else {
129-
alarm = new StrongAuthTimeoutAlarmListener(userId);
130-
mStrongAuthTimeoutAlarmListenerForUser.put(userId, alarm);
131-
}
132-
// schedule a new alarm listener for the user
133-
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, when, STRONG_AUTH_TIMEOUT_ALARM_TAG,
134-
alarm, mHandler);
123+
Slog.d(TAG, "getRequiredStrongAuthTimeout: " + dpm.getRequiredStrongAuthTimeout(null, userId));
135124
}
136125

137126
private void notifyStrongAuthTrackers(int strongAuthReason, int userId) {

0 commit comments

Comments
 (0)