This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc0eefa
commit 0331268
Showing
509 changed files
with
69,634 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
PRODUCT_MAKEFILES := \ | ||
$(LOCAL_DIR)/treble_arm64_avS.mk \ | ||
$(LOCAL_DIR)/treble_arm64_avN.mk \ | ||
$(LOCAL_DIR)/treble_arm_avS.mk \ | ||
$(LOCAL_DIR)/treble_arm_avN.mk \ | ||
$(LOCAL_DIR)/treble_a64_avS.mk \ | ||
$(LOCAL_DIR)/treble_a64_avN.mk \ | ||
$(LOCAL_DIR)/treble_arm64_agS.mk \ | ||
$(LOCAL_DIR)/treble_arm64_agN.mk \ | ||
$(LOCAL_DIR)/treble_arm_agS.mk \ | ||
$(LOCAL_DIR)/treble_arm_agN.mk \ | ||
$(LOCAL_DIR)/treble_a64_agS.mk \ | ||
$(LOCAL_DIR)/treble_a64_agN.mk \ | ||
$(LOCAL_DIR)/treble_arm64_afS.mk \ | ||
$(LOCAL_DIR)/treble_arm64_afN.mk \ | ||
$(LOCAL_DIR)/treble_arm_afS.mk \ | ||
$(LOCAL_DIR)/treble_arm_afN.mk \ | ||
$(LOCAL_DIR)/treble_a64_afS.mk \ | ||
$(LOCAL_DIR)/treble_a64_afN.mk \ | ||
$(LOCAL_DIR)/treble_arm64_aoS.mk \ | ||
$(LOCAL_DIR)/treble_arm64_aoN.mk \ | ||
$(LOCAL_DIR)/treble_arm_aoS.mk \ | ||
$(LOCAL_DIR)/treble_arm_aoN.mk \ | ||
$(LOCAL_DIR)/treble_a64_aoS.mk \ | ||
$(LOCAL_DIR)/treble_a64_aoN.mk \ | ||
$(LOCAL_DIR)/treble_arm64_bvS.mk \ | ||
$(LOCAL_DIR)/treble_arm64_bvN.mk \ | ||
$(LOCAL_DIR)/treble_arm_bvS.mk \ | ||
$(LOCAL_DIR)/treble_arm_bvN.mk \ | ||
$(LOCAL_DIR)/treble_a64_bvS.mk \ | ||
$(LOCAL_DIR)/treble_a64_bvN.mk \ | ||
$(LOCAL_DIR)/treble_arm64_bgS.mk \ | ||
$(LOCAL_DIR)/treble_arm64_bgN.mk \ | ||
$(LOCAL_DIR)/treble_arm_bgS.mk \ | ||
$(LOCAL_DIR)/treble_arm_bgN.mk \ | ||
$(LOCAL_DIR)/treble_a64_bgS.mk \ | ||
$(LOCAL_DIR)/treble_a64_bgN.mk \ | ||
$(LOCAL_DIR)/treble_arm64_bfS.mk \ | ||
$(LOCAL_DIR)/treble_arm64_bfN.mk \ | ||
$(LOCAL_DIR)/treble_arm_bfS.mk \ | ||
$(LOCAL_DIR)/treble_arm_bfN.mk \ | ||
$(LOCAL_DIR)/treble_a64_bfS.mk \ | ||
$(LOCAL_DIR)/treble_a64_bfN.mk \ | ||
$(LOCAL_DIR)/treble_arm64_boS.mk \ | ||
$(LOCAL_DIR)/treble_arm64_boN.mk \ | ||
$(LOCAL_DIR)/treble_arm_boS.mk \ | ||
$(LOCAL_DIR)/treble_arm_boN.mk \ | ||
$(LOCAL_DIR)/treble_a64_boS.mk \ | ||
$(LOCAL_DIR)/treble_a64_boN.mk \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
You'll need to call generate.sh in this folder to generate the Makefiles to build the Treble targets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) | ||
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk) | ||
$(call inherit-product, vendor/aosp/common.mk) | ||
TARGET_BOOT_ANIMATION_RES := 1080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$(call inherit-product, vendor/amy/config/common.mk) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import /system/etc/init/zygote/init.${ro.zygote}.rc | ||
|
||
on early-fs | ||
mkdir /mnt/runtime/full 0755 root root | ||
mkdir /mnt/runtime/full/self 0755 root root | ||
mkdir /apex 0777 root root | ||
mount tmpfs tmpfs /apex mode=0755,uid=0,gid=0 | ||
restorecon /apex | ||
exec -- /system/bin/apexd --bootstrap | ||
export ANDROID_RUNTIME_ROOT /apex/com.android.runtime | ||
export ANDROID_TZDATA_ROOT /apex/com.android.tzdata | ||
symlink /system/product /product | ||
|
||
on fs | ||
exec u:r:su:s0 -- /system/bin/umount -l /product | ||
exec u:r:su:s0 -- /system/bin/rmdir /product | ||
symlink /system/product /product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (C) 2022 bengris32 | ||
* Copyright (C) 2022 LineageOS | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
android_app { | ||
name: "MtkInCallService", | ||
|
||
srcs: ["src/**/*.java"], | ||
resource_dirs: ["res"], | ||
|
||
certificate: "platform", | ||
platform_apis: true, | ||
privileged: true, | ||
|
||
optimize: { | ||
enabled: false, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="org.lineageos.mediatek.incallservice" | ||
android:versionCode="1" | ||
android:versionName="1.0" | ||
android:sharedUserId="android.uid.system"> | ||
|
||
<application | ||
android:label="@string/app_name" | ||
android:persistent="true"> | ||
<receiver | ||
android:directBootAware="true" | ||
android:exported="true" | ||
android:name="org.lineageos.mediatek.incallservice.OnLockedBootCompleteReceiver"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</receiver> | ||
<service | ||
android:directBootAware="true" | ||
android:name="org.lineageos.mediatek.incallservice.VolumeChangeService"> | ||
</service> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">Mediatek In-Call Service</string> | ||
</resources> |
31 changes: 31 additions & 0 deletions
31
app/InCallService/src/org/lineageos/mediatek/incallservice/CallStateListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2023 The LineageOS Project | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.lineageos.mediatek.incallservice; | ||
|
||
import android.media.AudioManager; | ||
|
||
import android.telephony.TelephonyManager; | ||
import android.telephony.TelephonyCallback; | ||
|
||
import android.util.Log; | ||
|
||
public class CallStateListener extends TelephonyCallback implements TelephonyCallback.CallStateListener { | ||
private static final String LOG_TAG = "MtkInCallService"; | ||
private AudioManager mAudioManager; | ||
|
||
public CallStateListener(AudioManager audioManager) { | ||
mAudioManager = audioManager; | ||
} | ||
|
||
@Override | ||
public void onCallStateChanged(int state) { | ||
if (state == TelephonyManager.CALL_STATE_OFFHOOK || state == TelephonyManager.CALL_STATE_RINGING) { | ||
Log.d(LOG_TAG, "CallStateListener: CALL_STATE_OFFHOOK, setting gain."); | ||
GainUtils.setGainLevel(mAudioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL)); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
app/InCallService/src/org/lineageos/mediatek/incallservice/GainUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.lineageos.mediatek.incallservice; | ||
|
||
import android.media.AudioDeviceInfo; | ||
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); | ||
} | ||
|
||
/** | ||
* Sets the gain level for built-in earpiece and bluetooth SCO devices. | ||
* @param gainIndex The gain level to set. | ||
*/ | ||
public static void setGainLevel(int gainIndex) { | ||
GainUtils.setGainLevel(AudioDeviceInfo.TYPE_BUILTIN_EARPIECE, gainIndex, AudioSystem.STREAM_VOICE_CALL); | ||
GainUtils.setGainLevel(AudioDeviceInfo.TYPE_BLUETOOTH_SCO, gainIndex, AudioSystem.STREAM_VOICE_CALL); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
app/InCallService/src/org/lineageos/mediatek/incallservice/OnLockedBootCompleteReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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"); | ||
if(!android.os.SystemProperties.get("ro.hardware", "none").startsWith("mt")) { | ||
Log.i(LOG_TAG, "Not a mediatek, byebye"); | ||
return; | ||
} | ||
|
||
Intent sIntent = new Intent(context, VolumeChangeService.class); | ||
context.startService(sIntent); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/InCallService/src/org/lineageos/mediatek/incallservice/VolumeChangeReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
app/InCallService/src/org/lineageos/mediatek/incallservice/VolumeChangeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.lineageos.mediatek.incallservice; | ||
|
||
import android.media.AudioManager; | ||
|
||
import android.telephony.TelephonyManager; | ||
import android.telephony.TelephonyCallback; | ||
|
||
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; | ||
private CallStateListener mCallStateListener; | ||
|
||
@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); | ||
TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); | ||
mVolumeChangeReceiver = new VolumeChangeReceiver(audioManager); | ||
mCallStateListener = new CallStateListener(audioManager); | ||
|
||
Log.i(LOG_TAG, "Service is starting..."); | ||
|
||
this.registerReceiver(mVolumeChangeReceiver, | ||
new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION)); | ||
|
||
telephonyManager.registerTelephonyCallback(getMainExecutor(), mCallStateListener); | ||
|
||
// Restore gain levels on service start. | ||
GainUtils.setGainLevel(audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL)); | ||
|
||
return START_STICKY; | ||
} | ||
} |
Oops, something went wrong.