blob: f69f975a4b677f772dddead6d7f27750143e5052 [file] [log] [blame]
Jungshik Jang67ea5212014-05-15 14:05:24 +09001/*
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
Jungshik Jang67ea5212014-05-15 14:05:24 +090019/**
20 * Feature action that handles ARC action initiated by TV devices.
21 *
22 * <p>This action is created by TV's hot plug event of ARC port.
23 */
24final class RequestArcInitiationAction extends RequestArcAction {
25 private static final String TAG = "RequestArcInitiationAction";
26
27 /**
28 * @Constructor
29 *
30 * For more details look at {@link RequestArcAction#RequestArcAction}.
31 */
Jungshik Jang79c58a42014-06-16 16:45:36 +090032 RequestArcInitiationAction(HdmiCecLocalDevice source, int avrAddress) {
33 super(source, avrAddress);
Jungshik Jang67ea5212014-05-15 14:05:24 +090034 }
35
36 @Override
37 boolean start() {
Jinsuk Kim71651d32015-03-27 08:21:15 +090038 // Seq #38
Jungshik Jang2e8f1b62014-09-03 08:28:02 +090039 mState = STATE_WATING_FOR_REQUEST_ARC_REQUEST_RESPONSE;
40 addTimer(mState, HdmiConfig.TIMEOUT_MS);
41
Jungshik Jang79c58a42014-06-16 16:45:36 +090042 HdmiCecMessage command = HdmiCecMessageBuilder.buildRequestArcInitiation(
43 getSourceAddress(), mAvrAddress);
Jungshik Jangd643f762014-05-22 19:28:09 +090044 sendCommand(command, new HdmiControlService.SendMessageCallback() {
45 @Override
46 public void onSendCompleted(int error) {
Jungshik Jang2e8f1b62014-09-03 08:28:02 +090047 if (error != Constants.SEND_RESULT_SUCCESS) {
Jinsuk Kim71651d32015-03-27 08:21:15 +090048 // Turn off ARC status if <Request ARC Initiation> fails.
49 tv().setArcStatus(false);
Jungshik Jangd643f762014-05-22 19:28:09 +090050 finish();
51 }
52 }
53 });
Jungshik Jang67ea5212014-05-15 14:05:24 +090054 return true;
55 }
56}