sm8150-common: Remove play/pause hack while toggling Dolby

Not required with/fixed by:
35217: audioflinger: Do not allow DAP effect to be suspended | https://gerrit.aospa.co/c/AOSPA/android_frameworks_av/+/35217

Change-Id: I842df18e1f95bbe9146f256297d1eea2e9d21140
This commit is contained in:
Adithya R 2023-10-09 21:58:58 +05:30 committed by fazilsheik96
parent 41932f4739
commit 9cd354ec40
1 changed files with 0 additions and 72 deletions

View File

@ -17,18 +17,7 @@
package co.aospa.settings.dolby;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.session.MediaController;
import android.media.session.MediaSessionManager;
import android.media.session.PlaybackState;
import android.os.Handler;
import android.os.SystemClock;
import android.os.UserHandle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.KeyEvent;
import co.aospa.settings.dolby.R;
@ -43,14 +32,11 @@ public final class DolbyUtils {
private static DolbyUtils mInstance;
private DolbyAtmos mDolbyAtmos;
private MediaSessionManager mMediaSessionManager;
private Context mContext;
private Handler mHandler = new Handler();
private DolbyUtils(Context context) {
mContext = context;
mDolbyAtmos = new DolbyAtmos(EFFECT_PRIORITY, 0);
mMediaSessionManager = context.getSystemService(MediaSessionManager.class);
}
public static synchronized DolbyUtils getInstance(Context context) {
@ -66,63 +52,6 @@ public final class DolbyUtils {
mDolbyAtmos.setVolumeLevelerEnabled(false);
}
private void triggerPlayPause(MediaController controller) {
long when = SystemClock.uptimeMillis();
final KeyEvent evDownPause = new KeyEvent(when, when, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PAUSE, 0);
final KeyEvent evUpPause = KeyEvent.changeAction(evDownPause, KeyEvent.ACTION_UP);
final KeyEvent evDownPlay = new KeyEvent(when, when, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY, 0);
final KeyEvent evUpPlay = KeyEvent.changeAction(evDownPlay, KeyEvent.ACTION_UP);
mHandler.post(new Runnable() {
@Override
public void run() {
controller.dispatchMediaButtonEvent(evDownPause);
}
});
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
controller.dispatchMediaButtonEvent(evUpPause);
}
}, 20);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
controller.dispatchMediaButtonEvent(evDownPlay);
}
}, 1000);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
controller.dispatchMediaButtonEvent(evUpPlay);
}
}, 1020);
}
private int getMediaControllerPlaybackState(MediaController controller) {
if (controller != null) {
final PlaybackState playbackState = controller.getPlaybackState();
if (playbackState != null) {
return playbackState.getState();
}
}
return PlaybackState.STATE_NONE;
}
private void refreshPlaybackIfNecessary(){
if (mMediaSessionManager == null) return;
final List<MediaController> sessions
= mMediaSessionManager.getActiveSessionsForUser(
null, UserHandle.ALL);
for (MediaController controller : sessions) {
if (PlaybackState.STATE_PLAYING ==
getMediaControllerPlaybackState(controller)) {
triggerPlayPause(controller);
break;
}
}
}
private void checkEffect() {
if (!mDolbyAtmos.hasControl()) {
Log.w(TAG, "lost control, recreating effect");
@ -135,7 +64,6 @@ public final class DolbyUtils {
checkEffect();
Log.i(TAG, "setDsOn: " + on);
mDolbyAtmos.setDsOn(on);
refreshPlaybackIfNecessary();
}
public boolean getDsOn() {