Skip to content

Commit

Permalink
Added System Report
Browse files Browse the repository at this point in the history
  • Loading branch information
duraidabdul committed Jun 1, 2021
1 parent 9b5e0d8 commit 5094ddc
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 15 deletions.
4 changes: 0 additions & 4 deletions Sources/LocalConsole/BorderManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// Copyright © 2021 Duraid Abdul. All rights reserved.
//

#if canImport(UIKit)

import UIKit

/// This class handles enabling and disabling debug borders on a specified view.
Expand Down Expand Up @@ -64,5 +62,3 @@ class BorderManager {
}
}
}

#endif
4 changes: 0 additions & 4 deletions Sources/LocalConsole/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// Copyright © 2021 Duraid Abdul. All rights reserved.
//

#if canImport(UIKit)

import UIKit

extension UIScreen {
Expand Down Expand Up @@ -59,5 +57,3 @@ extension UIView {
frame.origin.y = (round(frame.origin.y * UIScreen.main.scale)) / UIScreen.main.scale
}
}

#endif
4 changes: 0 additions & 4 deletions Sources/LocalConsole/GestureEndpointPredictor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// Copyright © 2021 Duraid Abdul. All rights reserved.
//

#if canImport(UIKit)

import UIKit

extension CGPoint {
Expand Down Expand Up @@ -80,5 +78,3 @@ func nearestTargetTo(_ point: CGPoint, possibleTargets: [CGPoint]) -> CGPoint {
}
return nearestEndpoint
}

#endif
58 changes: 55 additions & 3 deletions Sources/LocalConsole/LCManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
// Copyright © 2021 Duraid Abdul. All rights reserved.
//

#if canImport(UIKit)
//#if canImport(UIKit)

import UIKit
import MachO

var GLOBAL_DEBUG_BORDERS = false
var GLOBAL_BORDER_TRACKERS: [BorderManager] = []
Expand Down Expand Up @@ -306,6 +307,52 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
}
}

func systemReport() {
print("Screen Scale: \(UIScreen.main.scale)\n")
print("Screen Size: \(UIScreen.main.bounds.size)")
print("Screen Radius: \(UIScreen.main.value(forKey: "_displayCornerRadius") as! CGFloat)")
print("Max Frame Rate: \(UIScreen.main.maximumFramesPerSecond) Hz")
print("Low Power Mode: \(ProcessInfo.processInfo.isLowPowerModeEnabled)")
print("System Uptime: \(Int(ProcessInfo.processInfo.systemUptime))s")
print("OS Version: \(versionString)")
print("Thermal State: \(thermalState)")
print("Processor Cores: \(Int(ProcessInfo.processInfo.processorCount))")
print("Device RAM: \(round(100 * Double(ProcessInfo.processInfo.physicalMemory) * pow(10, -9)) / 100) GB")
print("Architecture: \(deviceArchitecture)")
print("Model: \(modelIdentifier)")

}

var modelIdentifier: String {
if let simulatorModelIdentifier = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] { return simulatorModelIdentifier }
var sysinfo = utsname()
uname(&sysinfo) // ignore return value
return String(bytes: Data(bytes: &sysinfo.machine, count: Int(_SYS_NAMELEN)), encoding: .ascii)!.trimmingCharacters(in: .controlCharacters)
}

var deviceArchitecture: String {
let info = NXGetLocalArchInfo()
return String(utf8String: (info?.pointee.description)!) ?? "Unknown"
}

var versionString: String {
ProcessInfo.processInfo.operatingSystemVersionString
.replacingOccurrences(of: "Build ", with: "")
.replacingOccurrences(of: "Version ", with: "")
}

var thermalState: String {
let state = ProcessInfo.processInfo.thermalState

switch state {
case .nominal: return "Nominal"
case .fair : return "Fair"
case .serious : return "Serious"
case .critical : return "Critical"
default: return "Unknown"
}
}

@objc func toggleLock() {
scrollLocked.toggle()
}
Expand Down Expand Up @@ -372,6 +419,11 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
self.menuButton.menu = self.makeMenu()
})

let systemReport = UIAction(title: "System Report",
image: UIImage(systemName: "doc.badge.gearshape"), handler: { _ in
self.systemReport()
})

let respring = UIAction(title: "Restart SpringBoard",
image: UIImage(systemName: "apps.iphone"), handler: { _ in
guard let window = UIApplication.shared.windows.first else { return }
Expand All @@ -390,7 +442,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
}
animator.startAnimation()
})
let debugActions = UIMenu(title: "", options: .displayInline, children: [viewFrames, respring])
let debugActions = UIMenu(title: "", options: .displayInline, children: [viewFrames, systemReport, respring])

var menuContent: [UIMenuElement] = []

Expand Down Expand Up @@ -590,4 +642,4 @@ extension UIWindow {
}
}

#endif
//#endif

0 comments on commit 5094ddc

Please sign in to comment.