Git Product home page Git Product logo

alsystemutilities's Introduction

IMPORTANT

This repository is no longer maintained, but now there is a new library which inherit a lot from ALSystemUtilities and is Luminous which is written in Swift and actively maintained.

ALSystemUtilities

In order to use the framework you have to open the project in Xcode and then click on Product -> Archive and drag the .embeddedframework file into the project you want to import it.

When import the .embeddedframework, don't forget to import these frameworks to your project if they're not imported :

  • AssetsLibrary.framework;
  • AudioToolbox.framework;
  • CFNetwork.framework;
  • CoreTelephony.framework;
  • ExternalAccessory.framework;
  • Security.framework;
  • SystemConfiguration.framework;
  • UIKit.framework;
  • CoreGraphics.framework;
  • CoreFoundation.framework;
  • Foundation.framework;

The project is built using the iOS Universal Framework template (Fake framework) by kstenerud (https://github.com/kstenerud/iOS-Universal-Framework?source=cc).

CocoaPods

You can install the library via cocoapods. Use : pod 'ALSystemUtilities'

Overview

The library provides informations for these purviews :

  • battery;
  • disk;
  • hardware;
  • jailbreak;
  • localization;
  • memory (RAM);
  • network;
  • processor;
  • carrier;
  • accessories;

Now I'll explain you what informations are contained for every purview.

Battery

  • + (BOOL)batteryFullCharged;
  • + (BOOL)inCharge;
  • + (BOOL)devicePluggedIntoPower;
  • + (UIDeviceBatteryState)batteryState;
  • + (CGFloat)batteryLevel;
  • + (NSString *)remainingHoursForStandby;
  • + (NSString *)remainingHoursFor3gConversation;
  • + (NSString *)remainingHoursFor2gConversation;
  • + (NSString *)remainingHoursForInternet3g;
  • + (NSString *)remainingHoursForInternetWiFi;
  • + (NSString *)remainingHoursForVideo;
  • + (NSString *)remainingHoursForAudio;

Disk

  • + (NSString *)totalDiskSpace;
  • + (NSString *)freeDiskSpace;
  • + (NSString *)usedDiskSpace;
  • + (CGFloat)totalDiskSpaceInBytes;
  • + (CGFloat)freeDiskSpaceInBytes;
  • + (CGFloat)usedDiskSpaceInBytes;

Hardware

  • + (NSString *)deviceModel;
  • + (NSString *)deviceName;
  • + (NSString *)systemName;
  • + (NSString *)systemVersion;
  • + (NSInteger)screenWidth;
  • + (NSInteger)screenHeight;
  • + (CGFloat)brightness;
  • + (NSString *)platformType;
  • + (NSDate *)bootTime;
  • + (BOOL)proximitySensor;
  • + (BOOL)multitaskingEnabled;
  • + (NSString *)sim;
  • + (NSString *)dimensions;
  • + (NSString *)weight;
  • + (NSString *)displayType;
  • + (NSString *)displayDensity;
  • + (NSString *)WLAN;
  • + (NSString *)bluetooth;
  • + (NSString *)cameraPrimary;
  • + (NSString *)cameraSecondary;
  • + (NSString *)cpu;
  • + (NSString *)gpu;
  • + (BOOL)siri;
  • + (BOOL)touchID;

Jailbreak

  • + (BOOL)isJailbroken;

Localization

  • + (NSString *)language;
  • + (NSString *)timeZone;
  • + (NSString *)currencySymbol;
  • + (NSString *)currencyCode;
  • + (NSString *)country;
  • + (NSString *)measurementSystem;

Memory (RAM)

  • + (NSInteger)totalMemory;
  • + (CGFloat)freeMemory;
  • + (CGFloat)usedMemory;
  • + (CGFloat)activeMemory;
  • + (CGFloat)wiredMemory;
  • + (CGFloat)inactiveMemory;

Network

  • + (NSString *)currentIPAddress;
  • + (BOOL)connectedViaWiFi;
  • + (BOOL)connectedVia3G;
  • + (NSString *)macAddress;
  • + (NSString *)externalIPAddress;
  • + (NSString *)cellIPAddress;
  • + (NSString *)WiFiNetmaskAddress;
  • + (NSString *)WiFiBroadcastAddress;
  • + (NSString *)BSSID;
  • + (NSString *)SSID;

Processor

  • + (NSInteger)processorsNumber;
  • + (NSInteger)activeProcessorsNumber;
  • + (CGFloat)cpuUsageForApp;
  • + (NSArray *)activeProcesses;
  • + (NSInteger)numberOfActiveProcesses;

Carrier

  • + (NSString *)carrierName;
  • + (NSString *)carrierISOCountryCode;
  • + (NSString *)carrierMobileCountryCode;
  • + (NSString *)carrierMobileNetworkCode;
  • + (BOOL)carrierAllowsVOIP;

Accessories

  • + (BOOL)accessoriesPluggedIn;
  • + (NSInteger)numberOfAccessoriesPluggedIn;
  • + (BOOL)isHeadphonesAttached;

So, there are 78 methods to get every kind of information!

All methods are class methods, so you can use the syntax [ALCarrier carrierName]. This make the use of the library very very simple!

If you want to let me know if you use my library in your applications, you are free to send me an email to [email protected] :)

alsystemutilities's People

Contributors

andrealufino avatar blacklee avatar bogdan-stasjuk avatar gorkamm avatar kaishin-r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alsystemutilities's Issues

ALBattery remaining hours methods not working

Hey @andrealufino

ALBattery remaining hours methods don't work for me.
As I saw the infoForDevice method returns nil on device & on simulator it returns the dictionary, but doesn't find the needed data & it returns in both situations "NS".

Tested on iPhone 5 with iOS 8.4, iOS & iOS Simulator with iOS 8.2.

It applies for all the methods listed:

  • + (NSString *)remainingHoursForStandby;
  • + (NSString *)remainingHoursFor3gConversation;
  • + (NSString *)remainingHoursFor2gConversation;
  • + (NSString *)remainingHoursForInternet3g;
  • + (NSString *)remainingHoursForInternetWiFi;
  • + (NSString *)remainingHoursForVideo;
  • + (NSString *)remainingHoursForAudio;

Any idea why is that so, any changes in Apple's API maybe?

Thanks for the library,

@kexoth

license file missing

its not really a problem, but FYI:
while installing via cocoapods, this message pops up:
[!] Unable to read the license file /../Pods/ALSystemUtilities/LICENSE for the spec `ALSystemUtilities (1.0)

[Question] Memory usage calculation

I have tried various ways to measure memory usage (different code snippets from around the web) and each has a different result (Including the method you supply)

Do you have any insight?

vm_size_t usedMemory(void) {
    struct task_basic_info info;
    mach_msg_type_number_t size = sizeof(info);
    kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size);
    return (kerr == KERN_SUCCESS) ? info.resident_size : 0; // size in bytes
}

vm_size_t freeMemory(void) {
    mach_port_t host_port = mach_host_self();
    mach_msg_type_number_t host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
    vm_size_t pagesize;
    vm_statistics_data_t vm_stat;

    host_page_size(host_port, &pagesize);
    (void) host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size);
    return vm_stat.free_count * pagesize;
}

void logMemUsage(void) {
    // compute memory usage and log if different by >= 100k
    static long prevMemUsage = 0;
    long curMemUsage = usedMemory();
    long memUsageDiff = curMemUsage - prevMemUsage;

//    if (memUsageDiff > 100000 || memUsageDiff < -100000) {
        prevMemUsage = curMemUsage;
        NSLog(@"Memory used %7.1f (%+5.0f), free %7.1f kb", curMemUsage/1000.0f, memUsageDiff/1000.0f, freeMemory()/1000.0f);
//    }
}

Mac Address: 02:00:00:00:00:00

My Mac Address is showing "Mac Address: 02:00:00:00:00:00" in my log file.

I have imported the framework and tested with various other configs you have and they work fine.

and code

NSLog(@"Mac Address: %@", [ALNetwork macAddress]);

iPhone 5S, 7.0.4, Jailbroken (NO MAC filter/Fake Location apps)
Xcode 5.02 - Building 7.0.4 -32 Bit (Non 64 Bit) Build for App

Free + Used memory doesn't add up

If I sum the freeMemory and usedMemory the result is never the total available RAM.
For example, on my iPhone 5c, it says I have 30mb free and 440mb used.

won't build for 64-bit iPhone

This doesn't work with iPhone 64-bit devices

I get this error when linking the framework:
ld: file is universal (2 slices) but does not contain a(n) armv7s slice: /Users/marcus.milne/Library/Developer/Xcode/DerivedData/ALSystemUtilities-bviykdlzbhozoqdhsgktchmuceqh/Build/Intermediates/ArchiveIntermediates/ALSystemUtilities/IntermediateBuildFilesPath/UninstalledProducts/ALSystemUtilities.embeddedframework/ALSystemUtilities.framework/ALSystemUtilities file '/Users/marcus.milne/Library/Developer/Xcode/DerivedData/ALSystemUtilities-bviykdlzbhozoqdhsgktchmuceqh/Build/Intermediates/ArchiveIntermediates/ALSystemUtilities/IntermediateBuildFilesPath/UninstalledProducts/ALSystemUtilities.embeddedframework/ALSystemUtilities.framework/ALSystemUtilities' for architecture armv7s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.