• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

Revision420dcd798d36fc45e70d5859ad2263117dfa8429 (tree)
Time2020-04-14 23:46:48
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
@@ -22,6 +22,8 @@ import static com.android.server.input.InputManagerService.SW_LINEOUT_INSERT;
2222 import static com.android.server.input.InputManagerService.SW_LINEOUT_INSERT_BIT;
2323 import static com.android.server.input.InputManagerService.SW_MICROPHONE_INSERT;
2424 import static com.android.server.input.InputManagerService.SW_MICROPHONE_INSERT_BIT;
25+import static com.android.server.input.InputManagerService.SW_VIDEOOUT_INSERT;
26+import static com.android.server.input.InputManagerService.SW_VIDEOOUT_INSERT_BIT;
2527
2628 import android.content.Context;
2729 import android.media.AudioManager;
@@ -118,8 +120,11 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
118120 if (mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_LINEOUT_INSERT) == 1) {
119121 switchValues |= SW_LINEOUT_INSERT_BIT;
120122 }
123+ if (mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_VIDEOOUT_INSERT) == 1) {
124+ switchValues |= SW_VIDEOOUT_INSERT_BIT;
125+ }
121126 notifyWiredAccessoryChanged(0, switchValues,
122- SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_LINEOUT_INSERT_BIT);
127+ SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_LINEOUT_INSERT_BIT | SW_VIDEOOUT_INSERT_BIT);
123128 }
124129
125130
@@ -137,7 +142,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
137142 @Override
138143 public void notifyWiredAccessoryChanged(long whenNanos, int switchValues, int switchMask) {
139144 if (LOG) {
140- Slog.v(TAG, "notifyWiredAccessoryChanged: when=" + whenNanos
145+ Slog.i(TAG, "notifyWiredAccessoryChanged: when=" + whenNanos
141146 + " bits=" + switchCodeToString(switchValues, switchMask)
142147 + " mask=" + Integer.toHexString(switchMask));
143148 }
@@ -146,7 +151,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
146151 int headset;
147152 mSwitchValues = (mSwitchValues & ~switchMask) | switchValues;
148153 switch (mSwitchValues &
149- (SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_LINEOUT_INSERT_BIT)) {
154+ (SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_LINEOUT_INSERT_BIT | SW_VIDEOOUT_INSERT_BIT)) {
150155 case 0:
151156 headset = 0;
152157 break;
@@ -159,6 +164,11 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
159164 headset = BIT_LINEOUT;
160165 break;
161166
167+ case SW_VIDEOOUT_INSERT_BIT:
168+ case SW_VIDEOOUT_INSERT_BIT | SW_LINEOUT_INSERT_BIT:
169+ headset = BIT_HDMI_AUDIO;
170+ break;
171+
162172 case SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT:
163173 headset = BIT_HEADSET;
164174 break;
@@ -173,7 +183,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
173183 }
174184
175185 updateLocked(NAME_H2W,
176- (mHeadsetState & ~(BIT_HEADSET | BIT_HEADSET_NO_MIC | BIT_LINEOUT)) | headset);
186+ (mHeadsetState & ~(BIT_HEADSET | BIT_HEADSET_NO_MIC | BIT_LINEOUT | BIT_HDMI_AUDIO)) | headset);
177187 }
178188 }
179189
@@ -305,7 +315,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
305315 }
306316
307317 if (LOG) {
308- Slog.v(TAG, "headsetName: " + headsetName +
318+ Slog.i(TAG, "headsetName: " + headsetName +
309319 (state == 1 ? " connected" : " disconnected"));
310320 }
311321
@@ -328,6 +338,14 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
328338 (switchValues & SW_MICROPHONE_INSERT_BIT) != 0) {
329339 sb.append("SW_MICROPHONE_INSERT");
330340 }
341+ if ((switchMask & SW_LINEOUT_INSERT_BIT) != 0 &&
342+ (switchValues & SW_LINEOUT_INSERT_BIT) != 0) {
343+ sb.append("SW_LINEOUT_INSERT ");
344+ }
345+ if ((switchMask & SW_VIDEOOUT_INSERT_BIT) != 0 &&
346+ (switchValues & SW_VIDEOOUT_INSERT_BIT) != 0) {
347+ sb.append("SW_VIDEOOUT_INSERT ");
348+ }
331349 return sb.toString();
332350 }
333351
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -294,6 +294,9 @@ public class InputManagerService extends IInputManager.Stub
294294 /** Switch code: Headphone/Microphone Jack. When set, something is inserted. */
295295 public static final int SW_JACK_PHYSICAL_INSERT = 0x07;
296296
297+ /** Switch code: Video out jack. When set, something is inserted. */
298+ public static final int SW_VIDEOOUT_INSERT = 0x08;
299+
297300 /** Switch code: Camera lens cover. When set the lens is covered. */
298301 public static final int SW_CAMERA_LENS_COVER = 0x09;
299302
@@ -304,8 +307,9 @@ public class InputManagerService extends IInputManager.Stub
304307 public static final int SW_MICROPHONE_INSERT_BIT = 1 << SW_MICROPHONE_INSERT;
305308 public static final int SW_LINEOUT_INSERT_BIT = 1 << SW_LINEOUT_INSERT;
306309 public static final int SW_JACK_PHYSICAL_INSERT_BIT = 1 << SW_JACK_PHYSICAL_INSERT;
310+ public static final int SW_VIDEOOUT_INSERT_BIT = 1 << SW_VIDEOOUT_INSERT;
307311 public static final int SW_JACK_BITS =
308- SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_JACK_PHYSICAL_INSERT_BIT | SW_LINEOUT_INSERT_BIT;
312+ SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_JACK_PHYSICAL_INSERT_BIT | SW_LINEOUT_INSERT_BIT | SW_VIDEOOUT_INSERT_BIT;
309313 public static final int SW_CAMERA_LENS_COVER_BIT = 1 << SW_CAMERA_LENS_COVER;
310314
311315 /** Whether to use the dev/input/event or uevent subsystem for the audio jack. */