diff --git a/dap/Android.bp b/dap/Android.bp new file mode 100644 index 0000000..be5fd86 --- /dev/null +++ b/dap/Android.bp @@ -0,0 +1,12 @@ +android_app { + name: "SamsungDAP", + + srcs: ["src/**/*.kt"], + + certificate: "platform", + platform_apis: true, + + optimize: { + proguard_flags_files: ["proguard.flags"], + }, +} diff --git a/dap/AndroidManifest.xml b/dap/AndroidManifest.xml new file mode 100644 index 0000000..f0faa5b --- /dev/null +++ b/dap/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/dap/proguard.flags b/dap/proguard.flags new file mode 100644 index 0000000..2908800 --- /dev/null +++ b/dap/proguard.flags @@ -0,0 +1,3 @@ +-keep class org.lineageos.dap.gef.* { + *; +} diff --git a/dap/src/org/lineageos/dap/BootCompletedReceiver.kt b/dap/src/org/lineageos/dap/BootCompletedReceiver.kt new file mode 100644 index 0000000..c3350ac --- /dev/null +++ b/dap/src/org/lineageos/dap/BootCompletedReceiver.kt @@ -0,0 +1,58 @@ +/* + * 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 + } +} diff --git a/universal7885-common/universal7885-common.mk b/universal7885-common/universal7885-common.mk index 7dfa6ce..9ab2878 100644 --- a/universal7885-common/universal7885-common.mk +++ b/universal7885-common/universal7885-common.mk @@ -13,7 +13,8 @@ PRODUCT_PACKAGES += \ android.hardware.audio.effect@6.0-impl \ libtinycompress \ audio.r_submix.default \ - audio.usb.default + audio.usb.default \ + SamsungDAP PRODUCT_COPY_FILES += \ frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \