RequestArcInitiationAction.java revision 61ced38d61926bc28638d805436086db22b642c3
1/* 2 * Copyright (C) 2014 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 17package com.android.server.hdmi; 18 19import android.hardware.hdmi.HdmiCecMessage; 20 21/** 22 * Feature action that handles ARC action initiated by TV devices. 23 * 24 * <p>This action is created by TV's hot plug event of ARC port. 25 */ 26final class RequestArcInitiationAction extends RequestArcAction { 27 private static final String TAG = "RequestArcInitiationAction"; 28 29 /** 30 * @Constructor 31 * 32 * For more details look at {@link RequestArcAction#RequestArcAction}. 33 */ 34 RequestArcInitiationAction(HdmiControlService service, int sourceAddress, int avrAddress) { 35 super(service, sourceAddress, avrAddress); 36 } 37 38 @Override 39 boolean start() { 40 HdmiCecMessage command = HdmiCecMessageBuilder.buildRequestArcInitiation(mSourceAddress, 41 mAvrAddress); 42 sendCommand(command, new HdmiControlService.SendMessageCallback() { 43 @Override 44 public void onSendCompleted(int error) { 45 if (error == HdmiControlService.SEND_RESULT_SUCCESS) { 46 mState = STATE_WATING_FOR_REQUEST_ARC_REQUEST_RESPONSE; 47 addTimer(mState, TIMEOUT_MS); 48 } else { 49 // If failed to send <Request ARC Initiation>, start "Disabled" 50 // ARC transmission action. 51 disableArcTransmission(); 52 finish(); 53 } 54 } 55 }); 56 return true; 57 } 58} 59