am ace5759f: am e0ab5efa: am 75119bcb: Merge "Prevent hot plug detection action from multiple device polling" into lmp-dev

* commit 'ace5759ffa591941600ce8375ec51b3be4804944':
  Prevent hot plug detection action from multiple device polling
This commit is contained in:
Jungshik Jang
2014-08-07 00:39:45 +00:00
committed by Android Git Automerger
11 changed files with 41 additions and 98 deletions

View File

@@ -82,6 +82,7 @@ public final class HdmiPlaybackClient extends HdmiClient {
}
}
@Override
public int getDeviceType() {
return HdmiCecDeviceInfo.DEVICE_PLAYBACK;
}
@@ -93,7 +94,6 @@ public final class HdmiPlaybackClient extends HdmiClient {
* of the result
*/
public void queryDisplayStatus(DisplayStatusCallback callback) {
// TODO: PendingResult.
try {
mService.queryDisplayStatus(getCallbackWrapper(callback));
} catch (RemoteException e) {

View File

@@ -101,10 +101,6 @@ final class ActiveSourceHandler {
return mSource.getDeviceInfo().getLogicalAddress();
}
private final int getSourcePath() {
return mSource.getDeviceInfo().getPhysicalAddress();
}
private void invokeCallback(int result) {
if (mCallback == null) {
return;

View File

@@ -21,7 +21,7 @@ import android.hardware.hdmi.HdmiCecDeviceInfo;
/**
* Defines constants related to HDMI-CEC protocol internal implementation.
* If a constant will be used in the public api, it should be located in
* {@link android.hardware.hdmi.HdmiCec}.
* {@link android.hardware.hdmi.HdmiControlManager}.
*/
final class Constants {

View File

@@ -17,19 +17,19 @@ package com.android.server.hdmi;
*/
import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.HdmiPlaybackClient;
import android.hardware.hdmi.HdmiPlaybackClient.DisplayStatusCallback;
import android.hardware.hdmi.IHdmiControlCallback;
import android.os.RemoteException;
import android.util.Slog;
/**
* Feature action that queries the power status of other device.
*
* This action is initiated via {@link HdmiControlManager#queryDisplayStatus()} from
* the Android system working as playback device to get the power status of TV device.
*
* <p>Package-private, accessed by {@link HdmiControlService} only.
* Feature action that queries the power status of other device. This action is initiated via
* {@link HdmiPlaybackClient#queryDisplayStatus(DisplayStatusCallback)} from the Android system
* working as playback device to get the power status of TV device.
* <p>
* Package-private, accessed by {@link HdmiControlService} only.
*/
final class DevicePowerStatusAction extends FeatureAction {
private static final String TAG = "DevicePowerStatusAction";

View File

@@ -65,16 +65,6 @@ final class HdmiCecController {
private static final byte[] EMPTY_BODY = EmptyArray.BYTE;
// A message to pass cec send command to IO looper.
private static final int MSG_SEND_CEC_COMMAND = 1;
// A message to delegate logical allocation to IO looper.
private static final int MSG_ALLOCATE_LOGICAL_ADDRESS = 2;
// Message types to handle incoming message in main service looper.
private final static int MSG_RECEIVE_CEC_COMMAND = 1;
// A message to report allocated logical address to main control looper.
private final static int MSG_REPORT_LOGICAL_ADDRESS = 2;
private static final int NUM_LOGICAL_ADDRESS = 16;
// Predicate for whether the given logical address is remote device's one or not.
@@ -196,7 +186,15 @@ final class HdmiCecController {
int curAddress = (startAddress + i) % NUM_LOGICAL_ADDRESS;
if (curAddress != Constants.ADDR_UNREGISTERED
&& deviceType == HdmiUtils.getTypeFromAddress(curAddress)) {
if (!sendPollMessage(curAddress, curAddress, HdmiConfig.ADDRESS_ALLOCATION_RETRY)) {
int failedPollingCount = 0;
for (int j = 0; j < HdmiConfig.ADDRESS_ALLOCATION_RETRY; ++j) {
if (!sendPollMessage(curAddress, curAddress, 1)) {
failedPollingCount++;
}
}
// Pick logical address if failed ratio is more than a half of all retries.
if (failedPollingCount * 2 > HdmiConfig.ADDRESS_ALLOCATION_RETRY) {
logicalAddress = curAddress;
break;
}
@@ -206,7 +204,7 @@ final class HdmiCecController {
final int assignedAddress = logicalAddress;
if (callback != null) {
runOnServiceThread(new Runnable() {
@Override
@Override
public void run() {
callback.onAllocated(deviceType, assignedAddress);
}

View File

@@ -812,12 +812,6 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
addAndStartAction(VolumeControlAction.ofMute(this, avr.getLogicalAddress(), mute));
}
private boolean isSystemAudioOn() {
synchronized (mLock) {
return mSystemAudioActivated;
}
}
@Override
@ServiceThreadOnly
protected boolean handleInitiateArc(HdmiCecMessage message) {
@@ -965,7 +959,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
* Return a list of all {@link HdmiCecDeviceInfo}.
*
* <p>Declared as package-private. accessed by {@link HdmiControlService} only.
* This is not thread-safe. For thread safety, call {@link #getSafeDeviceInfoList(boolean)}.
* This is not thread-safe. For thread safety, call {@link #getSafeExternalInputs} which
* does not include local device.
*/
@ServiceThreadOnly
List<HdmiCecDeviceInfo> getDeviceInfoList(boolean includelLocalDevice) {

View File

@@ -16,9 +16,6 @@
package com.android.server.hdmi;
import android.os.Parcel;
import android.os.Parcelable;
import libcore.util.EmptyArray;
import java.util.Arrays;
@@ -28,11 +25,10 @@ import java.util.Arrays;
* HDMI cable to communicate with one another. A message is defined by its
* source and destination address, command (or opcode), and optional parameters.
*/
public final class HdmiCecMessage implements Parcelable {
public final class HdmiCecMessage {
public static final byte[] EMPTY_PARAM = EmptyArray.BYTE;
private static final int MAX_MESSAGE_LENGTH = 16;
private static final int MAX_MESSAGE_PARAM_LENGTH = 14;
private final int mSource;
private final int mDestination;
@@ -47,6 +43,12 @@ public final class HdmiCecMessage implements Parcelable {
mSource = source;
mDestination = destination;
mOpcode = opcode & 0xFF;
if (params.length > MAX_MESSAGE_PARAM_LENGTH) {
throw new IllegalArgumentException(
"Param length should be at most 13 but current param length is "
+ params.length);
}
mParams = Arrays.copyOf(params, params.length);
}
@@ -91,53 +93,6 @@ public final class HdmiCecMessage implements Parcelable {
return mParams;
}
/**
* Describe the kinds of special objects contained in this Parcelable's
* marshalled representation.
*/
@Override
public int describeContents() {
return 0;
}
/**
* Flatten this object in to a Parcel.
*
* @param dest The Parcel in which the object should be written.
* @param flags Additional flags about how the object should be written.
* May be 0 or {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}.
*/
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mSource);
dest.writeInt(mDestination);
dest.writeInt(mOpcode);
dest.writeInt(mParams.length);
dest.writeByteArray(mParams);
}
public static final Parcelable.Creator<HdmiCecMessage> CREATOR
= new Parcelable.Creator<HdmiCecMessage>() {
/**
* Rebuild a HdmiCecMessage previously stored with writeToParcel().
* @param p HdmiCecMessage object to read the Rating from
* @return a new HdmiCecMessage created from the data in the parcel
*/
@Override
public HdmiCecMessage createFromParcel(Parcel p) {
int source = p.readInt();
int destination = p.readInt();
int opcode = p.readInt();
byte[] params = new byte[p.readInt()];
p.readByteArray(params);
return new HdmiCecMessage(source, destination, opcode, params);
}
@Override
public HdmiCecMessage[] newArray(int size) {
return new HdmiCecMessage[size];
}
};
@Override
public String toString() {
StringBuffer s = new StringBuffer();

View File

@@ -258,10 +258,11 @@ public final class HdmiCecMessageValidator {
}
/**
* Check if the given type is valid. A valid type is one of the actual
* logical device types defined in the standard ({@link #DEVICE_TV},
* {@link #DEVICE_PLAYBACK}, {@link #DEVICE_TUNER}, {@link #DEVICE_RECORDER},
* and {@link #DEVICE_AUDIO_SYSTEM}).
* Check if the given type is valid. A valid type is one of the actual logical device types
* defined in the standard ({@link HdmiCecDeviceInfo#DEVICE_TV},
* {@link HdmiCecDeviceInfo#DEVICE_PLAYBACK}, {@link HdmiCecDeviceInfo#DEVICE_TUNER},
* {@link HdmiCecDeviceInfo#DEVICE_RECORDER}, and
* {@link HdmiCecDeviceInfo#DEVICE_AUDIO_SYSTEM}).
*
* @param type device type
* @return true if the given type is valid

View File

@@ -34,7 +34,7 @@ final class HdmiConfig {
static final int DEVICE_POLLING_RETRY = 1;
// Number of retries for polling each device in periodic check (hotplug detection).
static final int HOTPLUG_DETECTION_RETRY = 2;
static final int HOTPLUG_DETECTION_RETRY = 1;
// Number of retries for polling each device in address allocation mechanism.
static final int ADDRESS_ALLOCATION_RETRY = 3;

View File

@@ -17,18 +17,17 @@ package com.android.server.hdmi;
import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.IHdmiControlCallback;
import android.hardware.hdmi.HdmiPlaybackClient.OneTouchPlayCallback;
import android.os.RemoteException;
import android.util.Slog;
/**
* Feature action that performs one touch play against TV/Display device.
*
* This action is initiated via {@link HdmiControlManager#oneTouchPlay()} from
* the Android system working as playback device to turn on the TV, and switch the input.
*
* <p>Package-private, accessed by {@link HdmiControlService} only.
* Feature action that performs one touch play against TV/Display device. This action is initiated
* via {@link android.hardware.hdmi.HdmiPlaybackClient#oneTouchPlay(OneTouchPlayCallback)} from the
* Android system working as playback device to turn on the TV, and switch the input.
* <p>
* Package-private, accessed by {@link HdmiControlService} only.
*/
final class OneTouchPlayAction extends FeatureAction {
private static final String TAG = "OneTouchPlayAction";

View File

@@ -59,4 +59,3 @@ final class UnmodifiableSparseArray<E> {
return mArray.toString();
}
}