Skip to content
This repository was archived by the owner on Oct 5, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -89,6 +90,9 @@ protected void addItems(List<RecyclerViewItem> items) {
if (mSound.hasVolumeGain()) {
volumeGainInit(items);
}
if (mSound.hasboefflasound()) {
boefflasoundInit(items);
}
}

private void soundControlEnableInit(List<RecyclerViewItem> items) {
Expand Down Expand Up @@ -330,4 +334,68 @@ public void onMove(SeekBarView seekBarView, int position, String value) {
items.add(microphoneFlar);
}

private void boefflasoundInit(List<RecyclerViewItem> items) {
List<RecyclerViewItem> 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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> mSpeakerGainFiles = new ArrayList<>();

private final List<String> mFauxLimits = new ArrayList<>();
private final List<String> mFrancoLimits = new ArrayList<>();
private final List<String> mFlarLimits = new ArrayList<>();
private final List<String> mFlarHpLimits = new ArrayList<>();
private final List<String> mboefflaLimits = new ArrayList<>();

{
mSpeakerGainFiles.add(SPEAKER_GAIN);
Expand All @@ -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;
Expand Down Expand Up @@ -263,6 +271,10 @@ public List<String> getSpeakerGainLimits() {
return mFrancoLimits;
case SPEAKER_FLAR:
return mFlarLimits;
case BOEFFLA_SPEAKER:
return mboefflaLimits;
case BOEFFLA_HP:
return mboefflaLimits;
}
return new ArrayList<>();
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<String> 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);
}

}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@
<string name="lock_mic_gain_summary">Prevent modifications to microphone gains</string>
<string name="microphone_gain">Microphone Gain</string>
<string name="volume_gain">Volume Gain</string>
<string name="boefflasound">Boeffla Sound</string>
<string name="boefflasound_summary">Turn On/Off Boeffla Sound Engine</string>

<!-- Battery -->
<string name="level">Level</string>
Expand Down