frameworks/base
修订版 | 4c12d8c482f7a4e6f0220139aef9c6a4f91765b0 (tree) |
---|---|
时间 | 2016-09-13 18:43:11 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
Detect HDMI audio by switch events
If detect SW_VIDEOOUT_INSERT, assume HDMI is plugged.
@@ -34,9 +34,11 @@ import com.android.server.input.InputManagerService.WiredAccessoryCallbacks; | ||
34 | 34 | import static com.android.server.input.InputManagerService.SW_HEADPHONE_INSERT; |
35 | 35 | import static com.android.server.input.InputManagerService.SW_MICROPHONE_INSERT; |
36 | 36 | import static com.android.server.input.InputManagerService.SW_LINEOUT_INSERT; |
37 | +import static com.android.server.input.InputManagerService.SW_VIDEOOUT_INSERT; | |
37 | 38 | import static com.android.server.input.InputManagerService.SW_HEADPHONE_INSERT_BIT; |
38 | 39 | import static com.android.server.input.InputManagerService.SW_MICROPHONE_INSERT_BIT; |
39 | 40 | import static com.android.server.input.InputManagerService.SW_LINEOUT_INSERT_BIT; |
41 | +import static com.android.server.input.InputManagerService.SW_VIDEOOUT_INSERT_BIT; | |
40 | 42 | |
41 | 43 | import java.io.File; |
42 | 44 | import java.io.FileReader; |
@@ -113,8 +115,11 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { | ||
113 | 115 | if (mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_LINEOUT_INSERT) == 1) { |
114 | 116 | switchValues |= SW_LINEOUT_INSERT_BIT; |
115 | 117 | } |
118 | + if (mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_VIDEOOUT_INSERT) == 1) { | |
119 | + switchValues |= SW_VIDEOOUT_INSERT_BIT; | |
120 | + } | |
116 | 121 | notifyWiredAccessoryChanged(0, switchValues, |
117 | - SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_LINEOUT_INSERT_BIT); | |
122 | + SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_LINEOUT_INSERT_BIT | SW_VIDEOOUT_INSERT_BIT); | |
118 | 123 | } |
119 | 124 | |
120 | 125 | mObserver.init(); |
@@ -122,7 +127,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { | ||
122 | 127 | |
123 | 128 | @Override |
124 | 129 | public void notifyWiredAccessoryChanged(long whenNanos, int switchValues, int switchMask) { |
125 | - if (LOG) Slog.v(TAG, "notifyWiredAccessoryChanged: when=" + whenNanos | |
130 | + if (LOG) Slog.i(TAG, "notifyWiredAccessoryChanged: when=" + whenNanos | |
126 | 131 | + " bits=" + switchCodeToString(switchValues, switchMask) |
127 | 132 | + " mask=" + Integer.toHexString(switchMask)); |
128 | 133 |
@@ -130,7 +135,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { | ||
130 | 135 | int headset; |
131 | 136 | mSwitchValues = (mSwitchValues & ~switchMask) | switchValues; |
132 | 137 | switch (mSwitchValues & |
133 | - (SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_LINEOUT_INSERT_BIT)) { | |
138 | + (SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_LINEOUT_INSERT_BIT | SW_VIDEOOUT_INSERT_BIT)) { | |
134 | 139 | case 0: |
135 | 140 | headset = 0; |
136 | 141 | break; |
@@ -143,6 +148,11 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { | ||
143 | 148 | headset = BIT_LINEOUT; |
144 | 149 | break; |
145 | 150 | |
151 | + case SW_VIDEOOUT_INSERT_BIT: | |
152 | + case SW_VIDEOOUT_INSERT_BIT | SW_LINEOUT_INSERT_BIT: | |
153 | + headset = BIT_HDMI_AUDIO; | |
154 | + break; | |
155 | + | |
146 | 156 | case SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT: |
147 | 157 | headset = BIT_HEADSET; |
148 | 158 | break; |
@@ -157,7 +167,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { | ||
157 | 167 | } |
158 | 168 | |
159 | 169 | updateLocked(NAME_H2W, |
160 | - (mHeadsetState & ~(BIT_HEADSET | BIT_HEADSET_NO_MIC | BIT_LINEOUT)) | headset); | |
170 | + (mHeadsetState & ~(BIT_HEADSET | BIT_HEADSET_NO_MIC | BIT_LINEOUT | BIT_HDMI_AUDIO)) | headset); | |
161 | 171 | } |
162 | 172 | } |
163 | 173 |
@@ -287,7 +297,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { | ||
287 | 297 | } |
288 | 298 | |
289 | 299 | if (LOG) { |
290 | - Slog.v(TAG, "headsetName: " + headsetName + | |
300 | + Slog.i(TAG, "headsetName: " + headsetName + | |
291 | 301 | (state == 1 ? " connected" : " disconnected")); |
292 | 302 | } |
293 | 303 |
@@ -259,6 +259,9 @@ public class InputManagerService extends IInputManager.Stub | ||
259 | 259 | /** Switch code: Headphone/Microphone Jack. When set, something is inserted. */ |
260 | 260 | public static final int SW_JACK_PHYSICAL_INSERT = 0x07; |
261 | 261 | |
262 | + /** Switch code: Video out jack. When set, something is inserted. */ | |
263 | + public static final int SW_VIDEOOUT_INSERT = 0x08; | |
264 | + | |
262 | 265 | /** Switch code: Camera lens cover. When set the lens is covered. */ |
263 | 266 | public static final int SW_CAMERA_LENS_COVER = 0x09; |
264 | 267 |
@@ -269,8 +272,9 @@ public class InputManagerService extends IInputManager.Stub | ||
269 | 272 | public static final int SW_MICROPHONE_INSERT_BIT = 1 << SW_MICROPHONE_INSERT; |
270 | 273 | public static final int SW_LINEOUT_INSERT_BIT = 1 << SW_LINEOUT_INSERT; |
271 | 274 | public static final int SW_JACK_PHYSICAL_INSERT_BIT = 1 << SW_JACK_PHYSICAL_INSERT; |
275 | + public static final int SW_VIDEOOUT_INSERT_BIT = 1 << SW_VIDEOOUT_INSERT; | |
272 | 276 | public static final int SW_JACK_BITS = |
273 | - SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_JACK_PHYSICAL_INSERT_BIT | SW_LINEOUT_INSERT_BIT; | |
277 | + SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_JACK_PHYSICAL_INSERT_BIT | SW_LINEOUT_INSERT_BIT | SW_VIDEOOUT_INSERT_BIT; | |
274 | 278 | public static final int SW_CAMERA_LENS_COVER_BIT = 1 << SW_CAMERA_LENS_COVER; |
275 | 279 | |
276 | 280 | /** Whether to use the dev/input/event or uevent subsystem for the audio jack. */ |