167ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang/* 267ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * Copyright (C) 2014 The Android Open Source Project 367ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * 467ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * Licensed under the Apache License, Version 2.0 (the "License"); 567ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * you may not use this file except in compliance with the License. 667ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * You may obtain a copy of the License at 767ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * 867ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * http://www.apache.org/licenses/LICENSE-2.0 967ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * 1067ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * Unless required by applicable law or agreed to in writing, software 1167ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * distributed under the License is distributed on an "AS IS" BASIS, 1267ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1367ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * See the License for the specific language governing permissions and 1467ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * limitations under the License. 1567ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang */ 1667ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang 1767ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jangpackage com.android.server.hdmi; 1867ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang 19bc6e372b25d7d62efecefba09304c5a66218c91aDonghyun Choimport android.hardware.tv.cec.V1_0.SendMessageResult; 20bc6e372b25d7d62efecefba09304c5a66218c91aDonghyun Cho 2167ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang/** 2267ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * Feature action that handles ARC action initiated by TV devices. 2367ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * 2467ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * <p>This action is created by TV's hot plug event of ARC port. 2567ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang */ 2667ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jangfinal class RequestArcInitiationAction extends RequestArcAction { 2767ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang private static final String TAG = "RequestArcInitiationAction"; 2867ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang 2967ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang /** 3067ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * @Constructor 3167ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * 3267ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang * For more details look at {@link RequestArcAction#RequestArcAction}. 3367ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang */ 3479c58a4b97f27ede6a1b680d2fece9c2a0edf7b7Jungshik Jang RequestArcInitiationAction(HdmiCecLocalDevice source, int avrAddress) { 3579c58a4b97f27ede6a1b680d2fece9c2a0edf7b7Jungshik Jang super(source, avrAddress); 3667ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang } 3767ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang 3867ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang @Override 3967ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang boolean start() { 4071651d37125a5fe7339fb5f140876c891a8275dfJinsuk Kim // Seq #38 412e8f1b6399089626b4f0249427626ba6e63a62efJungshik Jang mState = STATE_WATING_FOR_REQUEST_ARC_REQUEST_RESPONSE; 422e8f1b6399089626b4f0249427626ba6e63a62efJungshik Jang addTimer(mState, HdmiConfig.TIMEOUT_MS); 432e8f1b6399089626b4f0249427626ba6e63a62efJungshik Jang 4479c58a4b97f27ede6a1b680d2fece9c2a0edf7b7Jungshik Jang HdmiCecMessage command = HdmiCecMessageBuilder.buildRequestArcInitiation( 4579c58a4b97f27ede6a1b680d2fece9c2a0edf7b7Jungshik Jang getSourceAddress(), mAvrAddress); 46d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang sendCommand(command, new HdmiControlService.SendMessageCallback() { 47d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang @Override 48d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang public void onSendCompleted(int error) { 49bc6e372b25d7d62efecefba09304c5a66218c91aDonghyun Cho if (error != SendMessageResult.SUCCESS) { 5071651d37125a5fe7339fb5f140876c891a8275dfJinsuk Kim // Turn off ARC status if <Request ARC Initiation> fails. 5171651d37125a5fe7339fb5f140876c891a8275dfJinsuk Kim tv().setArcStatus(false); 52d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang finish(); 53d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang } 54d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang } 55d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang }); 5667ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang return true; 5767ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang } 5867ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang} 59