SamsungParts: add Dolby Atmos entry

* Basic ideas taken from https://github.com/SamarV-121/android_device_samsung_universal7885-common/tree/lineage-19.0/dap
This commit is contained in:
roynatech2544 2021-11-15 22:10:49 +09:00
commit 3eeab18801
No known key found for this signature in database
GPG key ID: 9675C32163D88D30
20 changed files with 347 additions and 117 deletions

View file

@ -1,12 +0,0 @@
android_app {
name: "SamsungDAP",
srcs: ["src/**/*.kt"],
certificate: "platform",
platform_apis: true,
optimize: {
proguard_flags_files: ["proguard.flags"],
},
}

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.lineageos.dap"
android:versionCode="1"
android:versionName="1.0"
android:sharedUserId="android.uid.system">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:label="SamsungDAP"
android:persistent="true"
android:defaultToDeviceProtectedStorage="true"
android:directBootAware="true">
<receiver android:name="org.lineageos.dap.BootCompletedReceiver">
<intent-filter>
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>

View file

@ -1,3 +0,0 @@
-keep class org.lineageos.dap.gef.* {
*;
}

View file

@ -1,58 +0,0 @@
/*
* Copyright (c) 2021 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lineageos.dap
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.media.audiofx.AudioEffect
import android.util.Log
import java.util.UUID
class BootCompletedReceiver : BroadcastReceiver() {
private val audioEffect = AudioEffect(
EFFECT_TYPE_DAP, AudioEffect.EFFECT_TYPE_NULL, 0, 0
)
override fun onReceive(context: Context, intent: Intent) {
Log.d(TAG, "Starting")
audioEffect.setParameter(EFFECT_PARAM_EFF_ENAB, 1)
audioEffect.setParameter(EFFECT_PARAM_PROFILE, PROFILE_AUTO)
audioEffect.enabled = true
}
companion object {
private const val TAG = "SamsungDAP"
private val EFFECT_TYPE_DAP = UUID.fromString("46d279d9-9be7-453d-9d7c-ef937f675587")
private const val EFFECT_PARAM_PROFILE = 0
private const val EFFECT_PARAM_STEREO_WIDENING_DISTANCE = 1
private const val EFFECT_PARAM_EFF_ENAB = 19
private const val PROFILE_AUTO = 0
private const val PROFILE_MOVIE = 1
private const val PROFILE_MUSIC = 2
private const val PROFILE_VOICE = 3
private const val PROFILE_GAME = 4
private const val PROFILE_OFF = 5
private const val PROFILE_GAME_1 = 6
private const val PROFILE_GAME_2 = 7
private const val PROFILE_SPACIAL_AUDIO = 8
}
}

View file

@ -2,6 +2,7 @@ android_app {
name: "SamsungParts",
srcs: [
"src/**/*.java",
"src/**/*.kt",
],
platform_apis: true,
privileged: true,

View file

@ -35,7 +35,6 @@
<activity
android:name=".DeviceSettingsActivity"
android:exported="true"
android:label="@string/advanced_settings"
android:excludeFromRecents="true"
android:launchMode="singleTask">
<intent-filter>
@ -81,6 +80,15 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".dolby.DolbyActivity"
android:exported="true"
android:label="@string/dolby_title">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".battery.BatteryActivity"
android:exported="true"
@ -102,6 +110,17 @@
<action android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
</service>
<service
android:name=".DolbyTile"
android:enabled="true"
android:icon="@drawable/ic_speaker_cleaner_icon"
android:label="@string/dolby_title"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:exported="true">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
</service>
<service
android:name=".FPSInfoService"
android:exported="false">

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#000"
android:pathData="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z" />
</vector>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#000"
android:pathData="M12,3V12.26C11.5,12.09 11,12 10.5,12C8,12 6,14 6,16.5C6,19 8,21 10.5,21C13,21 15,19 15,16.5V6H19V3H12Z" />
</vector>

View file

@ -8,4 +8,15 @@
<item>@string/battery_status</item>
<item>@string/battery_temp</item>
</string-array>
<string-array name="dolby_modes">
<item>@string/dolby_profile_auto</item>
<item>@string/dolby_profile_game</item>
<item>@string/dolby_profile_game_1</item>
<item>@string/dolby_profile_game_2</item>
<item>@string/dolby_profile_movie</item>
<item>@string/dolby_profile_music</item>
<item>@string/dolby_profile_off</item>
<item>@string/dolby_profile_special_audio</item>
<item>@string/dolby_profile_voice</item>
</string-array>
</resources>

View file

@ -21,23 +21,36 @@
<!-- Display category -->
<string name="display_category">Display</string>
<!-- Logs -->
<string name="quick_settings_log_tile_label">Logs</string>
<string name="quick_settings_log_tile_dialog_title">Options</string>
<string name="cannot_get_su">Action failed because of missing superuser access</string>
<!-- FPS Info -->
<string name="fps_info_title">FPS info overlay</string>
<string name="fps_info_summary">Show overlay with current frames per second</string>
<!-- Speaker category -->
<string name="speaker_category">Speaker</string>
<string name="speaker_category">Audio</string>
<!-- Clear Speaker -->
<string name="clear_speaker_title">Clear speaker</string>
<string name="clear_speaker_summary">Play a 30-second audio to clear the speaker</string>
<string name="clear_speaker_description">Run this feature once or twice if you find that your speaker is lightly blocked by dust. Set media volume to maximum.\n\nIf the speaker is blocked heavily, run this feature 25 times while shaking your device with the speaker facing downwards.</string>
<!-- Dolby -->
<string name="dolby_title">Dolby Atmos</string>
<string name="dolby_summary">Enable the Dolby Atmos audio effect</string>
<string name="dolby_description">Enable Dolby audio, just like in OneUI.</string>
<string name="dolby_modes_title">Available Dolby Modes</string>
<string name="dolby_modes_summary">Choose one of these</string>
<string name="dolby_profile_auto">Auto Profile</string>
<string name="dolby_profile_movie">Movie Profile</string>
<string name="dolby_profile_music">Music Profile</string>
<string name="dolby_profile_voice">Voice Profile</string>
<string name="dolby_profile_game">Game Profile</string>
<string name="dolby_profile_off">No Profile</string>
<string name="dolby_profile_game_1">Game 1 Profile</string>
<string name="dolby_profile_game_2">Game 2 Profile</string>
<string name="dolby_profile_special_audio">Special Audio Profile</string>
<!-- Eureka Kernel features category -->
<string name="eureka_kernel_features">Eureka Kernel Features</string>

View file

@ -6,7 +6,7 @@
<SwitchPreference
android:key="clear_speaker_pref"
android:title="@string/clear_speaker_title"
android:icon="@drawable/ic_speaker_cleaner_icon"
android:icon="@drawable/ic_sound"
android:summary="@string/clear_speaker_summary"/>
<com.android.settingslib.widget.FooterPreference

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/dolby_title">
<SwitchPreference
android:key="dolby_pref"
android:title="@string/dolby_title"
android:icon="@drawable/dolby"
android:summary="@string/dolby_summary"/>
<ListPreference
android:key="dolby_modes"
android:title="@string/dolby_modes_title"
android:summary="@string/dolby_modes_summary"
android:icon="@drawable/ic_settings"
android:entries="@array/dolby_modes"/>
<com.android.settingslib.widget.FooterPreference
android:key="footer_preference"
android:title="@string/dolby_description"
android:selectable="false" />
</PreferenceScreen>

View file

@ -17,12 +17,22 @@
android:key="clear_speaker_settings"
android:title="@string/clear_speaker_title"
android:summary="@string/clear_speaker_summary"
android:icon="@drawable/ic_speaker_cleaner_icon" >
android:icon="@drawable/ic_sound" >
<intent
android:action="android.intent.action.MAIN"
android:targetClass="com.eurekateam.samsungextras.ClearSpeakerActivity"
android:targetPackage="com.eurekateam.samsungextras.speaker" />
</Preference>
<Preference
android:key="dolby_settings"
android:title="@string/dolby_title"
android:summary="@string/dolby_summary"
android:icon="@drawable/ic_speaker_cleaner_icon" >
<intent
android:action="android.intent.action.MAIN"
android:targetClass="com.eurekateam.samsungextras.dolby.DolbyActivity"
android:targetPackage="com.eurekateam.samsungextras" />
</Preference>
</PreferenceCategory>
<PreferenceCategory
android:key="eureka_kernel_features"

View file

@ -28,16 +28,20 @@ import com.eurekateam.samsungextras.interfaces.GPU;
public class BootReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) {
if (context != null) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean fpsenabled = sharedPrefs.getBoolean(DeviceSettings.PREF_KEY_FPS_INFO, false);
if (fpsenabled) {
context.startService(new Intent(context, FPSInfoService.class));
}
boolean gpuenabled = sharedPrefs.getBoolean(DeviceSettings.PREF_GPUEXYNOS, false);
if (!gpuenabled){
GPU.setGPU(0);
}
}
}
boolean fpsenabled = sharedPrefs.getBoolean(DeviceSettings.PREF_KEY_FPS_INFO, false);
if (fpsenabled) {
context.startService(new Intent(context, FPSInfoService.class));
}
boolean gpuenabled = sharedPrefs.getBoolean(DeviceSettings.PREF_GPUEXYNOS, false);
if (!gpuenabled){
GPU.setGPU(0);
}
}
}

View file

@ -0,0 +1,33 @@
package com.eurekateam.samsungextras;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import com.eurekateam.samsungextras.dolby.DolbyCore;
public class DolbyTile extends TileService {
private boolean isRunning;
DolbyCore dolbyCore = new DolbyCore();
@Override
public void onStartListening() {
super.onStartListening();
isRunning = dolbyCore.isRunning();
updateTile();
}
@Override
public void onClick() {
if (isRunning) {
dolbyCore.stopDolbyEffect();
}else{
dolbyCore.justStartOnly();
}
isRunning = !isRunning;
updateTile();
}
private void updateTile() {
final Tile tile = getQsTile();
tile.setState(isRunning ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.updateTile();
}
}

View file

@ -0,0 +1,51 @@
/*
* Copyright (C) 2020 Paranoid Android
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eurekateam.samsungextras.dolby;
import android.app.Fragment;
import android.os.Bundle;
import android.view.MenuItem;
import androidx.fragment.app.FragmentActivity;
public class DolbyActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setDisplayHomeAsUpEnabled(true);
Fragment fragment = getFragmentManager().findFragmentById(android.R.id.content);
DolbyFragment dolbyFragment;
if (fragment == null) {
dolbyFragment = new DolbyFragment();
getFragmentManager().beginTransaction()
.add(android.R.id.content, dolbyFragment)
.commit();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}

View file

@ -0,0 +1,42 @@
package com.eurekateam.samsungextras.dolby
import android.media.audiofx.AudioEffect
import java.util.*
class DolbyCore {
private val audioEffect = AudioEffect(
EFFECT_TYPE_DAP, AudioEffect.EFFECT_TYPE_NULL, 0, 0
)
fun startDolbyEffect(PROFILE: Int){
audioEffect.setParameter(EFFECT_PARAM_EFF_ENAB, 1)
audioEffect.setParameter(EFFECT_PARAM_PROFILE, PROFILE)
audioEffect.enabled = true
}
fun stopDolbyEffect(){
audioEffect.enabled = false
}
fun isRunning (): Boolean {
return audioEffect.enabled
}
fun justStartOnly(){
audioEffect.enabled = true
}
companion object {
private val EFFECT_TYPE_DAP = UUID.fromString("46d279d9-9be7-453d-9d7c-ef937f675587")
private const val EFFECT_PARAM_PROFILE = 0
private const val EFFECT_PARAM_EFF_ENAB = 19
const val PROFILE_AUTO = 0
const val PROFILE_MOVIE = 1
const val PROFILE_MUSIC = 2
const val PROFILE_VOICE = 3
const val PROFILE_GAME = 4
const val PROFILE_OFF = 5
const val PROFILE_GAME_1 = 6
const val PROFILE_GAME_2 = 7
const val PROFILE_SPACIAL_AUDIO = 8
}
}

View file

@ -0,0 +1,97 @@
/*
* Copyright (C) 2020 Paranoid Android
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eurekateam.samsungextras.dolby;
import android.os.Bundle;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragment;
import androidx.preference.SwitchPreference;
import com.eurekateam.samsungextras.R;
public class DolbyFragment extends PreferenceFragment implements
Preference.OnPreferenceChangeListener {
private static final String PREF_DOLBY = "dolby_pref";
private static final String DOLBY_MODES = "dolby_modes";
ListPreference DolbyModesPreference;
SwitchPreference DolbyEnablePreference;
DolbyCore dolbyCore = new DolbyCore();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.dolby_settings);
DolbyModesPreference = findPreference(DOLBY_MODES);
DolbyEnablePreference = findPreference(PREF_DOLBY);
assert DolbyEnablePreference != null;
DolbyEnablePreference.setChecked(dolbyCore.isRunning());
DolbyEnablePreference.setOnPreferenceChangeListener(this);
CharSequence[] items = {
"1", "2", "3", "4", "5", "6", "7", "8", "9"
};
DolbyModesPreference.setEntryValues(items);
DolbyModesPreference.setOnPreferenceChangeListener((preference, newValue) -> {
switch (Integer.parseInt((String) newValue)){
case 1:
dolbyCore.startDolbyEffect(DolbyCore.PROFILE_AUTO);
break;
case 2:
dolbyCore.startDolbyEffect(DolbyCore.PROFILE_GAME);
break;
case 3:
dolbyCore.startDolbyEffect(DolbyCore.PROFILE_GAME_1);
break;
case 4:
dolbyCore.startDolbyEffect(DolbyCore.PROFILE_GAME_2);
break;
case 5:
dolbyCore.startDolbyEffect(DolbyCore.PROFILE_MOVIE);
break;
case 6:
dolbyCore.startDolbyEffect(DolbyCore.PROFILE_MUSIC);
break;
case 7:
dolbyCore.startDolbyEffect(DolbyCore.PROFILE_OFF);
break;
case 8:
dolbyCore.startDolbyEffect(DolbyCore.PROFILE_VOICE);
break;
case 9:
dolbyCore.startDolbyEffect(DolbyCore.PROFILE_SPACIAL_AUDIO);
break;
default:
break;
}
return true;
});
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == DolbyEnablePreference) {
Boolean value = (Boolean) newValue;
if(value){
dolbyCore.justStartOnly();
}else{
dolbyCore.stopDolbyEffect();
}
return true;
}
return false;
}
}

View file

@ -19,8 +19,7 @@ PRODUCT_PACKAGES += \
android.hardware.audio.effect@7.0-impl \
libtinycompress \
audio.r_submix.default \
audio.usb.default \
SamsungDAP
audio.usb.default
PRODUCT_COPY_FILES += \
frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration_7_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \