Jungshik Jang | 67ea521 | 2014-05-15 14:05:24 +0900 | [diff] [blame] | 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 | |
| 17 | package com.android.server.hdmi; |
| 18 | |
Jungshik Jang | 67ea521 | 2014-05-15 14:05:24 +0900 | [diff] [blame] | 19 | /** |
| 20 | * Feature action to handle <Request ARC Termination>. |
| 21 | * |
| 22 | * <p>It's initiated by user's manual termination or ARC channel close from TV. |
| 23 | */ |
| 24 | final class RequestArcTerminationAction extends RequestArcAction { |
| 25 | private static final String TAG = "RequestArcTerminationAction"; |
| 26 | |
| 27 | /** |
| 28 | * @Constructor |
| 29 | * |
| 30 | * @see RequestArcAction#RequestArcAction |
| 31 | */ |
Jungshik Jang | 79c58a4 | 2014-06-16 16:45:36 +0900 | [diff] [blame] | 32 | RequestArcTerminationAction(HdmiCecLocalDevice source, int avrAddress) { |
| 33 | super(source, avrAddress); |
Jungshik Jang | 67ea521 | 2014-05-15 14:05:24 +0900 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | @Override |
| 37 | boolean start() { |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 38 | HdmiCecMessage command = |
Jungshik Jang | 79c58a4 | 2014-06-16 16:45:36 +0900 | [diff] [blame] | 39 | HdmiCecMessageBuilder.buildRequestArcTermination(getSourceAddress(), mAvrAddress); |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 40 | sendCommand(command, new HdmiControlService.SendMessageCallback() { |
| 41 | @Override |
| 42 | public void onSendCompleted(int error) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 43 | if (error == Constants.SEND_RESULT_SUCCESS) { |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 44 | mState = STATE_WATING_FOR_REQUEST_ARC_REQUEST_RESPONSE; |
Jinsuk Kim | 5fba96d | 2014-07-11 11:51:34 +0900 | [diff] [blame] | 45 | addTimer(mState, HdmiConfig.TIMEOUT_MS); |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 46 | } else { |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 47 | // If failed to send <Request ARC Termination>, start "Disabled" ARC |
| 48 | // transmission action. |
| 49 | disableArcTransmission(); |
| 50 | finish(); |
| 51 | } |
| 52 | } |
| 53 | }); |
Jungshik Jang | 67ea521 | 2014-05-15 14:05:24 +0900 | [diff] [blame] | 54 | return true; |
| 55 | } |
| 56 | } |