114 lines
3.6 KiB
Matlab
114 lines
3.6 KiB
Matlab
|
|
//
|
||
|
|
// UnityAction.m
|
||
|
|
// Unity-iPhone
|
||
|
|
//
|
||
|
|
// Created by qyq on 2019/6/22.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "UnityAction.h"
|
||
|
|
|
||
|
|
@implementation UnityAction
|
||
|
|
|
||
|
|
+(void)login
|
||
|
|
{
|
||
|
|
[WXAppDelegate login];
|
||
|
|
}
|
||
|
|
|
||
|
|
+(void)share : (int) id : (const char*) str : (const char*) func
|
||
|
|
{
|
||
|
|
NSString* jsonString = [NSString stringWithUTF8String:str];
|
||
|
|
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
||
|
|
NSError *err;
|
||
|
|
NSDictionary *shareDic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
|
||
|
|
if(err)
|
||
|
|
{
|
||
|
|
NSLog(@"json解析失败:%@",err);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (1 == id)
|
||
|
|
[WXAppDelegate share:shareDic];
|
||
|
|
else
|
||
|
|
NSLog(@"获取id出错,id=%i", id);
|
||
|
|
}
|
||
|
|
|
||
|
|
+(int) GetWIFISignalStrength{
|
||
|
|
UIApplication *app = [UIApplication sharedApplication];
|
||
|
|
NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
|
||
|
|
NSString *dataNetworkItemView = nil;
|
||
|
|
|
||
|
|
for (id subview in subviews) {
|
||
|
|
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
|
||
|
|
dataNetworkItemView = subview;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
int signalStrength = [[dataNetworkItemView valueForKey:@"_wifiStrengthBars"] intValue];
|
||
|
|
|
||
|
|
return signalStrength;
|
||
|
|
}
|
||
|
|
+(int) GetTeleSignalStrength{
|
||
|
|
UIApplication *app = [UIApplication sharedApplication];
|
||
|
|
NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
|
||
|
|
NSString *dataNetworkItemView = nil;
|
||
|
|
|
||
|
|
for (id subview in subviews) {
|
||
|
|
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
|
||
|
|
dataNetworkItemView = subview;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
int signalStrength = [[dataNetworkItemView valueForKey:@"_wifiStrengthBars"] intValue];
|
||
|
|
|
||
|
|
return signalStrength;
|
||
|
|
}
|
||
|
|
+(int) __GetSignalStrength{
|
||
|
|
UIApplication *app = [UIApplication sharedApplication];
|
||
|
|
NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
|
||
|
|
NSString *dataNetworkItemView = nil;
|
||
|
|
int flag = 0;
|
||
|
|
for (id subview in subviews) {
|
||
|
|
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarSignalStrengthItemView") class]]){
|
||
|
|
dataNetworkItemView = subview;
|
||
|
|
flag = 1;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
|
||
|
|
dataNetworkItemView = subview;
|
||
|
|
flag = 2;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
int signalStrength = 0;
|
||
|
|
if (flag == 1){
|
||
|
|
signalStrength = [[dataNetworkItemView valueForKey:@"_signalStrengthBars"] intValue];
|
||
|
|
}
|
||
|
|
else if(flag == 2){
|
||
|
|
signalStrength = [[dataNetworkItemView valueForKey:@"_wifiStrengthBars"] intValue];
|
||
|
|
}
|
||
|
|
return signalStrength;
|
||
|
|
}
|
||
|
|
|
||
|
|
+(float) GetBatteryLevel{
|
||
|
|
UIDevice *device = [UIDevice currentDevice];
|
||
|
|
device.batteryMonitoringEnabled = YES;
|
||
|
|
|
||
|
|
return [[UIDevice currentDevice] batteryLevel];
|
||
|
|
}
|
||
|
|
+(bool) _ifChargingBattery{
|
||
|
|
if([UIDevice currentDevice].batteryState == UIDeviceBatteryStateUnknown || [UIDevice currentDevice].batteryState == UIDeviceBatteryStateUnplugged)
|
||
|
|
return false;
|
||
|
|
else if([UIDevice currentDevice].batteryState == UIDeviceBatteryStateCharging || [UIDevice currentDevice].batteryState == UIDeviceBatteryStateFull)
|
||
|
|
return true;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
+(void) CopyToClipboard:(const char*)textList
|
||
|
|
{
|
||
|
|
NSString *text = [NSString stringWithUTF8String: textList];
|
||
|
|
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
|
||
|
|
pasteboard.string = text;
|
||
|
|
}
|
||
|
|
|
||
|
|
@end
|