SDStatusBarOverriderPre8_3.m 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 "SDStatusBarOverriderPre8_3.h"
  26. /* Generated by RuntimeBrowser.
  27. Image: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/UIKit.framework/UIKit
  28. */
  29. typedef struct {
  30. char boolitemIsEnabled[25];
  31. char timeString[64];
  32. int gsmSignalStrengthRaw;
  33. int gsmSignalStrengthBars;
  34. char serviceString[100];
  35. char serviceCrossfadeString[100];
  36. char serviceImages[2][100];
  37. char operatorDirectory[1024];
  38. unsigned int serviceContentType;
  39. int wifiSignalStrengthRaw;
  40. int wifiSignalStrengthBars;
  41. unsigned int dataNetworkType;
  42. int batteryCapacity;
  43. unsigned int batteryState;
  44. char batteryDetailString[150];
  45. int bluetoothBatteryCapacity;
  46. int thermalColor;
  47. unsigned int thermalSunlightMode : 1;
  48. unsigned int slowActivity : 1;
  49. unsigned int syncActivity : 1;
  50. BOOL activityDisplayId[256];
  51. unsigned int bluetoothConnected : 1;
  52. unsigned int displayRawGSMSignal : 1;
  53. unsigned int displayRawWifiSignal : 1;
  54. unsigned int locationIconType : 1;
  55. unsigned int quietModeInactive : 1;
  56. unsigned int tetheringConnectionCount;
  57. } StatusBarRawData;
  58. typedef struct {
  59. char booloverrideItemIsEnabled[25];
  60. unsigned int overrideTimeString : 1;
  61. unsigned int overrideGsmSignalStrengthRaw : 1;
  62. unsigned int overrideGsmSignalStrengthBars : 1;
  63. unsigned int overrideServiceString : 1;
  64. unsigned int overrideServiceImages : 2;
  65. unsigned int overrideOperatorDirectory : 1;
  66. unsigned int overrideServiceContentType : 1;
  67. unsigned int overrideWifiSignalStrengthRaw : 1;
  68. unsigned int overrideWifiSignalStrengthBars : 1;
  69. unsigned int overrideDataNetworkType : 1;
  70. unsigned int disallowsCellularDataNetworkTypes : 1;
  71. unsigned int overrideBatteryCapacity : 1;
  72. unsigned int overrideBatteryState : 1;
  73. unsigned int overrideBatteryDetailString : 1;
  74. unsigned int overrideBluetoothBatteryCapacity : 1;
  75. unsigned int overrideThermalColor : 1;
  76. unsigned int overrideSlowActivity : 1;
  77. unsigned int overrideActivityDisplayId : 1;
  78. unsigned int overrideBluetoothConnected : 1;
  79. unsigned int overrideDisplayRawGSMSignal : 1;
  80. unsigned int overrideDisplayRawWifiSignal : 1;
  81. StatusBarRawData values;
  82. } StatusBarOverrideData;
  83. @class UIStatusBarServerClient;
  84. @interface UIStatusBarServer : NSObject {
  85. UIStatusBarServerClient *_statusBar;
  86. struct __CFRunLoopSource { } *_source;
  87. }
  88. @property(retain) UIStatusBarServerClient * statusBar;
  89. + (unsigned int)_serverPort;
  90. + (void)runServer;
  91. + (id)getDoubleHeightStatusStringForStyle:(long long)arg1;
  92. + (bool)getGlowAnimationStateForStyle:(long long)arg1;
  93. + (int)getStyleOverrides;
  94. + (StatusBarOverrideData *)getStatusBarOverrideData;
  95. + (const StatusBarRawData*)getStatusBarData;
  96. + (void)permanentizeStatusBarOverrideData;
  97. + (void)postStatusBarOverrideData:(StatusBarOverrideData*)arg1;
  98. + (void)postStatusBarData:(const StatusBarRawData*)arg1 withActions:(int)arg2;
  99. + (unsigned int)_publisherPort;
  100. + (double)getGlowAnimationEndTimeForStyle:(long long)arg1;
  101. + (void)removeStatusBarItem:(int)arg1;
  102. + (void)addStatusBarItem:(int)arg1;
  103. + (void)postDoubleHeightStatusString:(id)arg1 forStyle:(long long)arg2;
  104. + (void)postGlowAnimationState:(bool)arg1 forStyle:(long long)arg2;
  105. + (void)removeStyleOverrides:(int)arg1;
  106. + (void)addStyleOverrides:(int)arg1;
  107. @end
  108. @implementation SDStatusBarOverriderPre8_3
  109. @synthesize timeString;
  110. @synthesize dateString;
  111. @synthesize carrierName;
  112. @synthesize bluetoothConnected;
  113. @synthesize bluetoothEnabled;
  114. @synthesize batteryDetailEnabled;
  115. @synthesize networkType;
  116. @synthesize iPadDateEnabled;
  117. @synthesize iPadGsmSignalEnabled;
  118. - (void)enableOverrides
  119. {
  120. StatusBarOverrideData *overrides = [UIStatusBarServer getStatusBarOverrideData];
  121. // Set 9:41 time in current localization
  122. overrides->overrideTimeString = 1;
  123. strcpy(overrides->values.timeString, [self.timeString cStringUsingEncoding:NSUTF8StringEncoding]);
  124. // Enable 5 bars of mobile (iPhone only)
  125. if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
  126. overrides->booloverrideItemIsEnabled[3] = 1;
  127. overrides->values.boolitemIsEnabled[3] = 1;
  128. overrides->overrideGsmSignalStrengthBars = 1;
  129. overrides->values.gsmSignalStrengthBars = 5;
  130. }
  131. overrides->overrideDataNetworkType = self.networkType != SDStatusBarManagerNetworkTypeWiFi;
  132. overrides->values.dataNetworkType = self.networkType - 1;
  133. // Remove carrier text for iPhone, set it to "iPad" for the iPad
  134. NSString *carrierText = self.carrierName;
  135. if ([carrierText length] <= 0) {
  136. carrierText = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) ? @"" : @"iPad";
  137. }
  138. overrides->overrideServiceString = 1;
  139. strcpy(overrides->values.serviceString, [carrierText cStringUsingEncoding:NSUTF8StringEncoding]);
  140. // Battery
  141. overrides->booloverrideItemIsEnabled[8] = 1;
  142. overrides->values.boolitemIsEnabled[8] = 1;
  143. overrides->overrideBatteryDetailString = 1;
  144. strcpy(overrides->values.batteryDetailString, [self.batteryDetailEnabled? @"100%" : @" " cStringUsingEncoding:NSUTF8StringEncoding]);
  145. // Bluetooth
  146. overrides->booloverrideItemIsEnabled[11] = self.bluetoothEnabled;
  147. overrides->values.boolitemIsEnabled[11] = self.bluetoothEnabled;
  148. if (self.bluetoothEnabled) {
  149. overrides->overrideBluetoothConnected = self.bluetoothConnected;
  150. overrides->values.bluetoothConnected = self.bluetoothConnected;
  151. }
  152. // Actually update the status bar
  153. [UIStatusBarServer postStatusBarOverrideData:overrides];
  154. // if battery detail was not required, then it was set to one space @" ", so let's correct it here in case bluetooth icon comes after it
  155. if (!self.batteryDetailEnabled) {
  156. strcpy(overrides->values.batteryDetailString, [@"" cStringUsingEncoding:NSUTF8StringEncoding]);
  157. [UIStatusBarServer postStatusBarOverrideData:overrides];
  158. }
  159. // Lock in the changes, reset simulator will remove this
  160. [UIStatusBarServer permanentizeStatusBarOverrideData];
  161. }
  162. - (void)disableOverrides
  163. {
  164. StatusBarOverrideData *overrides = [UIStatusBarServer getStatusBarOverrideData];
  165. // Remove specific overrides (separate flags)
  166. overrides->overrideTimeString = 0;
  167. overrides->overrideGsmSignalStrengthBars = 0;
  168. overrides->overrideDataNetworkType = 0;
  169. overrides->overrideBatteryDetailString = 0;
  170. overrides->overrideBatteryDetailString = 0;
  171. overrides->overrideBluetoothConnected = 0;
  172. // Remove all overrides that use the array of bools
  173. for (int i = 0; i < 25; i++) {
  174. overrides->booloverrideItemIsEnabled[i] = 0;
  175. overrides->values.boolitemIsEnabled[i] = 0;
  176. }
  177. // Carrier text (it's an override to set it back to the default)
  178. overrides->overrideServiceString = 1;
  179. strcpy(overrides->values.serviceString, [NSLocalizedString(@"Carrier", @"Carrier") cStringUsingEncoding:NSUTF8StringEncoding]);
  180. // Actually update the status bar
  181. [UIStatusBarServer postStatusBarOverrideData:overrides];
  182. // Have to call this to remove all the overrides
  183. [UIStatusBarServer permanentizeStatusBarOverrideData];
  184. }
  185. @end