universal7885: FMRadio: Futher improve code

* Using enum classes for various statuses for good readability
* Implement favorite channel saving which was missing
* Use Kotlin coroutines again for refreshing channel list button, for faster UI response
* Added javadoc for better functions description
* Also, code native audio routing system on jni (fm_route.cpp)

Change-Id: I993c88fdb580248d8a55efd8e9b6fed0e36d9b24
Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
This commit is contained in:
roynatech2544 2022-02-28 18:05:41 +09:00
commit 9443bdc315
No known key found for this signature in database
GPG key ID: 9675C32163D88D30
17 changed files with 312 additions and 142 deletions

View file

@ -1,9 +1,12 @@
cc_library_shared {
name: "libfmioctl_jni",
name: "libfmnative_jni",
cflags: [
"-Wno-unused-parameter",
],
srcs: ["fm_ioctl.cpp"],
srcs: [
"fm_ioctl.cpp",
"fm_route.cpp",
],
shared_libs: [
"libhidlbase",
"liblog",
@ -11,7 +14,19 @@ cc_library_shared {
"vendor.eureka.hardware.fmradio@1.0",
"vendor.eureka.hardware.fmradio@1.1",
"vendor.eureka.hardware.fmradio@1.2",
"audioflinger-aidl-cpp",
"audiopolicy-aidl-cpp",
"audiopolicy-types-aidl-cpp",
"libaudiofoundation",
"libaudioutils",
"libaudioclient",
"libutils",
"libaudiopolicy",
"libaudiomanager",
],
header_libs: [
"libaudioclient_headers",
"jni_headers",
],
header_libs: ["jni_headers"],
}

View file

@ -0,0 +1,37 @@
/*
* Copyright 2021 Soo Hwan Na "Royna"
*
* 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.
*/
#include <jni.h>
#include <media/IAudioFlinger.h>
#include <media/AudioSystem.h>
#define FM_FAILURE -1
#define FM_SUCCESS 0
#define IOHANDLE 13
using namespace android;
extern "C"
JNIEXPORT jboolean JNICALL
Java_com_eurekateam_fmradio_NativeFMInterface_setAudioRoute
(__unused JNIEnv *env, __unused jobject thiz, jboolean speaker) {
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
if (speaker){
af->setParameters(IOHANDLE, String8("routing=2"));
}else{
af->setParameters(IOHANDLE, String8("routing=8"));
}
return FM_SUCCESS;
}