HdmiControlService.java revision 0792d37385e60aa8d73f8df174d0a32f4f618bc4
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.annotation.Nullable; 20import android.content.Context; 21import android.os.Handler; 22import android.os.HandlerThread; 23import android.os.Message; 24import android.util.Slog; 25 26import com.android.server.SystemService; 27 28/** 29 * Provides a service for sending and processing HDMI control messages, 30 * HDMI-CEC and MHL control command, and providing the information on both standard. 31 */ 32public final class HdmiControlService extends SystemService { 33 private static final String TAG = "HdmiControlService"; 34 35 // A thread to handle synchronous IO of CEC and MHL control service. 36 // Since all of CEC and MHL HAL interfaces processed in short time (< 200ms) 37 // and sparse call it shares a thread to handle IO operations. 38 private final HandlerThread mIoThread = new HandlerThread("Hdmi Control Io Thread"); 39 40 // Main handler class to handle incoming message from each controller. 41 private final Handler mHandler = new Handler() { 42 @Override 43 public void handleMessage(Message msg) { 44 // TODO: Add handler for each message type. 45 } 46 }; 47 48 @Nullable 49 private HdmiCecController mCecController; 50 51 @Nullable 52 private HdmiMhlController mMhlController; 53 54 public HdmiControlService(Context context) { 55 super(context); 56 } 57 58 @Override 59 public void onStart() { 60 mCecController = HdmiCecController.create(mIoThread.getLooper(), mHandler); 61 if (mCecController == null) { 62 Slog.i(TAG, "Device does not support HDMI-CEC."); 63 } 64 65 mMhlController = HdmiMhlController.create(mIoThread.getLooper(), mHandler); 66 if (mMhlController == null) { 67 Slog.i(TAG, "Device does not support MHL-control."); 68 } 69 } 70} 71