blob: 8b5a2931023319faa16d2d028c973324b548ee25 [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
Donghyun Chobc6e3722016-11-04 05:25:52 +090019import android.hardware.tv.cec.V1_0.SendMessageResult;
20
Jungshik Jang67ea5212014-05-15 14:05:24 +090021/**
22 * Feature action to handle <Request ARC Termination>.
23 *
24 * <p>It's initiated by user's manual termination or ARC channel close from TV.
25 */
26final class RequestArcTerminationAction extends RequestArcAction {
27 private static final String TAG = "RequestArcTerminationAction";
28
29 /**
30 * @Constructor
31 *
32 * @see RequestArcAction#RequestArcAction
33 */
Jungshik Jang79c58a42014-06-16 16:45:36 +090034 RequestArcTerminationAction(HdmiCecLocalDevice source, int avrAddress) {
35 super(source, avrAddress);
Jungshik Jang67ea5212014-05-15 14:05:24 +090036 }
37
38 @Override
39 boolean start() {
Jungshik Jang2e8f1b62014-09-03 08:28:02 +090040 mState = STATE_WATING_FOR_REQUEST_ARC_REQUEST_RESPONSE;
41 addTimer(mState, HdmiConfig.TIMEOUT_MS);
42
Jungshik Jangd643f762014-05-22 19:28:09 +090043 HdmiCecMessage command =
Jungshik Jang79c58a42014-06-16 16:45:36 +090044 HdmiCecMessageBuilder.buildRequestArcTermination(getSourceAddress(), mAvrAddress);
Jungshik Jangd643f762014-05-22 19:28:09 +090045 sendCommand(command, new HdmiControlService.SendMessageCallback() {
46 @Override
47 public void onSendCompleted(int error) {
Donghyun Chobc6e3722016-11-04 05:25:52 +090048 if (error != SendMessageResult.SUCCESS) {
Jungshik Jangd643f762014-05-22 19:28:09 +090049 // If failed to send <Request ARC Termination>, start "Disabled" ARC
50 // transmission action.
51 disableArcTransmission();
52 finish();
53 }
54 }
55 });
Jungshik Jang67ea5212014-05-15 14:05:24 +090056 return true;
57 }
58}