import display from '@ohos.display'
import { common, Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

export default class OhosDeviceInfoUtil {
  /**
   * 获取屏幕宽度
   * @returns
   */
  static getScreenWidth(): number {
    return display.getDefaultDisplaySync().width
  }

  /**
   * 跳转系统WiFi设置页面
   * @param context
   */
  static toSystemWiFiSettingPage(context: common.UIAbilityContext) {
    let want: Want = {
      bundleName: 'com.huawei.hmos.settings',
      abilityName: 'com.huawei.hmos.settings.MainAbility',
      // 根据”设置”应用配置的界面信息，选择不同的uri
      uri: 'wifi_entry'
    }
    context.startAbility(want).then(() => {
      console.info('Start settings ability successfully.');
    }).catch((err: BusinessError) => {
      console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
    })
  }
}