index.uts 973 字节
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 24 25 26 27 28 29 30 31
import { GetSystemSetting, GetSystemSettingResult } from '../interface.uts'
import { UTSiOS } from "DCloudUTSFoundation";

export const getSystemSetting : GetSystemSetting = () : GetSystemSettingResult => {
	let setting : Map<string, any> = UTSiOS.getSystemSetting();
	let result : GetSystemSettingResult = {
		deviceOrientation: "portrait",
		locationEnabled : false
	};
	if (setting.has("bluetoothEnabled")) {
		result.bluetoothEnabled = setting.get("bluetoothEnabled") as boolean;
	}

	if (setting.has("bluetoothError")) {
		result.bluetoothError = setting.get("bluetoothError") as string;
	}

	if (setting.has("locationEnabled")) {
		result.locationEnabled = setting.get("locationEnabled") as boolean;
	}

	if (setting.has("wifiEnabled")) {
		result.wifiEnabled = setting.get("wifiEnabled") as boolean;
	}

	if (setting.has("deviceOrientation")) {
		result.deviceOrientation = setting.get("deviceOrientation") as string;
	}

	return result;
}