sdm660-common: XiaomiParts: Add Headphone & Mic Gain
* This is manually ported by me from Lavender tree on Corvus-Devices * Thanks @StyloGey for reviewing the java code and giving me a better solution * Original repo: https://github.com/Corvus-Devices/device_xiaomi_lavender.git To get it working, you need these two commits in your kernel: >c04d6d6e61
>8e25ac3318
Signed-off-by: OdSazib <odsazib@gmail.com> Change-Id: I1bb48ced1f23728daa2e5170647ce08a04347110
This commit is contained in:
parent
7580f5f636
commit
9bd430ff9b
13 changed files with 94 additions and 2 deletions
9
XiaomiParts/res/drawable/ic_headphone.xml
Normal file
9
XiaomiParts/res/drawable/ic_headphone.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<!-- drawable/headphone-settings.xml -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path android:fillColor="#000000" android:pathData="M12,1A9,9 0 0,1 21,10V17A3,3 0 0,1 18,20H15V12H19V10A7,7 0 0,0 12,3A7,7 0 0,0 5,10V12H9V20H6A3,3 0 0,1 3,17V10A9,9 0 0,1 12,1M15,24V22H17V24H15M11,24V22H13V24H11M7,24V22H9V24H7Z" />
|
||||
</vector>
|
9
XiaomiParts/res/drawable/ic_mic.xml
Normal file
9
XiaomiParts/res/drawable/ic_mic.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path android:fillColor="#000000" android:pathData="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm-1-9c0-0.55 0.45 -1 1-1s1 0.45 1 1v6c0 0.55-0.45 1-1 1s-1-0.45-1-1V5zm6 6c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-0.49 6-3.39 6-6.92h-2z" />
|
||||
</vector>
|
|
@ -6,5 +6,7 @@
|
|||
<attr name="max" format="integer" />
|
||||
<attr name="units" format="string|reference" />
|
||||
<attr name="defaultText" format="string|reference" />
|
||||
<attr name="showSign" format="boolean" />
|
||||
<attr name="continuousUpdates" format="boolean" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
|
|
@ -82,7 +82,6 @@
|
|||
<string name="preset_warm_amoled">Warm Amoled</string>
|
||||
<string name="preset_hybrid_mamba">Hybrid Mamba</string>
|
||||
|
||||
|
||||
<string name="hall_wakeup_title">Flip Cover Wakeup</string>
|
||||
<string name="hall_title">Enable Flip Cover Wakeup</string>
|
||||
<string name="hall_wakeup_summary">Wakeup device via magnetic Flip Cover</string>
|
||||
|
@ -98,4 +97,9 @@
|
|||
<!-- FPS Info -->
|
||||
<string name="fps_info_title">FPS Overlay</string>
|
||||
<string name="fps_info_summary">Show overlay with with current frames per second</string>
|
||||
|
||||
<!-- Audio amplification -->
|
||||
<string name="audio_amplify">Amplify Audio</string>
|
||||
<string name="headphone_gain">Headphone Gain</string>
|
||||
<string name="mic_gain">Microphone Gain</string>
|
||||
</resources>
|
||||
|
|
|
@ -40,6 +40,27 @@
|
|||
android:defaultValue="100" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="audio_amplify"
|
||||
android:title="@string/audio_amplify">
|
||||
|
||||
<org.lineageos.settings.device.preferences.CustomSeekBarPreference
|
||||
android:defaultValue="0"
|
||||
android:key="headphone_gain"
|
||||
android:max="20"
|
||||
app:min="-10"
|
||||
android:icon="@drawable/ic_headphone"
|
||||
android:title="@string/headphone_gain"/>
|
||||
|
||||
<org.lineageos.settings.device.preferences.CustomSeekBarPreference
|
||||
android:defaultValue="0"
|
||||
android:key="mic_gain"
|
||||
android:max="20"
|
||||
app:min="-10"
|
||||
android:icon="@drawable/ic_mic"
|
||||
android:title="@string/mic_gain"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="display"
|
||||
android:title="@string/display_title">
|
||||
|
|
|
@ -29,6 +29,9 @@ import java.lang.Math.*;
|
|||
|
||||
public class BootReceiver extends BroadcastReceiver implements Utils {
|
||||
|
||||
public static final String HEADPHONE_GAIN_PATH = "/sys/kernel/sound_control/headphone_gain";
|
||||
public static final String MIC_GAIN_PATH = "/sys/kernel/sound_control/mic_gain";
|
||||
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
@ -59,6 +62,12 @@ public class BootReceiver extends BroadcastReceiver implements Utils {
|
|||
PREF_HUE, HUE_DEFAULT));
|
||||
}
|
||||
|
||||
int gain = Settings.Secure.getInt(context.getContentResolver(),
|
||||
DeviceSettings.PREF_HEADPHONE_GAIN, 0);
|
||||
FileUtils.setValue(HEADPHONE_GAIN_PATH, gain + " " + gain);
|
||||
FileUtils.setValue(MIC_GAIN_PATH, Settings.Secure.getInt(context.getContentResolver(),
|
||||
DeviceSettings.PREF_MIC_GAIN, 0));
|
||||
|
||||
FileUtils.setValue(DeviceSettings.NOTIF_LED_PATH,(1 + Math.pow(1.05694, Settings.Secure.getInt(
|
||||
context.getContentResolver(), DeviceSettings.PREF_NOTIF_LED, 100))));
|
||||
FileUtils.setValue(DeviceSettings.VIBRATION_STRENGTH_PATH, Settings.Secure.getInt(
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.lineageos.settings.device.preferences.SecureSettingListPreference;
|
|||
import org.lineageos.settings.device.preferences.SecureSettingSwitchPreference;
|
||||
import org.lineageos.settings.device.preferences.VibrationSeekBarPreference;
|
||||
import org.lineageos.settings.device.preferences.NotificationLedSeekBarPreference;
|
||||
import org.lineageos.settings.device.preferences.CustomSeekBarPreference;
|
||||
|
||||
import java.lang.Math.*;
|
||||
|
||||
|
@ -48,6 +49,12 @@ public class DeviceSettings extends PreferenceFragment implements
|
|||
|
||||
public static final String PREF_KEY_FPS_INFO = "fps_info";
|
||||
|
||||
public static final String CATEGORY_AUDIO_AMPLIFY = "audio_amplify";
|
||||
public static final String PREF_HEADPHONE_GAIN = "headphone_gain";
|
||||
public static final String PREF_MIC_GAIN = "mic_gain";
|
||||
public static final String HEADPHONE_GAIN_PATH = "/sys/kernel/sound_control/headphone_gain";
|
||||
public static final String MIC_GAIN_PATH = "/sys/kernel/sound_control/mic_gain";
|
||||
|
||||
// value of vtg_min and vtg_max
|
||||
public static final int MIN_VIBRATION = 116;
|
||||
public static final int MAX_VIBRATION = 3596;
|
||||
|
@ -94,6 +101,16 @@ public class DeviceSettings extends PreferenceFragment implements
|
|||
vibrationStrength.setOnPreferenceChangeListener(this);
|
||||
} else { getPreferenceScreen().removePreference(findPreference(CATEGORY_VIBRATOR)); }
|
||||
|
||||
// Headphone & Mic Gain
|
||||
if (FileUtils.fileWritable(HEADPHONE_GAIN_PATH) && FileUtils.fileWritable(MIC_GAIN_PATH)) {
|
||||
CustomSeekBarPreference headphoneGain = (CustomSeekBarPreference) findPreference(PREF_HEADPHONE_GAIN);
|
||||
headphoneGain.setOnPreferenceChangeListener(this);
|
||||
CustomSeekBarPreference micGain = (CustomSeekBarPreference) findPreference(PREF_MIC_GAIN);
|
||||
micGain.setOnPreferenceChangeListener(this);
|
||||
} else {
|
||||
getPreferenceScreen().removePreference(findPreference(CATEGORY_AUDIO_AMPLIFY));
|
||||
}
|
||||
|
||||
PreferenceCategory displayCategory = (PreferenceCategory) findPreference(CATEGORY_DISPLAY);
|
||||
if (isAppNotInstalled(DEVICE_DOZE_PACKAGE_NAME)) {
|
||||
displayCategory.removePreference(findPreference(PREF_DEVICE_DOZE));
|
||||
|
@ -142,6 +159,14 @@ public class DeviceSettings extends PreferenceFragment implements
|
|||
FileUtils.setValue(VIBRATION_STRENGTH_PATH, vibrationValue);
|
||||
break;
|
||||
|
||||
case PREF_HEADPHONE_GAIN:
|
||||
FileUtils.setValue(HEADPHONE_GAIN_PATH, value + " " + value);
|
||||
break;
|
||||
|
||||
case PREF_MIC_GAIN:
|
||||
FileUtils.setValue(MIC_GAIN_PATH, (int) value);
|
||||
break;
|
||||
|
||||
case PREF_THERMAL:
|
||||
mTHERMAL.setValue((String) value);
|
||||
mTHERMAL.setSummary(mTHERMAL.getEntry());
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.content.Context;
|
|||
import android.content.res.TypedArray;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
import androidx.preference.*;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
|
|
|
@ -307,3 +307,4 @@ service vendor.hvdcp_opti /system/vendor/bin/hvdcp_opti
|
|||
user root
|
||||
group system wakelock
|
||||
writepid /dev/cpuset/system-background/tasks
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@ on boot
|
|||
chown system system /sys/class/graphics/fb0/measured_fps
|
||||
chmod 0660 /sys/class/graphics/fb0/measured_fps
|
||||
|
||||
# Audio Amplification
|
||||
chown system system /sys/kernel/sound_control/headphone_gain
|
||||
chown system system /sys/kernel/sound_control/mic_gain
|
||||
chmod 0660 /sys/kernel/sound_control/headphone_gain
|
||||
chmod 0660 /sys/kernel/sound_control/mic_gain
|
||||
|
||||
# KCal
|
||||
chown system system /sys/devices/platform/kcal_ctrl.0/kcal_cont
|
||||
chown system system /sys/devices/platform/kcal_ctrl.0/kcal_enable
|
||||
|
|
2
sepolicy/vendor/file.te
vendored
2
sepolicy/vendor/file.te
vendored
|
@ -25,3 +25,5 @@ type thermal_data_file, file_type, data_file_type;
|
|||
|
||||
# XiamiParts
|
||||
type sysfs_fpsinfo, sysfs_type, fs_type;
|
||||
type sysfs_headphonegain, sysfs_type, fs_type;
|
||||
type sysfs_micgain, sysfs_type, fs_type;
|
||||
|
|
2
sepolicy/vendor/genfs_contexts
vendored
2
sepolicy/vendor/genfs_contexts
vendored
|
@ -38,3 +38,5 @@ genfscon sysfs /devices/soc/800f000.qcom,spmi/spmi-0/spmi0-03/800f000.qcom,spmi:
|
|||
# XiaomiParts
|
||||
genfscon sysfs /devices/virtual/graphics/fb0/measured_fps u:object_r:sysfs_fpsinfo:s0
|
||||
genfscon sysfs /class/graphics/fb0/measured_fps u:object_r:sysfs_fpsinfo:s0
|
||||
genfscon sysfs /kernel/sound_control/headphone_gain u:object_r:sysfs_headphonegain:s0
|
||||
genfscon sysfs /kernel/sound_control/mic_gain u:object_r:sysfs_micgain:s0
|
||||
|
|
3
sepolicy/vendor/system_app.te
vendored
3
sepolicy/vendor/system_app.te
vendored
|
@ -13,5 +13,6 @@ allow system_app sysfs_graphics:dir search;
|
|||
allow system_app sysfs_graphics:file rw_file_perms;
|
||||
allow system_app sysfs_leds:dir search;
|
||||
allow system_app sysfs_fpsinfo:file rw_file_perms;
|
||||
|
||||
allow system_app sysfs_headphonegain:file rw_file_perms;
|
||||
allow system_app sysfs_micgain:file rw_file_perms;
|
||||
set_prop(system_app, system_prop);
|
||||
|
|
Loading…
Reference in a new issue