Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package com.android.server.hdmi; |
| 17 | |
Amy | 6506bd6 | 2018-07-02 17:29:36 -0700 | [diff] [blame] | 18 | import static com.android.server.hdmi.Constants.ALWAYS_SYSTEM_AUDIO_CONTROL_ON_POWER_ON; |
| 19 | import static com.android.server.hdmi.Constants.PROPERTY_SYSTEM_AUDIO_CONTROL_ON_POWER_ON; |
| 20 | import static com.android.server.hdmi.Constants.USE_LAST_STATE_SYSTEM_AUDIO_CONTROL_ON_POWER_ON; |
| 21 | |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 22 | import android.hardware.hdmi.HdmiDeviceInfo; |
Amy | 2a6c3dc | 2018-06-05 17:31:55 -0700 | [diff] [blame] | 23 | import android.media.AudioManager; |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 24 | import android.os.SystemProperties; |
Amy | 87eda82 | 2018-06-06 17:56:39 -0700 | [diff] [blame] | 25 | import com.android.internal.annotations.GuardedBy; |
Amy | 6506bd6 | 2018-07-02 17:29:36 -0700 | [diff] [blame] | 26 | import com.android.internal.annotations.VisibleForTesting; |
Amy | 4a92266 | 2018-06-05 17:31:55 -0700 | [diff] [blame] | 27 | import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly; |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 30 | * Represent a logical device of type {@link HdmiDeviceInfo#DEVICE_AUDIO_SYSTEM} residing in Android |
| 31 | * system. |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 32 | */ |
| 33 | public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDevice { |
| 34 | |
Amy | 4a92266 | 2018-06-05 17:31:55 -0700 | [diff] [blame] | 35 | private static final String TAG = "HdmiCecLocalDeviceAudioSystem"; |
| 36 | |
Amy | 87eda82 | 2018-06-06 17:56:39 -0700 | [diff] [blame] | 37 | // Whether System audio mode is activated or not. |
| 38 | // This becomes true only when all system audio sequences are finished. |
| 39 | @GuardedBy("mLock") |
| 40 | private boolean mSystemAudioActivated; |
| 41 | |
Amy | 9b91e8c | 2018-06-11 17:26:26 -0700 | [diff] [blame] | 42 | // Whether the System Audio Control feature is enabled or not. True by default. |
| 43 | @GuardedBy("mLock") |
| 44 | private boolean mSystemAudioControlFeatureEnabled; |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 45 | |
Shubang | c480a71 | 2018-06-11 18:02:42 -0700 | [diff] [blame] | 46 | protected Integer mSystemAudioSource; |
Amy | 9b91e8c | 2018-06-11 17:26:26 -0700 | [diff] [blame] | 47 | |
Shubang | ec66896 | 2018-07-13 19:03:19 -0700 | [diff] [blame] | 48 | private boolean mTvSystemAudioModeSupport; |
| 49 | |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 50 | protected HdmiCecLocalDeviceAudioSystem(HdmiControlService service) { |
| 51 | super(service, HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM); |
Amy | 9b91e8c | 2018-06-11 17:26:26 -0700 | [diff] [blame] | 52 | mSystemAudioControlFeatureEnabled = true; |
| 53 | // TODO(amyjojo) make System Audio Control controllable by users |
| 54 | /*mSystemAudioControlFeatureEnabled = |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 55 | mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, true);*/ |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | @Override |
Amy | 4a92266 | 2018-06-05 17:31:55 -0700 | [diff] [blame] | 59 | @ServiceThreadOnly |
Amy | b887fa0 | 2018-06-21 11:22:13 -0700 | [diff] [blame] | 60 | protected void onStandby(boolean initiatedByCec, int standbyAction) { |
| 61 | assertRunOnServiceThread(); |
Shubang | ec66896 | 2018-07-13 19:03:19 -0700 | [diff] [blame] | 62 | mTvSystemAudioModeSupport = false; |
Amy | 6506bd6 | 2018-07-02 17:29:36 -0700 | [diff] [blame] | 63 | // Record the last state of System Audio Control before going to standby |
| 64 | synchronized (mLock) { |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 65 | SystemProperties.set( |
| 66 | Constants.PROPERTY_LAST_SYSTEM_AUDIO_CONTROL, |
| 67 | mSystemAudioActivated ? "true" : "false"); |
Amy | 6506bd6 | 2018-07-02 17:29:36 -0700 | [diff] [blame] | 68 | } |
Amy | b887fa0 | 2018-06-21 11:22:13 -0700 | [diff] [blame] | 69 | if (setSystemAudioMode(false)) { |
Amy | 6506bd6 | 2018-07-02 17:29:36 -0700 | [diff] [blame] | 70 | mService.sendCecCommand( |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 71 | HdmiCecMessageBuilder.buildSetSystemAudioMode( |
| 72 | mAddress, Constants.ADDR_BROADCAST, false)); |
Amy | b887fa0 | 2018-06-21 11:22:13 -0700 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | @ServiceThreadOnly |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 78 | protected void onAddressAllocated(int logicalAddress, int reason) { |
| 79 | assertRunOnServiceThread(); |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 80 | mService.sendCecCommand( |
| 81 | HdmiCecMessageBuilder.buildReportPhysicalAddressCommand( |
| 82 | mAddress, mService.getPhysicalAddress(), mDeviceType)); |
| 83 | mService.sendCecCommand( |
| 84 | HdmiCecMessageBuilder.buildDeviceVendorIdCommand(mAddress, mService.getVendorId())); |
| 85 | int systemAudioControlOnPowerOnProp = |
| 86 | SystemProperties.getInt( |
| 87 | PROPERTY_SYSTEM_AUDIO_CONTROL_ON_POWER_ON, |
| 88 | ALWAYS_SYSTEM_AUDIO_CONTROL_ON_POWER_ON); |
| 89 | boolean lastSystemAudioControlStatus = |
| 90 | SystemProperties.getBoolean(Constants.PROPERTY_LAST_SYSTEM_AUDIO_CONTROL, true); |
Amy | 6506bd6 | 2018-07-02 17:29:36 -0700 | [diff] [blame] | 91 | systemAudioControlOnPowerOn(systemAudioControlOnPowerOnProp, lastSystemAudioControlStatus); |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 92 | startQueuedActions(); |
| 93 | } |
| 94 | |
Amy | 6506bd6 | 2018-07-02 17:29:36 -0700 | [diff] [blame] | 95 | @VisibleForTesting |
| 96 | protected void systemAudioControlOnPowerOn( |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 97 | int systemAudioOnPowerOnProp, boolean lastSystemAudioControlStatus) { |
| 98 | if ((systemAudioOnPowerOnProp == ALWAYS_SYSTEM_AUDIO_CONTROL_ON_POWER_ON) |
| 99 | || ((systemAudioOnPowerOnProp == USE_LAST_STATE_SYSTEM_AUDIO_CONTROL_ON_POWER_ON) |
| 100 | && lastSystemAudioControlStatus)) { |
Amy | 6506bd6 | 2018-07-02 17:29:36 -0700 | [diff] [blame] | 101 | addAndStartAction(new SystemAudioInitiationActionFromAvr(this)); |
| 102 | } |
| 103 | } |
| 104 | |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 105 | @Override |
Amy | 4a92266 | 2018-06-05 17:31:55 -0700 | [diff] [blame] | 106 | @ServiceThreadOnly |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 107 | protected int getPreferredAddress() { |
| 108 | assertRunOnServiceThread(); |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 109 | return SystemProperties.getInt( |
| 110 | Constants.PROPERTY_PREFERRED_ADDRESS_AUDIO_SYSTEM, Constants.ADDR_UNREGISTERED); |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | @Override |
Amy | 4a92266 | 2018-06-05 17:31:55 -0700 | [diff] [blame] | 114 | @ServiceThreadOnly |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 115 | protected void setPreferredAddress(int addr) { |
| 116 | assertRunOnServiceThread(); |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 117 | SystemProperties.set( |
| 118 | Constants.PROPERTY_PREFERRED_ADDRESS_AUDIO_SYSTEM, String.valueOf(addr)); |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 119 | } |
Amy | 4a92266 | 2018-06-05 17:31:55 -0700 | [diff] [blame] | 120 | |
| 121 | @Override |
| 122 | @ServiceThreadOnly |
| 123 | protected boolean handleReportAudioStatus(HdmiCecMessage message) { |
| 124 | assertRunOnServiceThread(); |
| 125 | // TODO(amyjojo): implement report audio status handler |
| 126 | HdmiLogger.debug(TAG + "Stub handleReportAudioStatus"); |
| 127 | return true; |
| 128 | } |
| 129 | |
| 130 | @Override |
| 131 | @ServiceThreadOnly |
| 132 | protected boolean handleInitiateArc(HdmiCecMessage message) { |
| 133 | assertRunOnServiceThread(); |
| 134 | // TODO(amyjojo): implement initiate arc handler |
| 135 | HdmiLogger.debug(TAG + "Stub handleInitiateArc"); |
| 136 | return true; |
| 137 | } |
| 138 | |
| 139 | @Override |
| 140 | @ServiceThreadOnly |
| 141 | protected boolean handleReportArcInitiate(HdmiCecMessage message) { |
| 142 | assertRunOnServiceThread(); |
| 143 | // TODO(amyjojo): implement report arc initiate handler |
| 144 | HdmiLogger.debug(TAG + "Stub handleReportArcInitiate"); |
| 145 | return true; |
| 146 | } |
| 147 | |
| 148 | @Override |
| 149 | @ServiceThreadOnly |
| 150 | protected boolean handleReportArcTermination(HdmiCecMessage message) { |
| 151 | assertRunOnServiceThread(); |
| 152 | // TODO(amyjojo): implement report arc terminate handler |
| 153 | HdmiLogger.debug(TAG + "Stub handleReportArcTermination"); |
| 154 | return true; |
| 155 | } |
Amy | 2a6c3dc | 2018-06-05 17:31:55 -0700 | [diff] [blame] | 156 | |
| 157 | @Override |
| 158 | @ServiceThreadOnly |
| 159 | protected boolean handleGiveAudioStatus(HdmiCecMessage message) { |
| 160 | assertRunOnServiceThread(); |
| 161 | |
| 162 | reportAudioStatus(message); |
| 163 | return true; |
| 164 | } |
| 165 | |
Amy | 87eda82 | 2018-06-06 17:56:39 -0700 | [diff] [blame] | 166 | @Override |
| 167 | @ServiceThreadOnly |
| 168 | protected boolean handleGiveSystemAudioModeStatus(HdmiCecMessage message) { |
| 169 | assertRunOnServiceThread(); |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 170 | mService.sendCecCommand( |
| 171 | HdmiCecMessageBuilder.buildReportSystemAudioMode( |
| 172 | mAddress, message.getSource(), mSystemAudioActivated)); |
Amy | 87eda82 | 2018-06-06 17:56:39 -0700 | [diff] [blame] | 173 | return true; |
| 174 | } |
| 175 | |
Amy | 4e7ff1a | 2018-06-07 16:24:31 -0700 | [diff] [blame] | 176 | @Override |
| 177 | @ServiceThreadOnly |
| 178 | protected boolean handleRequestArcInitiate(HdmiCecMessage message) { |
| 179 | assertRunOnServiceThread(); |
| 180 | // TODO(b/80296911): Check if ARC supported. |
| 181 | |
| 182 | // TODO(b/80296911): Check if port is ready to accept. |
| 183 | |
| 184 | // TODO(b/80296911): if both true, activate ARC functinality and |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 185 | mService.sendCecCommand( |
| 186 | HdmiCecMessageBuilder.buildInitiateArc(mAddress, message.getSource())); |
Amy | 4e7ff1a | 2018-06-07 16:24:31 -0700 | [diff] [blame] | 187 | // TODO(b/80296911): else, send <Feature Abort>["Unrecongnized opcode"] |
| 188 | |
| 189 | return true; |
| 190 | } |
| 191 | |
| 192 | @Override |
| 193 | @ServiceThreadOnly |
| 194 | protected boolean handleRequestArcTermination(HdmiCecMessage message) { |
| 195 | assertRunOnServiceThread(); |
| 196 | // TODO(b/80297105): Check if ARC supported. |
| 197 | |
| 198 | // TODO(b/80297105): Check is currently in arc. |
| 199 | |
| 200 | // TODO(b/80297105): If both true, deactivate ARC functionality and |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 201 | mService.sendCecCommand( |
| 202 | HdmiCecMessageBuilder.buildTerminateArc(mAddress, message.getSource())); |
Amy | 4e7ff1a | 2018-06-07 16:24:31 -0700 | [diff] [blame] | 203 | // TODO(b/80297105): else, send <Feature Abort>["Unrecongnized opcode"] |
| 204 | |
| 205 | return true; |
| 206 | } |
| 207 | |
Nick Chalko | 6f5d69e | 2018-07-17 16:07:11 -0700 | [diff] [blame] | 208 | @ServiceThreadOnly |
| 209 | protected boolean handleRequestShortAudioDescriptor(HdmiCecMessage message) { |
| 210 | assertRunOnServiceThread(); |
| 211 | // TODO(b/80297701): implement request short audio descriptor |
| 212 | HdmiLogger.debug(TAG + "Stub handleRequestShortAudioDescriptor"); |
| 213 | mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED); |
| 214 | return true; |
| 215 | } |
| 216 | |
Amy | 9b91e8c | 2018-06-11 17:26:26 -0700 | [diff] [blame] | 217 | @Override |
| 218 | @ServiceThreadOnly |
| 219 | protected boolean handleSystemAudioModeRequest(HdmiCecMessage message) { |
| 220 | assertRunOnServiceThread(); |
| 221 | boolean systemAudioStatusOn = message.getParams().length != 0; |
| 222 | if (!setSystemAudioMode(systemAudioStatusOn)) { |
| 223 | mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED); |
| 224 | return true; |
| 225 | } |
| 226 | |
Shubang | de72882 | 2018-07-16 16:46:51 -0700 | [diff] [blame] | 227 | mSystemAudioSource = systemAudioStatusOn ? message.getSource() : null; |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 228 | mService.sendCecCommand( |
| 229 | HdmiCecMessageBuilder.buildSetSystemAudioMode( |
| 230 | mAddress, Constants.ADDR_BROADCAST, systemAudioStatusOn)); |
Amy | 9b91e8c | 2018-06-11 17:26:26 -0700 | [diff] [blame] | 231 | return true; |
| 232 | } |
| 233 | |
| 234 | @Override |
| 235 | @ServiceThreadOnly |
| 236 | protected boolean handleSetSystemAudioMode(HdmiCecMessage message) { |
| 237 | assertRunOnServiceThread(); |
| 238 | if (!setSystemAudioMode(HdmiUtils.parseCommandParamSystemAudioStatus(message))) { |
| 239 | mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED); |
| 240 | } |
| 241 | return true; |
| 242 | } |
| 243 | |
| 244 | @Override |
| 245 | @ServiceThreadOnly |
| 246 | protected boolean handleSystemAudioModeStatus(HdmiCecMessage message) { |
| 247 | assertRunOnServiceThread(); |
| 248 | if (!setSystemAudioMode(HdmiUtils.parseCommandParamSystemAudioStatus(message))) { |
| 249 | mService.maySendFeatureAbortCommand(message, Constants.ABORT_REFUSED); |
| 250 | } |
| 251 | return true; |
| 252 | } |
| 253 | |
Amy | 2a6c3dc | 2018-06-05 17:31:55 -0700 | [diff] [blame] | 254 | private void reportAudioStatus(HdmiCecMessage message) { |
| 255 | assertRunOnServiceThread(); |
| 256 | |
| 257 | int volume = mService.getAudioManager().getStreamVolume(AudioManager.STREAM_MUSIC); |
| 258 | boolean mute = mService.getAudioManager().isStreamMute(AudioManager.STREAM_MUSIC); |
| 259 | int maxVolume = mService.getAudioManager().getStreamMaxVolume(AudioManager.STREAM_MUSIC); |
| 260 | int scaledVolume = VolumeControlAction.scaleToCecVolume(volume, maxVolume); |
| 261 | |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 262 | mService.sendCecCommand( |
| 263 | HdmiCecMessageBuilder.buildReportAudioStatus( |
| 264 | mAddress, message.getSource(), scaledVolume, mute)); |
Amy | 2a6c3dc | 2018-06-05 17:31:55 -0700 | [diff] [blame] | 265 | } |
Amy | 9b91e8c | 2018-06-11 17:26:26 -0700 | [diff] [blame] | 266 | |
| 267 | protected boolean setSystemAudioMode(boolean newSystemAudioMode) { |
| 268 | if (!isSystemAudioControlFeatureEnabled()) { |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 269 | HdmiLogger.debug( |
| 270 | "Cannot turn " |
| 271 | + (newSystemAudioMode ? "on" : "off") |
| 272 | + "system audio mode " |
| 273 | + "because the System Audio Control feature is disabled."); |
Amy | 9b91e8c | 2018-06-11 17:26:26 -0700 | [diff] [blame] | 274 | return false; |
| 275 | } |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 276 | HdmiLogger.debug( |
| 277 | "System Audio Mode change[old:%b new:%b]", |
| 278 | mSystemAudioActivated, newSystemAudioMode); |
Amy | 0fd41e3 | 2018-06-21 13:40:27 -0700 | [diff] [blame] | 279 | // Wake up device if System Audio Control is turned on but device is still on standby |
| 280 | if (newSystemAudioMode && mService.isPowerStandbyOrTransient()) { |
| 281 | mService.wakeUp(); |
| 282 | // TODO(amyjojo): Switch to the corresponding input |
| 283 | } |
| 284 | // Mute device when feature is turned off and unmute device when feature is turned on |
| 285 | boolean currentMuteStatus = |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 286 | mService.getAudioManager().isStreamMute(AudioManager.STREAM_MUSIC); |
Amy | 0fd41e3 | 2018-06-21 13:40:27 -0700 | [diff] [blame] | 287 | if (currentMuteStatus == newSystemAudioMode) { |
Nick Chalko | f32fcea | 2018-07-17 16:17:40 -0700 | [diff] [blame] | 288 | mService.getAudioManager() |
| 289 | .adjustStreamVolume( |
| 290 | AudioManager.STREAM_MUSIC, |
| 291 | newSystemAudioMode |
| 292 | ? AudioManager.ADJUST_UNMUTE |
| 293 | : AudioManager.ADJUST_MUTE, |
| 294 | 0); |
Amy | 0fd41e3 | 2018-06-21 13:40:27 -0700 | [diff] [blame] | 295 | } |
Amy | 9b91e8c | 2018-06-11 17:26:26 -0700 | [diff] [blame] | 296 | updateAudioManagerForSystemAudio(newSystemAudioMode); |
| 297 | synchronized (mLock) { |
| 298 | if (mSystemAudioActivated != newSystemAudioMode) { |
| 299 | mSystemAudioActivated = newSystemAudioMode; |
| 300 | mService.announceSystemAudioModeChange(newSystemAudioMode); |
| 301 | } |
| 302 | } |
| 303 | return true; |
| 304 | } |
| 305 | |
| 306 | private void updateAudioManagerForSystemAudio(boolean on) { |
| 307 | int device = mService.getAudioManager().setHdmiSystemAudioSupported(on); |
| 308 | HdmiLogger.debug("[A]UpdateSystemAudio mode[on=%b] output=[%X]", on, device); |
| 309 | } |
| 310 | |
| 311 | protected boolean isSystemAudioControlFeatureEnabled() { |
| 312 | synchronized (mLock) { |
| 313 | return mSystemAudioControlFeatureEnabled; |
| 314 | } |
| 315 | } |
Nick Chalko | f28c7b5 | 2018-06-14 07:46:00 -0700 | [diff] [blame] | 316 | |
Shubang | 595a183 | 2018-06-27 17:52:18 -0700 | [diff] [blame] | 317 | protected boolean isSystemAudioActivated() { |
| 318 | synchronized (mLock) { |
| 319 | return mSystemAudioActivated; |
| 320 | } |
| 321 | } |
| 322 | |
Nick Chalko | f28c7b5 | 2018-06-14 07:46:00 -0700 | [diff] [blame] | 323 | /** Reports if System Audio Mode is supported by the connected TV */ |
| 324 | interface TvSystemAudioModeSupportedCallback { |
| 325 | |
| 326 | /** {@code supported} is true if the TV is connected and supports System Audio Mode. */ |
| 327 | void onResult(boolean supported); |
Nick Chalko | f28c7b5 | 2018-06-14 07:46:00 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | /** |
| 331 | * Queries the connected TV to detect if System Audio Mode is supported by the TV. |
| 332 | * |
| 333 | * <p>This query may take up to 2 seconds to complete. |
| 334 | * |
| 335 | * <p>The result of the query may be cached until Audio device type is put in standby or loses |
| 336 | * its physical address. |
| 337 | */ |
| 338 | void queryTvSystemAudioModeSupport(TvSystemAudioModeSupportedCallback callback) { |
Shubang | ec66896 | 2018-07-13 19:03:19 -0700 | [diff] [blame] | 339 | if (!mTvSystemAudioModeSupport) { |
| 340 | addAndStartAction(new DetectTvSystemAudioModeSupportAction(this, callback)); |
| 341 | } else { |
| 342 | callback.onResult(true); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | void setTvSystemAudioModeSupport(boolean supported) { |
| 347 | mTvSystemAudioModeSupport = supported; |
Nick Chalko | f28c7b5 | 2018-06-14 07:46:00 -0700 | [diff] [blame] | 348 | } |
Nick Chalko | b89d6ff | 2018-05-25 10:29:01 -0700 | [diff] [blame] | 349 | } |