Skip to content

Instantly share code, notes, and snippets.

@ifilipis
Created February 18, 2020 18:13
Show Gist options
  • Save ifilipis/460880d243e9bf33312e125a8334e3d2 to your computer and use it in GitHub Desktop.
Save ifilipis/460880d243e9bf33312e125a8334e3d2 to your computer and use it in GitHub Desktop.
iPhone XS night mode
/*
-------------------------------------------------
Here's the progress to date:
- Night mode UI is showing night mode controls
- Night mode triggers in low light automatically
- Core functionality of AVFoundation and Celestial does recognize Night mode
- All the logic is already implemented for XS and 11 (they even share the same ipsw for 13.3)
- iPhone X support could be significantly harder to get, plus I don't have it to test anyways
Here's what's not working:
- H10ISP.mediacapture is giving error
SetLTMCurve 35327: ERROR FigCaptureStreamLTMCurve_DigitalFlash is observed platform earlier than H12
- Probably ISP platform identifier has to be overriden somewhere
- Also, I haven't checked MediaToolbox.framework yet, it seems to handle AVCapture settings
- I have a weird bug, which only shows night mode UI after I rename D421 folder into D321 inside MediaToolbox.framework,
but don't respring or reboot
I need help from the developers who have had experience with low-level system modules and are aware of tools and methods to debug stuff.
---------------------------
*/
%hook CAMFlipButton
-(bool)_useCTMAppearance {
return YES;
}
%end
%hook CAMCaptureCapabilities
-(bool)deviceSupportsCTM {
return YES;
}
-(bool)isCTMSupported {
return YES;
}
/*- (bool)useCTMModeSelector {
return YES;
}*/
-(bool)arePortraitEffectsSupported {
return YES;
}
-(bool)isLivePreviewSupportedForLightingType:(long long)arg1 devicePosition:(long long)arg2 {
return YES;
return 1;
return 1;
}
-(long long)supportedPortraitLightingVersion {
return 2;
}
-(bool)isDepthEffectApertureSupported {
return YES;
}
-(bool)isDeepFusionSupported {
return YES;
}
-(bool)isLowLightSupported {
return YES;
}
-(bool)isSpatialOverCaptureSupported {
return YES;
}
- (bool)isSpatialOverCapturePreviewSupportedForMode:(long long)arg1 device:(long long)arg2 {
return YES;
}
- (bool)isSpatialOverCaptureSupportedForMode:(long long)arg1 device:(long long)arg2 photoEncodingBehavior:(long long)arg3 {
return YES;
}
- (bool)isSpatialOverCaptureSupportedForDevice:(long long)arg1 {
return YES;
}
- (bool)isLowLightSupportedForMode:(long long)arg1 device:(long long)arg2 {
%log;
return YES;
}
-(bool)isBackLowLightSupported {
return YES;
}
-(bool)isFrontLowLightSupported {
return YES;
}
-(bool)isPortraitEffectIntensitySupported {
return YES;
}
%end
/*%hook CAMCaptureConversions
+(long long)captureDigitalFlashModeForLowLightMode:(long long)arg2 {
%log;
return %orig;
}
+ (long long)lowLightStatusForCaptureStatus:(long long)arg1 {
%log;
return %orig;
}
%end
%hook AVCapturePhotoOutput
-(bool)isDigitalFlashCaptureEnabled {
NSLog(@"isDigitalFlashCaptureEnabled");
return %orig;
}
%end*/
%hook CAMDrawerLowLightButton
- (bool)isDisabled {
return NO;
}
%end
%hook CAMLowLightStatusIndicator
- (bool)isLowLightDisabled {
return NO;
}
%end
%hook BWUBNode
- (bool)deepFusionPreprocessingSupportEnabled {
return YES;
}
- (bool)deepFusionSupportEnabled {
return YES;
}
- (bool)digitalFlashSupportEnabled {
return YES;
}
%end
%hook BWUBProcessorController
- (void)_processDeepFusion {
%log;
return %orig;
}
- (void)_processLowLightFusion {
%log;
return %orig;
}
%end
%hook BWEspressoInferenceAdapter
+ (id)platformIdentifier {
%log;
return @"H12";
}
%end
%hook AVCaptureDevice
/*- (bool)isLowLightBoostSupported {
return YES;
}*/
/*- (bool)automaticallyEnablesLowLightBoostWhenAvailable {
return YES;
}*/
/*- (long long)digitalFlashMode {
return 0x2;
}*/
/*- (bool)isLowLightBoostEnabled {
return YES;
}*/
%end
%hook FigCaptureSourceVideoFormat
- (bool)isDeepFusionSupported {
return YES;
}
- (bool)isDigitalFlashSupported {
return YES;
}
- (bool)isDeferredPhotoProcessingSupported {
return YES;
}
%end
%hook AVCaptureDeviceFormat
-(float)minSimulatedAperture {
return 1.4;
}
-(float)maxSimulatedAperture {
return 16;
}
-(float)defaultSimulatedAperture {
return 4.5;
}
-(float)minPortraitLightingEffectStrength {
return 0;
}
-(float)maxPortraitLightingEffectStrength {
return 100;
}
-(float)defaultPortraitLightingEffectStrength {
return 50;
}
-(bool)isDigitalFlashSupported {
return YES;
}
-(bool)isDeepFusionSupported {
return YES;
}
- (bool)isDeferredPhotoProcessingSupported {
return YES;
}
- (bool)isLowLightVideoCaptureSupported {
return YES;
}
-(bool)supportsQuadraHighResolutionStillImageOutput {
return YES;
}
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment