DeviceUtil.uts 1.1 KB
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import { UIDevice, UIApplication, UIInterfaceOrientation, UIScreen } from 'UIKit';
import { NSLocale, URL, FileManager } from 'Foundation';
import { DispatchSemaphore, DispatchQueue } from 'Dispatch';



export class DeviceUtil {

	public static isPad(): boolean {
		return UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad
	}

	public static getOSVersion(): string {
		return UIDevice.current.systemVersion;
	}

	public static getLan(): string {
		let currentLanguage = NSLocale.preferredLanguages[0];
		return currentLanguage == null ? "" : currentLanguage
	}

	public static getOrientation(): string {
		let orientation = "portrait";
DCloud-yyl's avatar
DCloud-yyl 已提交
24 25 26 27
		const orient = UIApplication.shared.statusBarOrientation;
		if (orient == UIInterfaceOrientation.landscapeLeft || orient == UIInterfaceOrientation.landscapeRight) {
			orientation = "landscape";
		}
DCloud-yyl's avatar
DCloud-yyl 已提交
28 29 30 31 32 33 34 35 36
		return orientation;
	}

	public static getScreenScale(): string {
		return UIScreen.main.scale.description;
	}


	public static getIdfa(): string {
DCloud-yyl's avatar
DCloud-yyl 已提交
37
		return UTSiOS.getGgbs()
DCloud-yyl's avatar
DCloud-yyl 已提交
38 39 40
	}

	public static hasRootPrivilege(): boolean {
DCloud-yyl's avatar
DCloud-yyl 已提交
41
		return UTSiOS.isRoot()
DCloud-yyl's avatar
DCloud-yyl 已提交
42 43
	}
}