在OpenHarmony中调整系统设置的可行方式
一 设备端图形界面设置
二 从应用跳转到系统设置指定页面
import Want from '@ohos.app.ability.Want';
import common from '@ohos.app.ability.common';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BusinessError } from '@ohos.base';
@Entry
@Component
struct Index {
context = getContext(this) as common.UIAbilityContext;
openWifiSettings() {
let want: Want = {
bundleName: 'com.ohos.settings',
abilityName: 'com.ohos.settings.MainAbility',
uri: 'wifi'
};
this.context.startAbility(want).then(() => {}).catch((err: BusinessError) => {
hilog.error(0x0000, 'Failed', `${err.code} ${err.message}`);
});
}
openBluetoothSettings() {
let want: Want = {
bundleName: 'com.ohos.settings',
abilityName: 'com.ohos.settings.MainAbility',
uri: 'bluetooth'
};
this.context.startAbility(want).catch((err: BusinessError) => {
hilog.error(0x0000, 'Failed', `${err.code} ${err.message}`);
});
}
build() {
Column() {
Button('打开Wi‑Fi设置').onClick(() => this.openWifiSettings())
Button('打开蓝牙设置').onClick(() => this.openBluetoothSettings())
}
}
}
三 通过命令行临时调整系统设置
# 通过串口或 adb/hdc 执行
power-shell setmode 602
四 修改系统配置文件的持久化方式(开发/工程样机)
# 1) 设备改为可读写
hdc shell mount -o remount,rw /
# 2) 拉取配置(不同版本路径可能不同,示例:/system/etc/power_config/power_mode_config.xml)
hdc file recv /system/etc/power_config/power_mode_config.xml ./power_mode_config.xml
# 3) 用编辑器将 <switch id="101" value="30000"...> 改为 <switch id="101" value="-1"...>
# 4) 推送回设备
hdc file send ./power_mode_config.xml /system/etc/power_config/power_mode_config.xml
# 5) 重启
hdc shell reboot
# 拉取
hdc file recv /system/etc/param/ohos.para ./ohos.para
# 编辑文件中的相关键值(如 device_manufacturer、device_brand 等)
# 推送
hdc file send ./ohos.para /system/etc/param/ohos.para
# 重启
hdc shell reboot
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。