HdmiControlService.java revision c70d2295dd3fb87ce8c81c704688d1ad05043b4d
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.hardware.hdmi.HdmiCecDeviceInfo;
22import android.hardware.hdmi.HdmiCecMessage;
23import android.os.HandlerThread;
24import android.os.Looper;
25import android.util.Slog;
26
27import com.android.server.SystemService;
28
29/**
30 * Provides a service for sending and processing HDMI control messages,
31 * HDMI-CEC and MHL control command, and providing the information on both standard.
32 */
33public final class HdmiControlService extends SystemService {
34    private static final String TAG = "HdmiControlService";
35
36    // A thread to handle synchronous IO of CEC and MHL control service.
37    // Since all of CEC and MHL HAL interfaces processed in short time (< 200ms)
38    // and sparse call it shares a thread to handle IO operations.
39    private final HandlerThread mIoThread = new HandlerThread("Hdmi Control Io Thread");
40
41    @Nullable
42    private HdmiCecController mCecController;
43
44    @Nullable
45    private HdmiMhlController mMhlController;
46
47    public HdmiControlService(Context context) {
48        super(context);
49    }
50
51    @Override
52    public void onStart() {
53        mCecController = HdmiCecController.create(this);
54        if (mCecController == null) {
55            Slog.i(TAG, "Device does not support HDMI-CEC.");
56        }
57
58        mMhlController = HdmiMhlController.create(this);
59        if (mMhlController == null) {
60            Slog.i(TAG, "Device does not support MHL-control.");
61        }
62    }
63
64    /**
65     * Returns {@link Looper} for IO operation.
66     *
67     * <p>Declared as package-private.
68     */
69    Looper getIoLooper() {
70        return mIoThread.getLooper();
71    }
72
73    /**
74     * Returns {@link Looper} of main thread. Use this {@link Looper} instance
75     * for tasks that are running on main service thread.
76     *
77     * <p>Declared as package-private.
78     */
79    Looper getServiceLooper() {
80        return Looper.myLooper();
81    }
82
83    /**
84     * Add a new {@link FeatureAction} to the action queue.
85     *
86     * @param action {@link FeatureAction} to add
87     */
88    void addAction(FeatureAction action) {
89        // TODO: Implement this.
90    }
91
92
93    /**
94     * Remove the given {@link FeatureAction} object from the action queue.
95     *
96     * @param action {@link FeatureAction} to add
97     */
98    void removeAction(FeatureAction action) {
99        // TODO: Implement this.
100    }
101
102    /**
103     * Transmit a CEC command to CEC bus.
104     *
105     * @param command CEC command to send out
106     */
107    void sendCecCommand(HdmiCecMessage command) {
108        // TODO: Implement this.
109    }
110
111    /**
112     * Add a new {@link HdmiCecDeviceInfo} to controller.
113     *
114     * @param deviceInfo new device information object to add
115     */
116    void addDeviceInfo(HdmiCecDeviceInfo deviceInfo) {
117        // TODO: Implement this.
118    }
119}
120