SDStatusBarOverriderPost9_0.m 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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_0.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[27];
  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. unsigned int unknownOption : 1;
  58. } StatusBarRawData;
  59. typedef struct {
  60. char booloverrideItemIsEnabled[27];
  61. unsigned int overrideTimeString : 1;
  62. unsigned int overrideGsmSignalStrengthRaw : 1;
  63. unsigned int overrideGsmSignalStrengthBars : 1;
  64. unsigned int overrideServiceString : 1;
  65. unsigned int overrideServiceImages : 2;
  66. unsigned int overrideOperatorDirectory : 1;
  67. unsigned int overrideServiceContentType : 1;
  68. unsigned int overrideWifiSignalStrengthRaw : 1;
  69. unsigned int overrideWifiSignalStrengthBars : 1;
  70. unsigned int overrideDataNetworkType : 1;
  71. unsigned int disallowsCellularDataNetworkTypes : 1;
  72. unsigned int overrideBatteryCapacity : 1;
  73. unsigned int overrideBatteryState : 1;
  74. unsigned int overrideBatteryDetailString : 1;
  75. unsigned int overrideBluetoothBatteryCapacity : 1;
  76. unsigned int overrideThermalColor : 1;
  77. unsigned int overrideSlowActivity : 1;
  78. unsigned int overrideActivityDisplayId : 1;
  79. unsigned int overrideBluetoothConnected : 1;
  80. unsigned int overrideDisplayRawGSMSignal : 1;
  81. unsigned int overrideDisplayRawWifiSignal : 1;
  82. StatusBarRawData values;
  83. } StatusBarOverrideData;
  84. @class UIStatusBarServerClient;
  85. @interface UIStatusBarServer : NSObject {
  86. UIStatusBarServerClient *_statusBar;
  87. struct __CFRunLoopSource { } *_source;
  88. }
  89. @property(retain) UIStatusBarServerClient * statusBar;
  90. + (unsigned int)_serverPort;
  91. + (void)runServer;
  92. + (id)getDoubleHeightStatusStringForStyle:(long long)arg1;
  93. + (bool)getGlowAnimationStateForStyle:(long long)arg1;
  94. + (int)getStyleOverrides;
  95. + (StatusBarOverrideData *)getStatusBarOverrideData;
  96. + (const StatusBarRawData*)getStatusBarData;
  97. + (void)permanentizeStatusBarOverrideData;
  98. + (void)postStatusBarOverrideData:(StatusBarOverrideData*)arg1;
  99. + (void)postStatusBarData:(const StatusBarRawData*)arg1 withActions:(int)arg2;
  100. + (unsigned int)_publisherPort;
  101. + (double)getGlowAnimationEndTimeForStyle:(long long)arg1;
  102. + (void)removeStatusBarItem:(int)arg1;
  103. + (void)addStatusBarItem:(int)arg1;
  104. + (void)postDoubleHeightStatusString:(id)arg1 forStyle:(long long)arg2;
  105. + (void)postGlowAnimationState:(bool)arg1 forStyle:(long long)arg2;
  106. + (void)removeStyleOverrides:(int)arg1;
  107. + (void)addStyleOverrides:(int)arg1;
  108. @end
  109. @implementation SDStatusBarOverriderPost9_0
  110. @synthesize timeString;
  111. @synthesize dateString;
  112. @synthesize carrierName;
  113. @synthesize bluetoothConnected;
  114. @synthesize bluetoothEnabled;
  115. @synthesize batteryDetailEnabled;
  116. @synthesize networkType;
  117. @synthesize iPadDateEnabled;
  118. @synthesize iPadGsmSignalEnabled;
  119. - (void)enableOverrides
  120. {
  121. StatusBarOverrideData *overrides = [UIStatusBarServer getStatusBarOverrideData];
  122. // Set 9:41 time in current localization
  123. overrides->overrideTimeString = 1;
  124. strcpy(overrides->values.timeString, [self.timeString cStringUsingEncoding:NSUTF8StringEncoding]);
  125. // Enable 5 bars of mobile (iPhone only)
  126. if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
  127. overrides->booloverrideItemIsEnabled[3] = 1;
  128. overrides->values.boolitemIsEnabled[3] = 1;
  129. overrides->overrideGsmSignalStrengthBars = 1;
  130. overrides->values.gsmSignalStrengthBars = 5;
  131. }
  132. overrides->overrideDataNetworkType = self.networkType != SDStatusBarManagerNetworkTypeWiFi;
  133. overrides->values.dataNetworkType = self.networkType - 1;
  134. // Remove carrier text for iPhone, set it to "iPad" for the iPad
  135. NSString *carrierText = self.carrierName;
  136. if ([carrierText length] <= 0) {
  137. carrierText = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) ? @"" : @"iPad";
  138. }
  139. overrides->overrideServiceString = 1;
  140. strcpy(overrides->values.serviceString, [carrierText cStringUsingEncoding:NSUTF8StringEncoding]);
  141. // Battery
  142. overrides->booloverrideItemIsEnabled[8] = 1;
  143. overrides->values.boolitemIsEnabled[8] = 1;
  144. overrides->overrideBatteryDetailString = 1;
  145. strcpy(overrides->values.batteryDetailString, [self.batteryDetailEnabled? @"100%" : @" " cStringUsingEncoding:NSUTF8StringEncoding]);
  146. // Bluetooth
  147. overrides->booloverrideItemIsEnabled[11] = self.bluetoothEnabled;
  148. overrides->values.boolitemIsEnabled[11] = self.bluetoothEnabled;
  149. if (self.bluetoothEnabled) {
  150. overrides->overrideBluetoothConnected = self.bluetoothConnected;
  151. overrides->values.bluetoothConnected = self.bluetoothConnected;
  152. }
  153. // Actually update the status bar
  154. [UIStatusBarServer postStatusBarOverrideData:overrides];
  155. // 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
  156. if (!self.batteryDetailEnabled) {
  157. strcpy(overrides->values.batteryDetailString, [@"" cStringUsingEncoding:NSUTF8StringEncoding]);
  158. [UIStatusBarServer postStatusBarOverrideData:overrides];
  159. }
  160. // Lock in the changes, reset simulator will remove this
  161. [UIStatusBarServer permanentizeStatusBarOverrideData];
  162. }
  163. - (void)disableOverrides
  164. {
  165. StatusBarOverrideData *overrides = [UIStatusBarServer getStatusBarOverrideData];
  166. // Remove specific overrides (separate flags)
  167. overrides->overrideTimeString = 0;
  168. overrides->overrideGsmSignalStrengthBars = 0;
  169. overrides->overrideDataNetworkType = 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 < 27; 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