SDStatusBarOverriderPost9_3.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. // --------------------------------------------------------------------------------
  2. // The MIT License (MIT)
  3. //
  4. // Copyright (c) 2014 Shiny Development
  5. //
  6. // Permission is hereby granted, free of charge, to any person obtaining a copy
  7. // of this software and associated documentation files (the "Software"), to deal
  8. // in the Software without restriction, including without limitation the rights
  9. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. // copies of the Software, and to permit persons to whom the Software is
  11. // furnished to do so, subject to the following conditions:
  12. //
  13. // The above copyright notice and this permission notice shall be included in all
  14. // copies or substantial portions of the Software.
  15. //
  16. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. // SOFTWARE.
  23. // --------------------------------------------------------------------------------
  24. #import <UIKit/UIKit.h>
  25. #import "SDStatusBarOverriderPost9_3.h"
  26. enum {
  27. ItemIsEnabledDoNotDisturb = 1,
  28. ItemIsEnabledAirplaneIcon,
  29. ItemIsEnabledGsmSignalStrengthShowDots,
  30. // 4 : unknown,
  31. ItemIsEnabledGsmSignalStrengthRawValue,
  32. ItemIsEnabledBatteryDetailString = 9,
  33. ItemIsEnabledBatteryBluetoothIcon = 12,
  34. } ItemIsEnabledIndexes;
  35. @class UIStatusBarServer;
  36. // http://localhost:10000/protocols/UIStatusBarServerClient.h
  37. /* Generated by RuntimeBrowser.
  38. */
  39. @protocol UIStatusBarServerClient
  40. @required
  41. - (void)statusBarServer:(UIStatusBarServer *)arg1 didReceiveDoubleHeightStatusString:(NSString *)arg2 forStyle:(long long)arg3;
  42. - (void)statusBarServer:(UIStatusBarServer *)arg1 didReceiveGlowAnimationState:(bool)arg2 forStyle:(long long)arg3;
  43. - (void)statusBarServer:(UIStatusBarServer *)arg1 didReceiveStatusBarData:(const struct { bool x1[29]; BOOL x2[64]; int x3; int x4; BOOL x5[100]; BOOL x6[100]; BOOL x7[2][100]; BOOL x8[1024]; unsigned int x9; int x10; int x11; unsigned int x12; int x13; unsigned int x14; BOOL x15[150]; int x16; int x17; unsigned int x18 : 1; unsigned int x19 : 1; unsigned int x20 : 1; BOOL x21[256]; unsigned int x22 : 1; unsigned int x23 : 1; unsigned int x24 : 1; unsigned int x25 : 1; unsigned int x26 : 1; unsigned int x27; unsigned int x28 : 1; unsigned int x29 : 1; BOOL x30[256]; BOOL x31[256]; BOOL x32[100]; }*)arg2 withActions:(int)arg3;
  44. - (void)statusBarServer:(UIStatusBarServer *)arg1 didReceiveStyleOverrides:(int)arg2;
  45. @end
  46. // http://localhost:10000/classes/UIStatusBarServer.h (commented some methods, and added structs)
  47. /* Generated by RuntimeBrowser.
  48. */
  49. typedef struct {
  50. bool boolitemIsEnabled[29];//x_25_1_1[29]; // boolitemIsEnabled
  51. char timeString[64];//x_25_1_2[64]; // timeString
  52. int x_25_1_3; // gsmSignalStrengthRaw
  53. int gsmSignalStrengthBars;//x_25_1_4; // gsmSignalStrengthBars
  54. char serviceString[100]; // serviceString
  55. char serviceCrossfadeString[100];
  56. char x_25_1_7[2][100];
  57. char x_25_1_8[1024];
  58. unsigned int x_25_1_9;
  59. int x_25_1_10;
  60. int x_25_1_11;
  61. unsigned int dataNetworkType;
  62. int x_25_1_13;
  63. unsigned int x_25_1_14;
  64. char batteryDetailString[150];//x_25_1_15[150];
  65. int x_25_1_16;
  66. int x_25_1_17;
  67. unsigned int x_25_1_18 : 1;
  68. unsigned int x_25_1_19 : 1;
  69. unsigned int x_25_1_20 : 1;
  70. char x_25_1_21[256];
  71. unsigned int bluetoothConnected: 1;//x_25_1_22 : 1;
  72. unsigned int x_25_1_23 : 1;
  73. unsigned int x_25_1_24 : 1;
  74. unsigned int x_25_1_25 : 1;
  75. unsigned int x_25_1_26 : 1;
  76. unsigned int x_25_1_27;
  77. unsigned int x_25_1_28 : 1;
  78. unsigned int x_25_1_29 : 1;
  79. char x_25_1_30[256];
  80. char x_25_1_31[256];
  81. char x_25_1_32[100];
  82. } StatusBarRawData;
  83. typedef struct {
  84. bool booloverrideItemIsEnabled[29];//x1[29];
  85. unsigned int overrideTimeString : 1; // x2 : 1; // overrideTimeString
  86. unsigned int x3 : 1; // overrideGsmSignalStrengthRaw
  87. unsigned int overrideGsmSignalStrengthBars: 1;//x4 : 1; // overrideGsmSignalStrengthBars
  88. unsigned int overrideServiceString: 1;//x5 : 1; // overrideServiceString
  89. unsigned int x6 : 2; // overrideServiceImages
  90. unsigned int x7 : 1; // overrideOperatorDirectory
  91. unsigned int x8 : 1; // overrideServiceContentType
  92. unsigned int x9 : 1; // overrideWifiSignalStrengthRaw
  93. unsigned int x10 : 1; // overrideWifiSignalStrengthBars
  94. unsigned int overrideDataNetworkType : 1; // overrideDataNetworkType
  95. unsigned int x12 : 1; // disallowsCellularDataNetworkTypes
  96. unsigned int x13 : 1; // overrideBatteryCapacity
  97. unsigned int x14 : 1; // overrideBatteryState
  98. unsigned int overrideBatteryDetailString: 1;//x15 : 1; // overrideBatteryDetailString
  99. unsigned int x16 : 1; // overrideBluetoothBatteryCapacity
  100. unsigned int x17 : 1; // overrideThermalColor
  101. unsigned int x18 : 1; // overrideSlowActivity
  102. unsigned int x19 : 1; // overrideActivityDisplayId
  103. unsigned int overrideBluetoothConnected: 1; //x20 : 1; // overrideBluetoothConnected
  104. unsigned int x21 : 1; // overrideDisplayRawGSMSignal
  105. unsigned int x22 : 1; // overrideDisplayRawWifiSignal
  106. unsigned int x23 : 1;
  107. unsigned int x24 : 1;
  108. StatusBarRawData values;
  109. } StatusBarOverrideData;
  110. @interface UIStatusBarServer : NSObject {
  111. struct __CFRunLoopSource { } * _source;
  112. id<UIStatusBarServerClient> _statusBar;
  113. }
  114. //@property (nonatomic, retain) <UIStatusBarServerClient> *statusBar;
  115. @property (nonatomic, retain) id<UIStatusBarServerClient> statusBar;
  116. + (unsigned int)_publisherPort;
  117. + (unsigned int)_serverPort;
  118. + (void)addStatusBarItem:(int)arg1;
  119. + (void)addStyleOverrides:(int)arg1;
  120. + (id)getDoubleHeightStatusStringForStyle:(long long)arg1;
  121. + (double)getGlowAnimationEndTimeForStyle:(long long)arg1;
  122. + (bool)getGlowAnimationStateForStyle:(long long)arg1;
  123. //+ (const struct { bool x1[29]; BOOL x2[64]; int x3; int x4; BOOL x5[100]; BOOL x6[100]; BOOL x7[2][100]; BOOL x8[1024]; unsigned int x9; int x10; int x11; unsigned int x12; int x13; unsigned int x14; BOOL x15[150]; int x16; int x17; unsigned int x18 : 1; unsigned int x19 : 1; unsigned int x20 : 1; BOOL x21[256]; unsigned int x22 : 1; unsigned int x23 : 1; unsigned int x24 : 1; unsigned int x25 : 1; unsigned int x26 : 1; unsigned int x27; unsigned int x28 : 1; unsigned int x29 : 1; BOOL x30[256]; BOOL x31[256]; BOOL x32[100]; }*)getStatusBarData;
  124. + (const StatusBarRawData *)getStatusBarData;
  125. //+ (struct { bool x1[29]; unsigned int x2 : 1; unsigned int x3 : 1; unsigned int x4 : 1; unsigned int x5 : 1; unsigned int x6 : 2; unsigned int x7 : 1; unsigned int x8 : 1; unsigned int x9 : 1; unsigned int x10 : 1; unsigned int x11 : 1; unsigned int x12 : 1; unsigned int x13 : 1; unsigned int x14 : 1; unsigned int x15 : 1; unsigned int x16 : 1; unsigned int x17 : 1; unsigned int x18 : 1; unsigned int x19 : 1; unsigned int x20 : 1; unsigned int x21 : 1; unsigned int x22 : 1; unsigned int x23 : 1; unsigned int x24 : 1; struct { bool x_25_1_1[29]; BOOL x_25_1_2[64]; int x_25_1_3; int x_25_1_4; BOOL x_25_1_5[100]; BOOL x_25_1_6[100]; BOOL x_25_1_7[2][100]; BOOL x_25_1_8[1024]; unsigned int x_25_1_9; int x_25_1_10; int x_25_1_11; unsigned int x_25_1_12; int x_25_1_13; unsigned int x_25_1_14; BOOL x_25_1_15[150]; int x_25_1_16; int x_25_1_17; unsigned int x_25_1_18 : 1; unsigned int x_25_1_19 : 1; unsigned int x_25_1_20 : 1; BOOL x_25_1_21[256]; unsigned int x_25_1_22 : 1; unsigned int x_25_1_23 : 1; unsigned int x_25_1_24 : 1; unsigned int x_25_1_25 : 1; unsigned int x_25_1_26 : 1; unsigned int x_25_1_27; unsigned int x_25_1_28 : 1; unsigned int x_25_1_29 : 1; BOOL x_25_1_30[256]; BOOL x_25_1_31[256]; BOOL x_25_1_32[100]; } x25; }*)getStatusBarOverrideData;
  126. + (StatusBarOverrideData *)getStatusBarOverrideData;
  127. + (int)getStyleOverrides;
  128. + (void)permanentizeStatusBarOverrideData;
  129. + (void)postDoubleHeightStatusString:(id)arg1 forStyle:(long long)arg2;
  130. + (void)postGlowAnimationState:(bool)arg1 forStyle:(long long)arg2;
  131. //+ (void)postStatusBarData:(const struct { bool x1[29]; BOOL x2[64]; int x3; int x4; BOOL x5[100]; BOOL x6[100]; BOOL x7[2][100]; BOOL x8[1024]; unsigned int x9; int x10; int x11; unsigned int x12; int x13; unsigned int x14; BOOL x15[150]; int x16; int x17; unsigned int x18 : 1; unsigned int x19 : 1; unsigned int x20 : 1; BOOL x21[256]; unsigned int x22 : 1; unsigned int x23 : 1; unsigned int x24 : 1; unsigned int x25 : 1; unsigned int x26 : 1; unsigned int x27; unsigned int x28 : 1; unsigned int x29 : 1; BOOL x30[256]; BOOL x31[256]; BOOL x32[100]; }*)arg1 withActions:(int)arg2;
  132. + (void)postStatusBarData:(const StatusBarRawData *)arg1 withActions:(int)arg2;
  133. //+ (void)postStatusBarOverrideData:(struct { bool x1[29]; unsigned int x2 : 1; unsigned int x3 : 1; unsigned int x4 : 1; unsigned int x5 : 1; unsigned int x6 : 2; unsigned int x7 : 1; unsigned int x8 : 1; unsigned int x9 : 1; unsigned int x10 : 1; unsigned int x11 : 1; unsigned int x12 : 1; unsigned int x13 : 1; unsigned int x14 : 1; unsigned int x15 : 1; unsigned int x16 : 1; unsigned int x17 : 1; unsigned int x18 : 1; unsigned int x19 : 1; unsigned int x20 : 1; unsigned int x21 : 1; unsigned int x22 : 1; unsigned int x23 : 1; unsigned int x24 : 1; struct { bool x_25_1_1[29]; BOOL x_25_1_2[64]; int x_25_1_3; int x_25_1_4; BOOL x_25_1_5[100]; BOOL x_25_1_6[100]; BOOL x_25_1_7[2][100]; BOOL x_25_1_8[1024]; unsigned int x_25_1_9; int x_25_1_10; int x_25_1_11; unsigned int x_25_1_12; int x_25_1_13; unsigned int x_25_1_14; BOOL x_25_1_15[150]; int x_25_1_16; int x_25_1_17; unsigned int x_25_1_18 : 1; unsigned int x_25_1_19 : 1; unsigned int x_25_1_20 : 1; BOOL x_25_1_21[256]; unsigned int x_25_1_22 : 1; unsigned int x_25_1_23 : 1; unsigned int x_25_1_24 : 1; unsigned int x_25_1_25 : 1; unsigned int x_25_1_26 : 1; unsigned int x_25_1_27; unsigned int x_25_1_28 : 1; unsigned int x_25_1_29 : 1; BOOL x_25_1_30[256]; BOOL x_25_1_31[256]; BOOL x_25_1_32[100]; } x25; }*)arg1;
  134. + (void)postStatusBarOverrideData:(StatusBarOverrideData *)arg1;
  135. + (void)removeStatusBarItem:(int)arg1;
  136. + (void)removeStyleOverrides:(int)arg1;
  137. + (void)runServer;
  138. //- (void).cxx_destruct;
  139. - (void)_receivedDoubleHeightStatus:(const char *)arg1 forStyle:(long long)arg2;
  140. - (void)_receivedGlowAnimationState:(bool)arg1 forStyle:(long long)arg2;
  141. - (void)_receivedStatusBarData:(struct { bool x1[29]; BOOL x2[64]; int x3; int x4; BOOL x5[100]; BOOL x6[100]; BOOL x7[2][100]; BOOL x8[1024]; unsigned int x9; int x10; int x11; unsigned int x12; int x13; unsigned int x14; BOOL x15[150]; int x16; int x17; unsigned int x18 : 1; unsigned int x19 : 1; unsigned int x20 : 1; BOOL x21[256]; unsigned int x22 : 1; unsigned int x23 : 1; unsigned int x24 : 1; unsigned int x25 : 1; unsigned int x26 : 1; unsigned int x27; unsigned int x28 : 1; unsigned int x29 : 1; BOOL x30[256]; BOOL x31[256]; BOOL x32[100]; }*)arg1 actions:(int)arg2;
  142. - (void)_receivedStyleOverrides:(int)arg1;
  143. - (void)dealloc;
  144. - (id)initWithStatusBar:(id)arg1;
  145. //- (void)setStatusBar:(id)arg1;
  146. //- (id)statusBar;
  147. @end
  148. @implementation SDStatusBarOverriderPost9_3
  149. @synthesize timeString;
  150. @synthesize dateString;
  151. @synthesize carrierName;
  152. @synthesize bluetoothConnected;
  153. @synthesize bluetoothEnabled;
  154. @synthesize batteryDetailEnabled;
  155. @synthesize networkType;
  156. @synthesize iPadDateEnabled;
  157. @synthesize iPadGsmSignalEnabled;
  158. - (void)enableOverrides
  159. {
  160. StatusBarOverrideData *overrides = [UIStatusBarServer getStatusBarOverrideData];
  161. // Set 9:41 time in current localization
  162. overrides->overrideTimeString = 1;
  163. strcpy(overrides->values.timeString, [self.timeString cStringUsingEncoding:NSUTF8StringEncoding]);
  164. // Enable 5 bars of mobile (iPhone only)
  165. if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
  166. overrides->booloverrideItemIsEnabled[ItemIsEnabledGsmSignalStrengthShowDots] = 1;
  167. overrides->values.boolitemIsEnabled[ItemIsEnabledGsmSignalStrengthShowDots] = 1;
  168. overrides->overrideGsmSignalStrengthBars = 1;
  169. overrides->values.gsmSignalStrengthBars = 5;
  170. }
  171. overrides->overrideDataNetworkType = self.networkType != SDStatusBarManagerNetworkTypeWiFi;
  172. overrides->values.dataNetworkType = self.networkType - 1;
  173. // Remove carrier text for iPhone, set it to "iPad" for the iPad
  174. NSString *carrierText = self.carrierName;
  175. if ([carrierText length] <= 0) {
  176. carrierText = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) ? @"" : @"iPad";
  177. }
  178. overrides->overrideServiceString = 1;
  179. strcpy(overrides->values.serviceString, [carrierText cStringUsingEncoding:NSUTF8StringEncoding]);
  180. // Battery
  181. overrides->booloverrideItemIsEnabled[ItemIsEnabledBatteryDetailString] = 1;
  182. overrides->values.boolitemIsEnabled[ItemIsEnabledBatteryDetailString] = 1;
  183. overrides->overrideBatteryDetailString = 1;
  184. strcpy(overrides->values.batteryDetailString, [self.batteryDetailEnabled? @"100%" : @" " cStringUsingEncoding:NSUTF8StringEncoding]); // Setting this to an empty string will not work, it needs to be a @" "
  185. // Bluetooth
  186. overrides->booloverrideItemIsEnabled[ItemIsEnabledBatteryBluetoothIcon] = self.bluetoothEnabled;
  187. overrides->values.boolitemIsEnabled[ItemIsEnabledBatteryBluetoothIcon] = self.bluetoothEnabled;
  188. if (self.bluetoothEnabled) {
  189. overrides->overrideBluetoothConnected = self.bluetoothConnected;
  190. overrides->values.bluetoothConnected = self.bluetoothConnected;
  191. }
  192. // Actually update the status bar
  193. [UIStatusBarServer postStatusBarOverrideData:overrides];
  194. // Remove the @" " used to trick the battery percentage into not showing, if used
  195. if (!self.batteryDetailEnabled) {
  196. strcpy(overrides->values.batteryDetailString, [@"" cStringUsingEncoding:NSUTF8StringEncoding]);
  197. [UIStatusBarServer postStatusBarOverrideData:overrides];
  198. }
  199. // Lock in the changes, reset simulator will remove this
  200. [UIStatusBarServer permanentizeStatusBarOverrideData];
  201. }
  202. - (void)disableOverrides
  203. {
  204. StatusBarOverrideData *overrides = [UIStatusBarServer getStatusBarOverrideData];
  205. // Remove specific overrides (separate flags)
  206. overrides->overrideTimeString = 0;
  207. overrides->overrideGsmSignalStrengthBars = 0;
  208. overrides->overrideDataNetworkType = 0;
  209. overrides->overrideBatteryDetailString = 0;
  210. overrides->overrideBluetoothConnected = 0;
  211. // Remove all overrides that use the array of bools
  212. memset(overrides->booloverrideItemIsEnabled, 0, sizeof(overrides->booloverrideItemIsEnabled));
  213. memset(overrides->values.boolitemIsEnabled, 0, sizeof(overrides->values.boolitemIsEnabled));
  214. // Carrier text (it's an override to set it back to the default)
  215. overrides->overrideServiceString = 1;
  216. strcpy(overrides->values.serviceString, [NSLocalizedString(@"Carrier", @"Carrier") cStringUsingEncoding:NSUTF8StringEncoding]);
  217. // Actually update the status bar
  218. [UIStatusBarServer postStatusBarOverrideData:overrides];
  219. // Have to call this to remove all the overrides
  220. [UIStatusBarServer permanentizeStatusBarOverrideData];
  221. }
  222. @end