Notify ARC status update to AudioService.
Whenever ARC status is updated it should be notified to AudioService so that it reroutes audio output to others. Bug: 15841544, Bug: 15844022, Bug: 15844112 Change-Id: I06674ee4dd22c0f9be08e33fbacdd785578ba55f
This commit is contained in:
@@ -20,6 +20,7 @@ import android.hardware.hdmi.HdmiCec;
|
||||
import android.hardware.hdmi.HdmiCecDeviceInfo;
|
||||
import android.hardware.hdmi.HdmiCecMessage;
|
||||
import android.hardware.hdmi.IHdmiControlCallback;
|
||||
import android.media.AudioSystem;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
@@ -47,7 +48,6 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
@GuardedBy("mLock")
|
||||
private boolean mSystemAudioMode;
|
||||
|
||||
|
||||
// Copy of mDeviceInfos to guarantee thread-safety.
|
||||
@GuardedBy("mLock")
|
||||
private List<HdmiCecDeviceInfo> mSafeAllDeviceInfos = Collections.emptyList();
|
||||
@@ -312,15 +312,21 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
boolean oldStatus = mArcStatusEnabled;
|
||||
// 1. Enable/disable ARC circuit.
|
||||
mService.setAudioReturnChannel(enabled);
|
||||
|
||||
// TODO: notify arc mode change to AudioManager.
|
||||
|
||||
// 2. Update arc status;
|
||||
// 2. Notify arc status to audio service.
|
||||
notifyArcStatusToAudioService(enabled);
|
||||
// 3. Update arc status;
|
||||
mArcStatusEnabled = enabled;
|
||||
return oldStatus;
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyArcStatusToAudioService(boolean enabled) {
|
||||
// Note that we don't set any name to ARC.
|
||||
mService.getAudioManager().setWiredDeviceConnectionState(
|
||||
AudioSystem.DEVICE_OUT_HDMI_ARC,
|
||||
enabled ? 1 : 0, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether ARC is enabled or not.
|
||||
*/
|
||||
@@ -613,7 +619,6 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
@ServiceThreadOnly
|
||||
void onHotplug(int portNo, boolean connected) {
|
||||
assertRunOnServiceThread();
|
||||
// TODO: delegate onHotplug event to each local device.
|
||||
|
||||
// Tv device will have permanent HotplugDetectionAction.
|
||||
List<HotplugDetectionAction> hotplugActions = getActions(HotplugDetectionAction.class);
|
||||
@@ -623,10 +628,4 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
|
||||
hotplugActions.get(0).pollAllDevicesNow();
|
||||
}
|
||||
}
|
||||
|
||||
boolean canChangeSystemAudio() {
|
||||
// TODO: implement this.
|
||||
// return true if no system audio control sequence is running.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.hardware.hdmi.IHdmiControlService;
|
||||
import android.hardware.hdmi.IHdmiDeviceEventListener;
|
||||
import android.hardware.hdmi.IHdmiHotplugEventListener;
|
||||
import android.hardware.hdmi.IHdmiSystemAudioModeChangeListener;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
@@ -870,4 +871,8 @@ public final class HdmiControlService extends SystemService {
|
||||
private HdmiCecLocalDevicePlayback playback() {
|
||||
return (HdmiCecLocalDevicePlayback) mCecController.getLocalDevice(HdmiCec.DEVICE_PLAYBACK);
|
||||
}
|
||||
|
||||
AudioManager getAudioManager() {
|
||||
return (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ final class SystemAudioAutoInitiationAction extends FeatureAction {
|
||||
}
|
||||
|
||||
private boolean canChangeSystemAudio() {
|
||||
return tv().canChangeSystemAudio();
|
||||
return !(tv().hasAction(SystemAudioActionFromTv.class)
|
||||
|| tv().hasAction(SystemAudioActionFromAvr.class));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user