Created
July 10, 2020 11:49
-
-
Save esterTion/cfe5dacbe41d2ae1bf66a17f3407b665 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Manual update timer for DataMeter on iOS 13 | |
SBStatusBarStateAggregator hook is freezing SpringBoard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Package: com.estertion.datameter13 | |
Name: DataMeter13 | |
Depends: mobilesubstrate | |
Version: 1 | |
Architecture: iphoneos-arm | |
Description: Manual DataMeter updater on iOS 13 | |
Maintainer: esterTion | |
Author: esterTion | |
Section: Tweaks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ Filter = { Bundles = ( "com.apple.springboard" ); }; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include $(THEOS)/makefiles/common.mk | |
ARCHS = arm64 | |
TWEAK_NAME = DataMeterz13 | |
DataMeterz13_FILES = Tweak.xm | |
DataMeterz13_CFLAGS = -fobjc-arc | |
include $(THEOS_MAKE_PATH)/tweak.mk | |
after-install:: | |
install.exec "killall -9 SpringBoard" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import <objc/runtime.h> | |
@interface FloatView : UIView | |
-(void)show; | |
-(void)hide; | |
-(void)setRateText:(NSString*)rateText; | |
@end | |
@interface SBStatusBarStateAggregator : NSObject { | |
NSDateFormatter* _timeItemDateFormatter; | |
} | |
+(SBStatusBarStateAggregator*)sharedInstance; | |
-(void)_updateTimeItems; | |
@end | |
static FloatView* view = NULL; | |
static NSString* timeFormat = NULL; | |
@interface DataMeterUpdater : NSObject | |
@end | |
@implementation DataMeterUpdater | |
+(void)doWork { | |
NSDictionary* infoData = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.zx.DataMeterInfoData.plist"]; | |
uint64_t wifiRateByte = [infoData[@"wifiRateByte"] unsignedLongLongValue]; | |
uint64_t cellularRateByte = [infoData[@"cellularRateByte"] unsignedLongLongValue]; | |
uint64_t rate = cellularRateByte > wifiRateByte ? cellularRateByte : wifiRateByte; | |
NSString* rateText; | |
if (rate < 100 * 1024) { | |
rateText = [NSString stringWithFormat:@"%.2fK/s", (double)rate / 1024.0]; | |
} else if (rate < 1024*1024) { | |
rateText = [NSString stringWithFormat:@"%dK/s", (signed int)rate / 1024]; | |
} else if (rate < 99*1024*1024) { | |
rateText = [NSString stringWithFormat:@"%.2fM/s", (double)rate / 1024.0 / 1024.0]; | |
} else { | |
rateText = [NSString stringWithFormat:@"%dM/s", (signed int)rate / 1024 / 1024]; | |
} | |
if (view) { | |
if (rate) { | |
[view show]; | |
[view setRateText:rateText]; | |
[view setNeedsDisplay]; | |
} else { | |
[view hide]; | |
} | |
} | |
if (timeFormat) { | |
SBStatusBarStateAggregator *sbsba = [objc_getClass("SBStatusBarStateAggregator") sharedInstance]; | |
[[sbsba valueForKey:@"_timeItemDateFormatter"] setDateFormat:timeFormat]; | |
[sbsba _updateTimeItems]; | |
} | |
} | |
@end | |
%hook FloatView | |
-(void)hide { | |
%orig; | |
if (!view) view = self; | |
} | |
%end | |
%ctor { | |
[NSTimer scheduledTimerWithTimeInterval:1.0 target:[DataMeterUpdater class] selector:@selector(doWork) userInfo:nil repeats:YES]; | |
NSDictionary* prefs = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.zx.DataMeterConfig.plist"]; | |
timeFormat = prefs[@"timeFormat"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment