From 8d24cb6823ec9f3b22655bfc80c9d6ffaba8c24e Mon Sep 17 00:00:00 2001 From: Shirayuki39 Date: Fri, 26 Jul 2024 04:51:59 +0800 Subject: [PATCH] LG8n: Nuke InCallService Signed-off-by: Shirayuki39 --- app/InCallService/Android.bp | 31 -------------- app/InCallService/AndroidManifest.xml | 25 ----------- app/InCallService/res/values/strings.xml | 4 -- .../mediatek/incallservice/GainUtils.java | 21 ---------- .../OnLockedBootCompleteReceiver.java | 19 --------- .../incallservice/VolumeChangeReceiver.java | 41 ------------------ .../incallservice/VolumeChangeService.java | 42 ------------------- 7 files changed, 183 deletions(-) delete mode 100644 app/InCallService/Android.bp delete mode 100644 app/InCallService/AndroidManifest.xml delete mode 100644 app/InCallService/res/values/strings.xml delete mode 100644 app/InCallService/src/org/lineageos/mediatek/incallservice/GainUtils.java delete mode 100644 app/InCallService/src/org/lineageos/mediatek/incallservice/OnLockedBootCompleteReceiver.java delete mode 100644 app/InCallService/src/org/lineageos/mediatek/incallservice/VolumeChangeReceiver.java delete mode 100644 app/InCallService/src/org/lineageos/mediatek/incallservice/VolumeChangeService.java diff --git a/app/InCallService/Android.bp b/app/InCallService/Android.bp deleted file mode 100644 index 649bdc0..0000000 --- a/app/InCallService/Android.bp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2022 bengris32 - * Copyright (C) 2022 LineageOS - * - * 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. - */ - -android_app { - name: "MtkInCallService", - - srcs: ["src/**/*.java"], - resource_dirs: ["res"], - - certificate: "platform", - platform_apis: true, - privileged: true, - - optimize: { - enabled: false, - } -} diff --git a/app/InCallService/AndroidManifest.xml b/app/InCallService/AndroidManifest.xml deleted file mode 100644 index cb5c2bc..0000000 --- a/app/InCallService/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - diff --git a/app/InCallService/res/values/strings.xml b/app/InCallService/res/values/strings.xml deleted file mode 100644 index 2be002f..0000000 --- a/app/InCallService/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - Mediatek In-Call Service - diff --git a/app/InCallService/src/org/lineageos/mediatek/incallservice/GainUtils.java b/app/InCallService/src/org/lineageos/mediatek/incallservice/GainUtils.java deleted file mode 100644 index b62558a..0000000 --- a/app/InCallService/src/org/lineageos/mediatek/incallservice/GainUtils.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.lineageos.mediatek.incallservice; - -import android.os.SystemProperties; -import android.media.AudioSystem; -import android.util.Log; - -public class GainUtils { - public static final String LOG_TAG = "MediatekInCallService"; - - public static void setGainLevel(int audioDevice, int gainIndex, int streamType) { - int maxStep = SystemProperties.getInt("ro.config.vc_call_vol_steps", 7); - String parameters = String.format("volumeDevice=%d;volumeIndex=%d;volumeStreamType=%d", - audioDevice, - Math.round( - (15.0 / Math.log(maxStep + 1.0)) - * Math.log(Math.min(maxStep, gainIndex) + 1.0)), - streamType); - Log.d(LOG_TAG, "Setting audio parameters to: " + parameters); - AudioSystem.setParameters(parameters); - } -} diff --git a/app/InCallService/src/org/lineageos/mediatek/incallservice/OnLockedBootCompleteReceiver.java b/app/InCallService/src/org/lineageos/mediatek/incallservice/OnLockedBootCompleteReceiver.java deleted file mode 100644 index 218f437..0000000 --- a/app/InCallService/src/org/lineageos/mediatek/incallservice/OnLockedBootCompleteReceiver.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.lineageos.mediatek.incallservice; - -import android.content.BroadcastReceiver; -import android.content.Intent; -import android.content.Context; - -import android.util.Log; - -public class OnLockedBootCompleteReceiver extends BroadcastReceiver { - private static final String LOG_TAG = "MediatekInCallService"; - - @Override - public void onReceive(final Context context, Intent intent) { - Log.i(LOG_TAG, "onBoot"); - - Intent sIntent = new Intent(context, VolumeChangeService.class); - context.startService(sIntent); - } -} diff --git a/app/InCallService/src/org/lineageos/mediatek/incallservice/VolumeChangeReceiver.java b/app/InCallService/src/org/lineageos/mediatek/incallservice/VolumeChangeReceiver.java deleted file mode 100644 index 98d1d39..0000000 --- a/app/InCallService/src/org/lineageos/mediatek/incallservice/VolumeChangeReceiver.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.lineageos.mediatek.incallservice; - -import android.content.Intent; -import android.content.Context; -import android.content.BroadcastReceiver; - -import android.media.AudioManager; -import android.media.AudioSystem; -import android.media.AudioDeviceInfo; - -import android.util.Log; - -public class VolumeChangeReceiver extends BroadcastReceiver { - public static final String LOG_TAG = "MediatekInCallService"; - - private AudioManager mAudioManager; - - public VolumeChangeReceiver(AudioManager audioManager) { - mAudioManager = audioManager; - } - - private void handleVolumeStateChange(Intent intent) { - if (intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1) == AudioManager.STREAM_VOICE_CALL) { - AudioDeviceInfo callDevice = mAudioManager.getCommunicationDevice(); - - // Try to get volumeIndex - int volumeIndex = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, -1); - if (volumeIndex < 0) { - Log.w(LOG_TAG, "Could not get volumeIndex!"); - return; - } - - GainUtils.setGainLevel(callDevice.getPort().type(), volumeIndex, AudioSystem.STREAM_VOICE_CALL); - } - } - - @Override - public void onReceive(Context context, Intent intent) { - handleVolumeStateChange(intent); - } -} diff --git a/app/InCallService/src/org/lineageos/mediatek/incallservice/VolumeChangeService.java b/app/InCallService/src/org/lineageos/mediatek/incallservice/VolumeChangeService.java deleted file mode 100644 index daca4d6..0000000 --- a/app/InCallService/src/org/lineageos/mediatek/incallservice/VolumeChangeService.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.lineageos.mediatek.incallservice; - -import android.media.AudioManager; - -import android.content.Intent; -import android.content.IntentFilter; -import android.content.Context; -import android.app.Service; -import android.os.IBinder; - -import android.util.Log; - -public class VolumeChangeService extends Service { - public static final String LOG_TAG = "MediatekInCallService"; - - private Context mContext; - private VolumeChangeReceiver mVolumeChangeReceiver; - - @Override - public IBinder onBind(Intent intent) { - return null; - } - - @Override - public void onDestroy() { - super.onDestroy(); - } - - @Override - public int onStartCommand(Intent intent, int flags, int startid) { - mContext = this; - - AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); - mVolumeChangeReceiver = new VolumeChangeReceiver(audioManager); - - Log.i(LOG_TAG, "Service is starting..."); - - this.registerReceiver(mVolumeChangeReceiver, - new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION)); - return START_STICKY; - } -}