Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

frameworks-base: Commit

frameworks/base


Commit MetaInfo

Revision4c12d8c482f7a4e6f0220139aef9c6a4f91765b0 (tree)
Time2016-09-13 18:43:11
AuthorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Detect HDMI audio by switch events

If detect SW_VIDEOOUT_INSERT, assume HDMI is plugged.

Change Summary

Incremental Difference

--- a/services/core/java/com/android/server/WiredAccessoryManager.java
+++ b/services/core/java/com/android/server/WiredAccessoryManager.java
@@ -34,9 +34,11 @@ import com.android.server.input.InputManagerService.WiredAccessoryCallbacks;
3434 import static com.android.server.input.InputManagerService.SW_HEADPHONE_INSERT;
3535 import static com.android.server.input.InputManagerService.SW_MICROPHONE_INSERT;
3636 import static com.android.server.input.InputManagerService.SW_LINEOUT_INSERT;
37+import static com.android.server.input.InputManagerService.SW_VIDEOOUT_INSERT;
3738 import static com.android.server.input.InputManagerService.SW_HEADPHONE_INSERT_BIT;
3839 import static com.android.server.input.InputManagerService.SW_MICROPHONE_INSERT_BIT;
3940 import static com.android.server.input.InputManagerService.SW_LINEOUT_INSERT_BIT;
41+import static com.android.server.input.InputManagerService.SW_VIDEOOUT_INSERT_BIT;
4042
4143 import java.io.File;
4244 import java.io.FileReader;
@@ -113,8 +115,11 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
113115 if (mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_LINEOUT_INSERT) == 1) {
114116 switchValues |= SW_LINEOUT_INSERT_BIT;
115117 }
118+ if (mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_VIDEOOUT_INSERT) == 1) {
119+ switchValues |= SW_VIDEOOUT_INSERT_BIT;
120+ }
116121 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);
118123 }
119124
120125 mObserver.init();
@@ -122,7 +127,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
122127
123128 @Override
124129 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
126131 + " bits=" + switchCodeToString(switchValues, switchMask)
127132 + " mask=" + Integer.toHexString(switchMask));
128133
@@ -130,7 +135,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
130135 int headset;
131136 mSwitchValues = (mSwitchValues & ~switchMask) | switchValues;
132137 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)) {
134139 case 0:
135140 headset = 0;
136141 break;
@@ -143,6 +148,11 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
143148 headset = BIT_LINEOUT;
144149 break;
145150
151+ case SW_VIDEOOUT_INSERT_BIT:
152+ case SW_VIDEOOUT_INSERT_BIT | SW_LINEOUT_INSERT_BIT:
153+ headset = BIT_HDMI_AUDIO;
154+ break;
155+
146156 case SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT:
147157 headset = BIT_HEADSET;
148158 break;
@@ -157,7 +167,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
157167 }
158168
159169 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);
161171 }
162172 }
163173
@@ -287,7 +297,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
287297 }
288298
289299 if (LOG) {
290- Slog.v(TAG, "headsetName: " + headsetName +
300+ Slog.i(TAG, "headsetName: " + headsetName +
291301 (state == 1 ? " connected" : " disconnected"));
292302 }
293303
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -259,6 +259,9 @@ public class InputManagerService extends IInputManager.Stub
259259 /** Switch code: Headphone/Microphone Jack. When set, something is inserted. */
260260 public static final int SW_JACK_PHYSICAL_INSERT = 0x07;
261261
262+ /** Switch code: Video out jack. When set, something is inserted. */
263+ public static final int SW_VIDEOOUT_INSERT = 0x08;
264+
262265 /** Switch code: Camera lens cover. When set the lens is covered. */
263266 public static final int SW_CAMERA_LENS_COVER = 0x09;
264267
@@ -269,8 +272,9 @@ public class InputManagerService extends IInputManager.Stub
269272 public static final int SW_MICROPHONE_INSERT_BIT = 1 << SW_MICROPHONE_INSERT;
270273 public static final int SW_LINEOUT_INSERT_BIT = 1 << SW_LINEOUT_INSERT;
271274 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;
272276 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;
274278 public static final int SW_CAMERA_LENS_COVER_BIT = 1 << SW_CAMERA_LENS_COVER;
275279
276280 /** Whether to use the dev/input/event or uevent subsystem for the audio jack. */
Show on old repository browser