diff --git a/app/src/main/java/com/grarak/kerneladiutor/fragments/kernel/SoundFragment.java b/app/src/main/java/com/grarak/kerneladiutor/fragments/kernel/SoundFragment.java index 81a21947a..2560b86bb 100755 --- a/app/src/main/java/com/grarak/kerneladiutor/fragments/kernel/SoundFragment.java +++ b/app/src/main/java/com/grarak/kerneladiutor/fragments/kernel/SoundFragment.java @@ -28,6 +28,7 @@ import com.grarak.kerneladiutor.views.recyclerview.SwitchView; import com.grarak.kerneladiutor.views.recyclerview.TitleView; +import java.util.ArrayList; import java.util.List; /** @@ -89,6 +90,9 @@ protected void addItems(List items) { if (mSound.hasVolumeGain()) { volumeGainInit(items); } + if (mSound.hasboefflasound()) { + boefflasoundInit(items); + } } private void soundControlEnableInit(List items) { @@ -330,4 +334,68 @@ public void onMove(SeekBarView seekBarView, int position, String value) { items.add(microphoneFlar); } + private void boefflasoundInit(List items) { + List boefflasound = new ArrayList<>(); + + TitleView title = new TitleView(); + title.setText(getString(R.string.boefflasound)); + + if (mSound.hasboefflasound()) { + SwitchView boefflasoundenable = new SwitchView(); + boefflasoundenable.setSummary(getString(R.string.boefflasound_summary)); + boefflasoundenable.setChecked(mSound.isboefflasoundenabled()); + boefflasoundenable.addOnSwitchListener(new SwitchView.OnSwitchListener() { + @Override + public void onChanged(SwitchView switchView, boolean isChecked) { + mSound.enableboefflasound(isChecked, getActivity()); + } + }); + + boefflasound.add(boefflasoundenable); + } + + if (mSound.hasboefflaspeaker()) { + SeekBarView boefflaspeaker = new SeekBarView(); + boefflaspeaker.setTitle(getString(R.string.speaker_gain)); + boefflaspeaker.setItems(mSound.getboefflaLimits()); + boefflaspeaker.setProgress(mSound.getboefflaLimits().indexOf(mSound.getboefflaspeaker())); + boefflaspeaker.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() { + @Override + public void onStop(SeekBarView seekBarView, int position, String value) { + mSound.setboefflaspeaker(value, getActivity()); + } + + @Override + public void onMove(SeekBarView seekBarView, int position, String value) { + } + }); + + boefflasound.add(boefflaspeaker); + } + + if (mSound.hasboefflahp()) { + SeekBarView boefflahp = new SeekBarView(); + boefflahp.setTitle(getString(R.string.headphone_gain)); + boefflahp.setItems(mSound.getboefflaLimits()); + boefflahp.setProgress(mSound.getboefflaLimits().indexOf(mSound.getboefflahp())); + boefflahp.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() { + @Override + public void onStop(SeekBarView seekBarView, int position, String value) { + mSound.setboefflahp(value, getActivity()); + } + + @Override + public void onMove(SeekBarView seekBarView, int position, String value) { + } + }); + + boefflasound.add(boefflahp); + } + + if (boefflasound.size() > 0) { + items.add(title); + items.addAll(boefflasound); + } + } + } diff --git a/app/src/main/java/com/grarak/kerneladiutor/utils/kernel/sound/Sound.java b/app/src/main/java/com/grarak/kerneladiutor/utils/kernel/sound/Sound.java index ddd474768..175bbbf58 100755 --- a/app/src/main/java/com/grarak/kerneladiutor/utils/kernel/sound/Sound.java +++ b/app/src/main/java/com/grarak/kerneladiutor/utils/kernel/sound/Sound.java @@ -65,12 +65,17 @@ public static Sound getInstance() { private static final String MICROPHONE_FLAR = "/sys/kernel/sound_control/mic_gain"; private static final String SPEAKER_FLAR = "/sys/kernel/sound_control/speaker_gain"; + private static final String BOEFFLA_SOUND = "/sys/class/misc/boeffla_sound/boeffla_sound"; + private static final String BOEFFLA_SPEAKER = "/sys/class/misc/boeffla_sound/speaker_volume"; + private static final String BOEFFLA_HP = "/sys/class/misc/boeffla_sound/headphone_volume"; + private final List mSpeakerGainFiles = new ArrayList<>(); private final List mFauxLimits = new ArrayList<>(); private final List mFrancoLimits = new ArrayList<>(); private final List mFlarLimits = new ArrayList<>(); private final List mFlarHpLimits = new ArrayList<>(); + private final List mboefflaLimits = new ArrayList<>(); { mSpeakerGainFiles.add(SPEAKER_GAIN); @@ -94,6 +99,9 @@ public static Sound getInstance() { for (int i = -40; i < 21; i++) { mFlarHpLimits.add(String.valueOf(i)); } + for (int i = -30; i < 31; i++) { + mboefflaLimits.add(String.valueOf(i)); + } } private String SPEAKER_GAIN_FILE; @@ -263,6 +271,10 @@ public List getSpeakerGainLimits() { return mFrancoLimits; case SPEAKER_FLAR: return mFlarLimits; + case BOEFFLA_SPEAKER: + return mboefflaLimits; + case BOEFFLA_HP: + return mboefflaLimits; } return new ArrayList<>(); } @@ -386,7 +398,7 @@ public boolean supported() { || hasHandsetMicrophoneGain() || hasCamMicrophoneGain() || hasSpeakerGain() || hasHeadphonePowerAmpGain() || hasLockOutputGain() || hasLockMicGain() || hasMicrophoneGain() || hasVolumeGain() || hasHeadphoneFlar() - || hasMicrophoneFlar(); + || hasMicrophoneFlar() || hasboefflasound(); } private long getChecksum(int a, int b) { @@ -452,4 +464,59 @@ public boolean hasMicrophoneFlar() { return Utils.existFile(MICROPHONE_FLAR); } + public void enableboefflasound(boolean enable, Context context) { + run(Control.write(enable ? "1" : "0", BOEFFLA_SOUND), BOEFFLA_SOUND, context); + } + + public boolean isboefflasoundenabled() { + return Utils.readFile(BOEFFLA_SOUND).equals("Boeffla sound status: 1"); + } + + public boolean hasboefflasound() { + return Utils.existFile(BOEFFLA_SOUND); + } + public void setboefflaspeaker(String value, Context context) { + int newGain = Utils.strToInt(value); + if (newGain >= -30 && newGain <= 30) { + fauxRun(value + " " + value, BOEFFLA_SPEAKER, BOEFFLA_SPEAKER, context); + } + } + + public List getboefflaLimits() { + return mboefflaLimits; + } + + public String getboefflaspeaker() { + String value = Utils.readFile(BOEFFLA_SPEAKER); + int gain = Utils.strToInt(value.contains(" ") ? value.split(" ")[0] : value); + if (gain >= -30 && gain <= 30) { + return String.valueOf(gain); + } + return ""; + } + + public boolean hasboefflaspeaker() { + return Utils.existFile(BOEFFLA_SPEAKER); + } + + public void setboefflahp(String value, Context context) { + int newGain = Utils.strToInt(value); + if (newGain >= -30 && newGain <= 30) { + fauxRun(value + " " + value, BOEFFLA_HP, BOEFFLA_HP, context); + } + } + + public String getboefflahp() { + String value = Utils.readFile(BOEFFLA_HP); + int gain = Utils.strToInt(value.contains(" ") ? value.split(" ")[0] : value); + if (gain >= -30 && gain <= 30) { + return String.valueOf(gain); + } + return ""; + } + + public boolean hasboefflahp() { + return Utils.existFile(BOEFFLA_HP); + } + } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a331fbcb4..fe438b1de 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -555,6 +555,8 @@ Prevent modifications to microphone gains Microphone Gain Volume Gain + Boeffla Sound + Turn On/Off Boeffla Sound Engine Level