Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 004c366d authored by Daniel Jacob Chittoor's avatar Daniel Jacob Chittoor
Browse files

Merge branch '6077-fix-incall-volume' into 'v1-q'

Address volume controls not working in-call

See merge request !13
parents 7b5b4590 4c9b7811
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 bengris32
 *
 * 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,
    }
}
+25 −0
Original line number Diff line number Diff line
<?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>
+4 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">MTK In-call service</string>
</resources>
+16 −0
Original line number Diff line number Diff line
package org.lineageos.mediatek.incallservice;

import android.media.AudioSystem;

import android.util.Log;

public class GainUtils {
    public static final String LOG_TAG = "MtkInCallService";

    public static void setGainLevel(int audioDevice, int gainIndex, int streamType) {
        String parameters = String.format("volumeDevice=%d;volumeIndex=%d;volumeStreamType=%d",
                                          audioDevice, Math.min(7, gainIndex), streamType);
        Log.d(LOG_TAG, "Setting audio parameters to: " + parameters);
        AudioSystem.setParameters(parameters);
    }
}
+19 −0
Original line number Diff line number Diff line
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 = "MtkInCallService";

    @Override
    public void onReceive(final Context context, Intent intent) {
        Log.i(LOG_TAG, "onBoot");

        Intent sIntent = new Intent(context, VolumeChangeService.class);
        context.startService(sIntent);
    }
}
Loading