DeviceUtil.uts 952 字节
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
		return orientation;
	}

	public static hasRootPrivilege(): boolean {
DCloud-yyl's avatar
DCloud-yyl 已提交
32
		return UTSiOS.isRoot()
DCloud-yyl's avatar
DCloud-yyl 已提交
33 34
	}
}