如往开关功放系统属性(/sys/devices/platform/sound/spk_en)中写值,
命令写值:echo 1 > /sys/devices/platform/sound/spk_en
echo 0 > /sys/devices/platform/sound/spk_en
private static final String FS_PATH = "/sys/devices/platform/sound/spk_en";
private void enableSpeaker(boolean enable) {
String command = enable ? "1" : "0";
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter(FS_PATH));
writer.write(command);
writer.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
writer = null;
} catch (Exception e) {
e.printStackTrace();
}
}
}
}