diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ae9a87f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,13 @@
+ARCHS = armv7 arm64
+include $(THEOS)/makefiles/common.mk
+
+TWEAK_NAME = PearlRetry
+PearlRetry_FILES = Tweak.xm
+PearlRetry_PRIVATE_FRAMEWORKS = SpringBoardUIServices
+
+include $(THEOS_MAKE_PATH)/tweak.mk
+
+after-install::
+ install.exec "killall -9 SpringBoard"
+SUBPROJECTS += pearlretryprefs
+include $(THEOS_MAKE_PATH)/aggregate.mk
diff --git a/PearlRetry.plist b/PearlRetry.plist
new file mode 100644
index 0000000..10dc654
--- /dev/null
+++ b/PearlRetry.plist
@@ -0,0 +1 @@
+{ Filter = { Bundles = ( "com.apple.springboard" ); }; }
diff --git a/Tweak.xm b/Tweak.xm
new file mode 100644
index 0000000..0d99328
--- /dev/null
+++ b/Tweak.xm
@@ -0,0 +1,42 @@
+#define PLIST_PATH @"/var/mobile/Library/Preferences/com.gilshahar7.pearlretryprefs.plist"
+
+
+@interface SBUIBiometricResource : NSObject
++ (id)sharedInstance;
+- (void)noteScreenDidTurnOff;
+- (void)noteScreenWillTurnOn;
+@end
+
+float delay = 0;
+
+static void loadPrefs() {
+ NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:PLIST_PATH];
+ delay = [[prefs objectForKey:@"delay"] floatValue];
+}
+
+void pearlretry_settingsDidUpdate(CFNotificationCenterRef center,
+ void * observer,
+ CFStringRef name,
+ const void * object,
+ CFDictionaryRef userInfo) {
+
+}
+
+%hook SBDashBoardPearlUnlockBehavior
+-(void)_handlePearlFailure{
+ %orig;
+ [[%c(SBUIBiometricResource) sharedInstance] noteScreenDidTurnOff];
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ [[%c(SBUIBiometricResource) sharedInstance] noteScreenWillTurnOn];
+ });
+}
+%end
+
+
+
+%ctor{
+ loadPrefs();
+ CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.gilshahar7.pearlretryprefs.settingschanged"), NULL, CFNotificationSuspensionBehaviorCoalesce);
+
+
+}
diff --git a/control b/control
new file mode 100644
index 0000000..24a6818
--- /dev/null
+++ b/control
@@ -0,0 +1,9 @@
+Package: com.gilshahar7.pearlretry
+Name: PearlRetry
+Depends: mobilesubstrate
+Version: 1.0
+Architecture: iphoneos-arm
+Description: Retry FaceID when failed to recognize.
+Maintainer: gilshahar7
+Author: gilshahar7
+Section: Tweaks
diff --git a/packages/com.gilshahar7.pearlretry_1.0_iphoneos-arm.deb b/packages/com.gilshahar7.pearlretry_1.0_iphoneos-arm.deb
new file mode 100644
index 0000000..6591f2f
Binary files /dev/null and b/packages/com.gilshahar7.pearlretry_1.0_iphoneos-arm.deb differ
diff --git a/pearlretryprefs/Makefile b/pearlretryprefs/Makefile
new file mode 100644
index 0000000..6d623c2
--- /dev/null
+++ b/pearlretryprefs/Makefile
@@ -0,0 +1,14 @@
+ARCHS = armv7 arm64
+include $(THEOS)/makefiles/common.mk
+
+BUNDLE_NAME = PearlRetryPrefs
+PearlRetryPrefs_FILES = prpRootListController.m
+PearlRetryPrefs_INSTALL_PATH = /Library/PreferenceBundles
+PearlRetryPrefs_FRAMEWORKS = UIKit
+PearlRetryPrefs_PRIVATE_FRAMEWORKS = Preferences
+
+include $(THEOS_MAKE_PATH)/bundle.mk
+
+internal-stage::
+ $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END)
+ $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/PearlRetryPrefs.plist$(ECHO_END)
diff --git a/pearlretryprefs/Resources/Info.plist b/pearlretryprefs/Resources/Info.plist
new file mode 100644
index 0000000..e83a4e3
--- /dev/null
+++ b/pearlretryprefs/Resources/Info.plist
@@ -0,0 +1,24 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ English
+ CFBundleExecutable
+ PearlRetryPrefs
+ CFBundleIdentifier
+ com.gilshahar7.pearlretryprefs
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundlePackageType
+ BNDL
+ CFBundleShortVersionString
+ 1.0.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1.0
+ NSPrincipalClass
+ prpRootListController
+
+
diff --git a/pearlretryprefs/Resources/Root.plist b/pearlretryprefs/Resources/Root.plist
new file mode 100644
index 0000000..afbc50e
--- /dev/null
+++ b/pearlretryprefs/Resources/Root.plist
@@ -0,0 +1,45 @@
+
+
+
+
+ items
+
+
+ cell
+ PSGroupCell
+ label
+ PearlRetry
+
+
+ cell
+ PSStaticTextCell
+ label
+ Retry delay in seconds
+
+
+ cell
+ PSSliderCell
+ default
+ 0.7
+ min
+ 0.0
+ max
+ 1.5
+ showValue
+
+ isSegmented
+
+ segmentCount
+ 30
+ defaults
+ com.gilshahar7.pearlretryprefs
+ key
+ delay
+ PostNotification
+ com.gilshahar7.pearlretryprefs.settingschanged
+
+
+ title
+ PearlRetryPrefs
+
+
diff --git a/pearlretryprefs/Resources/icon@3x.png b/pearlretryprefs/Resources/icon@3x.png
new file mode 100644
index 0000000..c5aadec
Binary files /dev/null and b/pearlretryprefs/Resources/icon@3x.png differ
diff --git a/pearlretryprefs/entry.plist b/pearlretryprefs/entry.plist
new file mode 100644
index 0000000..7cafd0f
--- /dev/null
+++ b/pearlretryprefs/entry.plist
@@ -0,0 +1,21 @@
+
+
+
+
+ entry
+
+ bundle
+ PearlRetryPrefs
+ cell
+ PSLinkCell
+ detail
+ prpRootListController
+ icon
+ icon.png
+ isController
+
+ label
+ PearlRetry
+
+
+
diff --git a/pearlretryprefs/prpRootListController.h b/pearlretryprefs/prpRootListController.h
new file mode 100644
index 0000000..16d8c08
--- /dev/null
+++ b/pearlretryprefs/prpRootListController.h
@@ -0,0 +1,5 @@
+#import
+
+@interface prpRootListController : PSListController
+
+@end
diff --git a/pearlretryprefs/prpRootListController.m b/pearlretryprefs/prpRootListController.m
new file mode 100644
index 0000000..4c5af90
--- /dev/null
+++ b/pearlretryprefs/prpRootListController.m
@@ -0,0 +1,33 @@
+#import
+#include "prpRootListController.h"
+
+@implementation prpRootListController
+
+- (id)readPreferenceValue:(PSSpecifier*)specifier {
+ NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
+ NSMutableDictionary *settings = [NSMutableDictionary dictionary];
+ [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
+ return (settings[specifier.properties[@"key"]]) ?: specifier.properties[@"default"];
+}
+
+- (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier {
+ NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
+ NSMutableDictionary *settings = [NSMutableDictionary dictionary];
+ [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
+ [settings setObject:value forKey:specifier.properties[@"key"]];
+ [settings writeToFile:path atomically:YES];
+ CFStringRef notificationName = (CFStringRef)specifier.properties[@"PostNotification"];
+ if (notificationName) {
+ CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), notificationName, NULL, NULL, YES);
+ }
+}
+
+- (NSArray *)specifiers {
+ if (!_specifiers) {
+ _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
+ }
+
+ return _specifiers;
+}
+
+@end