├── .gitignore
├── LICENSE
├── README.md
├── Sample Images
├── Screenshot1.png
└── Screenshot2.png
├── System Services
├── SystemServices.h
├── SystemServices.m
└── Utilities
│ ├── SSAccelerometerInfo.h
│ ├── SSAccelerometerInfo.m
│ ├── SSAccessoryInfo.h
│ ├── SSAccessoryInfo.m
│ ├── SSApplicationInfo.h
│ ├── SSApplicationInfo.m
│ ├── SSBatteryInfo.h
│ ├── SSBatteryInfo.m
│ ├── SSCarrierInfo.h
│ ├── SSCarrierInfo.m
│ ├── SSDiskInfo.h
│ ├── SSDiskInfo.m
│ ├── SSHardwareInfo.h
│ ├── SSHardwareInfo.m
│ ├── SSJailbreakCheck.h
│ ├── SSJailbreakCheck.m
│ ├── SSLocalizationInfo.h
│ ├── SSLocalizationInfo.m
│ ├── SSMemoryInfo.h
│ ├── SSMemoryInfo.m
│ ├── SSNetworkInfo.h
│ ├── SSNetworkInfo.m
│ ├── SSProcessInfo.h
│ ├── SSProcessInfo.m
│ ├── SSProcessorInfo.h
│ ├── SSProcessorInfo.m
│ ├── SSUUID.h
│ ├── SSUUID.m
│ └── route.h
├── SystemServices.podspec
└── SystemServicesDemo
├── Default-568h@2x.png
├── SystemServicesDemo.xcodeproj
├── project.pbxproj
└── project.xcworkspace
│ └── contents.xcworkspacedata
├── SystemServicesDemo
├── Gauges
│ ├── MSAnnotatedGauge.h
│ ├── MSAnnotatedGauge.m
│ ├── MSArcLayer.h
│ ├── MSArcLayer.m
│ ├── MSArcLayerSubclass.h
│ ├── MSGradientArcLayer.h
│ ├── MSGradientArcLayer.m
│ ├── MSNeedleView.h
│ ├── MSNeedleView.m
│ ├── MSRangeGauge.h
│ ├── MSRangeGauge.m
│ ├── MSSimpleGauge.h
│ ├── MSSimpleGauge.m
│ └── MSSimpleGaugeSubclass.h
├── Images
│ ├── Disk.png
│ ├── Disk@2x.png
│ ├── Hardware.png
│ ├── Hardware@2x.png
│ ├── Memory.png
│ ├── Memory@2x.png
│ ├── Network.png
│ └── Network@2x.png
├── PCPieChart.h
├── PCPieChart.m
├── SystemServicesDemo-Info.plist
├── SystemServicesDemo-Prefix.pch
├── SystemServicesDemoAppDelegate.h
├── SystemServicesDemoAppDelegate.m
├── SystemServicesDemoDiskViewController.h
├── SystemServicesDemoDiskViewController.m
├── SystemServicesDemoMemoryViewController.h
├── SystemServicesDemoMemoryViewController.m
├── SystemServicesDemoNetworkViewController.h
├── SystemServicesDemoNetworkViewController.m
├── SystemServicesDemoViewController.h
├── SystemServicesDemoViewController.m
├── en.lproj
│ ├── InfoPlist.strings
│ └── MainStoryboard.storyboard
└── main.m
├── icon.png
└── icon@2x.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS X
2 | .DS_Store
3 |
4 | # Xcode
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 | *.xcuserstate
25 |
26 | ## Obj-C/Swift specific
27 | *.hmap
28 | *.ipa
29 | *.dSYM.zip
30 | *.dSYM
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2012 Shmoopi LLC
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iOS-System-Services
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | This is a singleton class to gather all available information about a device. It gives you over 60 methods to determine everything about a device, including:
10 |
11 | * Hardware Information
12 | * Network Information
13 | * Battery Usage
14 | * Accelerometer Data
15 | * Disk Usage
16 | * Memory Usage
17 |
18 | ## Installation
19 |
20 | [](http://cocoapods.org/pods/SystemServices)
21 | [](http://cocoapods.org/pods/SystemServices)
22 | [](http://cocoapods.org/pods/SystemServices)
23 |
24 | iOS System Services is available through [CocoaPods](http://cocoapods.org). To install
25 | it, simply add the following line to your Podfile:
26 |
27 | ```ruby
28 | pod 'SystemServices', '~> 2.0.1'
29 | ```
30 |
31 | ## Usage
32 |
33 | ```objective-c
34 | // Import System Services
35 | #import "SystemServices.h"
36 |
37 | // Log all System Information
38 | NSLog(@"All System Information: %@", [SystemServices sharedServices].allSystemInformation);
39 | ```
40 |
41 | ## Changes
42 |
43 | 1. Removed Older/Unavailable Methods
44 | 2. Updated Demo Project
45 | 3. Added CocoaPods Support
46 | 4. Fixed Bugs and Addressed Naming Issues
47 | 5. Deprecated Older/Unavailable Methods
48 |
49 | ## Available Device Information
50 |
51 | ```objective-c
52 | // System Information
53 |
54 | // Properties
55 |
56 | /* All System Information in Dictionary Format */
57 | NSDictionary *allSystemInformation;
58 |
59 | /* Hardware Information */
60 |
61 | // System Uptime (dd hh mm)
62 | NSString *systemsUptime;
63 |
64 | // Model of Device
65 | NSString *deviceModel;
66 |
67 | // Device Name
68 | NSString *deviceName;
69 |
70 | // System Name
71 | NSString *systemName;
72 |
73 | // System Version
74 | NSString *systemsVersion;
75 |
76 | // System Device Type (Not Formatted = iPhone1,0)
77 | NSString *systemDeviceTypeNotFormatted;
78 |
79 | // System Device Type (Formatted = iPhone 1)
80 | NSString *systemDeviceTypeFormatted;
81 |
82 | // Get the Screen Width (X)
83 | NSInteger screenWidth;
84 |
85 | // Get the Screen Height (Y)
86 | NSInteger screenHeight;
87 |
88 | // Get the Screen Brightness
89 | float screenBrightness;
90 |
91 | // Multitasking enabled?
92 | BOOL multitaskingEnabled;
93 |
94 | // Proximity sensor enabled?
95 | BOOL proximitySensorEnabled;
96 |
97 | // Debugger Attached?
98 | BOOL debuggerAttached;
99 |
100 | // Plugged In?
101 | BOOL pluggedIn;
102 |
103 | // Step-Counting Available?
104 | BOOL stepCountingAvailable;
105 |
106 | // Distance Available
107 | BOOL distanceAvailable;
108 |
109 | // Floor Counting Available
110 | BOOL floorCountingAvailable;
111 |
112 | /* Jailbreak Check */
113 |
114 | // Jailbroken?
115 | int jailbroken;
116 |
117 | /* Processor Information */
118 |
119 | // Number of processors
120 | NSInteger numberProcessors;
121 |
122 | // Number of Active Processors
123 | NSInteger numberActiveProcessors;
124 |
125 | // Processor Usage Information
126 | NSArray *processorsUsage;
127 |
128 | /* Accessory Information */
129 |
130 | // Are any accessories attached?
131 | BOOL accessoriesAttached;
132 |
133 | // Are headphone attached?
134 | BOOL headphonesAttached;
135 |
136 | // Number of attached accessories
137 | NSInteger numberAttachedAccessories;
138 |
139 | // Name of attached accessory/accessories (seperated by , comma's)
140 | NSString *nameAttachedAccessories;
141 |
142 | /* Carrier Information */
143 |
144 | // Carrier Name
145 | NSString *carrierName;
146 |
147 | // Carrier Country
148 | NSString *carrierCountry;
149 |
150 | // Carrier Mobile Country Code
151 | NSString *carrierMobileCountryCode;
152 |
153 | // Carrier ISO Country Code
154 | NSString *carrierISOCountryCode;
155 |
156 | // Carrier Mobile Network Code
157 | NSString *carrierMobileNetworkCode;
158 |
159 | // Carrier Allows VOIP
160 | BOOL carrierAllowsVOIP;
161 |
162 | /* Battery Information */
163 |
164 | // Battery Level
165 | float batteryLevel;
166 |
167 | // Charging?
168 | BOOL charging;
169 |
170 | // Fully Charged?
171 | BOOL fullyCharged;
172 |
173 | /* Network Information */
174 |
175 | // Get Current IP Address
176 | NSString *currentIPAddress;
177 |
178 | // Get External IP Address
179 | NSString *externalIPAddress;
180 |
181 | // Get Cell IP Address
182 | NSString *cellIPAddress;
183 |
184 | // Get Cell Netmask Address
185 | NSString *cellNetmaskAddress;
186 |
187 | // Get Cell Broadcast Address
188 | NSString *cellBroadcastAddress;
189 |
190 | // Get WiFi IP Address
191 | NSString *wiFiIPAddress;
192 |
193 | // Get WiFi Netmask Address
194 | NSString *wiFiNetmaskAddress;
195 |
196 | // Get WiFi Broadcast Address
197 | NSString *wiFiBroadcastAddress;
198 |
199 | // Get WiFi Router Address
200 | NSString *wiFiRouterAddress;
201 |
202 | // Connected to WiFi?
203 | BOOL connectedToWiFi;
204 |
205 | // Connected to Cellular Network?
206 | BOOL connectedToCellNetwork;
207 |
208 | /* Process Information */
209 |
210 | // Process ID
211 | int processID;
212 |
213 | /* Disk Information */
214 |
215 | // Total Disk Space
216 | NSString *diskSpace;
217 |
218 | // Total Free Disk Space (Raw)
219 | NSString *freeDiskSpaceinRaw;
220 |
221 | // Total Free Disk Space (Percentage)
222 | NSString *freeDiskSpaceinPercent;
223 |
224 | // Total Used Disk Space (Raw)
225 | NSString *usedDiskSpaceinRaw;
226 |
227 | // Total Used Disk Space (Percentage)
228 | NSString *usedDiskSpaceinPercent;
229 |
230 | // Get the total disk space in long format
231 | long long longDiskSpace;
232 |
233 | // Get the total free disk space in long format
234 | long long longFreeDiskSpace;
235 |
236 | /* Memory Information */
237 |
238 | // Total Memory
239 | double totalMemory;
240 |
241 | // Free Memory (Raw)
242 | double freeMemoryinRaw;
243 |
244 | // Free Memory (Percent)
245 | double freeMemoryinPercent;
246 |
247 | // Used Memory (Raw)
248 | double usedMemoryinRaw;
249 |
250 | // Used Memory (Percent)
251 | double usedMemoryinPercent;
252 |
253 | // Active Memory (Raw)
254 | double activeMemoryinRaw;
255 |
256 | // Active Memory (Percent)
257 | double activeMemoryinPercent;
258 |
259 | // Inactive Memory (Raw)
260 | double inactiveMemoryinRaw;
261 |
262 | // Inactive Memory (Percent)
263 | double inactiveMemoryinPercent;
264 |
265 | // Wired Memory (Raw)
266 | double wiredMemoryinRaw;
267 |
268 | // Wired Memory (Percent)
269 | double wiredMemoryinPercent;
270 |
271 | // Purgable Memory (Raw)
272 | double purgableMemoryinRaw;
273 |
274 | // Purgable Memory (Percent)
275 | double purgableMemoryinPercent;
276 |
277 | /* Accelerometer Information */
278 |
279 | // Device Orientation
280 | UIInterfaceOrientation deviceOrientation;
281 |
282 | /* Localization Information */
283 |
284 | // Country
285 | NSString *country;
286 |
287 | // Language
288 | NSString *language;
289 |
290 | // TimeZone
291 | NSString *timeZoneSS;
292 |
293 | // Currency Symbol
294 | NSString *currency;
295 |
296 | /* Application Information */
297 |
298 | // Application Version
299 | NSString *applicationVersion;
300 |
301 | // Clipboard Content
302 | NSString *clipboardContent;
303 |
304 | // Application CPU Usage
305 | float applicationCPUUsage;
306 |
307 | /* Universal Unique Identifiers */
308 |
309 | // CFUUID
310 | NSString *cfuuid;
311 | ```
312 |
313 | ## Third-Party Plugins
314 |
315 | A big thank you to the makers of:
316 |
317 | * Annotated Gauge iOS Class here:
318 | * Pie Chart iOS Class here:
319 | * NSObject+PerformBlockAfterDelay iOS Class here:
320 |
321 | ## License
322 |
323 | Copyright © 2012 Shmoopi LLC
324 |
325 | If you like what you see here, or on our website, please feel free to drop us a line or purchase one of our applications!
--------------------------------------------------------------------------------
/Sample Images/Screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/Sample Images/Screenshot1.png
--------------------------------------------------------------------------------
/Sample Images/Screenshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/Sample Images/Screenshot2.png
--------------------------------------------------------------------------------
/System Services/SystemServices.h:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServices.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/15/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSAccelerometerInfo.h"
10 | #import "SSAccessoryInfo.h"
11 | #import "SSApplicationInfo.h"
12 | #import "SSBatteryInfo.h"
13 | #import "SSCarrierInfo.h"
14 | #import "SSDiskInfo.h"
15 | #import "SSHardwareInfo.h"
16 | #import "SSJailbreakCheck.h"
17 | #import "SSLocalizationInfo.h"
18 | #import "SSMemoryInfo.h"
19 | #import "SSNetworkInfo.h"
20 | #import "SSProcessInfo.h"
21 | #import "SSProcessorInfo.h"
22 | #import "SSUUID.h"
23 |
24 | @interface SystemServices : NSObject
25 |
26 | // Shared Manager
27 | + (nonnull instancetype)sharedServices;
28 |
29 | // Properties
30 |
31 | /* All System Information in Dictionary Format */
32 | @property (nonatomic, readonly, nullable) NSDictionary *allSystemInformation;
33 |
34 | /* Hardware Information */
35 |
36 | // System Uptime (dd hh mm)
37 | @property (nonatomic, readonly, nullable) NSString *systemsUptime;
38 |
39 | // Model of Device
40 | @property (nonatomic, readonly, nullable) NSString *deviceModel;
41 |
42 | // Device Name
43 | @property (nonatomic, readonly, nullable) NSString *deviceName;
44 |
45 | // System Name
46 | @property (nonatomic, readonly, nullable) NSString *systemName;
47 |
48 | // System Version
49 | @property (nonatomic, readonly, nullable) NSString *systemsVersion;
50 |
51 | // System Device Type (Not Formatted = iPhone1,0)
52 | @property (nonatomic, readonly, nullable) NSString *systemDeviceTypeNotFormatted;
53 |
54 | // System Device Type (Formatted = iPhone 1)
55 | @property (nonatomic, readonly, nullable) NSString *systemDeviceTypeFormatted;
56 |
57 | // Get the Screen Width (X)
58 | @property (nonatomic, readonly) NSInteger screenWidth;
59 |
60 | // Get the Screen Height (Y)
61 | @property (nonatomic, readonly) NSInteger screenHeight;
62 |
63 | // Get the Screen Brightness
64 | @property (nonatomic, readonly) float screenBrightness;
65 |
66 | // Multitasking enabled?
67 | @property (nonatomic, readonly) BOOL multitaskingEnabled;
68 |
69 | // Proximity sensor enabled?
70 | @property (nonatomic, readonly) BOOL proximitySensorEnabled;
71 |
72 | // Debugger Attached?
73 | @property (nonatomic, readonly) BOOL debuggerAttached;
74 |
75 | // Plugged In?
76 | @property (nonatomic, readonly) BOOL pluggedIn;
77 |
78 | // Step-Counting Available?
79 | @property (nonatomic, readonly) BOOL stepCountingAvailable;
80 |
81 | // Distance Available
82 | @property (nonatomic, readonly) BOOL distanceAvailable;
83 |
84 | // Floor Counting Available
85 | @property (nonatomic, readonly) BOOL floorCountingAvailable;
86 |
87 | /* Jailbreak Check */
88 |
89 | // Jailbroken?
90 | @property (nonatomic, readonly) int jailbroken;
91 |
92 | /* Processor Information */
93 |
94 | // Number of processors
95 | @property (nonatomic, readonly) NSInteger numberProcessors;
96 |
97 | // Number of Active Processors
98 | @property (nonatomic, readonly) NSInteger numberActiveProcessors;
99 |
100 | // Processor Usage Information
101 | @property (nonatomic, readonly, nullable) NSArray *processorsUsage;
102 |
103 | /* Accessory Information */
104 |
105 | // Are any accessories attached?
106 | @property (nonatomic, readonly) BOOL accessoriesAttached;
107 |
108 | // Are headphone attached?
109 | @property (nonatomic, readonly) BOOL headphonesAttached;
110 |
111 | // Number of attached accessories
112 | @property (nonatomic, readonly) NSInteger numberAttachedAccessories;
113 |
114 | // Name of attached accessory/accessories (seperated by , comma's)
115 | @property (nonatomic, readonly, nullable) NSString *nameAttachedAccessories;
116 |
117 | /* Carrier Information */
118 |
119 | // Carrier Name
120 | @property (nonatomic, readonly, nullable) NSString *carrierName;
121 |
122 | // Carrier Country
123 | @property (nonatomic, readonly, nullable) NSString *carrierCountry;
124 |
125 | // Carrier Mobile Country Code
126 | @property (nonatomic, readonly, nullable) NSString *carrierMobileCountryCode;
127 |
128 | // Carrier ISO Country Code
129 | @property (nonatomic, readonly, nullable) NSString *carrierISOCountryCode;
130 |
131 | // Carrier Mobile Network Code
132 | @property (nonatomic, readonly, nullable) NSString *carrierMobileNetworkCode;
133 |
134 | // Carrier Allows VOIP
135 | @property (nonatomic, readonly) BOOL carrierAllowsVOIP;
136 |
137 | /* Battery Information */
138 |
139 | // Battery Level
140 | @property (nonatomic, readonly) float batteryLevel;
141 |
142 | // Charging?
143 | @property (nonatomic, readonly) BOOL charging;
144 |
145 | // Fully Charged?
146 | @property (nonatomic, readonly) BOOL fullyCharged;
147 |
148 | /* Network Information */
149 |
150 | // Get Current IP Address
151 | @property (nonatomic, readonly, nullable) NSString *currentIPAddress;
152 |
153 | // Get External IP Address
154 | @property (nonatomic, readonly, nullable) NSString *externalIPAddress;
155 |
156 | // Get Cell IP Address
157 | @property (nonatomic, readonly, nullable) NSString *cellIPAddress;
158 |
159 | // Get Cell Netmask Address
160 | @property (nonatomic, readonly, nullable) NSString *cellNetmaskAddress;
161 |
162 | // Get Cell Broadcast Address
163 | @property (nonatomic, readonly, nullable) NSString *cellBroadcastAddress;
164 |
165 | // Get WiFi IP Address
166 | @property (nonatomic, readonly, nullable) NSString *wiFiIPAddress;
167 |
168 | // Get WiFi Netmask Address
169 | @property (nonatomic, readonly, nullable) NSString *wiFiNetmaskAddress;
170 |
171 | // Get WiFi Broadcast Address
172 | @property (nonatomic, readonly, nullable) NSString *wiFiBroadcastAddress;
173 |
174 | // Get WiFi Router Address
175 | @property (nonatomic, readonly, nullable) NSString *wiFiRouterAddress;
176 |
177 | // Connected to WiFi?
178 | @property (nonatomic, readonly) BOOL connectedToWiFi;
179 |
180 | // Connected to Cellular Network?
181 | @property (nonatomic, readonly) BOOL connectedToCellNetwork;
182 |
183 | /* Process Information */
184 |
185 | // Process ID
186 | @property (nonatomic, readonly) int processID;
187 |
188 | /* Disk Information */
189 |
190 | // Total Disk Space
191 | @property (nonatomic, readonly, nullable) NSString *diskSpace;
192 |
193 | // Total Free Disk Space (Raw)
194 | @property (nonatomic, readonly, nullable) NSString *freeDiskSpaceinRaw;
195 |
196 | // Total Free Disk Space (Percentage)
197 | @property (nonatomic, readonly, nullable) NSString *freeDiskSpaceinPercent;
198 |
199 | // Total Used Disk Space (Raw)
200 | @property (nonatomic, readonly, nullable) NSString *usedDiskSpaceinRaw;
201 |
202 | // Total Used Disk Space (Percentage)
203 | @property (nonatomic, readonly, nullable) NSString *usedDiskSpaceinPercent;
204 |
205 | // Get the total disk space in long format
206 | @property (nonatomic, readonly) long long longDiskSpace;
207 |
208 | // Get the total free disk space in long format
209 | @property (nonatomic, readonly) long long longFreeDiskSpace;
210 |
211 | /* Memory Information */
212 |
213 | // Total Memory
214 | @property (nonatomic, readonly) double totalMemory;
215 |
216 | // Free Memory (Raw)
217 | @property (nonatomic, readonly) double freeMemoryinRaw;
218 |
219 | // Free Memory (Percent)
220 | @property (nonatomic, readonly) double freeMemoryinPercent;
221 |
222 | // Used Memory (Raw)
223 | @property (nonatomic, readonly) double usedMemoryinRaw;
224 |
225 | // Used Memory (Percent)
226 | @property (nonatomic, readonly) double usedMemoryinPercent;
227 |
228 | // Active Memory (Raw)
229 | @property (nonatomic, readonly) double activeMemoryinRaw;
230 |
231 | // Active Memory (Percent)
232 | @property (nonatomic, readonly) double activeMemoryinPercent;
233 |
234 | // Inactive Memory (Raw)
235 | @property (nonatomic, readonly) double inactiveMemoryinRaw;
236 |
237 | // Inactive Memory (Percent)
238 | @property (nonatomic, readonly) double inactiveMemoryinPercent;
239 |
240 | // Wired Memory (Raw)
241 | @property (nonatomic, readonly) double wiredMemoryinRaw;
242 |
243 | // Wired Memory (Percent)
244 | @property (nonatomic, readonly) double wiredMemoryinPercent;
245 |
246 | // Purgable Memory (Raw)
247 | @property (nonatomic, readonly) double purgableMemoryinRaw;
248 |
249 | // Purgable Memory (Percent)
250 | @property (nonatomic, readonly) double purgableMemoryinPercent;
251 |
252 | /* Accelerometer Information */
253 |
254 | // Device Orientation
255 | @property (nonatomic, readonly) UIInterfaceOrientation deviceOrientation;
256 |
257 | /* Localization Information */
258 |
259 | // Country
260 | @property (nonatomic, readonly, nullable) NSString *country;
261 |
262 | // Language
263 | @property (nonatomic, readonly, nullable) NSString *language;
264 |
265 | // TimeZone
266 | @property (nonatomic, readonly, nullable) NSString *timeZoneSS;
267 |
268 | // Currency Symbol
269 | @property (nonatomic, readonly, nullable) NSString *currency;
270 |
271 | /* Application Information */
272 |
273 | // Application Version
274 | @property (nonatomic, readonly, nullable) NSString *applicationVersion;
275 |
276 | // Clipboard Content
277 | @property (nonatomic, readonly, nullable) NSString *clipboardContent;
278 |
279 | // Application CPU Usage
280 | @property (nonatomic, readonly) float applicationCPUUsage;
281 |
282 | /* Universal Unique Identifiers */
283 |
284 | // CFUUID
285 | @property (nonatomic, readonly, nullable) NSString *cfuuid;
286 |
287 | @end
288 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSAccelerometerInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSAccelerometerInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/20/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | // Core Motion
13 | #import
14 |
15 | @interface SSAccelerometerInfo : NSObject {
16 | CMMotionManager *motionManager;
17 |
18 | NSOperationQueue *deviceMotionQueue;
19 | NSOperationQueue *accelQueue;
20 | NSOperationQueue *gyroQueue;
21 | }
22 |
23 | // Accelerometer Information
24 |
25 | // Device Orientation
26 | + (UIInterfaceOrientation)deviceOrientation;
27 |
28 | // Attitude
29 | @property (nonatomic, readonly, nullable) NSString *attitudeString;
30 |
31 | // Gravity
32 | @property (nonatomic, readonly, nullable) NSString *gravityString;
33 |
34 | // Magnetic Field
35 | @property (nonatomic, readonly, nullable) NSString *magneticFieldString;
36 |
37 | // Rotation Rate
38 | @property (nonatomic, readonly, nullable) NSString *rotationRateString;
39 |
40 | // User Acceleration
41 | @property (nonatomic, readonly, nullable) NSString *userAccelerationString;
42 |
43 | // Raw Gyroscope
44 | @property (nonatomic, readonly, nullable) NSString *rawGyroscopeString;
45 |
46 | // Raw Accelerometer
47 | @property (nonatomic, readonly, nullable) NSString *rawAccelerometerString;
48 |
49 | /**
50 | * startLoggingMotionData
51 | *
52 | * This method uses the boolean instance variables to tell the CMMotionManager what
53 | * to do. The three main types of IMU capture each have their own NSOperationQueue.
54 | * A queue will only be utilized if its respective motion type is going to be logged.
55 | *
56 | */
57 | - (void)startLoggingMotionData;
58 |
59 | /**
60 | * stopLoggingMotionDataAndSave
61 | *
62 | * Tells the CMMotionManager to stop the motion updates and calls the writeDataToDisk
63 | * method. The only gotchya is that we wait for the NSOperationQueues to finish
64 | * what they are doing first so that we're not accessing the same resource from
65 | * different points in the program.
66 | */
67 | - (void)stopLoggingMotionData;
68 |
69 | @end
70 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSAccelerometerInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSAccelerometerInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/20/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSAccelerometerInfo.h"
10 |
11 | // Private
12 | @interface SSAccelerometerInfo ()
13 |
14 | /**
15 | * processMotion:withError:
16 | *
17 | * Appends the new motion data to the appropriate instance variable strings.
18 | */
19 | - (void)processMotion:(CMDeviceMotion*)motion withError:(NSError*)error;
20 |
21 | /**
22 | * processAccel:withError:
23 | *
24 | * Appends the new raw accleration data to the appropriate instance variable string.
25 | */
26 | - (void)processAccel:(CMAccelerometerData*)accelData withError:(NSError*)error;
27 |
28 | /**
29 | * processGyro:withError:
30 | *
31 | * Appends the new raw gyro data to the appropriate instance variable string.
32 | */
33 | - (void)processGyro:(CMGyroData*)gyroData withError:(NSError*)error;
34 |
35 | @end
36 |
37 | // Implementation
38 | @implementation SSAccelerometerInfo
39 |
40 | @synthesize attitudeString, gravityString, magneticFieldString, rotationRateString, userAccelerationString, rawGyroscopeString, rawAccelerometerString;
41 |
42 | // Accelerometer Information
43 |
44 | // Device Orientation
45 | + (UIInterfaceOrientation)deviceOrientation {
46 | // Get the device's current orientation
47 | @try {
48 | #if !(defined(__has_feature) && __has_feature(attribute_availability_app_extension))
49 | // Device orientation
50 | UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
51 |
52 | // Successful
53 | return orientation;
54 | #endif
55 | }
56 | @catch (NSException *exception) {
57 | return -1;
58 | }
59 | // Error
60 | return -1;
61 | }
62 |
63 | // Start logging motion data
64 | - (void)startLoggingMotionData {
65 | motionManager = [[CMMotionManager alloc] init];
66 | motionManager.deviceMotionUpdateInterval = 0.01; //100 Hz
67 | motionManager.accelerometerUpdateInterval = 0.01;
68 | motionManager.gyroUpdateInterval = 0.01;
69 |
70 | // Limiting the concurrent ops to 1 is a cheap way to avoid two handlers editing the same
71 | // string at the same time.
72 | deviceMotionQueue = [[NSOperationQueue alloc] init];
73 | [deviceMotionQueue setMaxConcurrentOperationCount:1];
74 |
75 | accelQueue = [[NSOperationQueue alloc] init];
76 | [accelQueue setMaxConcurrentOperationCount:1];
77 |
78 | gyroQueue = [[NSOperationQueue alloc] init];
79 | [gyroQueue setMaxConcurrentOperationCount:1];
80 |
81 | // Logging Motion Data
82 |
83 | CMDeviceMotionHandler motionHandler = ^(CMDeviceMotion *motion, NSError *error) {
84 | [self processMotion:motion withError:error];
85 | };
86 |
87 | CMGyroHandler gyroHandler = ^(CMGyroData *gyroData, NSError *error) {
88 | [self processGyro:gyroData withError:error];
89 | };
90 |
91 | CMAccelerometerHandler accelHandler = ^(CMAccelerometerData *accelerometerData, NSError *error) {
92 | [self processAccel:accelerometerData withError:error];
93 | };
94 |
95 | [motionManager startDeviceMotionUpdatesToQueue:deviceMotionQueue withHandler:motionHandler];
96 |
97 | [motionManager startGyroUpdatesToQueue:gyroQueue withHandler:gyroHandler];
98 |
99 | [motionManager startAccelerometerUpdatesToQueue:accelQueue withHandler:accelHandler];
100 | }
101 |
102 | // Stop logging motion data
103 | - (void)stopLoggingMotionData {
104 |
105 | // Stop everything
106 | [motionManager stopDeviceMotionUpdates];
107 | [deviceMotionQueue waitUntilAllOperationsAreFinished];
108 |
109 | [motionManager stopAccelerometerUpdates];
110 | [accelQueue waitUntilAllOperationsAreFinished];
111 |
112 | [motionManager stopGyroUpdates];
113 | [gyroQueue waitUntilAllOperationsAreFinished];
114 |
115 | }
116 |
117 | #pragma mark - Set Motion Variables when Updating (in background)
118 |
119 | - (void)processAccel:(CMAccelerometerData*)accelData withError:(NSError*)error {
120 | rawAccelerometerString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", accelData.timestamp,
121 | accelData.acceleration.x,
122 | accelData.acceleration.y,
123 | accelData.acceleration.z,
124 | nil];
125 | }
126 |
127 | - (void)processGyro:(CMGyroData*)gyroData withError:(NSError*)error {
128 |
129 | rawGyroscopeString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", gyroData.timestamp,
130 | gyroData.rotationRate.x,
131 | gyroData.rotationRate.y,
132 | gyroData.rotationRate.z,
133 | nil];
134 | }
135 |
136 | - (void)processMotion:(CMDeviceMotion*)motion withError:(NSError*)error {
137 |
138 | attitudeString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", motion.timestamp,
139 | motion.attitude.roll,
140 | motion.attitude.pitch,
141 | motion.attitude.yaw,
142 | nil];
143 |
144 | gravityString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", motion.timestamp,
145 | motion.gravity.x,
146 | motion.gravity.y,
147 | motion.gravity.z,
148 | nil];
149 |
150 | magneticFieldString = [NSString stringWithFormat:@"%f,%f,%f,%f,%d\n", motion.timestamp,
151 | motion.magneticField.field.x,
152 | motion.magneticField.field.y,
153 | motion.magneticField.field.z,
154 | (int)motion.magneticField.accuracy,
155 | nil];
156 |
157 | rotationRateString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", motion.timestamp,
158 | motion.rotationRate.x,
159 | motion.rotationRate.y,
160 | motion.rotationRate.z,
161 | nil];
162 |
163 | userAccelerationString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", motion.timestamp,
164 | motion.userAcceleration.x,
165 | motion.userAcceleration.y,
166 | motion.userAcceleration.z,
167 | nil];
168 |
169 | }
170 |
171 |
172 | @end
173 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSAccessoryInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSAccessoryInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSAccessoryInfo : NSObject
12 |
13 | // Accessory Information
14 |
15 | // Are any accessories attached?
16 | + (BOOL)accessoriesAttached;
17 |
18 | // Are headphone attached?
19 | + (BOOL)headphonesAttached;
20 |
21 | // Number of attached accessories
22 | + (NSInteger)numberAttachedAccessories;
23 |
24 | // Name of attached accessory/accessories (seperated by , comma's)
25 | + (nullable NSString *)nameAttachedAccessories;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSAccessoryInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSAccessoryInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSAccessoryInfo.h"
10 |
11 | // Accessory Manager
12 | #import
13 |
14 | // AVFoundation
15 | #import
16 |
17 | @implementation SSAccessoryInfo
18 |
19 | // Accessory Information
20 |
21 | // Are any accessories attached?
22 | + (BOOL)accessoriesAttached {
23 | // Check if any accessories are connected
24 | @try {
25 | // Set up the accessory manger
26 | EAAccessoryManager *accessoryManager = [EAAccessoryManager sharedAccessoryManager];
27 | // Get the number of accessories connected
28 | int numberOfAccessoriesConnected = (int)[accessoryManager.connectedAccessories count];
29 | // Check if there are any connected
30 | if (numberOfAccessoriesConnected > 0) {
31 | // There are accessories connected
32 | return true;
33 | } else {
34 | // There are no accessories connected
35 | return false;
36 | }
37 | }
38 | @catch (NSException *exception) {
39 | // Error, return false
40 | return false;
41 | }
42 | }
43 |
44 | // Are headphone attached?
45 | + (BOOL)headphonesAttached {
46 | // Check if the headphones are connected
47 | @try {
48 | // Get the audiosession route information
49 | AVAudioSessionRouteDescription *route = [[AVAudioSession sharedInstance] currentRoute];
50 |
51 | // Run through all the route outputs
52 | for (AVAudioSessionPortDescription *desc in [route outputs]) {
53 |
54 | // Check if any of the ports are equal to the string headphones
55 | if ([[desc portType] isEqualToString:AVAudioSessionPortHeadphones]) {
56 |
57 | // Return YES
58 | return YES;
59 | }
60 | }
61 |
62 | // No headphones attached
63 | return NO;
64 | }
65 | @catch (NSException *exception) {
66 | // Error, return false
67 | return false;
68 | }
69 | }
70 |
71 | // Number of attached accessories
72 | + (NSInteger)numberAttachedAccessories {
73 | // Get the number of attached accessories
74 | @try {
75 | // Set up the accessory manger
76 | EAAccessoryManager *accessoryManager = [EAAccessoryManager sharedAccessoryManager];
77 | // Get the number of accessories connected
78 | int numberOfAccessoriesConnected = (int)[accessoryManager.connectedAccessories count];
79 | // Return how many accessories are attached
80 | return numberOfAccessoriesConnected;
81 | }
82 | @catch (NSException *exception) {
83 | // Error, return false
84 | return false;
85 | }
86 | }
87 |
88 | // Name of attached accessory/accessories (seperated by , comma's)
89 | + (NSString *)nameAttachedAccessories {
90 | // Get the name of the attached accessories
91 | @try {
92 | // Set up the accessory manger
93 | EAAccessoryManager *accessoryManager = [EAAccessoryManager sharedAccessoryManager];
94 | // Set up an accessory (for later use)
95 | EAAccessory *accessory;
96 | // Get the number of accessories connected
97 | int numberOfAccessoriesConnected = (int)[accessoryManager.connectedAccessories count];
98 |
99 | // Check to make sure there are accessories connected
100 | if (numberOfAccessoriesConnected > 0) {
101 | // Set up a string for all the accessory names
102 | NSString *allAccessoryNames = @"";
103 | // Set up a string for the accessory names
104 | NSString *accessoryName;
105 | // Get the accessories
106 | NSArray *accessoryArray = accessoryManager.connectedAccessories;
107 | // Run through all the accessories
108 | for (int x = 0; x < numberOfAccessoriesConnected; x++) {
109 | // Get the accessory at that index
110 | accessory = [accessoryArray objectAtIndex:x];
111 | // Get the name of it
112 | accessoryName = [accessory name];
113 | // Make sure there is a name
114 | if (accessoryName == nil || accessoryName.length == 0) {
115 | // If there isn't, try and get the manufacturer name
116 | accessoryName = [accessory manufacturer];
117 | }
118 | // Make sure there is a manufacturer name
119 | if (accessoryName == nil || accessoryName.length == 0) {
120 | // If there isn't a manufacturer name still
121 | accessoryName = @"Unknown";
122 | }
123 | // Format that name
124 | allAccessoryNames = [allAccessoryNames stringByAppendingFormat:@"%@", accessoryName];
125 | if (x < numberOfAccessoriesConnected - 1) {
126 | allAccessoryNames = [allAccessoryNames stringByAppendingFormat:@", "];
127 | }
128 | }
129 | // Return the name/s of the connected accessories
130 | return allAccessoryNames;
131 | } else {
132 | // No accessories connected
133 | return nil;
134 | }
135 | }
136 | @catch (NSException *exception) {
137 | // Error, return false
138 | return nil;
139 | }
140 | }
141 |
142 | @end
143 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSApplicationInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSApplicationInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/20/12.
6 | // Created by binaryboy on 10/24/15.
7 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
8 | //
9 |
10 | #import
11 |
12 | @interface SSApplicationInfo : NSObject
13 |
14 | // Application Information
15 |
16 | // Application Version
17 | + (nullable NSString *)applicationVersion;
18 |
19 | // Clipboard Content
20 | + (nullable NSString *)clipboardContent;
21 |
22 | // Application CPU Usage
23 | + (float)cpuUsage;
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSApplicationInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSApplicationInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/20/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSApplicationInfo.h"
10 |
11 | // UIKit
12 | #import
13 |
14 | // mach
15 | #import
16 |
17 | @implementation SSApplicationInfo
18 |
19 | // Application Information
20 |
21 | // Application Version
22 | + (NSString *)applicationVersion {
23 | // Get the Application Version Number
24 | @try {
25 |
26 | // Query the plist for the version
27 | NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
28 |
29 | // Validate the Version
30 | if (version == nil || version.length <= 0) {
31 | // Invalid Version number
32 | return nil;
33 | }
34 | // Successful
35 | return version;
36 | }
37 | @catch (NSException *exception) {
38 | // Error
39 | return nil;
40 | }
41 | }
42 |
43 | // Clipboard Content
44 | + (NSString *)clipboardContent {
45 | // Get the string content of the clipboard (copy, paste)
46 | @try {
47 | // Get the Pasteboard
48 | UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
49 | // Get the string value of the pasteboard
50 | NSString *clipboardContent = [pasteBoard string];
51 | // Check for validity
52 | if (clipboardContent == nil || clipboardContent.length <= 0) {
53 | // Error, invalid pasteboard
54 | return nil;
55 | }
56 | // Successful
57 | return clipboardContent;
58 | }
59 | @catch (NSException *exception) {
60 | // Error
61 | return nil;
62 | }
63 | }
64 |
65 | // Application CPU Usage
66 | + (float)cpuUsage {
67 | @try {
68 | kern_return_t kr;
69 | task_info_data_t tinfo;
70 | mach_msg_type_number_t task_info_count;
71 |
72 | task_info_count = TASK_INFO_MAX;
73 | kr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)tinfo, &task_info_count);
74 | if (kr != KERN_SUCCESS) {
75 | return -1;
76 | }
77 |
78 | task_basic_info_t basic_info;
79 | thread_array_t thread_list;
80 | mach_msg_type_number_t thread_count;
81 |
82 | thread_info_data_t thinfo;
83 | mach_msg_type_number_t thread_info_count;
84 |
85 | thread_basic_info_t basic_info_th;
86 | uint32_t stat_thread = 0; // Mach threads
87 |
88 | basic_info = (task_basic_info_t)tinfo;
89 |
90 | // get threads in the task
91 | kr = task_threads(mach_task_self(), &thread_list, &thread_count);
92 | if (kr != KERN_SUCCESS) {
93 | return -1;
94 | }
95 | if (thread_count > 0)
96 | stat_thread += thread_count;
97 |
98 | long tot_sec = 0;
99 | long tot_usec = 0;
100 | float tot_cpu = 0;
101 | int j;
102 |
103 | for (j = 0; j < thread_count; j++)
104 | {
105 | thread_info_count = THREAD_INFO_MAX;
106 | kr = thread_info(thread_list[j], THREAD_BASIC_INFO,
107 | (thread_info_t)thinfo, &thread_info_count);
108 | if (kr != KERN_SUCCESS) {
109 | return -1;
110 | }
111 |
112 | basic_info_th = (thread_basic_info_t)thinfo;
113 |
114 | if (!(basic_info_th->flags & TH_FLAGS_IDLE)) {
115 | tot_sec = tot_sec + basic_info_th->user_time.seconds + basic_info_th->system_time.seconds;
116 | tot_usec = tot_usec + basic_info_th->system_time.microseconds + basic_info_th->system_time.microseconds;
117 | tot_cpu = tot_cpu + basic_info_th->cpu_usage / (float)TH_USAGE_SCALE * 100.0;
118 | }
119 |
120 | } // for each thread
121 |
122 | kr = vm_deallocate(mach_task_self(), (vm_offset_t)thread_list, thread_count * sizeof(thread_t));
123 | assert(kr == KERN_SUCCESS);
124 |
125 | return tot_cpu;
126 | }
127 | @catch (NSException *exception) {
128 | // Error
129 | return -1;
130 | }
131 | }
132 |
133 | @end
134 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSBatteryInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSBatteryInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/18/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSBatteryInfo : NSObject
12 |
13 | // Battery Information
14 |
15 | // Battery Level
16 | + (float)batteryLevel;
17 |
18 | // Charging?
19 | + (BOOL)charging;
20 |
21 | // Fully Charged?
22 | + (BOOL)fullyCharged;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSBatteryInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSBatteryInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/18/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSBatteryInfo.h"
10 |
11 | // UIKit
12 | #import
13 |
14 | @implementation SSBatteryInfo
15 |
16 | // Battery Information
17 |
18 | // Battery Level
19 | + (float)batteryLevel {
20 | // Find the battery level
21 | @try {
22 | // Get the device
23 | UIDevice *device = [UIDevice currentDevice];
24 | // Set battery monitoring on
25 | device.batteryMonitoringEnabled = YES;
26 |
27 | // Set up the battery level float
28 | float batteryLevel = 0.0;
29 | // Get the battery level
30 | float batteryCharge = [device batteryLevel];
31 |
32 | // Check to make sure the battery level is more than zero
33 | if (batteryCharge > 0.0f) {
34 | // Make the battery level float equal to the charge * 100
35 | batteryLevel = batteryCharge * 100;
36 | } else {
37 | // Unable to find the battery level
38 | return -1;
39 | }
40 |
41 | // Output the battery level
42 | return batteryLevel;
43 | }
44 | @catch (NSException *exception) {
45 | // Error out
46 | return -1;
47 | }
48 | }
49 |
50 | // Charging?
51 | + (BOOL)charging {
52 | // Is the battery charging?
53 | @try {
54 | // Get the device
55 | UIDevice *device = [UIDevice currentDevice];
56 | // Set battery monitoring on
57 | device.batteryMonitoringEnabled = YES;
58 |
59 | // Check the battery state
60 | if ([device batteryState] == UIDeviceBatteryStateCharging || [device batteryState] == UIDeviceBatteryStateFull) {
61 | // Device is charging
62 | return true;
63 | } else {
64 | // Device is not charging
65 | return false;
66 | }
67 | }
68 | @catch (NSException *exception) {
69 | // Error out
70 | return false;
71 | }
72 | }
73 |
74 | // Fully Charged?
75 | + (BOOL)fullyCharged {
76 | // Is the battery fully charged?
77 | @try {
78 | // Get the device
79 | UIDevice *device = [UIDevice currentDevice];
80 | // Set battery monitoring on
81 | device.batteryMonitoringEnabled = YES;
82 |
83 | // Check the battery state
84 | if ([device batteryState] == UIDeviceBatteryStateFull) {
85 | // Device is fully charged
86 | return true;
87 | } else {
88 | // Device is not fully charged
89 | return false;
90 | }
91 | }
92 | @catch (NSException *exception) {
93 | // Error out
94 | return false;
95 | }
96 | }
97 |
98 | @end
99 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSCarrierInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSCarrierInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSCarrierInfo : NSObject
12 |
13 | // Carrier Information
14 |
15 | // Carrier Name
16 | + (nullable NSString *)carrierName;
17 |
18 | // Carrier Country
19 | + (nullable NSString *)carrierCountry;
20 |
21 | // Carrier Mobile Country Code
22 | + (nullable NSString *)carrierMobileCountryCode;
23 |
24 | // Carrier ISO Country Code
25 | + (nullable NSString *)carrierISOCountryCode;
26 |
27 | // Carrier Mobile Network Code
28 | + (nullable NSString *)carrierMobileNetworkCode;
29 |
30 | // Carrier Allows VOIP
31 | + (BOOL)carrierAllowsVOIP;
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSCarrierInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSCarrierInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSCarrierInfo.h"
10 |
11 | // Core Telephony
12 | #import
13 | #import
14 |
15 | @implementation SSCarrierInfo
16 |
17 | // Carrier Information
18 |
19 | // Carrier Name
20 | + (NSString *)carrierName {
21 | // Get the carrier name
22 | @try {
23 | // Get the Telephony Network Info
24 | CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
25 | // Get the carrier
26 | CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
27 | // Get the carrier name
28 | NSString *carrierName = [carrier carrierName];
29 |
30 | // Check to make sure it's valid
31 | if (carrierName == nil || carrierName.length <= 0) {
32 | // Return unknown
33 | return nil;
34 | }
35 |
36 | // Return the name
37 | return carrierName;
38 | }
39 | @catch (NSException *exception) {
40 | // Error finding the name
41 | return nil;
42 | }
43 | }
44 |
45 | // Carrier Country
46 | + (NSString *)carrierCountry {
47 | // Get the country that the carrier is located in
48 | @try {
49 | // Get the locale
50 | NSLocale *currentCountry = [NSLocale currentLocale];
51 | // Get the country Code
52 | NSString *country = [currentCountry objectForKey:NSLocaleCountryCode];
53 | // Check if it returned anything
54 | if (country == nil || country.length <= 0) {
55 | // No country found
56 | return nil;
57 | }
58 | // Return the country
59 | return country;
60 | }
61 | @catch (NSException *exception) {
62 | // Failed, return nil
63 | return nil;
64 | }
65 | }
66 |
67 | // Carrier Mobile Country Code
68 | + (NSString *)carrierMobileCountryCode {
69 | // Get the carrier mobile country code
70 | @try {
71 | // Get the Telephony Network Info
72 | CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
73 | // Get the carrier
74 | CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
75 | // Get the carrier mobile country code
76 | NSString *carrierCode = [carrier mobileCountryCode];
77 |
78 | // Check to make sure it's valid
79 | if (carrierCode == nil || carrierCode.length <= 0) {
80 | // Return unknown
81 | return nil;
82 | }
83 |
84 | // Return the name
85 | return carrierCode;
86 | }
87 | @catch (NSException *exception) {
88 | // Error finding the name
89 | return nil;
90 | }
91 | }
92 |
93 | // Carrier ISO Country Code
94 | + (NSString *)carrierISOCountryCode {
95 | // Get the carrier ISO country code
96 | @try {
97 | // Get the Telephony Network Info
98 | CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
99 | // Get the carrier
100 | CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
101 | // Get the carrier ISO country code
102 | NSString *carrierCode = [carrier isoCountryCode];
103 |
104 | // Check to make sure it's valid
105 | if (carrierCode == nil || carrierCode.length <= 0) {
106 | // Return unknown
107 | return nil;
108 | }
109 |
110 | // Return the name
111 | return carrierCode;
112 | }
113 | @catch (NSException *exception) {
114 | // Error finding the name
115 | return nil;
116 | }
117 | }
118 |
119 | // Carrier Mobile Network Code
120 | + (NSString *)carrierMobileNetworkCode {
121 | // Get the carrier mobile network code
122 | @try {
123 | // Get the Telephony Network Info
124 | CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
125 | // Get the carrier
126 | CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
127 | // Get the carrier mobile network code
128 | NSString *carrierCode = [carrier mobileNetworkCode];
129 |
130 | // Check to make sure it's valid
131 | if (carrierCode == nil || carrierCode.length <= 0) {
132 | // Return unknown
133 | return nil;
134 | }
135 |
136 | // Return the name
137 | return carrierCode;
138 | }
139 | @catch (NSException *exception) {
140 | // Error finding the name
141 | return nil;
142 | }
143 | }
144 |
145 | // Carrier Allows VOIP
146 | + (BOOL)carrierAllowsVOIP {
147 | // Check if the carrier allows VOIP
148 | @try {
149 | // Get the Telephony Network Info
150 | CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
151 | // Get the carrier
152 | CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
153 | // Get the carrier VOIP Status
154 | BOOL carrierVOIP = [carrier allowsVOIP];
155 |
156 | // Return the VOIP Status
157 | return carrierVOIP;
158 | }
159 | @catch (NSException *exception) {
160 | // Error finding the VOIP Status
161 | return false;
162 | }
163 | }
164 |
165 | @end
166 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSDiskInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSDiskInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/18/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSDiskInfo : NSObject
12 |
13 | // Disk Information
14 |
15 | // Total Disk Space
16 | + (nullable NSString *)diskSpace;
17 |
18 | // Total Free Disk Space
19 | + (nullable NSString *)freeDiskSpace:(BOOL)inPercent;
20 |
21 | // Total Used Disk Space
22 | + (nullable NSString *)usedDiskSpace:(BOOL)inPercent;
23 |
24 | // Get the total disk space in long format
25 | + (long long)longDiskSpace;
26 |
27 | // Get the total free disk space in long format
28 | + (long long)longFreeDiskSpace;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSDiskInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSDiskInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/18/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSDiskInfo.h"
10 |
11 | // Memory Info
12 | #define MB (1000*1000)
13 | #define GB (MB*1000)
14 |
15 | @implementation SSDiskInfo
16 |
17 | // Disk Information
18 |
19 | // Total Disk Space
20 | + (NSString *)diskSpace {
21 | // Get the total disk space
22 | @try {
23 | // Get the long total disk space
24 | long long space = [self longDiskSpace];
25 |
26 | // Check to make sure it's valid
27 | if (space <= 0) {
28 | // Error, no disk space found
29 | return nil;
30 | }
31 |
32 | // Turn that long long into a string
33 | NSString *diskSpace = [self formatMemory:space];
34 |
35 | // Check to make sure it's valid
36 | if (diskSpace == nil || diskSpace.length <= 0) {
37 | // Error, diskspace not given
38 | return nil;
39 | }
40 |
41 | // Return successful
42 | return diskSpace;
43 | }
44 | @catch (NSException * ex) {
45 | // Error
46 | return nil;
47 | }
48 | }
49 |
50 | // Total Free Disk Space
51 | + (NSString *)freeDiskSpace:(BOOL)inPercent {
52 | // Get the total free disk space
53 | @try {
54 | // Get the long size of free space
55 | long long Space = [self longFreeDiskSpace];
56 |
57 | // Check to make sure it's valid
58 | if (Space <= 0) {
59 | // Error, no disk space found
60 | return nil;
61 | }
62 |
63 | // Set up the string output variable
64 | NSString *diskSpace;
65 |
66 | // If the user wants the output in percentage
67 | if (inPercent) {
68 | // Get the total amount of space
69 | long long TotalSpace = [self longDiskSpace];
70 | // Make a float to get the percent of those values
71 | float PercentDiskSpace = (Space * 100) / TotalSpace;
72 | // Check it to make sure it's okay
73 | if (PercentDiskSpace <= 0) {
74 | // Error, invalid percent
75 | return nil;
76 | }
77 | // Convert that float to a string
78 | diskSpace = [NSString stringWithFormat:@"%.f%%", PercentDiskSpace];
79 | } else {
80 | // Turn that long long into a string
81 | diskSpace = [self formatMemory:Space];
82 | }
83 |
84 | // Check to make sure it's valid
85 | if (diskSpace == nil || diskSpace.length <= 0) {
86 | // Error, diskspace not given
87 | return nil;
88 | }
89 |
90 | // Return successful
91 | return diskSpace;
92 | }
93 | @catch (NSException * ex) {
94 | // Error
95 | return nil;
96 | }
97 | }
98 |
99 | // Total Used Disk Space
100 | + (NSString *)usedDiskSpace:(BOOL)inPercent {
101 | // Get the total used disk space
102 | @try {
103 | // Make a variable to hold the Used Disk Space
104 | long long uds;
105 | // Get the long total disk space
106 | long long tds = [self longDiskSpace];
107 | // Get the long free disk space
108 | long long fds = [self longFreeDiskSpace];
109 |
110 | // Make sure they're valid
111 | if (tds <= 0 || fds <= 0) {
112 | // Error, invalid values
113 | return nil;
114 | }
115 |
116 | // Now subtract the free space from the total space
117 | uds = tds - fds;
118 |
119 | // Make sure it's valid
120 | if (uds <= 0) {
121 | // Error, invalid value
122 | return nil;
123 | }
124 |
125 | // Set up the string output variable
126 | NSString *usedDiskSpace;
127 |
128 | // If the user wants the output in percentage
129 | if (inPercent) {
130 | // Make a float to get the percent of those values
131 | float percentUsedDiskSpace = (uds * 100) / tds;
132 | // Check it to make sure it's okay
133 | if (percentUsedDiskSpace <= 0) {
134 | // Error, invalid percent
135 | return nil;
136 | }
137 | // Convert that float to a string
138 | usedDiskSpace = [NSString stringWithFormat:@"%.f%%", percentUsedDiskSpace];
139 | } else {
140 | // Turn that long long into a string
141 | usedDiskSpace = [self formatMemory:uds];
142 | }
143 |
144 | // Check to make sure it's valid
145 | if (usedDiskSpace == nil || usedDiskSpace.length <= 0) {
146 | // Error, diskspace not given
147 | return nil;
148 | }
149 |
150 | // Return successful
151 | return usedDiskSpace;
152 |
153 | // Now convert that to a string
154 | }
155 | @catch (NSException *exception) {
156 | // Error
157 | return nil;
158 | }
159 | }
160 |
161 | #pragma mark - Disk Information Long Values
162 |
163 | // Get the total disk space in long format
164 | + (long long)longDiskSpace {
165 | // Get the long long disk space
166 | @try {
167 | // Set up variables
168 | long long diskSpace = 0L;
169 | NSError *error = nil;
170 | NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:&error];
171 |
172 | // Get the file attributes of the home directory assuming no errors
173 | if (error == nil) {
174 | // Get the size of the filesystem
175 | diskSpace = [[fileAttributes objectForKey:NSFileSystemSize] longLongValue];
176 | } else {
177 | // Error, return nil
178 | return -1;
179 | }
180 |
181 | // Check to make sure it's a valid size
182 | if (diskSpace <= 0) {
183 | // Invalid size
184 | return -1;
185 | }
186 |
187 | // Successful
188 | return diskSpace;
189 | }
190 | @catch (NSException *exception) {
191 | // Error
192 | return -1;
193 | }
194 | }
195 |
196 | // Get the total free disk space in long format
197 | + (long long)longFreeDiskSpace {
198 | // Get the long total free disk space
199 | @try {
200 | // Set up the variables
201 | long long FreeDiskSpace = 0L;
202 | NSError *error = nil;
203 | NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:&error];
204 |
205 | // Get the file attributes of the home directory assuming no errors
206 | if (error == nil) {
207 | FreeDiskSpace = [[fileAttributes objectForKey:NSFileSystemFreeSize] longLongValue];
208 | } else {
209 | // There was an error
210 | return -1;
211 | }
212 |
213 | // Check for valid size
214 | if (FreeDiskSpace <= 0) {
215 | // Invalid size
216 | return -1;
217 | }
218 |
219 | // Successful
220 | return FreeDiskSpace;
221 | }
222 | @catch (NSException *exception) {
223 | // Error
224 | return -1;
225 | }
226 | }
227 |
228 | #pragma mark - Memory Value Formatting
229 |
230 | // Format the memory to a string in GB, MB, or Bytes
231 | + (NSString *)formatMemory:(long long)Space {
232 | // Format the long long disk space
233 | @try {
234 | // Set up the string
235 | NSString *formattedBytes = nil;
236 |
237 | // Get the bytes, megabytes, and gigabytes
238 | double numberBytes = 1.0 * Space;
239 | double totalGB = numberBytes / GB;
240 | double totalMB = numberBytes / MB;
241 |
242 | // Display them appropriately
243 | if (totalGB >= 1.0) {
244 | formattedBytes = [NSString stringWithFormat:@"%.2f GB", totalGB];
245 | } else if (totalMB >= 1)
246 | formattedBytes = [NSString stringWithFormat:@"%.2f MB", totalMB];
247 | else {
248 | formattedBytes = [self formattedMemory:Space];
249 | formattedBytes = [formattedBytes stringByAppendingString:@" bytes"];
250 | }
251 |
252 | // Check for errors
253 | if (formattedBytes == nil || formattedBytes.length <= 0) {
254 | // Error, invalid string
255 | return nil;
256 | }
257 |
258 | // Completed Successfully
259 | return formattedBytes;
260 | }
261 | @catch (NSException *exception) {
262 | // Error
263 | return nil;
264 | }
265 | }
266 |
267 | // Format bytes to a string
268 | + (NSString *)formattedMemory:(unsigned long long)Space {
269 | // Format for bytes
270 | @try {
271 | // Set up the string variable
272 | NSString *formattedBytes = nil;
273 |
274 | // Set up the format variable
275 | NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
276 |
277 | // Format the bytes
278 | [formatter setPositiveFormat:@"###,###,###,###"];
279 |
280 | // Get the bytes
281 | NSNumber *theNumber = [NSNumber numberWithLongLong:Space];
282 |
283 | // Format the bytes appropriately
284 | formattedBytes = [formatter stringFromNumber:theNumber];
285 |
286 | // Check for errors
287 | if (formattedBytes == nil || formattedBytes.length <= 0) {
288 | // Error, invalid value
289 | return nil;
290 | }
291 |
292 | // Completed Successfully
293 | return formattedBytes;
294 | }
295 | @catch (NSException *exception) {
296 | // Error
297 | return nil;
298 | }
299 | }
300 |
301 | @end
302 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSHardwareInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSHardwareInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/15/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSHardwareInfo : NSObject
12 |
13 | // System Hardware Information
14 |
15 | // System Uptime (dd hh mm)
16 | + (nullable NSString *)systemUptime;
17 |
18 | // Model of Device
19 | + (nullable NSString *)deviceModel;
20 |
21 | // Device Name
22 | + (nullable NSString *)deviceName;
23 |
24 | // System Name
25 | + (nullable NSString *)systemName;
26 |
27 | // System Version
28 | + (nullable NSString *)systemVersion;
29 |
30 | // System Device Type (iPhone1,0) (Formatted = iPhone 1)
31 | + (nullable NSString *)systemDeviceTypeFormatted:(BOOL)formatted;
32 |
33 | // Get the Screen Width (X)
34 | + (NSInteger)screenWidth;
35 |
36 | // Get the Screen Height (Y)
37 | + (NSInteger)screenHeight;
38 |
39 | // Get the Screen Brightness
40 | + (float)screenBrightness;
41 |
42 | // Multitasking enabled?
43 | + (BOOL)multitaskingEnabled;
44 |
45 | // Proximity sensor enabled?
46 | + (BOOL)proximitySensorEnabled;
47 |
48 | // Debugger Attached?
49 | + (BOOL)debuggerAttached;
50 |
51 | // Plugged In?
52 | + (BOOL)pluggedIn;
53 |
54 | // Step-Counting Available?
55 | + (BOOL)stepCountingAvailable;
56 |
57 | // Distance Available
58 | + (BOOL)distanceAvailable;
59 |
60 | // Floor Counting Available
61 | + (BOOL)floorCountingAvailable;
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSHardwareInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSHardwareInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/15/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSHardwareInfo.h"
10 |
11 | // UIKit
12 | #import
13 |
14 | // Core Motion
15 | #import
16 |
17 | // sysctl
18 | #import
19 | // utsname
20 | #import
21 |
22 | static BOOL sCachedIsProximityEnabled = false;
23 |
24 | @implementation SSHardwareInfo
25 |
26 | // System Hardware Information
27 |
28 | // System Uptime (dd hh mm)
29 | + (NSString *)systemUptime {
30 | // Set up the days/hours/minutes
31 | NSNumber *days, *hours, *minutes;
32 |
33 | // Get the info about a process
34 | NSProcessInfo *processInfo = [NSProcessInfo processInfo];
35 | // Get the uptime of the system
36 | NSTimeInterval uptimeInterval = [processInfo systemUptime];
37 | // Get the calendar
38 | NSCalendar *calendar = [NSCalendar currentCalendar];
39 | // Create the Dates
40 | NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:(0-uptimeInterval)];
41 | unsigned int unitFlags = NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute;
42 | NSDateComponents *components = [calendar components:unitFlags fromDate:date toDate:[NSDate date] options:0];
43 |
44 | // Get the day, hour and minutes
45 | days = [NSNumber numberWithLong:[components day]];
46 | hours = [NSNumber numberWithLong:[components hour]];
47 | minutes = [NSNumber numberWithLong:[components minute]];
48 |
49 | // Format the dates
50 | NSString *uptime = [NSString stringWithFormat:@"%@ %@ %@",
51 | [days stringValue],
52 | [hours stringValue],
53 | [minutes stringValue]];
54 |
55 | // Error checking
56 | if (!uptime) {
57 | // No uptime found
58 | // Return nil
59 | return nil;
60 | }
61 |
62 | // Return the uptime
63 | return uptime;
64 | }
65 |
66 | // Model of Device
67 | + (NSString *)deviceModel {
68 | // Get the device model
69 | if ([[UIDevice currentDevice] respondsToSelector:@selector(model)]) {
70 | // Make a string for the device model
71 | NSString *deviceModel = [[UIDevice currentDevice] model];
72 | // Set the output to the device model
73 | return deviceModel;
74 | } else {
75 | // Device model not found
76 | return nil;
77 | }
78 | }
79 |
80 | // Device Name
81 | + (NSString *)deviceName {
82 | // Get the current device name
83 | if ([[UIDevice currentDevice] respondsToSelector:@selector(name)]) {
84 | // Make a string for the device name
85 | NSString *deviceName = [[UIDevice currentDevice] name];
86 | // Set the output to the device name
87 | return deviceName;
88 | } else {
89 | // Device name not found
90 | return nil;
91 | }
92 | }
93 |
94 | // System Name
95 | + (NSString *)systemName {
96 | // Get the current system name
97 | if ([[UIDevice currentDevice] respondsToSelector:@selector(systemName)]) {
98 | // Make a string for the system name
99 | NSString *systemName = [[UIDevice currentDevice] systemName];
100 | // Set the output to the system name
101 | return systemName;
102 | } else {
103 | // System name not found
104 | return nil;
105 | }
106 | }
107 |
108 | // System Version
109 | + (NSString *)systemVersion {
110 | // Get the current system version
111 | if ([[UIDevice currentDevice] respondsToSelector:@selector(systemVersion)]) {
112 | // Make a string for the system version
113 | NSString *systemVersion = [[UIDevice currentDevice] systemVersion];
114 | // Set the output to the system version
115 | return systemVersion;
116 | } else {
117 | // System version not found
118 | return nil;
119 | }
120 | }
121 |
122 | // System Device Type (iPhone1,0) (Formatted = iPhone 1)
123 | + (NSString *)systemDeviceTypeFormatted:(BOOL)formatted {
124 | // Set up a Device Type String
125 | NSString *deviceType;
126 |
127 | // Check if it should be formatted
128 | if (formatted) {
129 | // Formatted
130 | @try {
131 | // Set up a new Device Type String
132 | NSString *newDeviceType;
133 | // Set up a struct
134 | struct utsname dt;
135 | // Get the system information
136 | uname(&dt);
137 | // Set the device type to the machine type
138 | deviceType = [NSString stringWithFormat:@"%s", dt.machine];
139 |
140 | // Simulators
141 | if ([deviceType isEqualToString:@"i386"])
142 | newDeviceType = @"iPhone Simulator";
143 | else if ([deviceType isEqualToString:@"x86_64"])
144 | newDeviceType = @"iPhone Simulator";
145 | // iPhones
146 | else if ([deviceType isEqualToString:@"iPhone1,1"])
147 | newDeviceType = @"iPhone";
148 | else if ([deviceType isEqualToString:@"iPhone1,2"])
149 | newDeviceType = @"iPhone 3G";
150 | else if ([deviceType isEqualToString:@"iPhone2,1"])
151 | newDeviceType = @"iPhone 3GS";
152 | else if ([deviceType isEqualToString:@"iPhone3,1"])
153 | newDeviceType = @"iPhone 4";
154 | else if ([deviceType isEqualToString:@"iPhone4,1"])
155 | newDeviceType = @"iPhone 4S";
156 | else if ([deviceType isEqualToString:@"iPhone5,1"])
157 | newDeviceType = @"iPhone 5 (GSM)";
158 | else if ([deviceType isEqualToString:@"iPhone5,2"])
159 | newDeviceType = @"iPhone 5 (GSM+CDMA)";
160 | else if ([deviceType isEqualToString:@"iPhone5,3"])
161 | newDeviceType = @"iPhone 5c (GSM)";
162 | else if ([deviceType isEqualToString:@"iPhone5,4"])
163 | newDeviceType = @"iPhone 5c (GSM+CDMA)";
164 | else if ([deviceType isEqualToString:@"iPhone6,1"])
165 | newDeviceType = @"iPhone 5s (GSM)";
166 | else if ([deviceType isEqualToString:@"iPhone6,2"])
167 | newDeviceType = @"iPhone 5s (GSM+CDMA)";
168 | else if ([deviceType isEqualToString:@"iPhone7,1"])
169 | newDeviceType = @"iPhone 6 Plus";
170 | else if ([deviceType isEqualToString:@"iPhone7,2"])
171 | newDeviceType = @"iPhone 6";
172 | else if ([deviceType isEqualToString:@"iPhone8,1"])
173 | newDeviceType = @"iPhone 6s";
174 | else if ([deviceType isEqualToString:@"iPhone8,2"])
175 | newDeviceType = @"iPhone 6s Plus";
176 | else if ([deviceType isEqualToString:@"iPhone8,4"])
177 | newDeviceType = @"iPhone SE";
178 | else if ([deviceType isEqualToString:@"iPhone9,1"])
179 | newDeviceType = @"iPhone 7 (CDMA+GSM/LTE)";
180 | else if ([deviceType isEqualToString:@"iPhone9,3"])
181 | newDeviceType = @"iPhone 7 (GSM/LTE)";
182 | else if ([deviceType isEqualToString:@"iPhone9,2"])
183 | newDeviceType = @"iPhone 7 Plus (CDMA+GSM/LTE)";
184 | else if ([deviceType isEqualToString:@"iPhone9,4"])
185 | newDeviceType = @"iPhone 7 Plus (GSM/LTE)";
186 | else if ([deviceType isEqualToString:@"iPhone10,1"])
187 | newDeviceType = @"iPhone 8 (CDMA+GSM/LTE)";
188 | else if ([deviceType isEqualToString:@"iPhone10,2"])
189 | newDeviceType = @"iPhone 8 Plus (CDMA+GSM/LTE)";
190 | else if ([deviceType isEqualToString:@"iPhone10,3"])
191 | newDeviceType = @"iPhone X (CDMA+GSM/LTE)";
192 | else if ([deviceType isEqualToString:@"iPhone10,4"])
193 | newDeviceType = @"iPhone 8 (GSM/LTE)";
194 | else if ([deviceType isEqualToString:@"iPhone10,5"])
195 | newDeviceType = @"iPhone 8 Plus (GSM/LTE)";
196 | else if ([deviceType isEqualToString:@"iPhone10,6"])
197 | newDeviceType = @"iPhone X (GSM/LTE)";
198 | else if ([deviceType isEqualToString:@"iPhone11,2"])
199 | newDeviceType = @"iPhone XS";
200 | else if ([deviceType isEqualToString:@"iPhone11,4"])
201 | newDeviceType = @"iPhone XS MAX";
202 | else if ([deviceType isEqualToString:@"iPhone11,6"])
203 | newDeviceType = @"iPhone XS MAX (CDMA+GSM/LTE)";
204 | else if ([deviceType isEqualToString:@"iPhone11,8"])
205 | newDeviceType = @"iPhone XR";
206 | // iPods
207 | else if ([deviceType isEqualToString:@"iPod1,1"])
208 | newDeviceType = @"iPod Touch 1G";
209 | else if ([deviceType isEqualToString:@"iPod2,1"])
210 | newDeviceType = @"iPod Touch 2G";
211 | else if ([deviceType isEqualToString:@"iPod3,1"])
212 | newDeviceType = @"iPod Touch 3G";
213 | else if ([deviceType isEqualToString:@"iPod4,1"])
214 | newDeviceType = @"iPod Touch 4G";
215 | else if ([deviceType isEqualToString:@"iPod5,1"])
216 | newDeviceType = @"iPod Touch 5G";
217 | else if ([deviceType isEqualToString:@"iPod7,1"])
218 | newDeviceType = @"iPod Touch 6G";
219 | // iPads
220 | else if ([deviceType isEqualToString:@"iPad1,1"])
221 | newDeviceType = @"iPad";
222 | else if ([deviceType isEqualToString:@"iPad2,1"])
223 | newDeviceType = @"iPad 2 (WiFi)";
224 | else if ([deviceType isEqualToString:@"iPad2,2"])
225 | newDeviceType = @"iPad 2 (GSM)";
226 | else if ([deviceType isEqualToString:@"iPad2,3"])
227 | newDeviceType = @"iPad 2 (CDMA)";
228 | else if ([deviceType isEqualToString:@"iPad2,4"])
229 | newDeviceType = @"iPad 2 (WiFi + New Chip)";
230 | else if ([deviceType isEqualToString:@"iPad2,5"])
231 | newDeviceType = @"iPad mini (WiFi)";
232 | else if ([deviceType isEqualToString:@"iPad2,6"])
233 | newDeviceType = @"iPad mini (GSM)";
234 | else if ([deviceType isEqualToString:@"iPad2,7"])
235 | newDeviceType = @"iPad mini (GSM+CDMA)";
236 | else if ([deviceType isEqualToString:@"iPad3,1"])
237 | newDeviceType = @"iPad 3 (WiFi)";
238 | else if ([deviceType isEqualToString:@"iPad3,2"])
239 | newDeviceType = @"iPad 3 (GSM)";
240 | else if ([deviceType isEqualToString:@"iPad3,3"])
241 | newDeviceType = @"iPad 3 (GSM+CDMA)";
242 | else if ([deviceType isEqualToString:@"iPad3,4"])
243 | newDeviceType = @"iPad 4 (WiFi)";
244 | else if ([deviceType isEqualToString:@"iPad3,5"])
245 | newDeviceType = @"iPad 4 (GSM)";
246 | else if ([deviceType isEqualToString:@"iPad3,6"])
247 | newDeviceType = @"iPad 4 (GSM+CDMA)";
248 | else if ([deviceType isEqualToString:@"iPad4,1"])
249 | newDeviceType = @"iPad Air (WiFi)";
250 | else if ([deviceType isEqualToString:@"iPad4,2"])
251 | newDeviceType = @"iPad Air (Cellular)";
252 | else if ([deviceType isEqualToString:@"iPad4,3"])
253 | newDeviceType = @"iPad Air (China)";
254 | else if ([deviceType isEqualToString:@"iPad4,4"])
255 | newDeviceType = @"iPad mini 2 (WiFi)";
256 | else if ([deviceType isEqualToString:@"iPad4,5"])
257 | newDeviceType = @"iPad mini 2 (Cellular)";
258 | else if ([deviceType isEqualToString:@"iPad5,1"])
259 | newDeviceType = @"iPad mini 4 (WiFi)";
260 | else if ([deviceType isEqualToString:@"iPad5,2"])
261 | newDeviceType = @"iPad mini 4 (Cellular)";
262 | else if ([deviceType isEqualToString:@"iPad5,4"])
263 | newDeviceType = @"iPad Air 2 (WiFi)";
264 | else if ([deviceType isEqualToString:@"iPad5,5"])
265 | newDeviceType = @"iPad Air 2 (Cellular)";
266 | else if ([deviceType isEqualToString:@"iPad6,3"])
267 | newDeviceType = @"9.7-inch iPad Pro (WiFi)";
268 | else if ([deviceType isEqualToString:@"iPad6,4"])
269 | newDeviceType = @"9.7-inch iPad Pro (Cellular)";
270 | else if ([deviceType isEqualToString:@"iPad6,7"])
271 | newDeviceType = @"12.9-inch iPad Pro (WiFi)";
272 | else if ([deviceType isEqualToString:@"iPad6,8"])
273 | newDeviceType = @"12.9-inch iPad Pro (Cellular)";
274 | else if ([deviceType isEqualToString:@"iPad6,11"])
275 | newDeviceType = @"iPad 5 (WiFi)";
276 | else if ([deviceType isEqualToString:@"iPad6,12"])
277 | newDeviceType = @"iPad 5 (Cellular)";
278 | else if ([deviceType isEqualToString:@"iPad7,1"])
279 | newDeviceType = @"iPad Pro 12.9 (2nd Gen - WiFi)";
280 | else if ([deviceType isEqualToString:@"iPad7,2"])
281 | newDeviceType = @"iPad Pro 12.9 (2nd Gen - Cellular)";
282 | else if ([deviceType isEqualToString:@"iPad7,3"])
283 | newDeviceType = @"iPad Pro 10.5 (WiFi)";
284 | else if ([deviceType isEqualToString:@"iPad7,4"])
285 | newDeviceType = @"iPad Pro 10.5 (Cellular)";
286 | else if ([deviceType isEqualToString:@"iPad7,5"])
287 | newDeviceType = @"iPad 6 (WiFi)";
288 | else if ([deviceType isEqualToString:@"iPad7,6"])
289 | newDeviceType = @"iPad 6 (WiFi+Cellular)";
290 | else if ([deviceType isEqualToString:@"iPad8,1"])
291 | newDeviceType = @"iPad Pro 11 (3rd Gen - WiFi)";
292 | else if ([deviceType isEqualToString:@"iPad8,2"])
293 | newDeviceType = @"iPad Pro 11 (3rd Gen - 1TB, WiFi)";
294 | else if ([deviceType isEqualToString:@"iPad8,3"])
295 | newDeviceType = @"iPad Pro 11 (3rd Gen - WiFi+Cellular)";
296 | else if ([deviceType isEqualToString:@"iPad8,4"])
297 | newDeviceType = @"iPad Pro 11 (3rd Gen - 1TB, WiFi+Cellular)";
298 | else if ([deviceType isEqualToString:@"iPad8,5"])
299 | newDeviceType = @"iPad Pro 12.9 (3rd Gen - WiFi)";
300 | else if ([deviceType isEqualToString:@"iPad8,6"])
301 | newDeviceType = @"iPad Pro 12.9 (3rd Gen - 1TB, WiFi)";
302 | else if ([deviceType isEqualToString:@"iPad8,7"])
303 | newDeviceType = @"iPad Pro 12.9 (3rd Gen - WiFi+Cellular)";
304 | else if ([deviceType isEqualToString:@"iPad8,8"])
305 | newDeviceType = @"iPad Pro 12.9 (3rd Gen - 1TB, WiFi+Cellular)";
306 | // Catch All iPad
307 | else if ([deviceType hasPrefix:@"iPad"])
308 | newDeviceType = @"iPad";
309 | // Apple TV
310 | else if ([deviceType isEqualToString:@"AppleTV2,1"])
311 | newDeviceType = @"Apple TV 2";
312 | else if ([deviceType isEqualToString:@"AppleTV3,1"])
313 | newDeviceType = @"Apple TV 3";
314 | else if ([deviceType isEqualToString:@"AppleTV3,2"])
315 | newDeviceType = @"Apple TV 3 (2013)";
316 |
317 | // Return the new device type
318 | return newDeviceType;
319 | }
320 | @catch (NSException *exception) {
321 | // Error
322 | return nil;
323 | }
324 | } else {
325 | // Unformatted
326 | @try {
327 | // Set up a struct
328 | struct utsname dt;
329 | // Get the system information
330 | uname(&dt);
331 | // Set the device type to the machine type
332 | deviceType = [NSString stringWithFormat:@"%s", dt.machine];
333 |
334 | // Return the device type
335 | return deviceType;
336 | }
337 | @catch (NSException *exception) {
338 | // Error
339 | return nil;
340 | }
341 | }
342 | }
343 |
344 | // Get the Screen Width (X)
345 | + (NSInteger)screenWidth {
346 | // Get the screen width
347 | @try {
348 | // Screen bounds
349 | CGRect Rect = [[UIScreen mainScreen] bounds];
350 | // Find the width (X)
351 | NSInteger Width = Rect.size.width;
352 | // Verify validity
353 | if (Width <= 0) {
354 | // Invalid Width
355 | return -1;
356 | }
357 |
358 | // Successful
359 | return Width;
360 | }
361 | @catch (NSException *exception) {
362 | // Error
363 | return -1;
364 | }
365 | }
366 |
367 | // Get the Screen Height (Y)
368 | + (NSInteger)screenHeight {
369 | // Get the screen height
370 | @try {
371 | // Screen bounds
372 | CGRect Rect = [[UIScreen mainScreen] bounds];
373 | // Find the Height (Y)
374 | NSInteger Height = Rect.size.height;
375 | // Verify validity
376 | if (Height <= 0) {
377 | // Invalid Height
378 | return -1;
379 | }
380 |
381 | // Successful
382 | return Height;
383 | }
384 | @catch (NSException *exception) {
385 | // Error
386 | return -1;
387 | }
388 | }
389 |
390 | // Get the Screen Brightness
391 | + (float)screenBrightness {
392 | // Get the screen brightness
393 | @try {
394 | // Brightness
395 | float brightness = [UIScreen mainScreen].brightness;
396 | // Verify validity
397 | if (brightness < 0.0 || brightness > 1.0) {
398 | // Invalid brightness
399 | return -1;
400 | }
401 |
402 | // Successful
403 | return (brightness * 100);
404 | }
405 | @catch (NSException *exception) {
406 | // Error
407 | return -1;
408 | }
409 | }
410 |
411 | // Multitasking enabled?
412 | + (BOOL)multitaskingEnabled {
413 | // Is multitasking enabled?
414 | if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) {
415 | // Create a bool
416 | BOOL MultitaskingSupported = [UIDevice currentDevice].multitaskingSupported;
417 | // Return the value
418 | return MultitaskingSupported;
419 | } else {
420 | // Doesn't respond to selector
421 | return false;
422 | }
423 | }
424 |
425 | // Proximity sensor enabled?
426 | + (BOOL)proximitySensorEnabled {
427 | if (![NSThread isMainThread]) {
428 | return sCachedIsProximityEnabled;
429 | }
430 |
431 | // Is the proximity sensor enabled?
432 | if ([[UIDevice currentDevice] respondsToSelector:@selector(setProximityMonitoringEnabled:)]) {
433 | // Create a UIDevice variable
434 | UIDevice *device = [UIDevice currentDevice];
435 |
436 | // Make a Bool for the proximity Sensor
437 | BOOL ProximitySensor;
438 |
439 | // Turn the sensor on, if not already on, and see if it works
440 | if (device.proximityMonitoringEnabled != YES) {
441 | // Sensor is off
442 | // Turn it on
443 | [device setProximityMonitoringEnabled:YES];
444 | // See if it turned on
445 | if (device.proximityMonitoringEnabled == YES) {
446 | // It turned on! Turn it off
447 | [device setProximityMonitoringEnabled:NO];
448 | // It works
449 | ProximitySensor = true;
450 | } else {
451 | // Didn't turn on, no good
452 | ProximitySensor = false;
453 | }
454 | } else {
455 | // Sensor is already on
456 | ProximitySensor = true;
457 | }
458 |
459 | // Return on or off
460 | sCachedIsProximityEnabled = ProximitySensor;
461 | return ProximitySensor;
462 | } else {
463 | // Doesn't respond to selector
464 | sCachedIsProximityEnabled = false;
465 | return false;
466 | }
467 | }
468 |
469 | // Debugging attached?
470 | + (BOOL)debuggerAttached {
471 | // Is the debugger attached?
472 | @try {
473 | // Set up the variables
474 | int ret;
475 | int mib[4];
476 | struct kinfo_proc info;
477 | size_t size;
478 | info.kp_proc.p_flag = 0;
479 | mib[0] = CTL_KERN;
480 | mib[1] = KERN_PROC;
481 | mib[2] = KERN_PROC_PID;
482 | mib[3] = getpid();
483 | size = sizeof(info);
484 | ret = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
485 |
486 | // Verify ret
487 | if (ret) {
488 | // Sysctl() failed
489 | // Return the output of sysctl
490 | return ret;
491 | }
492 |
493 | // Return whether the process is being traced or not
494 | return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
495 |
496 | }
497 | @catch (NSException *exception) {
498 | // Error
499 | return false;
500 | }
501 | }
502 |
503 | // Plugged In?
504 | + (BOOL)pluggedIn {
505 | // Is the device plugged in?
506 | if ([[UIDevice currentDevice] respondsToSelector:@selector(batteryState)]) {
507 | // Create a bool
508 | BOOL PluggedIn;
509 | // Set the battery monitoring enabled
510 | [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
511 | // Get the battery state
512 | UIDeviceBatteryState batteryState = [UIDevice currentDevice].batteryState;
513 | // Check if it's plugged in or finished charging
514 | if (batteryState == UIDeviceBatteryStateCharging || batteryState == UIDeviceBatteryStateFull) {
515 | // We're plugged in
516 | PluggedIn = true;
517 | } else {
518 | PluggedIn = false;
519 | }
520 | // Return the value
521 | return PluggedIn;
522 | } else {
523 | // Doesn't respond to selector
524 | return false;
525 | }
526 | }
527 |
528 | // Step-Counting Available?
529 | + (BOOL)stepCountingAvailable {
530 | @try {
531 | // Make sure the Pedometer class exists
532 | if ([CMPedometer class]) {
533 | // Make sure the selector exists
534 | if ([CMPedometer respondsToSelector:@selector(isStepCountingAvailable)]) {
535 | // Return whether it's available
536 | return [CMPedometer isStepCountingAvailable];
537 | }
538 | }
539 | // Not available
540 | return false;
541 | }
542 | @catch (NSException *exception) {
543 | // Error
544 | return false;
545 | }
546 | }
547 |
548 | // Distance Available
549 | + (BOOL)distanceAvailable {
550 | @try {
551 | // Make sure the Pedometer class exists
552 | if ([CMPedometer class]) {
553 | // Make sure the selector exists
554 | if ([CMPedometer respondsToSelector:@selector(isDistanceAvailable)]) {
555 | // Return whether it's available
556 | return [CMPedometer isDistanceAvailable];
557 | }
558 | }
559 | // Not available
560 | return false;
561 | }
562 | @catch (NSException *exception) {
563 | // Error
564 | return false;
565 | }
566 | }
567 |
568 | // Floor Counting Available
569 | + (BOOL)floorCountingAvailable {
570 | @try {
571 | // Make sure the Pedometer class exists
572 | if ([CMPedometer class]) {
573 | // Make sure the selector exists
574 | if ([CMPedometer respondsToSelector:@selector(isFloorCountingAvailable)]) {
575 | // Return whether it's available
576 | return [CMPedometer isFloorCountingAvailable];
577 | }
578 | }
579 | // Not available
580 | return false;
581 | }
582 | @catch (NSException *exception) {
583 | // Error
584 | return false;
585 | }
586 | }
587 |
588 | @end
589 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSJailbreakCheck.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSJailbreakCheck.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | /* Jailbreak Check Definitions */
12 |
13 | #define NOTJAIL 4783242
14 |
15 | // Define the filesystem check
16 | #define FILECHECK [NSFileManager defaultManager] fileExistsAtPath:
17 | // Define the exe path
18 | #define EXEPATH [[NSBundle mainBundle] executablePath]
19 | // Define the plist path
20 | #define PLISTPATH [[NSBundle mainBundle] infoDictionary]
21 |
22 | // Jailbreak Check Definitions
23 | #define CYDIAPACKAGE @"cydia://package/com.fake.package"
24 | #define CYDIALOC @"/Applications/Cydia.app"
25 | #define HIDDENFILES [NSArray arrayWithObjects:@"/Applications/RockApp.app",@"/Applications/Icy.app",@"/usr/sbin/sshd",@"/usr/bin/sshd",@"/usr/libexec/sftp-server",@"/Applications/WinterBoard.app",@"/Applications/SBSettings.app",@"/Applications/MxTube.app",@"/Applications/IntelliScreen.app",@"/Library/MobileSubstrate/DynamicLibraries/Veency.plist",@"/Library/MobileSubstrate/DynamicLibraries/LiveClock.plist",@"/private/var/lib/apt",@"/private/var/stash",@"/System/Library/LaunchDaemons/com.ikey.bbot.plist",@"/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist",@"/private/var/tmp/cydia.log",@"/private/var/lib/cydia", @"/etc/clutch.conf", @"/var/cache/clutch.plist", @"/etc/clutch_cracked.plist", @"/var/cache/clutch_cracked.plist", @"/var/lib/clutch/overdrive.dylib", @"/var/root/Documents/Cracked/", nil]
26 |
27 | /* End Jailbreak Definitions */
28 |
29 | @interface SSJailbreakCheck : NSObject
30 |
31 | // Jailbreak Check
32 |
33 | // Jailbroken?
34 | + (int)jailbroken;
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSJailbreakCheck.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSJailbreakCheck.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | /* Check out "Hacking and Securing iOS Applications" Book to determine all available methods */
10 |
11 | #import "SSJailbreakCheck.h"
12 |
13 | // UIKit
14 | #import
15 |
16 | // stat
17 | #import
18 |
19 | // sysctl
20 | #import
21 |
22 | // System Version Less Than
23 | #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
24 |
25 | // Failed jailbroken checks
26 | enum {
27 | // Failed the Jailbreak Check
28 | KFJailbroken = 3429542,
29 | // Failed the OpenURL Check
30 | KFOpenURL = 321,
31 | // Failed the Cydia Check
32 | KFCydia = 432,
33 | // Failed the Inaccessible Files Check
34 | KFIFC = 47293,
35 | // Failed the plist check
36 | KFPlist = 9412,
37 | // Failed the Symbolic Link Check
38 | KFSymbolic = 34859,
39 | // Failed the File Exists Check
40 | KFFileExists = 6625,
41 | } JailbrokenChecks;
42 |
43 | @implementation SSJailbreakCheck
44 |
45 | // Is the application running on a jailbroken device?
46 | + (int)jailbroken {
47 | // Is the device jailbroken?
48 |
49 | // Make an int to monitor how many checks are failed
50 | int motzart = 0;
51 |
52 | // Check if iOS 8 or lower
53 | if (SYSTEM_VERSION_LESS_THAN(@"9.0")) {
54 | // URL Check
55 | if ([self urlCheck] != NOTJAIL) {
56 | // Jailbroken
57 | motzart += 3;
58 | }
59 | }
60 |
61 | // Cydia Check
62 | if ([self cydiaCheck] != NOTJAIL) {
63 | // Jailbroken
64 | motzart += 3;
65 | }
66 |
67 | // Inaccessible Files Check
68 | if ([self inaccessibleFilesCheck] != NOTJAIL) {
69 | // Jailbroken
70 | motzart += 2;
71 | }
72 |
73 | // Plist Check
74 | if ([self plistCheck] != NOTJAIL) {
75 | // Jailbroken
76 | motzart += 2;
77 | }
78 |
79 | // Symbolic Link Check
80 | if ([self symbolicLinkCheck] != NOTJAIL) {
81 | // Jailbroken
82 | motzart += 2;
83 | }
84 |
85 | // FilesExist Integrity Check
86 | if ([self filesExistCheck] != NOTJAIL) {
87 | // Jailbroken
88 | motzart += 2;
89 | }
90 |
91 | // Check if the Jailbreak Integer is 3 or more
92 | if (motzart >= 3) {
93 | // Jailbroken
94 | return KFJailbroken;
95 | }
96 |
97 | // Not Jailbroken
98 | return NOTJAIL;
99 | }
100 |
101 | #pragma mark - Static Jailbreak Checks
102 |
103 | // UIApplication CanOpenURL Check
104 | + (int)urlCheck {
105 | @try {
106 | #if !(defined(__has_feature) && __has_feature(attribute_availability_app_extension))
107 | // Create a fake url for cydia
108 | NSURL *fakeURL = [NSURL URLWithString:CYDIAPACKAGE];
109 | // Return whether or not cydia's openurl item exists
110 | if ([[UIApplication sharedApplication] canOpenURL:fakeURL])
111 | return KFOpenURL;
112 | #endif
113 | }
114 | @catch (NSException *exception) {
115 | // Error, return false
116 | return NOTJAIL;
117 | }
118 | return NOTJAIL;
119 | }
120 |
121 | // Cydia Check
122 | + (int)cydiaCheck {
123 | @try {
124 | // Create a file path string
125 | NSString *filePath = CYDIALOC;
126 | // Check if it exists
127 | if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
128 | // It exists
129 | return KFCydia;
130 | } else {
131 | // It doesn't exist
132 | return NOTJAIL;
133 | }
134 | }
135 | @catch (NSException *exception) {
136 | // Error, return false
137 | return NOTJAIL;
138 | }
139 | }
140 |
141 | // Inaccessible Files Check
142 | + (int)inaccessibleFilesCheck {
143 | @try {
144 | // Run through the array of files
145 | for (NSString *key in HIDDENFILES) {
146 | // Check if any of the files exist (should return no)
147 | if ([[NSFileManager defaultManager] fileExistsAtPath:key]) {
148 | // Jailbroken
149 | return KFIFC;
150 | }
151 | }
152 |
153 | // No inaccessible files found, return NOT Jailbroken
154 | return NOTJAIL;
155 | }
156 | @catch (NSException *exception) {
157 | // Error, return NOT Jailbroken
158 | return NOTJAIL;
159 | }
160 | }
161 |
162 | // Plist Check
163 | + (int)plistCheck {
164 | @try {
165 | // Define the Executable name
166 | NSString *exeName = EXEPATH;
167 | NSDictionary *ipl = PLISTPATH;
168 | // Check if the plist exists
169 | if ([FILECHECK exeName] == FALSE || ipl == nil || ipl.count <= 0) {
170 | // Executable file can't be found and the plist can't be found...hmmm
171 | return KFPlist;
172 | } else {
173 | // Everything is good
174 | return NOTJAIL;
175 | }
176 | }
177 | @catch (NSException *exception) {
178 | // Error, return false
179 | return NOTJAIL;
180 | }
181 | }
182 |
183 | // Symbolic Link available
184 | + (int)symbolicLinkCheck {
185 | @try {
186 | // See if the Applications folder is a symbolic link
187 | struct stat s;
188 | if (lstat("/Applications", &s) != 0) {
189 | if (s.st_mode & S_IFLNK) {
190 | // Device is jailbroken
191 | return KFSymbolic;
192 | } else
193 | // Not jailbroken
194 | return NOTJAIL;
195 | } else {
196 | // Not jailbroken
197 | return NOTJAIL;
198 | }
199 | }
200 | @catch (NSException *exception) {
201 | // Not Jailbroken
202 | return NOTJAIL;
203 | }
204 | }
205 |
206 | // FileSystem working correctly?
207 | + (int)filesExistCheck {
208 | @try {
209 | // Check if filemanager is working
210 | if (![FILECHECK [[NSBundle mainBundle] executablePath]]) {
211 | // Jailbroken and trying to hide it
212 | return KFFileExists;
213 | } else
214 | // Not Jailbroken
215 | return NOTJAIL;
216 | }
217 | @catch (NSException *exception) {
218 | // Not Jailbroken
219 | return NOTJAIL;
220 | }
221 | }
222 |
223 | // Get the running processes
224 | + (NSArray *)runningProcesses {
225 | // Define the int array of the kernel's processes
226 | int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0};
227 | size_t miblen = 4;
228 |
229 | // Make a new size and int of the sysctl calls
230 | size_t size = 0;
231 | int st;
232 |
233 | // Make new structs for the processes
234 | struct kinfo_proc * process = NULL;
235 | struct kinfo_proc * newprocess = NULL;
236 |
237 | // Do get all the processes while there are no errors
238 | do {
239 | // Add to the size
240 | size += (size / 10);
241 | // Get the new process
242 | newprocess = realloc(process, size);
243 | // If the process selected doesn't exist
244 | if (!newprocess){
245 | // But the process exists
246 | if (process){
247 | // Free the process
248 | free(process);
249 | }
250 | // Return that nothing happened
251 | return nil;
252 | }
253 |
254 | // Make the process equal
255 | process = newprocess;
256 |
257 | // Set the st to the next process
258 | st = sysctl(mib, (int)miblen, process, &size, NULL, 0);
259 |
260 | } while (st == -1 && errno == ENOMEM);
261 |
262 | // As long as the process list is empty
263 | if (st == 0){
264 |
265 | // And the size of the processes is 0
266 | if (size % sizeof(struct kinfo_proc) == 0){
267 | // Define the new process
268 | int nprocess = (int)(size / sizeof(struct kinfo_proc));
269 | // If the process exists
270 | if (nprocess){
271 | // Create a new array
272 | NSMutableArray * array = [[NSMutableArray alloc] init];
273 | // Run through a for loop of the processes
274 | for (int i = nprocess - 1; i >= 0; i--){
275 | // Get the process ID
276 | NSString * processID = [[NSString alloc] initWithFormat:@"%d", process[i].kp_proc.p_pid];
277 | // Get the process Name
278 | NSString * processName = [[NSString alloc] initWithFormat:@"%s", process[i].kp_proc.p_comm];
279 | // Get the process Priority
280 | NSString *processPriority = [[NSString alloc] initWithFormat:@"%d", process[i].kp_proc.p_priority];
281 | // Get the process running time
282 | NSDate *processStartDate = [NSDate dateWithTimeIntervalSince1970:process[i].kp_proc.p_un.__p_starttime.tv_sec];
283 | // Create a new dictionary containing all the process ID's and Name's
284 | NSDictionary *dict = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:processID, processPriority, processName, processStartDate, nil]
285 | forKeys:[NSArray arrayWithObjects:@"ProcessID", @"ProcessPriority", @"ProcessName", @"ProcessStartDate", nil]];
286 |
287 | // Add the dictionary to the array
288 | [array addObject:dict];
289 | }
290 | // Free the process array
291 | free(process);
292 |
293 | // Return the process array
294 | return array;
295 |
296 | }
297 | }
298 | }
299 |
300 | // Free the process array
301 | free(process);
302 |
303 | // If no processes are found, return nothing
304 | return nil;
305 | }
306 |
307 | @end
308 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSLocalizationInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSLocalizationInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/20/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSLocalizationInfo : NSObject
12 |
13 | // Localization Information
14 |
15 | // Country
16 | + (nullable NSString *)country;
17 |
18 | // Language
19 | + (nullable NSString *)language;
20 |
21 | // TimeZone
22 | + (nullable NSString *)timeZone;
23 |
24 | // Currency Symbol
25 | + (nullable NSString *)currency;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSLocalizationInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSLocalizationInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/20/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSLocalizationInfo.h"
10 |
11 | @implementation SSLocalizationInfo
12 |
13 | // Localization Information
14 |
15 | // Country
16 | + (NSString *)country {
17 | // Get the user's country
18 | @try {
19 | // Get the locale
20 | NSLocale *locale = [NSLocale currentLocale];
21 | // Get the country from the locale
22 | NSString *country = [locale localeIdentifier];
23 | // Check for validity
24 | if (country == nil || country.length <= 0) {
25 | // Error, invalid country
26 | return nil;
27 | }
28 | // Completed Successfully
29 | return country;
30 | }
31 | @catch (NSException *exception) {
32 | // Error
33 | return nil;
34 | }
35 | }
36 |
37 | // Language
38 | + (NSString *)language {
39 | // Get the user's language
40 | @try {
41 | // Get the list of languages
42 | NSArray *languageArray = [NSLocale preferredLanguages];
43 | // Get the user's language
44 | NSString *language = [languageArray objectAtIndex:0];
45 | // Check for validity
46 | if (language == nil || language.length <= 0) {
47 | // Error, invalid language
48 | return nil;
49 | }
50 | // Completed Successfully
51 | return language;
52 | }
53 | @catch (NSException *exception) {
54 | // Error
55 | return nil;
56 | }
57 | }
58 |
59 | // TimeZone
60 | + (NSString *)timeZone {
61 | // Get the user's timezone
62 | @try {
63 | // Get the system timezone
64 | NSTimeZone *localTime = [NSTimeZone systemTimeZone];
65 | // Convert the time zone to a string
66 | NSString *timeZone = [localTime name];
67 | // Check for validity
68 | if (timeZone == nil || timeZone.length <= 0) {
69 | // Error, invalid TimeZone
70 | return nil;
71 | }
72 | // Completed Successfully
73 | return timeZone;
74 | }
75 | @catch (NSException *exception) {
76 | // Error
77 | return nil;
78 | }
79 | }
80 |
81 | // Currency Symbol
82 | + (NSString *)currency {
83 | // Get the user's currency
84 | @try {
85 | // Get the system currency
86 | NSString *currency = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencySymbol];
87 | // Check for validity
88 | if (currency == nil || currency.length <= 0) {
89 | // Error, invalid Currency
90 | return nil;
91 | }
92 | // Completed Successfully
93 | return currency;
94 | }
95 | @catch (NSException *exception) {
96 | // Error
97 | return nil;
98 | }
99 | }
100 |
101 | @end
102 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSMemoryInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSMemoryInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/19/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSMemoryInfo : NSObject
12 |
13 | // Memory Information
14 |
15 | // Total Memory
16 | + (double)totalMemory;
17 |
18 | // Free Memory
19 | + (double)freeMemory:(BOOL)inPercent;
20 |
21 | // Used Memory
22 | + (double)usedMemory:(BOOL)inPercent;
23 |
24 | // Active Memory
25 | + (double)activeMemory:(BOOL)inPercent;
26 |
27 | // Inactive Memory
28 | + (double)inactiveMemory:(BOOL)inPercent;
29 |
30 | // Wired Memory
31 | + (double)wiredMemory:(BOOL)inPercent;
32 |
33 | // Purgable Memory
34 | + (double)purgableMemory:(BOOL)inPercent;
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSMemoryInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSMemoryInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/19/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSMemoryInfo.h"
10 |
11 | // stat
12 | #import
13 |
14 | // mach
15 | #import
16 |
17 | @implementation SSMemoryInfo
18 |
19 | // Total Memory
20 | + (double)totalMemory {
21 | // Find the total amount of memory
22 | @try {
23 | // Set up the variables
24 | double totalMemory = 0.00;
25 | double allMemory = [[NSProcessInfo processInfo] physicalMemory];
26 |
27 | // Total Memory (formatted)
28 | totalMemory = (allMemory / 1024.0) / 1024.0;
29 |
30 | // Round to the nearest multiple of 256mb - Almost all RAM is a multiple of 256mb (I do believe)
31 | int toNearest = 256;
32 | int remainder = (int)totalMemory % toNearest;
33 |
34 | if (remainder >= toNearest / 2) {
35 | // Round the final number up
36 | totalMemory = ((int)totalMemory - remainder) + 256;
37 | } else {
38 | // Round the final number down
39 | totalMemory = (int)totalMemory - remainder;
40 | }
41 |
42 | // Check to make sure it's valid
43 | if (totalMemory <= 0) {
44 | // Error, invalid memory value
45 | return -1;
46 | }
47 |
48 | // Completed Successfully
49 | return totalMemory;
50 | }
51 | @catch (NSException *exception) {
52 | // Error
53 | return -1;
54 | }
55 | }
56 |
57 | // Free Memory
58 | + (double)freeMemory:(BOOL)inPercent {
59 | // Find the total amount of free memory
60 | @try {
61 | // Set up the variables
62 | double totalMemory = 0.00;
63 | vm_statistics_data_t vmStats;
64 | mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;
65 | kern_return_t kernReturn = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmStats, &infoCount);
66 |
67 | if(kernReturn != KERN_SUCCESS) {
68 | return -1;
69 | }
70 |
71 | // Check if the user wants it in percent
72 | if (inPercent) {
73 | // Percent
74 | // Convert to doubles
75 | double fm = [self totalMemory];
76 | double am = ((vm_page_size * vmStats.free_count) / 1024.0) / 1024.0;
77 | // Get the percent
78 | totalMemory = (am * 100) / fm;
79 | } else {
80 | // Not in percent
81 | // Total Memory (formatted)
82 | totalMemory = ((vm_page_size * vmStats.free_count) / 1024.0) / 1024.0;
83 | }
84 |
85 | // Check to make sure it's valid
86 | if (totalMemory <= 0) {
87 | // Error, invalid memory value
88 | return -1;
89 | }
90 |
91 | // Completed Successfully
92 | return totalMemory;
93 | }
94 | @catch (NSException *exception) {
95 | // Error
96 | return -1;
97 | }
98 | }
99 |
100 | // Used Memory
101 | + (double)usedMemory:(BOOL)inPercent {
102 | // Find the total amount of used memory
103 | @try {
104 | // Set up the variables
105 | double totalUsedMemory = 0.00;
106 | mach_port_t host_port;
107 | mach_msg_type_number_t host_size;
108 | vm_size_t pagesize;
109 |
110 | // Get the variable values
111 | host_port = mach_host_self();
112 | host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
113 | host_page_size(host_port, &pagesize);
114 |
115 | vm_statistics_data_t vm_stat;
116 |
117 | // Check for any system errors
118 | if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) {
119 | // Error, failed to get Virtual memory info
120 | return -1;
121 | }
122 |
123 | // Memory statistics in bytes
124 | natural_t usedMemory = (natural_t)((vm_stat.active_count +
125 | vm_stat.inactive_count +
126 | vm_stat.wire_count) * pagesize);
127 | natural_t allMemory = [self totalMemory];
128 |
129 | // Check if the user wants it in percent
130 | if (inPercent) {
131 | // Percent
132 | // Convert to doubles
133 | double um = (usedMemory /1024) / 1024;
134 | double am = allMemory;
135 | // Get the percent
136 | totalUsedMemory = (um * 100) / am;
137 | } else {
138 | // Not in percent
139 | // Total Used Memory (formatted)
140 | totalUsedMemory = (usedMemory / 1024.0) / 1024.0;
141 | }
142 |
143 | // Check to make sure it's valid
144 | if (totalUsedMemory <= 0) {
145 | // Error, invalid memory value
146 | return -1;
147 | }
148 |
149 | // Completed Successfully
150 | return totalUsedMemory;
151 | }
152 | @catch (NSException *exception) {
153 | // Error
154 | return -1;
155 | }
156 | }
157 |
158 | // Active Memory
159 | + (double)activeMemory:(BOOL)inPercent {
160 | // Find the Active memory
161 | @try {
162 | // Set up the variables
163 | double totalMemory = 0.00;
164 | mach_port_t host_port;
165 | mach_msg_type_number_t host_size;
166 | vm_size_t pagesize;
167 |
168 | // Get the variable values
169 | host_port = mach_host_self();
170 | host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
171 | host_page_size(host_port, &pagesize);
172 |
173 | vm_statistics_data_t vm_stat;
174 |
175 | // Check for any system errors
176 | if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) {
177 | // Error, failed to get Virtual memory info
178 | return -1;
179 | }
180 |
181 | // Check if the user wants it in percent
182 | if (inPercent) {
183 | // Percent
184 | // Convert to doubles
185 | double FM = [self totalMemory];
186 | double AM = ((vm_stat.active_count * pagesize) / 1024.0) / 1024.0;
187 | // Get the percent
188 | totalMemory = (AM * 100) / FM;
189 | } else {
190 | // Not in percent
191 | // Total Memory (formatted)
192 | totalMemory = ((vm_stat.active_count * pagesize) / 1024.0) / 1024.0;
193 | }
194 |
195 | // Check to make sure it's valid
196 | if (totalMemory <= 0) {
197 | // Error, invalid memory value
198 | return -1;
199 | }
200 |
201 | // Completed Successfully
202 | return totalMemory;
203 | }
204 | @catch (NSException *exception) {
205 | // Error
206 | return -1;
207 | }
208 | }
209 |
210 | // Inactive Memory
211 | + (double)inactiveMemory:(BOOL)inPercent {
212 | // Find the Inactive memory
213 | @try {
214 | // Set up the variables
215 | double totalMemory = 0.00;
216 | mach_port_t host_port;
217 | mach_msg_type_number_t host_size;
218 | vm_size_t pagesize;
219 |
220 | // Get the variable values
221 | host_port = mach_host_self();
222 | host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
223 | host_page_size(host_port, &pagesize);
224 |
225 | vm_statistics_data_t vm_stat;
226 |
227 | // Check for any system errors
228 | if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) {
229 | // Error, failed to get Virtual memory info
230 | return -1;
231 | }
232 |
233 | // Check if the user wants it in percent
234 | if (inPercent) {
235 | // Percent
236 | // Convert to doubles
237 | double FM = [self totalMemory];
238 | double AM = ((vm_stat.inactive_count * pagesize) / 1024.0) / 1024.0;
239 | // Get the percent
240 | totalMemory = (AM * 100) / FM;
241 | } else {
242 | // Not in percent
243 | // Total Memory (formatted)
244 | totalMemory = ((vm_stat.inactive_count * pagesize) / 1024.0) / 1024.0;
245 | }
246 |
247 | // Check to make sure it's valid
248 | if (totalMemory <= 0) {
249 | // Error, invalid memory value
250 | return -1;
251 | }
252 |
253 | // Completed Successfully
254 | return totalMemory;
255 | }
256 | @catch (NSException *exception) {
257 | // Error
258 | return -1;
259 | }
260 | }
261 |
262 | // Wired Memory
263 | + (double)wiredMemory:(BOOL)inPercent {
264 | // Find the Wired memory
265 | @try {
266 | // Set up the variables
267 | double totalMemory = 0.00;
268 | mach_port_t host_port;
269 | mach_msg_type_number_t host_size;
270 | vm_size_t pagesize;
271 |
272 | // Get the variable values
273 | host_port = mach_host_self();
274 | host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
275 | host_page_size(host_port, &pagesize);
276 |
277 | vm_statistics_data_t vm_stat;
278 |
279 | // Check for any system errors
280 | if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) {
281 | // Error, failed to get Virtual memory info
282 | return -1;
283 | }
284 |
285 | // Check if the user wants it in percent
286 | if (inPercent) {
287 | // Percent
288 | // Convert to doubles
289 | double FM = [self totalMemory];
290 | double AM = ((vm_stat.wire_count * pagesize) / 1024.0) / 1024.0;
291 | // Get the percent
292 | totalMemory = (AM * 100) / FM;
293 | } else {
294 | // Not in percent
295 | // Total Memory (formatted)
296 | totalMemory = ((vm_stat.wire_count * pagesize) / 1024.0) / 1024.0;
297 | }
298 |
299 | // Check to make sure it's valid
300 | if (totalMemory <= 0) {
301 | // Error, invalid memory value
302 | return -1;
303 | }
304 |
305 | // Completed Successfully
306 | return totalMemory;
307 | }
308 | @catch (NSException *exception) {
309 | // Error
310 | return -1;
311 | }
312 | }
313 |
314 | // Purgable Memory
315 | + (double)purgableMemory:(BOOL)inPercent {
316 | // Find the Purgable memory
317 | @try {
318 | // Set up the variables
319 | double totalMemory = 0.00;
320 | mach_port_t host_port;
321 | mach_msg_type_number_t host_size;
322 | vm_size_t pagesize;
323 |
324 | // Get the variable values
325 | host_port = mach_host_self();
326 | host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
327 | host_page_size(host_port, &pagesize);
328 |
329 | vm_statistics_data_t vm_stat;
330 |
331 | // Check for any system errors
332 | if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) {
333 | // Error, failed to get Virtual memory info
334 | return -1;
335 | }
336 |
337 | // Check if the user wants it in percent
338 | if (inPercent) {
339 | // Percent
340 | // Convert to doubles
341 | double fm = [self totalMemory];
342 | double am = ((vm_stat.purgeable_count * pagesize) / 1024.0) / 1024.0;
343 | // Get the percent
344 | totalMemory = (am * 100) / fm;
345 | } else {
346 | // Not in percent
347 | // Total Memory (formatted)
348 | totalMemory = ((vm_stat.purgeable_count * pagesize) / 1024.0) / 1024.0;
349 | }
350 |
351 | // Check to make sure it's valid
352 | if (totalMemory <= 0) {
353 | // Error, invalid memory value
354 | return -1;
355 | }
356 |
357 | // Completed Successfully
358 | return totalMemory;
359 | }
360 | @catch (NSException *exception) {
361 | // Error
362 | return -1;
363 | }
364 | }
365 |
366 | @end
367 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSNetworkInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSNetworkInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/18/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSNetworkInfo : NSObject
12 |
13 | // Network Information
14 |
15 | // Get Current IP Address
16 | + (nullable NSString *)currentIPAddress;
17 |
18 | // Get the External IP Address
19 | + (nullable NSString *)externalIPAddress;
20 |
21 | // Get Cell IP Address
22 | + (nullable NSString *)cellIPAddress;
23 |
24 | // Get Cell IPv6 Address
25 | + (nullable NSString *)cellIPv6Address;
26 |
27 | // Get Cell Netmask Address
28 | + (nullable NSString *)cellNetmaskAddress;
29 |
30 | // Get Cell Broadcast Address
31 | + (nullable NSString *)cellBroadcastAddress;
32 |
33 | // Get WiFi IP Address
34 | + (nullable NSString *)wiFiIPAddress;
35 |
36 | // Get WiFi IPv6 Address
37 | + (nullable NSString *)wiFiIPv6Address;
38 |
39 | // Get WiFi Netmask Address
40 | + (nullable NSString *)wiFiNetmaskAddress;
41 |
42 | // Get WiFi Broadcast Address
43 | + (nullable NSString *)wiFiBroadcastAddress;
44 |
45 | // Get WiFi Router Address
46 | + (nullable NSString *)wiFiRouterAddress;
47 |
48 | // Connected to WiFi?
49 | + (BOOL)connectedToWiFi;
50 |
51 | // Connected to Cellular Network?
52 | + (BOOL)connectedToCellNetwork;
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSProcessInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSProcessInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/18/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSProcessInfo : NSObject
12 |
13 | // Process Information
14 |
15 | // Process ID
16 | + (int)processID;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSProcessInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSProcessInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/18/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSProcessInfo.h"
10 |
11 | // sysctl
12 | #import
13 |
14 | @implementation SSProcessInfo
15 |
16 | // Process Information
17 |
18 | // Process ID
19 | + (int)processID {
20 | // Get the Process ID
21 | @try {
22 | // Get the PID
23 | int pid = getpid();
24 | // Make sure it's correct
25 | if (pid <= 0) {
26 | // Incorrect PID
27 | return -1;
28 | }
29 | // Successful
30 | return pid;
31 | }
32 | @catch (NSException *exception) {
33 | // Error
34 | return -1;
35 | }
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSProcessorInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSProcessorInfo.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSProcessorInfo : NSObject
12 |
13 | // Processor Information
14 |
15 | // Number of processors
16 | + (NSInteger)numberProcessors;
17 |
18 | // Number of Active Processors
19 | + (NSInteger)numberActiveProcessors;
20 |
21 | // Get Processor Usage Information (i.e. ["0.2216801", "0.1009614"])
22 | + (NSArray *)processorsUsage;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSProcessorInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSProcessorInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSProcessorInfo.h"
10 |
11 | // Sysctl
12 | #import
13 |
14 | // Mach
15 | #include
16 |
17 | @implementation SSProcessorInfo
18 |
19 | // Processor Information
20 |
21 | // Number of processors
22 | + (NSInteger)numberProcessors {
23 | // See if the process info responds to selector
24 | if ([[NSProcessInfo processInfo] respondsToSelector:@selector(processorCount)]) {
25 | // Get the number of processors
26 | NSInteger processorCount = [[NSProcessInfo processInfo] processorCount];
27 | // Return the number of processors
28 | return processorCount;
29 | } else {
30 | // Return -1 (not found)
31 | return -1;
32 | }
33 | }
34 |
35 | // Number of Active Processors
36 | + (NSInteger)numberActiveProcessors {
37 | // See if the process info responds to selector
38 | if ([[NSProcessInfo processInfo] respondsToSelector:@selector(activeProcessorCount)]) {
39 | // Get the number of active processors
40 | NSInteger activeprocessorCount = [[NSProcessInfo processInfo] activeProcessorCount];
41 | // Return the number of active processors
42 | return activeprocessorCount;
43 | } else {
44 | // Return -1 (not found)
45 | return -1;
46 | }
47 | }
48 |
49 | // Get Processor Usage Information (i.e. ["0.2216801", "0.1009614"])
50 | + (NSArray *)processorsUsage {
51 |
52 | // Try to get Processor Usage Info
53 | @try {
54 | // Variables
55 | processor_info_array_t _cpuInfo, _prevCPUInfo = nil;
56 | mach_msg_type_number_t _numCPUInfo, _numPrevCPUInfo = 0;
57 | unsigned _numCPUs;
58 | NSLock *_cpuUsageLock;
59 |
60 | // Get the number of processors from sysctl
61 | int _mib[2U] = { CTL_HW, HW_NCPU };
62 | size_t _sizeOfNumCPUs = sizeof(_numCPUs);
63 | int _status = sysctl(_mib, 2U, &_numCPUs, &_sizeOfNumCPUs, NULL, 0U);
64 | if (_status)
65 | _numCPUs = 1;
66 |
67 | // Allocate the lock
68 | _cpuUsageLock = [[NSLock alloc] init];
69 |
70 | // Get the processor info
71 | natural_t _numCPUsU = 0U;
72 | kern_return_t err = host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &_numCPUsU, &_cpuInfo, &_numCPUInfo);
73 | if (err == KERN_SUCCESS) {
74 | [_cpuUsageLock lock];
75 |
76 | // Go through info for each processor
77 | NSMutableArray *processorInfo = [NSMutableArray new];
78 | for (unsigned i = 0U; i < _numCPUs; ++i) {
79 | Float32 _inUse, _total;
80 | if (_prevCPUInfo) {
81 | _inUse = (
82 | (_cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_USER] - _prevCPUInfo[(CPU_STATE_MAX * i) + CPU_STATE_USER])
83 | + (_cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_SYSTEM] - _prevCPUInfo[(CPU_STATE_MAX * i) + CPU_STATE_SYSTEM])
84 | + (_cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_NICE] - _prevCPUInfo[(CPU_STATE_MAX * i) + CPU_STATE_NICE])
85 | );
86 | _total = _inUse + (_cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_IDLE] - _prevCPUInfo[(CPU_STATE_MAX * i) + CPU_STATE_IDLE]);
87 | } else {
88 | _inUse = _cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_USER] + _cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_SYSTEM] + _cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_NICE];
89 | _total = _inUse + _cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_IDLE];
90 | }
91 | // Add to the processor usage info
92 | [processorInfo addObject:@(_inUse / _total)];
93 | }
94 |
95 | [_cpuUsageLock unlock];
96 | if (_prevCPUInfo) {
97 | size_t prevCpuInfoSize = sizeof(integer_t) * _numPrevCPUInfo;
98 | vm_deallocate(mach_task_self(), (vm_address_t)_prevCPUInfo, prevCpuInfoSize);
99 | }
100 | // Retrieved processor information
101 | return processorInfo;
102 | } else {
103 | // Unable to get processor information
104 | return nil;
105 | }
106 | } @catch (NSException *exception) {
107 | // Getting processor information failed
108 | return nil;
109 | }
110 | }
111 |
112 | @end
113 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSUUID.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSUUID.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/21/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SSUUID : NSObject
12 |
13 | // CFUUID - Random Unique Identifier that changes every time
14 | + (nullable NSString *)cfuuid;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/System Services/Utilities/SSUUID.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSUUID.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/21/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSUUID.h"
10 | #import "SSHardwareInfo.h"
11 | #import "SSProcessorInfo.h"
12 | #import "SSNetworkInfo.h"
13 | #import "SSDiskInfo.h"
14 | #import "SSAccelerometerInfo.h"
15 | #import "SSLocalizationInfo.h"
16 | #import "SSMemoryInfo.h"
17 | #import "SSJailbreakCheck.h"
18 | #import "SSAccessoryInfo.h"
19 | #import "SSBatteryInfo.h"
20 |
21 | @implementation SSUUID
22 |
23 | // CFUUID
24 | + (NSString *)cfuuid {
25 | // Create a new CFUUID (Unique, random ID number) (Always different)
26 | @try {
27 | // Create a new instance of CFUUID using CFUUIDCreate using the default allocator
28 | CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault);
29 |
30 | // Check to make sure it exists
31 | if (theUUID)
32 | {
33 | // Make the new UUID String
34 | NSString *tempUniqueID = (__bridge NSString *)CFUUIDCreateString(kCFAllocatorDefault, theUUID);
35 |
36 | // Check to make sure it created it
37 | if (tempUniqueID == nil || tempUniqueID.length <= 0) {
38 | // Error, Unable to create
39 | // Release the UUID Reference
40 | CFRelease(theUUID);
41 | // Return nil
42 | return nil;
43 | }
44 |
45 | // Release the UUID Reference
46 | CFRelease(theUUID);
47 |
48 | // Successful
49 | return tempUniqueID;
50 | } else {
51 | // Error
52 | // Release the UUID Reference
53 | CFRelease(theUUID);
54 | // Return nil
55 | return nil;
56 | }
57 | }
58 | @catch (NSException *exception) {
59 | // Error
60 | return nil;
61 | }
62 | }
63 |
64 | @end
65 |
--------------------------------------------------------------------------------
/System Services/Utilities/route.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | * Copyright (c) 1980, 1986, 1993
30 | * The Regents of the University of California. All rights reserved.
31 | *
32 | * Redistribution and use in source and binary forms, with or without
33 | * modification, are permitted provided that the following conditions
34 | * are met:
35 | * 1. Redistributions of source code must retain the above copyright
36 | * notice, this list of conditions and the following disclaimer.
37 | * 2. Redistributions in binary form must reproduce the above copyright
38 | * notice, this list of conditions and the following disclaimer in the
39 | * documentation and/or other materials provided with the distribution.
40 | * 3. All advertising materials mentioning features or use of this software
41 | * must display the following acknowledgement:
42 | * This product includes software developed by the University of
43 | * California, Berkeley and its contributors.
44 | * 4. Neither the name of the University nor the names of its contributors
45 | * may be used to endorse or promote products derived from this software
46 | * without specific prior written permission.
47 | *
48 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 | * SUCH DAMAGE.
59 | *
60 | * @(#)route.h 8.3 (Berkeley) 4/19/94
61 | * $FreeBSD: src/sys/net/route.h,v 1.36.2.1 2000/08/16 06:14:23 jayanth Exp $
62 | */
63 |
64 | #ifndef _NET_ROUTE_H_
65 | #define _NET_ROUTE_H_
66 | #include
67 | #include
68 | #include
69 | #include
70 |
71 | /*
72 | * These numbers are used by reliable protocols for determining
73 | * retransmission behavior and are included in the routing structure.
74 | */
75 | struct rt_metrics {
76 | u_int32_t rmx_locks; /* Kernel leaves these values alone */
77 | u_int32_t rmx_mtu; /* MTU for this path */
78 | u_int32_t rmx_hopcount; /* max hops expected */
79 | int32_t rmx_expire; /* lifetime for route, e.g. redirect */
80 | u_int32_t rmx_recvpipe; /* inbound delay-bandwidth product */
81 | u_int32_t rmx_sendpipe; /* outbound delay-bandwidth product */
82 | u_int32_t rmx_ssthresh; /* outbound gateway buffer limit */
83 | u_int32_t rmx_rtt; /* estimated round trip time */
84 | u_int32_t rmx_rttvar; /* estimated rtt variance */
85 | u_int32_t rmx_pksent; /* packets sent using this route */
86 | u_int32_t rmx_filler[4]; /* will be used for T/TCP later */
87 | };
88 |
89 | /*
90 | * rmx_rtt and rmx_rttvar are stored as microseconds;
91 | */
92 | #define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */
93 |
94 |
95 |
96 | #define RTF_UP 0x1 /* route usable */
97 | #define RTF_GATEWAY 0x2 /* destination is a gateway */
98 | #define RTF_HOST 0x4 /* host entry (net otherwise) */
99 | #define RTF_REJECT 0x8 /* host or net unreachable */
100 | #define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */
101 | #define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */
102 | #define RTF_DONE 0x40 /* message confirmed */
103 | #define RTF_DELCLONE 0x80 /* delete cloned route */
104 | #define RTF_CLONING 0x100 /* generate new routes on use */
105 | #define RTF_XRESOLVE 0x200 /* external daemon resolves name */
106 | #define RTF_LLINFO 0x400 /* generated by link layer (e.g. ARP) */
107 | #define RTF_STATIC 0x800 /* manually added */
108 | #define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */
109 | #define RTF_NOIFREF 0x2000 /* not eligible for RTF_IFREF */
110 | #define RTF_PROTO2 0x4000 /* protocol specific routing flag */
111 | #define RTF_PROTO1 0x8000 /* protocol specific routing flag */
112 |
113 | #define RTF_PRCLONING 0x10000 /* protocol requires cloning */
114 | #define RTF_WASCLONED 0x20000 /* route generated through cloning */
115 | #define RTF_PROTO3 0x40000 /* protocol specific routing flag */
116 | /* 0x80000 unused */
117 | #define RTF_PINNED 0x100000 /* future use */
118 | #define RTF_LOCAL 0x200000 /* route represents a local address */
119 | #define RTF_BROADCAST 0x400000 /* route represents a bcast address */
120 | #define RTF_MULTICAST 0x800000 /* route represents a mcast address */
121 | #define RTF_IFSCOPE 0x1000000 /* has valid interface scope */
122 | #define RTF_CONDEMNED 0x2000000 /* defunct; no longer modifiable */
123 | #define RTF_IFREF 0x4000000 /* route holds a ref to interface */
124 | #define RTF_PROXY 0x8000000 /* proxying, no interface scope */
125 | #define RTF_ROUTER 0x10000000 /* host is a router */
126 | /* 0x20000000 and up unassigned */
127 |
128 | #define RTF_BITS \
129 | "\020\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE" \
130 | "\10DELCLONE\11CLONING\12XRESOLVE\13LLINFO\14STATIC\15BLACKHOLE" \
131 | "\16NOIFREF\17PROTO2\20PROTO1\21PRCLONING\22WASCLONED\23PROTO3" \
132 | "\25PINNED\26LOCAL\27BROADCAST\30MULTICAST\31IFSCOPE\32CONDEMNED" \
133 | "\33IFREF\34PROXY\35ROUTER"
134 |
135 | /*
136 | * Routing statistics.
137 | */
138 | struct rtstat {
139 | short rts_badredirect; /* bogus redirect calls */
140 | short rts_dynamic; /* routes created by redirects */
141 | short rts_newgateway; /* routes modified by redirects */
142 | short rts_unreach; /* lookups which failed */
143 | short rts_wildcard; /* lookups satisfied by a wildcard */
144 | };
145 |
146 | /*
147 | * Structures for routing messages.
148 | */
149 | struct rt_msghdr {
150 | u_short rtm_msglen; /* to skip over non-understood messages */
151 | u_char rtm_version; /* future binary compatibility */
152 | u_char rtm_type; /* message type */
153 | u_short rtm_index; /* index for associated ifp */
154 | int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
155 | int rtm_addrs; /* bitmask identifying sockaddrs in msg */
156 | pid_t rtm_pid; /* identify sender */
157 | int rtm_seq; /* for sender to identify action */
158 | int rtm_errno; /* why failed */
159 | int rtm_use; /* from rtentry */
160 | u_int32_t rtm_inits; /* which metrics we are initializing */
161 | struct rt_metrics rtm_rmx; /* metrics themselves */
162 | };
163 |
164 | struct rt_msghdr2 {
165 | u_short rtm_msglen; /* to skip over non-understood messages */
166 | u_char rtm_version; /* future binary compatibility */
167 | u_char rtm_type; /* message type */
168 | u_short rtm_index; /* index for associated ifp */
169 | int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
170 | int rtm_addrs; /* bitmask identifying sockaddrs in msg */
171 | int32_t rtm_refcnt; /* reference count */
172 | int rtm_parentflags; /* flags of the parent route */
173 | int rtm_reserved; /* reserved field set to 0 */
174 | int rtm_use; /* from rtentry */
175 | u_int32_t rtm_inits; /* which metrics we are initializing */
176 | struct rt_metrics rtm_rmx; /* metrics themselves */
177 | };
178 |
179 |
180 | #define RTM_VERSION 5 /* Up the ante and ignore older versions */
181 |
182 | /*
183 | * Message types.
184 | */
185 | #define RTM_ADD 0x1 /* Add Route */
186 | #define RTM_DELETE 0x2 /* Delete Route */
187 | #define RTM_CHANGE 0x3 /* Change Metrics or flags */
188 | #define RTM_GET 0x4 /* Report Metrics */
189 | #define RTM_LOSING 0x5 /* RTM_LOSING is no longer generated by xnu
190 | and is deprecated */
191 | #define RTM_REDIRECT 0x6 /* Told to use different route */
192 | #define RTM_MISS 0x7 /* Lookup failed on this address */
193 | #define RTM_LOCK 0x8 /* fix specified metrics */
194 | #define RTM_OLDADD 0x9 /* caused by SIOCADDRT */
195 | #define RTM_OLDDEL 0xa /* caused by SIOCDELRT */
196 | #define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */
197 | #define RTM_NEWADDR 0xc /* address being added to iface */
198 | #define RTM_DELADDR 0xd /* address being removed from iface */
199 | #define RTM_IFINFO 0xe /* iface going up/down etc. */
200 | #define RTM_NEWMADDR 0xf /* mcast group membership being added to if */
201 | #define RTM_DELMADDR 0x10 /* mcast group membership being deleted */
202 | #define RTM_IFINFO2 0x12 /* */
203 | #define RTM_NEWMADDR2 0x13 /* */
204 | #define RTM_GET2 0x14 /* */
205 |
206 | /*
207 | * Bitmask values for rtm_inits and rmx_locks.
208 | */
209 | #define RTV_MTU 0x1 /* init or lock _mtu */
210 | #define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */
211 | #define RTV_EXPIRE 0x4 /* init or lock _expire */
212 | #define RTV_RPIPE 0x8 /* init or lock _recvpipe */
213 | #define RTV_SPIPE 0x10 /* init or lock _sendpipe */
214 | #define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */
215 | #define RTV_RTT 0x40 /* init or lock _rtt */
216 | #define RTV_RTTVAR 0x80 /* init or lock _rttvar */
217 |
218 | /*
219 | * Bitmask values for rtm_addrs.
220 | */
221 | #define RTA_DST 0x1 /* destination sockaddr present */
222 | #define RTA_GATEWAY 0x2 /* gateway sockaddr present */
223 | #define RTA_NETMASK 0x4 /* netmask sockaddr present */
224 | #define RTA_GENMASK 0x8 /* cloning mask sockaddr present */
225 | #define RTA_IFP 0x10 /* interface name sockaddr present */
226 | #define RTA_IFA 0x20 /* interface addr sockaddr present */
227 | #define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */
228 | #define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */
229 |
230 | /*
231 | * Index offsets for sockaddr array for alternate internal encoding.
232 | */
233 | #define RTAX_DST 0 /* destination sockaddr present */
234 | #define RTAX_GATEWAY 1 /* gateway sockaddr present */
235 | #define RTAX_NETMASK 2 /* netmask sockaddr present */
236 | #define RTAX_GENMASK 3 /* cloning mask sockaddr present */
237 | #define RTAX_IFP 4 /* interface name sockaddr present */
238 | #define RTAX_IFA 5 /* interface addr sockaddr present */
239 | #define RTAX_AUTHOR 6 /* sockaddr for author of redirect */
240 | #define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */
241 | #define RTAX_MAX 8 /* size of array to allocate */
242 |
243 | struct rt_addrinfo {
244 | int rti_addrs;
245 | struct sockaddr *rti_info[RTAX_MAX];
246 | };
247 |
248 |
249 | #endif /* _NET_ROUTE_H_ */
250 |
--------------------------------------------------------------------------------
/SystemServices.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod spec lint SystemServices.podspec' to ensure this is a
3 | # valid spec and to remove all comments including this before submitting the spec.
4 | #
5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
7 | #
8 |
9 | Pod::Spec.new do |s|
10 |
11 | s.name = "SystemServices"
12 | s.version = "2.0.1"
13 | s.summary = "iOS System Services is a class to gather all available information about a device."
14 | s.description = <<-DESC
15 |
16 | This is a singleton class to gather all available information about a device. It gives you over 60 methods to determine everything about a device, including:
17 |
18 | Hardware Information
19 | Network Information
20 | Battery Usage
21 | Accelerometer Data
22 | Disk Usage
23 | Memory Usage
24 |
25 | DESC
26 |
27 | s.homepage = "https://github.com/Shmoopi/iOS-System-Services"
28 | s.screenshots = [ "https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/master/Sample%20Images/Screenshot1.png",
29 | "https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/master/Sample%20Images/Screenshot2.png" ]
30 | s.license = { :type => 'MIT' }
31 | s.author = { "Shmoopi" => "shmoopillc@gmail.com" }
32 | s.social_media_url = "http://twitter.com/shmoopillc"
33 | s.platform = :ios
34 | s.platform = :ios, "8.0"
35 | s.source = { :git => "https://github.com/Shmoopi/iOS-System-Services.git", :tag => "2.0.1" }
36 | s.source_files = "SystemServices", "System Services/**/*.{h,m}"
37 | s.frameworks = "AVFoundation", "CoreTelephony", "Security", "CoreMotion", "ExternalAccessory"
38 | s.requires_arc = true
39 |
40 | end
41 |
--------------------------------------------------------------------------------
/SystemServicesDemo/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/Default-568h@2x.png
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSAnnotatedGauge.h:
--------------------------------------------------------------------------------
1 | //
2 | // PBGauge.h
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/30/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import "MSSimpleGaugeSubclass.h"
10 |
11 | @interface MSAnnotatedGauge : MSSimpleGauge
12 | @property (nonatomic) NSNumberFormatter *valueFormatter;
13 | @property (nonatomic) UILabel *titleLabel;
14 | @property (nonatomic) UILabel *valueLabel;
15 | @property (nonatomic) UILabel *startRangeLabel;
16 | @property (nonatomic) UILabel *endRangeLabel;
17 | @end
18 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSAnnotatedGauge.m:
--------------------------------------------------------------------------------
1 | //
2 | // PBGauge.m
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/30/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import "MSAnnotatedGauge.h"
10 | #import "MSArcLayer.h"
11 |
12 | @interface MSAnnotatedGauge ()
13 | @end
14 |
15 | @implementation MSAnnotatedGauge
16 |
17 | - (void)setup
18 | {
19 | [super setup];
20 |
21 | _valueFormatter = [NSNumberFormatter new];
22 | _valueFormatter.minimumFractionDigits = 0;
23 | _valueFormatter.maximumFractionDigits = 2;
24 | }
25 |
26 | - (id)initWithFrame:(CGRect)frame
27 | {
28 | self = [super initWithFrame:frame];
29 | if (self)
30 | {
31 | UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 15)];
32 | _titleLabel = titleLabel;
33 | _titleLabel.font = [UIFont systemFontOfSize:10];
34 | _titleLabel.textAlignment = NSTextAlignmentCenter;
35 | _titleLabel.backgroundColor = [UIColor clearColor];
36 | _titleLabel.textColor = [UIColor lightGrayColor];
37 | _titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
38 | [self addSubview:_titleLabel];
39 |
40 | UILabel *valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _titleLabel.frame.size.height, frame.size.width, 28)];
41 | _valueLabel = valueLabel;
42 | _valueLabel.font = [UIFont boldSystemFontOfSize:32];
43 | _valueLabel.textAlignment = NSTextAlignmentCenter;
44 | _valueLabel.backgroundColor = [UIColor clearColor];
45 | _valueLabel.translatesAutoresizingMaskIntoConstraints = NO;
46 | [self addSubview:_valueLabel];
47 |
48 | NSDictionary *views = NSDictionaryOfVariableBindings(titleLabel, valueLabel);
49 | NSArray *contraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-5-[titleLabel(==12)]-0-[valueLabel(==32)]" options:0 metrics:nil views:views];
50 | [self addConstraints:contraints];
51 |
52 | CGPoint innerArcStartPoint = [self.backgroundArcLayer pointForArcEdge:ArcEdgeInner andArcSide:ArcSideBegining];
53 | _startRangeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, innerArcStartPoint.y+4, innerArcStartPoint.x, 14)];
54 | _startRangeLabel.font = [UIFont systemFontOfSize:10];
55 | _startRangeLabel.textColor = [UIColor lightGrayColor];
56 | _startRangeLabel.textAlignment = NSTextAlignmentRight;
57 | _startRangeLabel.backgroundColor = [UIColor clearColor];
58 | [self addSubview:_startRangeLabel];
59 |
60 | CGPoint innerArcEndPoint = [self.backgroundArcLayer pointForArcEdge:ArcEdgeInner andArcSide:ArcSideEnd];
61 | _endRangeLabel = [[UILabel alloc] initWithFrame:CGRectMake(innerArcEndPoint.x, innerArcEndPoint.y+4, self.frame.size.width-innerArcEndPoint.x, 14)];
62 | _endRangeLabel.font = [UIFont systemFontOfSize:10];
63 | _endRangeLabel.textColor = [UIColor lightGrayColor];
64 | _endRangeLabel.backgroundColor = [UIColor clearColor];
65 | [self addSubview:_endRangeLabel];
66 | }
67 | return self;
68 | }
69 |
70 | #pragma mark - Setters
71 | - (void)setValue:(float)value
72 | {
73 | [super setValue:value];
74 | if ( value <= self.maxValue && value >= self.minValue )
75 | {
76 | [self updateValueLabelAnimated:NO];
77 | }
78 | }
79 |
80 | - (void)updateValueLabelAnimated:(BOOL)animated
81 | {
82 | if ( animated )
83 | {
84 | //[NSTimer scheduledTimerWithTimeInterval:.05
85 | // target:self
86 | // selector:@selector(incrementTimerFired:)
87 | // userInfo:niln
88 | // repeats:YES];
89 | }
90 | else
91 | {
92 | [self updateValueLabelWithValue:self.value];
93 | }
94 | }
95 | //
96 | //- (void)setValue:(float)value animated:(BOOL)animated
97 | //{
98 | // [super setValue:value animated:animated];
99 | // [self updateValueLabelAnimated:animated];
100 | //}
101 | //
102 | //- (void)incrementTimerFired:(NSTimer*)timer
103 | //{
104 | // float currentLabelValue = _valueLabel.text.floatValue;
105 | // if ( currentLabelValue == self.value )
106 | // {
107 | // [timer invalidate];
108 | // }
109 | // else
110 | // {
111 | // currentLabelValue++;
112 | // [self updateValueLabelWithValue:currentLabelValue];
113 | // }
114 | //}
115 | //
116 | - (void)updateValueLabelWithValue:(float)value
117 | {
118 | _valueLabel.text = [NSString stringWithFormat:@"%@%% Used", [_valueFormatter stringFromNumber:@(value)]];
119 | }
120 |
121 | @end
122 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSArcLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // PBArcLayer.h
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/13/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef enum {
12 | ArcEdgeInner = 0,
13 | ArcEdgeOuter
14 | } ArcEdge;
15 |
16 | typedef enum {
17 | ArcSideBegining = 0,
18 | ArcSideEnd
19 | } ArcSide;
20 |
21 | @interface MSArcLayer : CALayer
22 | @property (nonatomic,assign) CGFloat startAngle;
23 | @property (nonatomic,assign) CGFloat endAngle;
24 | @property (nonatomic,assign) CGFloat strokeWidth;
25 | @property (nonatomic,assign) CGFloat arcThickness;
26 | @property (nonatomic) UIColor *fillColor;
27 | @property (nonatomic) UIColor *strokeColor;
28 | - (CGPoint)pointForArcEdge:(ArcEdge)edge andArcSide:(ArcSide)side;
29 | @end
30 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSArcLayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // PBArcLayer.m
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/13/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #define M_PI 3.14159265358979323846264338327950288
10 | #define DEGREES_TO_RADIANS(angle) (angle * (M_PI/180))
11 |
12 | #import "MSArcLayer.h"
13 |
14 | NSString * const startAngleKey = @"startAngle";
15 | NSString * const endAngleKey = @"endAngle";
16 |
17 | @implementation MSArcLayer
18 |
19 | + (BOOL)needsDisplayForKey:(NSString *)key
20 | {
21 | if ( [key isEqualToString:startAngleKey] ||
22 | [key isEqualToString:endAngleKey] )
23 | {
24 | return YES;
25 | }
26 | return [super needsDisplayForKey:key];
27 | }
28 |
29 | - (id)initWithLayer:(id)layer
30 | {
31 | self = [super initWithLayer:layer];
32 | if ( self )
33 | {
34 | if ( [layer isKindOfClass:[MSArcLayer class]] )
35 | {
36 | MSArcLayer *otherLayer = (MSArcLayer*)layer;
37 | self.startAngle = otherLayer.startAngle;
38 | self.endAngle = otherLayer.endAngle;
39 | self.fillColor = otherLayer.fillColor;
40 | self.arcThickness = otherLayer.arcThickness;
41 | self.strokeColor = otherLayer.strokeColor;
42 | self.strokeWidth = otherLayer.strokeWidth;
43 |
44 | // otherLayer.startAngle = self.startAngle;
45 | // otherLayer.endAngle = self.endAngle;
46 | // otherLayer.fillColor = self.fillColor;
47 | // otherLayer.arcThickness = self.arcThickness;
48 | // otherLayer.strokeColor = self.strokeColor;
49 | // otherLayer.strokeWidth = self.strokeWidth;
50 | }
51 | }
52 | return self;
53 | }
54 |
55 | #pragma mark - Public
56 | - (CGPoint)pointForArcEdge:(ArcEdge)edge andArcSide:(ArcSide)side
57 | {
58 | CGFloat width = self.bounds.size.width;
59 | CGFloat height = self.bounds.size.height;
60 | CGFloat radius = width/2;
61 | if ( edge == ArcEdgeInner )
62 | {
63 | radius -= self.arcThickness;
64 | }
65 |
66 | CGFloat angle = self.startAngle;
67 | if ( side == ArcSideEnd )
68 | {
69 | angle = self.endAngle;
70 | }
71 |
72 | CGFloat x = width/2 + radius * cosf(angle);
73 | CGFloat y = height + radius * sinf(angle);
74 |
75 | return CGPointMake(x,y);
76 | }
77 |
78 | #pragma mark - Private
79 | - (CABasicAnimation*)makeAnimationForKey:(NSString *)key
80 | {
81 | CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:key];
82 | anim.fromValue = [[self presentationLayer] valueForKey:key];
83 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
84 | anim.duration = 0.5;
85 |
86 | return anim;
87 | }
88 |
89 | #pragma mark - Protected
90 | - (void)drawArcInContext:(CGContextRef)ctx
91 | {
92 | CGPoint center = CGPointMake(self.bounds.size.width/2, self.bounds.size.height);
93 | CGFloat radius = self.bounds.size.width/2;
94 |
95 | CGContextBeginPath(ctx);
96 |
97 | // outer arc
98 | CGContextAddArc(ctx, center.x, center.y, radius, self.startAngle, self.endAngle, NO);
99 |
100 | // line down to the inner arc
101 | CGPoint innerArchEnd = [self pointForArcEdge:ArcEdgeInner andArcSide:ArcSideEnd];
102 | CGContextAddLineToPoint(ctx, innerArchEnd.x, innerArchEnd.y);
103 |
104 | // inner arc
105 | CGContextAddArc(ctx, center.x, center.y, radius-self.arcThickness, self.endAngle, self.startAngle, YES);
106 |
107 | // final connection back up to outer arc
108 | CGPoint outerArcStart = [self pointForArcEdge:ArcEdgeOuter andArcSide:ArcSideBegining];
109 | CGContextAddLineToPoint(ctx, outerArcStart.x, outerArcStart.y);
110 | }
111 |
112 | - (id)actionForKey:(NSString *)event
113 | {
114 | if ( [event isEqualToString:startAngleKey] ||
115 | [event isEqualToString:endAngleKey] )
116 | {
117 | return [self makeAnimationForKey:event];
118 | }
119 | return [super actionForKey:event];
120 | }
121 |
122 | - (void)drawInContext:(CGContextRef)ctx
123 | {
124 | if ( self.startAngle < self.endAngle )
125 | {
126 | [self drawArcInContext:ctx];
127 | CGContextClosePath(ctx);
128 |
129 | // Color it
130 | CGContextSetFillColorWithColor(ctx, self.fillColor.CGColor);
131 | CGContextSetStrokeColorWithColor(ctx, self.strokeColor.CGColor);
132 | CGContextSetLineWidth(ctx, self.strokeWidth);
133 |
134 | CGContextDrawPath(ctx, kCGPathFillStroke);
135 | }
136 | }
137 |
138 | @dynamic startAngle,endAngle,arcThickness,fillColor,strokeWidth,strokeColor;
139 | @end
140 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSArcLayerSubclass.h:
--------------------------------------------------------------------------------
1 | //
2 | // PBArcLayerSubclass.h
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/15/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #ifndef SimpleGauge_PBArcLayerSubclass_h
10 | #define SimpleGauge_PBArcLayerSubclass_h
11 |
12 | #import "MSArcLayer.h"
13 |
14 | @interface MSArcLayer (SubclassInfo)
15 | - (void)drawArcInContext:(CGContextRef)ctx;
16 | @end
17 |
18 | #endif
19 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSGradientArcLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // PBGradientArcLayer.h
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/15/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "MSArcLayerSubclass.h"
11 |
12 | @interface MSGradientArcLayer : MSArcLayer
13 | + (CGGradientRef)defaultGradient;
14 | @property (nonatomic,assign) CGGradientRef gradient;
15 | @end
16 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSGradientArcLayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // PBGradientArcLayer.m
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/15/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import "MSGradientArcLayer.h"
10 |
11 | @implementation MSGradientArcLayer
12 | + (CGGradientRef)defaultGradient
13 | {
14 | size_t num_locations = 2;
15 | CGFloat locations[2] = { 0.0, 1.0 };
16 | CGFloat components[8] = { .23,.56,.75,1.0, // Start color
17 | .48,.71,.84,1.0 }; // End color
18 | CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB();
19 | CGGradientRef myGradient = CGGradientCreateWithColorComponents (myColorspace, components, locations, num_locations);
20 | return myGradient;
21 | }
22 |
23 | - (id)initWithLayer:(id)layer
24 | {
25 | self = [super initWithLayer:layer];
26 | if ( self )
27 | {
28 | if ( [layer isKindOfClass:[MSGradientArcLayer class]] )
29 | {
30 | MSGradientArcLayer *otherLayer = (MSGradientArcLayer*)layer;
31 | self.gradient = otherLayer.gradient;
32 | }
33 | }
34 | return self;
35 | }
36 |
37 | - (void)drawInContext:(CGContextRef)ctx
38 | {
39 | // if there is a gradient defined, draw it. Otherwise have super do the drawing
40 | if ( self.gradient )
41 | {
42 | if ( self.startAngle < self.endAngle )
43 | {
44 | CGPoint center = CGPointMake(self.bounds.size.width/2, self.bounds.size.height);
45 | CGFloat radius = self.bounds.size.width/2;
46 |
47 | [self drawArcInContext:ctx];
48 | CGContextClip(ctx);
49 | CGContextDrawRadialGradient(ctx, _gradient, center, radius-self.arcThickness, center, radius, 0);
50 | }
51 | }
52 | else
53 | {
54 | [super drawInContext:ctx];
55 | }
56 | }
57 |
58 | - (void)setGradient:(CGGradientRef)gradient
59 | {
60 | _gradient = gradient;
61 | [self setNeedsDisplay];
62 | }
63 |
64 | @end
65 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSNeedleView.h:
--------------------------------------------------------------------------------
1 | //
2 | // PBNeedleView.h
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/10/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MSNeedleView : UIView
12 | @property (nonatomic) UIColor *needleColor;
13 | @end
14 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSNeedleView.m:
--------------------------------------------------------------------------------
1 | //
2 | // PBNeedleView.m
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/10/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import "MSNeedleView.h"
10 |
11 | @implementation MSNeedleView
12 |
13 | - (void)setup
14 | {
15 | _needleColor = [UIColor blackColor];
16 | }
17 |
18 | - (id)initWithFrame:(CGRect)frame
19 | {
20 | self = [super initWithFrame:frame];
21 | if (self)
22 | {
23 | [self setup];
24 | self.backgroundColor = [UIColor clearColor];
25 | }
26 | return self;
27 | }
28 |
29 | - (void)drawRect:(CGRect)rect
30 | {
31 | CGFloat width = rect.size.width;
32 | CGFloat height = rect.size.height;
33 |
34 | CGContextRef context = UIGraphicsGetCurrentContext();
35 | CGContextClearRect(context, rect);
36 |
37 | CGContextSetFillColorWithColor(context, _needleColor.CGColor);
38 | CGContextSetStrokeColorWithColor(context, _needleColor.CGColor);
39 |
40 | CGRect circleRect = CGRectMake(0, height-width, width, width);
41 | CGContextFillEllipseInRect(context, circleRect);
42 |
43 |
44 | CGMutablePathRef path = CGPathCreateMutable();
45 | CGPathMoveToPoint(path, NULL, 0, height-width/2);
46 | CGPathAddLineToPoint(path, NULL, width/2, 0);
47 | CGPathAddLineToPoint(path, NULL, width, height-width/2);
48 | CGPathAddLineToPoint(path, NULL, 0, height-width/2);
49 | CGPathCloseSubpath(path);
50 |
51 | CGContextAddPath(context, path);
52 | CGContextFillPath(context);
53 | }
54 |
55 | - (void)setNeedleColor:(UIColor *)needleColor
56 | {
57 | if ( _needleColor != needleColor )
58 | {
59 | _needleColor = needleColor;
60 | [self setNeedsDisplay];
61 | }
62 | }
63 | @end
64 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSRangeGauge.h:
--------------------------------------------------------------------------------
1 | //
2 | // PBRangeGauge.h
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/21/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import "MSSimpleGaugeSubclass.h"
10 |
11 | @interface MSRangeGauge : MSSimpleGauge
12 | @property (nonatomic,assign) float lowerRangeValue;
13 | @property (nonatomic,assign) float upperRangeValue;
14 | @property (nonatomic) UIColor *rangeFillColor;
15 | - (void)setLowerRangeValue:(float)lowerRangeValue animated:(BOOL)animated;
16 | - (void)setUpperRangeValue:(float)upperRangeValue animated:(BOOL)animated;
17 | @end
18 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSRangeGauge.m:
--------------------------------------------------------------------------------
1 | //
2 | // PBRangeGauge.m
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/21/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import "MSRangeGauge.h"
10 | #import "MSGradientArcLayer.h"
11 |
12 | @interface MSRangeGauge ()
13 | @property (nonatomic) MSGradientArcLayer *rangeArc;
14 | @end
15 |
16 | @implementation MSRangeGauge
17 |
18 | #pragma mark - Protected
19 | - (void)setupArcLayers
20 | {
21 | [super setupArcLayers];
22 | _rangeArc = [MSGradientArcLayer layer];
23 | _rangeArc.arcThickness = self.arcThickness;
24 | _rangeArc.startAngle = DEGREES_TO_RADIANS((self.startAngle+180));
25 | _rangeArc.endAngle = DEGREES_TO_RADIANS((self.startAngle+180));
26 | _rangeArc.bounds = self.containerLayer.bounds;
27 | _rangeArc.anchorPoint = CGPointZero;
28 | if ( [_rangeArc respondsToSelector:@selector(contentsScale)] )
29 | {
30 | _rangeArc.contentsScale = [[UIScreen mainScreen] scale];
31 | }
32 | [self.containerLayer addSublayer:_rangeArc];
33 | }
34 |
35 | // make this a no-op for the subclass
36 | - (void)fillUpToAngle:(float)angle {}
37 |
38 | #pragma mark - Setters
39 | - (void)setUpperRangeValue:(float)upperRangeValue animated:(BOOL)animated
40 | {
41 | [self setValue:@(upperRangeValue) forKey:@"upperRangeValue" animated:animated];
42 | }
43 |
44 | - (void)setLowerRangeValue:(float)lowerRangeValue animated:(BOOL)animated
45 | {
46 | [self setValue:@(lowerRangeValue) forKey:@"lowerRangeValue" animated:animated];
47 | }
48 |
49 | - (void)setUpperRangeValue:(float)upperRangeValue
50 | {
51 | upperRangeValue = fminf(upperRangeValue, self.maxValue);
52 | if ( _upperRangeValue != upperRangeValue )
53 | {
54 | _upperRangeValue = upperRangeValue;
55 | _rangeArc.endAngle = DEGREES_TO_RADIANS(([self angleForValue:_upperRangeValue]+180));
56 | }
57 | }
58 |
59 | - (void)setLowerRangeValue:(float)lowerRangeValue
60 | {
61 | lowerRangeValue = fmaxf(lowerRangeValue, self.minValue);
62 | if ( _lowerRangeValue != lowerRangeValue )
63 | {
64 | _lowerRangeValue = lowerRangeValue;
65 | _rangeArc.startAngle = DEGREES_TO_RADIANS(([self angleForValue:_lowerRangeValue]+180));
66 | }
67 | }
68 |
69 | - (void)setRangeFillColor:(UIColor *)rangeFillColor
70 | {
71 | _rangeArc.fillColor = rangeFillColor;
72 | }
73 | @end
74 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSSimpleGauge.h:
--------------------------------------------------------------------------------
1 | //
2 | // PBSimpleGauge.h
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/9/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "MSNeedleView.h"
11 |
12 | @interface MSSimpleGauge : UIView
13 | @property (nonatomic) MSNeedleView *needleView;
14 | @property (nonatomic,assign) float maxValue;
15 | @property (nonatomic,assign) float minValue;
16 | @property (nonatomic,assign) float value;
17 | @property (nonatomic,assign) float startAngle;
18 | @property (nonatomic,assign) float endAngle;
19 | @property (nonatomic,assign) float arcThickness;
20 | @property (nonatomic) UIColor *backgroundArcFillColor;
21 | @property (nonatomic) UIColor *backgroundArcStrokeColor;
22 | @property (nonatomic) UIColor *fillArcFillColor;
23 | @property (nonatomic) UIColor *fillArcStrokeColor;
24 | @property (nonatomic) CGGradientRef fillGradient;
25 | @property (nonatomic) CGGradientRef backgroundGradient;
26 | - (void)setValue:(float)value animated:(BOOL)animated;
27 | - (void)setStartAngle:(float)startAngle animated:(BOOL)animted;
28 | - (void)setEndAngle:(float)endAngle animated:(BOOL)animated;
29 | @end
30 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSSimpleGauge.m:
--------------------------------------------------------------------------------
1 | //
2 | // PBSimpleGauge.m
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/9/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #import "MSSimpleGauge.h"
10 | #import "MSArcLayer.h"
11 | #import "MSGradientArcLayer.h"
12 | #import
13 |
14 | #define M_PI 3.14159265358979323846264338327950288
15 | #define DEGREES_TO_RADIANS(angle) (angle * (M_PI/180))
16 |
17 | #define NEEDLE_BASE_WIDTH_RATIO .04
18 |
19 | @interface MSSimpleGauge ()
20 | @property (nonatomic) CALayer *containerLayer;
21 | @property (nonatomic) MSGradientArcLayer *valueArcLayer;
22 | @property (nonatomic) MSGradientArcLayer *backgroundArcLayer;
23 | @end
24 |
25 | @implementation MSSimpleGauge
26 | #pragma mark - Initialization / Construction
27 | - (void)setup
28 | {
29 | _minValue = 0;
30 | _maxValue = 100;
31 | _value = 0;
32 |
33 | _startAngle = 40;
34 | _endAngle = 140;
35 |
36 | _arcThickness = 50;
37 |
38 | _backgroundArcFillColor = [UIColor colorWithRed:.82 green:.82 blue:.82 alpha:1];
39 | _backgroundArcStrokeColor = [UIColor colorWithRed:.82 green:.82 blue:.82 alpha:1];
40 |
41 | CGFloat width = self.frame.size.width;
42 | CGFloat height = self.frame.size.height;
43 |
44 | CGFloat needleWidth = width * NEEDLE_BASE_WIDTH_RATIO;
45 | _needleView = [[MSNeedleView alloc] initWithFrame:CGRectMake(0,
46 | 0,
47 | needleWidth,
48 | width/2+4)];
49 | if ( [_needleView respondsToSelector:@selector(contentScaleFactor)] )
50 | {
51 | _needleView.contentScaleFactor = [[UIScreen mainScreen] scale];
52 | }
53 | [self addSubview:_needleView];
54 |
55 | self.backgroundColor = [UIColor whiteColor];
56 |
57 | _needleView.layer.anchorPoint = CGPointMake(.5, (height-(needleWidth/2))/height);
58 | _needleView.center = CGPointMake(width/2, height-needleWidth/2);
59 | [self rotateNeedleByAngle:-90+_startAngle];
60 |
61 | _containerLayer = [CALayer layer];
62 | _containerLayer.frame = CGRectMake(0, 0, width, height);
63 | [self.layer insertSublayer:_containerLayer atIndex:0];
64 | [self setupArcLayers];
65 | }
66 |
67 | - (id)initWithFrame:(CGRect)frame
68 | {
69 | self = [super initWithFrame:frame];
70 | if (self)
71 | {
72 | [self setup];
73 | }
74 | return self;
75 | }
76 |
77 | #pragma mark - Private / Protected
78 | - (void)setValue:(id)value forKey:(NSString *)key animated:(BOOL)animated
79 | {
80 | // half second duration or none depending on animated flag
81 | float duration = animated ? .5 : 0;
82 | [UIView animateWithDuration:duration
83 | delay:0
84 | options:UIViewAnimationOptionCurveEaseOut|UIViewAnimationOptionBeginFromCurrentState
85 | animations:^{
86 | [self setValue:value forKey:key];
87 | }
88 | completion:^(BOOL finished) {
89 | }];
90 | }
91 |
92 |
93 | - (void)rotateNeedleByAngle:(float)angle
94 | {
95 | CATransform3D rotatedTransform = self.needleView.layer.transform;
96 | rotatedTransform = CATransform3DRotate(rotatedTransform, DEGREES_TO_RADIANS(angle), 0.0f, 0.0f, 1.0f);
97 | self.needleView.layer.transform = rotatedTransform;
98 | }
99 |
100 | - (void)setupArcLayers
101 | {
102 | _backgroundArcLayer = [MSGradientArcLayer layer];
103 | _backgroundArcLayer.strokeColor = _backgroundArcStrokeColor;
104 | _backgroundArcLayer.fillColor = _backgroundArcFillColor;
105 | _backgroundArcLayer.gradient = _backgroundGradient;
106 | _backgroundArcLayer.strokeWidth = 1.0;
107 | _backgroundArcLayer.arcThickness = _arcThickness;
108 | _backgroundArcLayer.startAngle = DEGREES_TO_RADIANS((_startAngle+180));
109 | _backgroundArcLayer.endAngle = DEGREES_TO_RADIANS((_endAngle+180));
110 | _backgroundArcLayer.bounds = _containerLayer.bounds;
111 | _backgroundArcLayer.anchorPoint = CGPointZero;
112 | if ( [_backgroundArcLayer respondsToSelector:@selector(contentsScale)] )
113 | {
114 | _backgroundArcLayer.contentsScale = [[UIScreen mainScreen] scale];
115 | }
116 | [_containerLayer addSublayer:_backgroundArcLayer];
117 |
118 | _valueArcLayer = [MSGradientArcLayer layer];
119 | _valueArcLayer.strokeColor = _fillArcStrokeColor;
120 | _valueArcLayer.fillColor = _fillArcFillColor;
121 | _valueArcLayer.gradient = _fillGradient;
122 | _valueArcLayer.arcThickness = _arcThickness;
123 | _valueArcLayer.startAngle = DEGREES_TO_RADIANS((_startAngle+180));
124 | _valueArcLayer.endAngle = DEGREES_TO_RADIANS((_startAngle+180));
125 | _valueArcLayer.bounds = _containerLayer.bounds;
126 | _valueArcLayer.anchorPoint = CGPointZero;
127 | if ( [_valueArcLayer respondsToSelector:@selector(contentsScale)] )
128 | {
129 | _valueArcLayer.contentsScale = [[UIScreen mainScreen] scale];
130 | }
131 | [_containerLayer addSublayer:_valueArcLayer];
132 | }
133 |
134 | - (void)fillUpToAngle:(float)angle
135 | {
136 | if ( _valueArcLayer )
137 | {
138 | _valueArcLayer.endAngle = DEGREES_TO_RADIANS((angle+180));
139 | }
140 | }
141 |
142 | - (float)angleForValue:(float)value
143 | {
144 | float ratio = value / _maxValue;
145 | float angle = _startAngle + ((_endAngle - _startAngle) * ratio);
146 | return angle;
147 | }
148 |
149 | #pragma mark - Setters
150 | - (void)setArcThickness:(float)arcThickness
151 | {
152 | if ( _arcThickness != arcThickness )
153 | {
154 | _arcThickness = arcThickness;
155 | [self setNeedsDisplay];
156 | }
157 | }
158 |
159 | - (void)setStartAngle:(float)startAngle
160 | {
161 | if ( _startAngle != startAngle )
162 | {
163 | float oldNeedleAngle = [self angleForValue:self.value];
164 |
165 | _startAngle = startAngle;
166 | _backgroundArcLayer.startAngle = DEGREES_TO_RADIANS((_startAngle+180));
167 | _valueArcLayer.startAngle = DEGREES_TO_RADIANS((_startAngle+180));
168 |
169 | float newNeedleAngle = [self angleForValue:self.value];
170 | float newAngle = newNeedleAngle - oldNeedleAngle;
171 | [self rotateNeedleByAngle:newAngle];
172 | }
173 | }
174 |
175 | - (void)setEndAngle:(float)endAngle
176 | {
177 | if ( _endAngle != endAngle )
178 | {
179 | float oldNeedleAngle = [self angleForValue:self.value];
180 |
181 | _endAngle = endAngle;
182 | _backgroundArcLayer.endAngle = DEGREES_TO_RADIANS((_endAngle+180));
183 | _valueArcLayer.endAngle = DEGREES_TO_RADIANS((oldNeedleAngle+180));
184 |
185 | float newNeedleAngle = [self angleForValue:self.value];
186 | float newAngle = newNeedleAngle - oldNeedleAngle;
187 | [self rotateNeedleByAngle:newAngle];
188 | }
189 | }
190 |
191 | - (void)setMinValue:(float)minValue
192 | {
193 | if ( _minValue != minValue )
194 | {
195 | // don't let the min value be greater than the max value
196 | minValue = minValue > _maxValue ? _maxValue : minValue;
197 | _minValue = minValue;
198 | }
199 | }
200 |
201 | - (void)setMaxValue:(float)maxValue
202 | {
203 | if ( _maxValue != maxValue )
204 | {
205 | // don't let the max value be lower then the min value
206 | maxValue = maxValue < _minValue ? _minValue : maxValue;
207 | _maxValue = maxValue;
208 | }
209 | }
210 |
211 | - (void)setValue:(float)value
212 | {
213 | if ( _value != value )
214 | {
215 | // setting value above the max value sets to max value
216 | value = value > _maxValue ? _maxValue : value;
217 |
218 | // setting value below the min value set to min value
219 | value = value < _minValue ? _minValue : value;
220 |
221 | float oldAngle = [self angleForValue:_value];
222 | float newAngle = [self angleForValue:value];
223 | _value = value;
224 |
225 | [self rotateNeedleByAngle:newAngle - oldAngle];
226 | [self fillUpToAngle:newAngle];
227 | }
228 | }
229 |
230 | - (void)setBackgroundArcFillColor:(UIColor *)backgroundArcFillColor
231 | {
232 | _backgroundArcLayer.fillColor = backgroundArcFillColor;
233 | }
234 |
235 | - (void)setBackgroundArcStrokeColor:(UIColor *)backgroundArcStrokeColor
236 | {
237 | _backgroundArcLayer.strokeColor = backgroundArcStrokeColor;
238 | }
239 |
240 | - (void)setFillArcFillColor:(UIColor *)foregroundArcFillColor
241 | {
242 | _valueArcLayer.fillColor = foregroundArcFillColor;
243 | }
244 |
245 | - (void)setFillArcStrokeColor:(UIColor *)foregroundArcStrokeColor
246 | {
247 | _valueArcLayer.strokeColor = foregroundArcStrokeColor;
248 | }
249 |
250 | - (void)setFillGradient:(CGGradientRef)fillGradient
251 | {
252 | _valueArcLayer.gradient = fillGradient;
253 | }
254 |
255 | - (void)setBackgroundGradient:(CGGradientRef)backgroundGradient
256 | {
257 | _backgroundArcLayer.gradient = backgroundGradient;
258 | }
259 |
260 | #pragma mark - Animated Setters
261 | - (void)setValue:(float)value animated:(BOOL)animated
262 | {
263 | [self setValue:@(value) forKey:@"value" animated:animated];
264 | }
265 |
266 | - (void)setEndAngle:(float)endAngle animated:(BOOL)animated
267 | {
268 | [self setValue:@(endAngle) forKey:@"endAngle" animated:animated];
269 | }
270 |
271 | - (void)setStartAngle:(float)startAngle animated:(BOOL)animted
272 | {
273 | [self setValue:@(startAngle) forKey:@"startAngle" animated:animted];
274 | }
275 | @end
276 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Gauges/MSSimpleGaugeSubclass.h:
--------------------------------------------------------------------------------
1 | //
2 | // PBSimpleGaugeSubclass.h
3 | // SimpleGauge
4 | //
5 | // Created by Mike Sabatini on 1/21/13.
6 | // Copyright (c) 2013 Mike Sabatini. All rights reserved.
7 | //
8 |
9 | #ifndef SimpleGauge_PBSimpleGaugeSubclass_h
10 | #define SimpleGauge_PBSimpleGaugeSubclass_h
11 |
12 | #define M_PI 3.14159265358979323846264338327950288
13 | #define DEGREES_TO_RADIANS(angle) (angle * (M_PI/180))
14 |
15 | #import "MSSimpleGauge.h"
16 | #import "MSArcLayer.h"
17 |
18 | @interface MSSimpleGauge (Subclass)
19 | @property (nonatomic) CALayer *containerLayer;
20 | @property (nonatomic) MSArcLayer *backgroundArcLayer;
21 | - (void)setup;
22 | - (void)setupArcLayers;
23 | - (float)angleForValue:(float)value;
24 | - (void)fillUpToAngle:(float)angle;
25 | - (void)setValue:(id)value forKey:(NSString *)key animated:(BOOL)animated;
26 | @end
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Images/Disk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/SystemServicesDemo/Images/Disk.png
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Images/Disk@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/SystemServicesDemo/Images/Disk@2x.png
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Images/Hardware.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/SystemServicesDemo/Images/Hardware.png
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Images/Hardware@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/SystemServicesDemo/Images/Hardware@2x.png
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Images/Memory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/SystemServicesDemo/Images/Memory.png
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Images/Memory@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/SystemServicesDemo/Images/Memory@2x.png
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Images/Network.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/SystemServicesDemo/Images/Network.png
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/Images/Network@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/SystemServicesDemo/Images/Network@2x.png
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/PCPieChart.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2011 Muh Hon Cheng
3 | * Created by honcheng on 28/4/11.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining
6 | * a copy of this software and associated documentation files (the
7 | * "Software"), to deal in the Software without restriction, including
8 | * without limitation the rights to use, copy, modify, merge, publish,
9 | * distribute, sublicense, and/or sell copies of the Software, and to
10 | * permit persons to whom the Software is furnished to do so, subject
11 | * to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be
14 | * included in all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
17 | * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR
20 | * PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21 | * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR
25 | * IN CONNECTION WITH THE SOFTWARE OR
26 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 | *
28 | * @author Muh Hon Cheng
29 | * @copyright 2011 Muh Hon Cheng
30 | * @version
31 | *
32 | */
33 |
34 | #import
35 | #import "PCPieChart.h"
36 |
37 | @interface PCPieComponent : NSObject
38 | @property (nonatomic, assign) float value, startDeg, endDeg;
39 | @property (nonatomic, strong) UIColor *colour;
40 | @property (nonatomic, copy) NSString *title;
41 | - (id)initWithTitle:(NSString*)title value:(float)value;
42 | + (id)pieComponentWithTitle:(NSString*)title value:(float)value;
43 | @end
44 |
45 | #define PCColorBlue [UIColor colorWithRed:0.0 green:153/255.0 blue:204/255.0 alpha:1.0]
46 | #define PCColorGreen [UIColor colorWithRed:153/255.0 green:204/255.0 blue:51/255.0 alpha:1.0]
47 | #define PCColorOrange [UIColor colorWithRed:1.0 green:153/255.0 blue:51/255.0 alpha:1.0]
48 | #define PCColorRed [UIColor colorWithRed:1.0 green:51/255.0 blue:51/255.0 alpha:1.0]
49 | #define PCColorYellow [UIColor colorWithRed:1.0 green:220/255.0 blue:0.0 alpha:1.0]
50 | #define PCColorDefault [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0]
51 |
52 | @interface PCPieChart : UIView
53 | @property (nonatomic, assign) int diameter;
54 | @property (nonatomic, strong) NSMutableArray *components;
55 | @property (nonatomic, strong) UIFont *titleFont, *percentageFont;
56 | @property (nonatomic, assign) BOOL showArrow, sameColorLabel;
57 | @property (nonatomic, assign, getter = hasOutline) BOOL outline;
58 | @end
59 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemo-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | SS Demo
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIcons
12 |
13 | CFBundlePrimaryIcon
14 |
15 | CFBundleIconFiles
16 |
17 | icon@2x.png
18 | icon.png
19 |
20 |
21 |
22 | CFBundleIdentifier
23 | $(PRODUCT_BUNDLE_IDENTIFIER)
24 | CFBundleInfoDictionaryVersion
25 | 6.0
26 | CFBundleName
27 | ${PRODUCT_NAME}
28 | CFBundlePackageType
29 | APPL
30 | CFBundleShortVersionString
31 | 2.0.1
32 | CFBundleSignature
33 | ????
34 | CFBundleVersion
35 | 1
36 | LSRequiresIPhoneOS
37 |
38 | NSAppTransportSecurity
39 |
40 | NSAllowsArbitraryLoads
41 |
42 |
43 | UIMainStoryboardFile
44 | MainStoryboard
45 | UIRequiredDeviceCapabilities
46 |
47 | armv7
48 |
49 | UIStatusBarHidden
50 |
51 | UISupportedInterfaceOrientations
52 |
53 | UIInterfaceOrientationPortrait
54 | UIInterfaceOrientationPortraitUpsideDown
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemo-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'SystemServicesDemo' target in the 'SystemServicesDemo' project
3 | //
4 |
5 | #import
6 |
7 | #ifndef __IPHONE_5_0
8 | #warning "This project uses features only available in iOS SDK 5.0 and later."
9 | #endif
10 |
11 | #ifdef __OBJC__
12 | #import
13 | #import
14 | #endif
15 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemoAppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServicesDemoAppDelegate.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/15/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SystemServicesDemoAppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemoAppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServicesDemoAppDelegate.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/15/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SystemServicesDemoAppDelegate.h"
10 |
11 | @implementation SystemServicesDemoAppDelegate
12 |
13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
14 | {
15 | // Override point for customization after application launch.
16 | return YES;
17 | }
18 |
19 | - (void)applicationWillResignActive:(UIApplication *)application
20 | {
21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
23 | }
24 |
25 | - (void)applicationDidEnterBackground:(UIApplication *)application
26 | {
27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | - (void)applicationWillEnterForeground:(UIApplication *)application
32 | {
33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | - (void)applicationDidBecomeActive:(UIApplication *)application
37 | {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application
42 | {
43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemoDiskViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServicesDemoDiskViewController.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Kramer on 4/4/13.
6 | // Copyright (c) 2013 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SystemServicesDemoDiskViewController : UIViewController
12 |
13 | @property (strong, nonatomic) IBOutlet UILabel *lblTotalDiskSpace;
14 | @property (strong, nonatomic) IBOutlet UILabel *lblUsedDiskSpace;
15 | @property (strong, nonatomic) IBOutlet UILabel *lblFreeDiskSpace;
16 |
17 | - (IBAction)refresh:(id)sender;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemoDiskViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServicesDemoDiskViewController.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Kramer on 4/4/13.
6 | // Copyright (c) 2013 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SystemServicesDemoDiskViewController.h"
10 | #import "SystemServices.h"
11 |
12 | // Annotated Gauge
13 | #import "MSAnnotatedGauge.h"
14 | #import "MSGradientArcLayer.h"
15 |
16 | #define SystemSharedServices [SystemServices sharedServices]
17 |
18 | #define isiPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE
19 |
20 | @interface SystemServicesDemoDiskViewController ()
21 | // Annotated Gauge
22 | @property (nonatomic) MSAnnotatedGauge *annotatedGauge;
23 | @end
24 |
25 | @implementation SystemServicesDemoDiskViewController
26 |
27 | - (void)viewDidLoad
28 | {
29 | [super viewDidLoad];
30 | // Do any additional setup after loading the view.
31 |
32 | // Get all the disk info
33 | [self performSelector:@selector(getAllDiskInformation)];
34 | }
35 |
36 | - (void)getAllDiskInformation {
37 | // Total Disk Space
38 | self.lblTotalDiskSpace.text = [NSString stringWithFormat:@"Total Disk Space: %@",[SystemSharedServices diskSpace]];
39 | // Used Disk Space
40 | self.lblUsedDiskSpace.text = [NSString stringWithFormat:@"Used Disk Space: %@ %@", [SystemSharedServices usedDiskSpaceinRaw], [SystemSharedServices usedDiskSpaceinPercent]];
41 | // Free Disk Space
42 | self.lblFreeDiskSpace.text = [NSString stringWithFormat:@"Free Disk Space: %@ %@", [SystemSharedServices freeDiskSpaceinRaw], [SystemSharedServices freeDiskSpaceinPercent]];
43 |
44 | [self.annotatedGauge removeFromSuperview];
45 | self.annotatedGauge = nil;
46 | int yPosition = (isiPhone5) ? 350 : 300;
47 | self.annotatedGauge = [[MSAnnotatedGauge alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - yPosition, 320, 210)];
48 | self.annotatedGauge.minValue = 0;
49 | self.annotatedGauge.maxValue = 100;
50 | [self.annotatedGauge setBackgroundColor:[UIColor clearColor]];
51 | self.annotatedGauge.titleLabel.text = [NSString stringWithFormat:@"Total Space: %@", [SystemSharedServices diskSpace]];
52 | self.annotatedGauge.startRangeLabel.text = [NSString stringWithFormat:@"%@ Used", [SystemSharedServices usedDiskSpaceinRaw]];
53 | self.annotatedGauge.endRangeLabel.text = [NSString stringWithFormat:@"%@ Free", [SystemSharedServices freeDiskSpaceinRaw]];
54 | self.annotatedGauge.fillGradient = [MSGradientArcLayer defaultGradient];
55 | self.annotatedGauge.value = [[SystemSharedServices usedDiskSpaceinPercent] floatValue];
56 | [self.annotatedGauge setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
57 | [self.view addSubview:self.annotatedGauge];
58 | }
59 |
60 | - (IBAction)refresh:(id)sender {
61 | [self getAllDiskInformation];
62 | }
63 |
64 | - (void)didReceiveMemoryWarning
65 | {
66 | [super didReceiveMemoryWarning];
67 | // Dispose of any resources that can be recreated.
68 | }
69 |
70 | - (void)viewDidUnload {
71 | [self setLblTotalDiskSpace:nil];
72 | [self setLblUsedDiskSpace:nil];
73 | [self setLblFreeDiskSpace:nil];
74 | [super viewDidUnload];
75 | }
76 |
77 | @end
78 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemoMemoryViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServicesDemoMemoryViewController.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Kramer on 4/4/13.
6 | // Copyright (c) 2013 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SystemServicesDemoMemoryViewController : UIViewController
12 |
13 | @property (strong, nonatomic) IBOutlet UILabel *lblMemoryRAM;
14 | @property (strong, nonatomic) IBOutlet UILabel *lblUsedMemory;
15 | @property (strong, nonatomic) IBOutlet UILabel *lblWiredMemory;
16 | @property (strong, nonatomic) IBOutlet UILabel *lblActiveMemory;
17 | @property (strong, nonatomic) IBOutlet UILabel *lblInactiveMemory;
18 | @property (strong, nonatomic) IBOutlet UILabel *lblFreeMemory;
19 | @property (strong, nonatomic) IBOutlet UILabel *lblPurgeableMemory;
20 |
21 | - (IBAction)refresh:(id)sender;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemoMemoryViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServicesDemoMemoryViewController.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Kramer on 4/4/13.
6 | // Copyright (c) 2013 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SystemServicesDemoMemoryViewController.h"
10 | #import "SystemServices.h"
11 | #import "PCPieChart.h"
12 |
13 | #define SystemSharedServices [SystemServices sharedServices]
14 |
15 | #define isiPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE
16 |
17 | @interface SystemServicesDemoMemoryViewController () {
18 | PCPieChart *pieChart;
19 | NSMutableArray *components;
20 | }
21 |
22 | @end
23 |
24 | @implementation SystemServicesDemoMemoryViewController
25 |
26 | - (void)viewDidLoad
27 | {
28 | [super viewDidLoad];
29 | // Do any additional setup after loading the view.
30 |
31 | // Get all the memory info
32 | [self performSelector:@selector(getAllMemoryInformation)];
33 |
34 | // Get all the data
35 | components = [[NSMutableArray alloc] init];
36 |
37 | // Make the piechart view
38 | int yPosition = (isiPhone5) ? 250 : 220;
39 | int height = [self.view bounds].size.width/3*2.; // 220;
40 | int width = [self.view bounds].size.width - 7; //320;
41 | pieChart = [[PCPieChart alloc] initWithFrame:CGRectMake(0,yPosition,width,height)];
42 | [pieChart setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin];
43 | [pieChart setDiameter:width/2];
44 | [pieChart setSameColorLabel:YES];
45 |
46 | // Add the piechart to the view
47 | [self.view addSubview:pieChart];
48 |
49 | // Set up for iPad and iPhone
50 | if ([[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPad)
51 | {
52 | pieChart.titleFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:30];
53 | pieChart.percentageFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:50];
54 | }
55 |
56 | // Make all the components
57 | PCPieComponent *component1 = [PCPieComponent pieComponentWithTitle:@"Used Memory" value:[SystemSharedServices usedMemoryinPercent]];
58 | [component1 setColour:PCColorYellow];
59 | [components addObject:component1];
60 |
61 | PCPieComponent *component2 = [PCPieComponent pieComponentWithTitle:@"Wired Memory" value:[SystemSharedServices wiredMemoryinPercent]];
62 | [component2 setColour:PCColorGreen];
63 | [components addObject:component2];
64 |
65 | PCPieComponent *component3 = [PCPieComponent pieComponentWithTitle:@"Active Memory" value:[SystemSharedServices activeMemoryinPercent]];
66 | [component3 setColour:PCColorOrange];
67 | [components addObject:component3];
68 |
69 | PCPieComponent *component4 = [PCPieComponent pieComponentWithTitle:@"Inactive Memory" value:[SystemSharedServices inactiveMemoryinPercent]];
70 | [component4 setColour:PCColorRed];
71 | [components addObject:component4];
72 |
73 | PCPieComponent *component5 = [PCPieComponent pieComponentWithTitle:@"Free Memory" value:[SystemSharedServices freeMemoryinPercent]];
74 | [component5 setColour:PCColorBlue];
75 | [components addObject:component5];
76 |
77 | PCPieComponent *component6 = [PCPieComponent pieComponentWithTitle:@"Purgeable Memory" value:[SystemSharedServices purgableMemoryinPercent]];
78 | [component6 setColour:PCColorDefault];
79 | [components addObject:component6];
80 |
81 | // Set all the componenets
82 | [pieChart setComponents:components];
83 | }
84 |
85 | // Get all the memory information and put it on the labels
86 | - (void)getAllMemoryInformation {
87 | // Amount of Memory (RAM)
88 | self.lblMemoryRAM.text = [NSString stringWithFormat:@"Memory (RAM): (±)%.2f MB",[SystemSharedServices totalMemory]];
89 |
90 | // Used Memory
91 | self.lblUsedMemory.text = [NSString stringWithFormat:@"Used Memory: %.2f MB %.0f%%", [SystemSharedServices usedMemoryinRaw], [SystemSharedServices usedMemoryinPercent]];
92 | [self.lblUsedMemory setTextColor:PCColorYellow];
93 |
94 | // Wired Memory
95 | self.lblWiredMemory.text = [NSString stringWithFormat:@"Wired Memory: %.2f MB %.0f%%", [SystemSharedServices wiredMemoryinRaw], [SystemSharedServices wiredMemoryinPercent]];
96 | [self.lblWiredMemory setTextColor:PCColorGreen];
97 |
98 | // Active Memory
99 | self.lblActiveMemory.text = [NSString stringWithFormat:@"Active Memory: %.2f MB %.0f%%", [SystemSharedServices activeMemoryinRaw], [SystemSharedServices activeMemoryinPercent]];
100 | [self.lblActiveMemory setTextColor:PCColorOrange];
101 |
102 | // Inactive Memory
103 | self.lblInactiveMemory.text = [NSString stringWithFormat:@"Inactive Memory: %.2f MB %.0f%%", [SystemSharedServices inactiveMemoryinRaw], [SystemSharedServices inactiveMemoryinPercent]];
104 | [self.lblInactiveMemory setTextColor:PCColorRed];
105 |
106 | // Free Memory
107 | self.lblFreeMemory.text = [NSString stringWithFormat:@"Free Memory: %.2f MB %.0f%%", [SystemSharedServices freeMemoryinRaw], [SystemSharedServices freeMemoryinPercent]];
108 | [self.lblFreeMemory setTextColor:PCColorBlue];
109 |
110 | // Purgeable Memory
111 | self.lblPurgeableMemory.text = [NSString stringWithFormat:@"Purgeable Memory: %.2f MB %.0f%%", [SystemSharedServices purgableMemoryinRaw], [SystemSharedServices purgableMemoryinPercent]];
112 | [self.lblPurgeableMemory setTextColor:PCColorDefault];
113 | }
114 |
115 | - (IBAction)refresh:(id)sender {
116 | [self getAllMemoryInformation];
117 |
118 | // Remove all components
119 | [components removeAllObjects];
120 | // Remove the piecomponent
121 | [pieChart removeFromSuperview];
122 |
123 | // Make the piechart view - set the frame based on the device
124 | int yPosition = (isiPhone5) ? 250 : 220;
125 | int height = [self.view bounds].size.width/3*2.; // 220;
126 | int width = [self.view bounds].size.width - 7; //320;
127 | pieChart = [[PCPieChart alloc] initWithFrame:CGRectMake(0,yPosition,width,height)];
128 | [pieChart setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin];
129 | [pieChart setDiameter:width/2];
130 | [pieChart setSameColorLabel:YES];
131 |
132 | // Add the piechart to the view
133 | [self.view addSubview:pieChart];
134 |
135 | // Set up for iPad and iPhone
136 | if ([[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPad)
137 | {
138 | pieChart.titleFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:30];
139 | pieChart.percentageFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:50];
140 | }
141 |
142 | // Make all the components
143 | PCPieComponent *component1 = [PCPieComponent pieComponentWithTitle:@"Used Memory" value:[SystemSharedServices usedMemoryinPercent]];
144 | [component1 setColour:PCColorYellow];
145 | [components addObject:component1];
146 |
147 | PCPieComponent *component2 = [PCPieComponent pieComponentWithTitle:@"Wired Memory" value:[SystemSharedServices wiredMemoryinPercent]];
148 | [component2 setColour:PCColorGreen];
149 | [components addObject:component2];
150 |
151 | PCPieComponent *component3 = [PCPieComponent pieComponentWithTitle:@"Active Memory" value:[SystemSharedServices activeMemoryinPercent]];
152 | [component3 setColour:PCColorOrange];
153 | [components addObject:component3];
154 |
155 | PCPieComponent *component4 = [PCPieComponent pieComponentWithTitle:@"Inactive Memory" value:[SystemSharedServices inactiveMemoryinPercent]];
156 | [component4 setColour:PCColorRed];
157 | [components addObject:component4];
158 |
159 | PCPieComponent *component5 = [PCPieComponent pieComponentWithTitle:@"Free Memory" value:[SystemSharedServices freeMemoryinPercent]];
160 | [component5 setColour:PCColorBlue];
161 | [components addObject:component5];
162 |
163 | PCPieComponent *component6 = [PCPieComponent pieComponentWithTitle:@"Purgeable Memory" value:[SystemSharedServices purgableMemoryinPercent]];
164 | [component6 setColour:PCColorDefault];
165 | [components addObject:component6];
166 |
167 | // Set all the componenets
168 | [pieChart setComponents:components];
169 | }
170 |
171 | - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
172 | duration:(NSTimeInterval)duration{
173 | NSLog(@"Frame: %f, %f, %f, %f", pieChart.frame.origin.x, pieChart.frame.origin.y, pieChart.frame.size.width, pieChart.frame.size.height);
174 | }
175 |
176 | - (void)didReceiveMemoryWarning
177 | {
178 | [super didReceiveMemoryWarning];
179 | // Dispose of any resources that can be recreated.
180 | }
181 |
182 | - (void)viewDidUnload {
183 | [self setLblMemoryRAM:nil];
184 | [self setLblUsedMemory:nil];
185 | [self setLblWiredMemory:nil];
186 | [self setLblActiveMemory:nil];
187 | [self setLblInactiveMemory:nil];
188 | [self setLblFreeMemory:nil];
189 | [self setLblPurgeableMemory:nil];
190 | [super viewDidUnload];
191 | }
192 |
193 | @end
194 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemoNetworkViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServicesDemoNetworkViewController.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Kramer on 4/4/13.
6 | // Copyright (c) 2013 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SystemServicesDemoNetworkViewController : UIViewController
12 |
13 | @property (strong, nonatomic) IBOutlet UITextView *textView;
14 |
15 | - (IBAction)refresh:(id)sender;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemoNetworkViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServicesDemoNetworkViewController.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Kramer on 4/4/13.
6 | // Copyright (c) 2013 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SystemServicesDemoNetworkViewController.h"
10 | #import "SystemServices.h"
11 |
12 | #define SystemSharedServices [SystemServices sharedServices]
13 |
14 | @interface SystemServicesDemoNetworkViewController ()
15 |
16 | @end
17 |
18 | @implementation SystemServicesDemoNetworkViewController
19 |
20 | - (void)viewDidLoad
21 | {
22 | [super viewDidLoad];
23 | // Do any additional setup after loading the view.
24 |
25 | // Update the network info
26 | [self performSelector:@selector(getAllNetworkInformation)];
27 | }
28 |
29 | - (void)getAllNetworkInformation {
30 |
31 | // Empty the textview text
32 | self.textView.text = @"";
33 |
34 | // All Network Information
35 | NSString *CarrierName = [NSString stringWithFormat:@"Carrier Name: %@",[SystemSharedServices carrierName]];
36 | NSString *CarrierCountry = [NSString stringWithFormat:@"Carrier Country: %@",[SystemSharedServices carrierCountry]];
37 | NSString *CarrierMobileCountryCode = [NSString stringWithFormat:@"Carrier Mobile Country: %@",[SystemSharedServices carrierMobileCountryCode]];
38 | NSString *CarrierISOCountryCode = [NSString stringWithFormat:@"Carrier ISO Country Code: %@",[SystemSharedServices carrierISOCountryCode]];
39 | NSString *CarrierMobileNetworkCode = [NSString stringWithFormat:@"Carrier Mobile Network Code: %@",[SystemSharedServices carrierMobileNetworkCode]];
40 | NSString *CarrierAllowsVOIP = ([SystemSharedServices carrierAllowsVOIP]) ? @"Carrier Allows VOIP: Yes" : @"Carrier Allows VOIP: No";
41 | NSString *CurrentIPAddress = [NSString stringWithFormat:@"Current IP Address: %@",[SystemSharedServices currentIPAddress]];
42 | NSString *ExternalIPAddress = [NSString stringWithFormat:@"External IP Address: %@",[SystemSharedServices externalIPAddress]];
43 | NSString *CellIPAddress = [NSString stringWithFormat:@"Cell IP Address: %@",[SystemSharedServices cellIPAddress]];
44 | NSString *CellNetmaskAddress = [NSString stringWithFormat:@"Cell Netmask Address: %@",[SystemSharedServices cellNetmaskAddress]];
45 | NSString *CellBroadcastAddress = [NSString stringWithFormat:@"Cell Broadcast Address: %@",[SystemSharedServices cellBroadcastAddress]];
46 | NSString *WiFiIPAddress = [NSString stringWithFormat:@"WiFi IP Address: %@",[SystemSharedServices wiFiIPAddress]];
47 | NSString *WiFiNetmaskAddress = [NSString stringWithFormat:@"WiFi Netmask Address: %@",[SystemSharedServices wiFiNetmaskAddress]];
48 | NSString *WiFiBroadcastAddress = [NSString stringWithFormat:@"WiFi Broadcast Address: %@",[SystemSharedServices wiFiBroadcastAddress]];
49 | NSString *WiFiRouterAddress = [NSString stringWithFormat:@"WiFi Router Address: %@",[SystemSharedServices wiFiRouterAddress]];
50 | NSString *ConnectedToWiFi = ([SystemSharedServices connectedToWiFi]) ? @"Connected to WiFi: Yes" : @"Connected to WiFi: No";
51 | NSString *ConnectedToCellNetwork = ([SystemSharedServices connectedToCellNetwork]) ? @"Connected to Cell Network: Yes" : @"Connected to Cell Network: No";
52 |
53 | // Make an array to hold all the objects
54 | NSArray *array = [[NSArray alloc] initWithObjects:CarrierName, CarrierCountry, CarrierMobileCountryCode, CarrierISOCountryCode, CarrierMobileNetworkCode, CarrierAllowsVOIP, CurrentIPAddress, ExternalIPAddress, CellIPAddress, CellNetmaskAddress, CellBroadcastAddress, WiFiIPAddress, WiFiNetmaskAddress, WiFiBroadcastAddress, WiFiRouterAddress, ConnectedToWiFi, ConnectedToCellNetwork, nil];
55 |
56 | // Run through all the information
57 | for (NSString *objects in array) {
58 | if (![self.textView.text isEqualToString:@""]) {
59 | // Output all the names and values to the textview
60 | self.textView.text = [NSString stringWithFormat:@"%@\n%@", self.textView.text, objects];
61 | } else {
62 | // Output all the names and values to the textview
63 | self.textView.text = [NSString stringWithFormat:@"%@", objects];
64 | }
65 | }
66 | }
67 |
68 | - (IBAction)refresh:(id)sender {
69 | // Reload the hardware info
70 | [self getAllNetworkInformation];
71 | }
72 |
73 | - (void)didReceiveMemoryWarning
74 | {
75 | [super didReceiveMemoryWarning];
76 | // Dispose of any resources that can be recreated.
77 | }
78 |
79 | - (void)viewDidUnload {
80 | [self setTextView:nil];
81 | [super viewDidUnload];
82 | }
83 |
84 | @end
85 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemoViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServicesDemoViewController.h
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/15/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SystemServicesDemoViewController : UIViewController
12 |
13 | @property (strong, nonatomic) IBOutlet UITextView *TextView;
14 |
15 | - (IBAction)refresh:(id)sender;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/SystemServicesDemoViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SystemServicesDemoViewController.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/15/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SystemServicesDemoViewController.h"
10 | #import "SystemServices.h"
11 | #import "SSAccelerometerInfo.h"
12 |
13 | #define SystemSharedServices [SystemServices sharedServices]
14 |
15 | @interface SystemServicesDemoViewController () {
16 | SSAccelerometerInfo *accel;
17 | }
18 |
19 | @end
20 |
21 | @implementation SystemServicesDemoViewController
22 | @synthesize TextView = _TextView;
23 |
24 | - (void)viewDidLoad
25 | {
26 | [super viewDidLoad];
27 | // Do any additional setup after loading the view, typically from a nib.
28 |
29 | // Let's find the accelerometer information (if we're not in the simulator)
30 | #if !TARGET_IPHONE_SIMULATOR
31 | accel = [[SSAccelerometerInfo alloc] init];
32 | [accel startLoggingMotionData];
33 |
34 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
35 | // Log any accelerometer data
36 | NSLog(@"Raw Accelerometer String: %@", [accel rawAccelerometerString]);
37 | [accel stopLoggingMotionData];
38 | });
39 | #endif
40 |
41 | [self performSelector:@selector(getAllHardwareInformation) withObject:nil afterDelay:0.01];
42 | }
43 |
44 | // Get all the system information
45 | - (void)getAllHardwareInformation {
46 |
47 | // Set the textview text to nothing
48 | self.TextView.text = @"";
49 |
50 | // Get an array from the system uptime (to format it)
51 | NSArray *uptimeFormat = [[SystemSharedServices systemsUptime] componentsSeparatedByString:@" "];
52 | // Get all Harware Information
53 | NSString *SystemUptime = [NSString stringWithFormat:@"System Uptime: %@ Days %@ Hours %@ Minutes", [uptimeFormat objectAtIndex:0], [uptimeFormat objectAtIndex:1], [uptimeFormat objectAtIndex:2]];
54 | NSString *DeviceModel = [NSString stringWithFormat:@"Device Model: %@", [SystemSharedServices deviceModel]];
55 | NSString *DeviceName = [NSString stringWithFormat:@"Device Name: %@", [SystemSharedServices deviceName]];
56 | NSString *SystemName = [NSString stringWithFormat:@"System Name: %@", [SystemSharedServices systemName]];
57 | NSString *SystemVersion = [NSString stringWithFormat:@"System Version: %@", [SystemSharedServices systemsVersion]];
58 | NSString *SystemDeviceTypeFormattedNO = [NSString stringWithFormat:@"System Device Type Unformatted: %@", [SystemSharedServices systemDeviceTypeNotFormatted]];
59 | NSString *SystemDeviceTypeFormattedYES = [NSString stringWithFormat:@"System Device Type Formatted: %@", [SystemSharedServices systemDeviceTypeFormatted]];
60 | NSString *ScreenWidth = [NSString stringWithFormat:@"Screen Width: %ld Pixels", (long)[SystemSharedServices screenWidth]];
61 | NSString *ScreenHeight = [NSString stringWithFormat:@"Screen Height: %ld Pixels", (long)[SystemSharedServices screenHeight]];
62 | NSString *ScreenBrightness = [NSString stringWithFormat:@"Screen Brightness: %.0f%%", [SystemSharedServices screenBrightness]];
63 | NSString *MultitaskingEnabled = ([SystemSharedServices multitaskingEnabled]) ? @"Multitasking Enabled: Yes" : @"Multitasking: No";
64 | NSString *ProximitySensorEnabled = ([SystemSharedServices proximitySensorEnabled]) ? @"Proximity Sensor: Yes" : @"Proximity Sensor: No";
65 | NSString *DebuggerAttached = ([SystemSharedServices debuggerAttached]) ? @"Debugger Attached: Yes" : @"Debugger Attached: No";
66 | NSString *PluggedIn = ([SystemSharedServices pluggedIn]) ? @"Plugged In: Yes" : @"Plugged In: No";
67 | NSString *stepCountingAvailable = ([SystemSharedServices stepCountingAvailable]) ? @"Step Counting Available: Yes" : @"Step Counting Available: No";
68 | NSString *distanceAvailable = ([SystemSharedServices distanceAvailable]) ? @"Distance Available: Yes" : @"Distance Available: No";
69 | NSString *floorCountingAvailable = ([SystemSharedServices floorCountingAvailable]) ? @"Floor Counting Available: Yes" : @"Floor Counting Available: No";
70 | NSString *Jailbroken = ([SystemSharedServices jailbroken] != NOTJAIL) ? @"Jailbroken: Yes" : @"Jailbroken: No";
71 | NSString *NumberProcessors = [NSString stringWithFormat:@"Number of Processors: %ld", (long)[SystemSharedServices numberProcessors]];
72 | NSString *NumberActiveProcessors = [NSString stringWithFormat:@"Number of Active Processors: %ld", (long)[SystemSharedServices numberActiveProcessors]];
73 | NSString *ProcessorsUsage = [NSString stringWithFormat:@"Processors Usage: %@", [SystemSharedServices processorsUsage]];
74 | NSString *AccessoriesAttached = ([SystemSharedServices accessoriesAttached]) ? @"Accessories Attached: Yes" : @"Accessories Attached: No";
75 | NSString *HeadphonesAttached = ([SystemSharedServices headphonesAttached]) ? @"Headphones Attached: Yes" : @"Headphones Attached: No";
76 | NSString *NumberAttachedAccessories = [NSString stringWithFormat:@"Number of Attached Accessories: %ld", (long)[SystemSharedServices numberAttachedAccessories]];
77 | NSString *NameAttachedAccessories = [NSString stringWithFormat:@"Name of Attached Accessories: %@", [SystemSharedServices nameAttachedAccessories]];
78 | NSString *BatteryLevel = [NSString stringWithFormat:@"Battery Level: %f%%", [SystemSharedServices batteryLevel]];
79 | NSString *Charging = ([SystemSharedServices charging]) ? @"Charging: Yes" : @"Charging: No";
80 | NSString *FullyCharged = ([SystemSharedServices fullyCharged]) ? @"Fully Charged: Yes" : @"Fully Charged: No";
81 | NSString *DeviceOrientation = [NSString stringWithFormat:@"Device Orientation: %ld", [SystemSharedServices deviceOrientation]];
82 | NSString *Country = [NSString stringWithFormat:@"Country: %@", [SystemSharedServices country]];
83 | NSString *Language = [NSString stringWithFormat:@"Language: %@", [SystemSharedServices language]];
84 | NSString *TimeZone = [NSString stringWithFormat:@"TimeZone: %@", [SystemSharedServices timeZoneSS]];
85 | NSString *Currency = [NSString stringWithFormat:@"Currency: %@", [SystemSharedServices currency]];
86 | NSString *ApplicationVersion = [NSString stringWithFormat:@"Application Version: %@", [SystemSharedServices applicationVersion]];
87 | NSString *ClipboardContent = [NSString stringWithFormat:@"ClipBoard Content: \"%@\"", [SystemSharedServices clipboardContent]];
88 | NSString *CFUUID = [NSString stringWithFormat:@"CFUUID: %@", [SystemSharedServices cfuuid]];
89 |
90 | NSDictionary *allSystemInformation = [[SystemServices sharedServices] allSystemInformation];
91 | NSAssert(![[allSystemInformation allKeys] containsObject:@"ClipboardContent"], @"We should not be including clipboard content in allSystemInformation");
92 | NSAssert([[allSystemInformation allKeys] containsObject:@"ApplicationVersion"], @"We should be including application version in allSystemInformation");
93 |
94 | // Make an array of all the hardware information
95 | NSArray *arrayofHW = [[NSArray alloc] initWithObjects:SystemUptime, DeviceModel, DeviceName, SystemName, SystemVersion, SystemDeviceTypeFormattedNO, SystemDeviceTypeFormattedYES, ScreenWidth, ScreenHeight, ScreenBrightness, MultitaskingEnabled, ProximitySensorEnabled, DebuggerAttached, PluggedIn, stepCountingAvailable, distanceAvailable, floorCountingAvailable, Jailbroken, NumberProcessors, NumberActiveProcessors, ProcessorsUsage, AccessoriesAttached, HeadphonesAttached, NumberAttachedAccessories, NameAttachedAccessories, BatteryLevel, Charging, FullyCharged, DeviceOrientation, Country, Language, TimeZone, Currency, ApplicationVersion, ClipboardContent, CFUUID, nil];
96 |
97 | // Run through all the information
98 | for (NSString *objects in arrayofHW) {
99 | if (![self.TextView.text isEqualToString:@""]) {
100 | // Output all the names and values to the textview
101 | self.TextView.text = [NSString stringWithFormat:@"%@\n%@", self.TextView.text, objects];
102 | } else {
103 | // Output all the names and values to the textview
104 | self.TextView.text = [NSString stringWithFormat:@"%@", objects];
105 | }
106 | }
107 |
108 | // End of this
109 | }
110 |
111 | - (void)viewDidUnload
112 | {
113 | [self setTextView:nil];
114 | [super viewDidUnload];
115 | // Release any retained subviews of the main view.
116 | }
117 |
118 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
119 | {
120 | return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
121 | }
122 |
123 | - (IBAction)refresh:(id)sender {
124 | // Reload the hardware info
125 | [self getAllHardwareInformation];
126 | }
127 | @end
128 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/SystemServicesDemo/SystemServicesDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/15/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "SystemServicesDemoAppDelegate.h"
12 |
13 | int main(int argc, char *argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([SystemServicesDemoAppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/SystemServicesDemo/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/icon.png
--------------------------------------------------------------------------------
/SystemServicesDemo/icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shmoopi/iOS-System-Services/dfe2a22b13f2a5c89f4dabbf28a4a40f8d6fd3c6/SystemServicesDemo/icon@2x.png
--------------------------------------------------------------------------------