diff options
| author | Shubang Lu <shubang@google.com> | 2019-01-17 03:19:05 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-01-17 03:19:05 +0000 |
| commit | 7e355f522e6f17192adfa97aba19dc46c9f3c4f3 (patch) | |
| tree | 64f4f6d153b46b878ce45135f4cd75d6283075a5 /core/java/android | |
| parent | 842af1ecd6d57751cde99ab402ee7e82f6003017 (diff) | |
| parent | aa8ae68c65092754f2b352b8b57281343790135a (diff) | |
Merge changes Ibcebfcc2,Ic2e63185,I90def978,I30031fc9,I0cfa1989
* changes:
Fix hdmi framework tests.
Use the Short Audio Descriptor xml parser to get config when receive request short audio descriptor message.
Add parser for Short Audio Descriptor xml config
Add an API for clients to know if a target device is connected to the current device.
Add TV_INPUT_ALLOW_3RD_PARTY_INPUTS to settings
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/hardware/hdmi/HdmiControlManager.java | 33 | ||||
| -rw-r--r-- | core/java/android/hardware/hdmi/HdmiUtils.java | 81 | ||||
| -rw-r--r-- | core/java/android/provider/Settings.java | 17 |
3 files changed, 130 insertions, 1 deletions
diff --git a/core/java/android/hardware/hdmi/HdmiControlManager.java b/core/java/android/hardware/hdmi/HdmiControlManager.java index a7734f544607..a98b31ad6a5e 100644 --- a/core/java/android/hardware/hdmi/HdmiControlManager.java +++ b/core/java/android/hardware/hdmi/HdmiControlManager.java @@ -55,6 +55,10 @@ public final class HdmiControlManager { @Nullable private final IHdmiControlService mService; + private static final int INVALID_PHYSICAL_ADDRESS = 0xFFFF; + + private int mPhysicalAddress = INVALID_PHYSICAL_ADDRESS; + /** * Broadcast Action: Display OSD message. * <p>Send when the service has a message to display on screen for events @@ -505,14 +509,41 @@ public final class HdmiControlManager { * @hide */ public int getPhysicalAddress() { + if (mPhysicalAddress != INVALID_PHYSICAL_ADDRESS) { + return mPhysicalAddress; + } try { - return mService.getPhysicalAddress(); + mPhysicalAddress = mService.getPhysicalAddress(); + return mPhysicalAddress; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** + * Check if the target device is connected to the current device. The + * API also returns true if the current device is the target. + * + * @param targetDevice {@link HdmiDeviceInfo} of the target device. + * @return true if {@code device} is directly or indirectly connected to the + * + * TODO(b/110094868): unhide for Q + * @hide + */ + public boolean isTargetDeviceConnected(HdmiDeviceInfo targetDevice) { + mPhysicalAddress = getPhysicalAddress(); + if (mPhysicalAddress == INVALID_PHYSICAL_ADDRESS) { + return false; + } + int targetPhysicalAddress = targetDevice.getPhysicalAddress(); + if (targetPhysicalAddress == INVALID_PHYSICAL_ADDRESS) { + return false; + } + return HdmiUtils.getLocalPortFromPhysicalAddress(targetPhysicalAddress, mPhysicalAddress) + != HdmiUtils.TARGET_NOT_UNDER_LOCAL_DEVICE; + } + + /** * Listener used to get hotplug event from HDMI port. */ public interface HotplugEventListener { diff --git a/core/java/android/hardware/hdmi/HdmiUtils.java b/core/java/android/hardware/hdmi/HdmiUtils.java new file mode 100644 index 000000000000..308173816f13 --- /dev/null +++ b/core/java/android/hardware/hdmi/HdmiUtils.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.hdmi; + +/** + * Various utilities to handle HDMI CEC messages. + * + * TODO(b/110094868): unhide for Q + * @hide + */ +public class HdmiUtils { + + /** + * Return value of {@link #getLocalPortFromPhysicalAddress(int, int)} + */ + static final int TARGET_NOT_UNDER_LOCAL_DEVICE = -1; + static final int TARGET_SAME_PHYSICAL_ADDRESS = 0; + + private HdmiUtils() { /* cannot be instantiated */ } + + /** + * Method to parse target physical address to the port number on the current device. + * + * <p>This check assumes target address is valid. + * + * @param targetPhysicalAddress is the physical address of the target device + * @param myPhysicalAddress is the physical address of the current device + * @return + * If the target device is under the current device, return the port number of current device + * that the target device is connected to. This also applies to the devices that are indirectly + * connected to the current device. + * + * <p>If the target device has the same physical address as the current device, return + * {@link #TARGET_SAME_PHYSICAL_ADDRESS}. + * + * <p>If the target device is not under the current device, return + * {@link #TARGET_NOT_UNDER_LOCAL_DEVICE}. + */ + public static int getLocalPortFromPhysicalAddress( + int targetPhysicalAddress, int myPhysicalAddress) { + if (myPhysicalAddress == targetPhysicalAddress) { + return TARGET_SAME_PHYSICAL_ADDRESS; + } + + int mask = 0xF000; + int finalMask = 0xF000; + int maskedAddress = myPhysicalAddress; + + while (maskedAddress != 0) { + maskedAddress = myPhysicalAddress & mask; + finalMask |= mask; + mask >>= 4; + } + + int portAddress = targetPhysicalAddress & finalMask; + if ((portAddress & (finalMask << 4)) != myPhysicalAddress) { + return TARGET_NOT_UNDER_LOCAL_DEVICE; + } + + mask <<= 4; + int port = portAddress & mask; + while ((port >> 4) != 0) { + port >>= 4; + } + return port; + } +} diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 73e90d6ee628..757c03e132e6 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -7732,6 +7732,23 @@ public final class Settings { public static final String TV_INPUT_CUSTOM_LABELS = "tv_input_custom_labels"; /** + * Whether TV app uses non-system inputs. + * + * <p> + * The value is boolean (1 or 0), where 1 means non-system TV inputs are allowed, + * and 0 means non-system TV inputs are not allowed. + * + * <p> + * Devices such as sound bars may have changed the system property allow_third_party_inputs + * to false so the TV Application only uses HDMI and other built in inputs. This setting + * allows user to override the default and have the TV Application use third party TV inputs + * available on play store. + * + * @hide + */ + public static final String TV_APP_USES_NON_SYSTEM_INPUTS = "tv_app_uses_non_system_inputs"; + + /** * Whether automatic routing of system audio to USB audio peripheral is disabled. * The value is boolean (1 or 0), where 1 means automatic routing is disabled, * and 0 means automatic routing is enabled. |
