am 554055d8: am c907319c: am e208fb35: Merge "Rename FeatureAction into HdmiCecFeatureAction" into lmp-dev
* commit '554055d8cb067f5343444eeafe9544486c3de1e2': Rename FeatureAction into HdmiCecFeatureAction
This commit is contained in:
@@ -39,7 +39,7 @@ import java.util.List;
|
||||
* <li>Gather "Vendor id" of all acknowledge devices
|
||||
* </ol>
|
||||
*/
|
||||
final class DeviceDiscoveryAction extends FeatureAction {
|
||||
final class DeviceDiscoveryAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "DeviceDiscoveryAction";
|
||||
|
||||
// State in which the action is waiting for device polling.
|
||||
|
||||
@@ -30,7 +30,7 @@ import android.util.Slog;
|
||||
* <p>
|
||||
* Package-private, accessed by {@link HdmiControlService} only.
|
||||
*/
|
||||
final class DevicePowerStatusAction extends FeatureAction {
|
||||
final class DevicePowerStatusAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "DevicePowerStatusAction";
|
||||
|
||||
// State in which the action is waiting for <Report Power Status>.
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback;
|
||||
* for a new active source. It does its best to wake up the target in standby mode
|
||||
* before issuing the command >Set Stream path<.
|
||||
*/
|
||||
final class DeviceSelectAction extends FeatureAction {
|
||||
final class DeviceSelectAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "DeviceSelect";
|
||||
|
||||
// Time in milliseconds we wait for the device power status to switch to 'Standby'
|
||||
|
||||
@@ -29,21 +29,19 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Encapsulates a sequence of CEC/MHL command exchange for a certain feature.
|
||||
*
|
||||
* <p>Many CEC/MHL features are accomplished by CEC devices on the bus exchanging
|
||||
* more than one command. {@link FeatureAction} represents the life cycle of the communication,
|
||||
* manages the state as the process progresses, and if necessary, returns the result
|
||||
* to the caller which initiates the action, through the callback given at the creation
|
||||
* of the object. All the actual action classes inherit FeatureAction.
|
||||
*
|
||||
* <p>More than one FeatureAction objects can be up and running simultaneously,
|
||||
* maintained by {@link HdmiCecLocalDevice}. Each action is passed a new command
|
||||
* arriving from the bus, and either consumes it if the command is what the action expects,
|
||||
* or yields it to other action.
|
||||
*
|
||||
* Declared as package private, accessed by {@link HdmiControlService} only.
|
||||
* <p>
|
||||
* Many CEC/MHL features are accomplished by CEC devices on the bus exchanging more than one
|
||||
* command. {@link HdmiCecFeatureAction} represents the life cycle of the communication, manages the
|
||||
* state as the process progresses, and if necessary, returns the result to the caller which
|
||||
* initiates the action, through the callback given at the creation of the object. All the actual
|
||||
* action classes inherit FeatureAction.
|
||||
* <p>
|
||||
* More than one FeatureAction objects can be up and running simultaneously, maintained by
|
||||
* {@link HdmiCecLocalDevice}. Each action is passed a new command arriving from the bus, and either
|
||||
* consumes it if the command is what the action expects, or yields it to other action. Declared as
|
||||
* package private, accessed by {@link HdmiControlService} only.
|
||||
*/
|
||||
abstract class FeatureAction {
|
||||
abstract class HdmiCecFeatureAction {
|
||||
private static final String TAG = "FeatureAction";
|
||||
|
||||
// Timer handler message used for timeout event
|
||||
@@ -61,9 +59,9 @@ abstract class FeatureAction {
|
||||
// Timer that manages timeout events.
|
||||
protected ActionTimer mActionTimer;
|
||||
|
||||
private ArrayList<Pair<FeatureAction, Runnable>> mOnFinishedCallbacks;
|
||||
private ArrayList<Pair<HdmiCecFeatureAction, Runnable>> mOnFinishedCallbacks;
|
||||
|
||||
FeatureAction(HdmiCecLocalDevice source) {
|
||||
HdmiCecFeatureAction(HdmiCecLocalDevice source) {
|
||||
mSource = source;
|
||||
mService = mSource.getService();
|
||||
mActionTimer = createActionTimer(mService.getServiceLooper());
|
||||
@@ -173,11 +171,11 @@ abstract class FeatureAction {
|
||||
mService.sendCecCommand(cmd, callback);
|
||||
}
|
||||
|
||||
protected final void addAndStartAction(FeatureAction action) {
|
||||
protected final void addAndStartAction(HdmiCecFeatureAction action) {
|
||||
mSource.addAndStartAction(action);
|
||||
}
|
||||
|
||||
protected final <T extends FeatureAction> List<T> getActions(final Class<T> clazz) {
|
||||
protected final <T extends HdmiCecFeatureAction> List<T> getActions(final Class<T> clazz) {
|
||||
return mSource.getActions(clazz);
|
||||
}
|
||||
|
||||
@@ -191,16 +189,16 @@ abstract class FeatureAction {
|
||||
*
|
||||
* @param action
|
||||
*/
|
||||
protected final void removeAction(FeatureAction action) {
|
||||
protected final void removeAction(HdmiCecFeatureAction action) {
|
||||
mSource.removeAction(action);
|
||||
}
|
||||
|
||||
protected final <T extends FeatureAction> void removeAction(final Class<T> clazz) {
|
||||
protected final <T extends HdmiCecFeatureAction> void removeAction(final Class<T> clazz) {
|
||||
mSource.removeActionExcept(clazz, null);
|
||||
}
|
||||
|
||||
protected final <T extends FeatureAction> void removeActionExcept(final Class<T> clazz,
|
||||
final FeatureAction exception) {
|
||||
protected final <T extends HdmiCecFeatureAction> void removeActionExcept(final Class<T> clazz,
|
||||
final HdmiCecFeatureAction exception) {
|
||||
mSource.removeActionExcept(clazz, exception);
|
||||
}
|
||||
|
||||
@@ -233,7 +231,7 @@ abstract class FeatureAction {
|
||||
removeAction(this);
|
||||
}
|
||||
if (mOnFinishedCallbacks != null) {
|
||||
for (Pair<FeatureAction, Runnable> actionCallbackPair: mOnFinishedCallbacks) {
|
||||
for (Pair<HdmiCecFeatureAction, Runnable> actionCallbackPair: mOnFinishedCallbacks) {
|
||||
if (actionCallbackPair.first.mState != STATE_NONE) {
|
||||
actionCallbackPair.second.run();
|
||||
}
|
||||
@@ -269,7 +267,7 @@ abstract class FeatureAction {
|
||||
getSourceAddress(), targetAddress));
|
||||
}
|
||||
|
||||
protected final void addOnFinishedCallback(FeatureAction action, Runnable runnable) {
|
||||
protected final void addOnFinishedCallback(HdmiCecFeatureAction action, Runnable runnable) {
|
||||
if (mOnFinishedCallbacks == null) {
|
||||
mOnFinishedCallbacks = new ArrayList<>();
|
||||
}
|
||||
@@ -102,7 +102,7 @@ abstract class HdmiCecLocalDevice {
|
||||
|
||||
// A collection of FeatureAction.
|
||||
// Note that access to this collection should happen in service thread.
|
||||
private final LinkedList<FeatureAction> mActions = new LinkedList<>();
|
||||
private final LinkedList<HdmiCecFeatureAction> mActions = new LinkedList<>();
|
||||
|
||||
private final Handler mHandler = new Handler () {
|
||||
@Override
|
||||
@@ -250,7 +250,7 @@ abstract class HdmiCecLocalDevice {
|
||||
@ServiceThreadOnly
|
||||
private boolean dispatchMessageToAction(HdmiCecMessage message) {
|
||||
assertRunOnServiceThread();
|
||||
for (FeatureAction action : mActions) {
|
||||
for (HdmiCecFeatureAction action : mActions) {
|
||||
if (action.processCommand(message)) {
|
||||
return true;
|
||||
}
|
||||
@@ -486,7 +486,7 @@ abstract class HdmiCecLocalDevice {
|
||||
}
|
||||
|
||||
@ServiceThreadOnly
|
||||
void addAndStartAction(final FeatureAction action) {
|
||||
void addAndStartAction(final HdmiCecFeatureAction action) {
|
||||
assertRunOnServiceThread();
|
||||
if (mService.isPowerStandbyOrTransient()) {
|
||||
Slog.w(TAG, "Skip the action during Standby: " + action);
|
||||
@@ -498,9 +498,9 @@ abstract class HdmiCecLocalDevice {
|
||||
|
||||
// See if we have an action of a given type in progress.
|
||||
@ServiceThreadOnly
|
||||
<T extends FeatureAction> boolean hasAction(final Class<T> clazz) {
|
||||
<T extends HdmiCecFeatureAction> boolean hasAction(final Class<T> clazz) {
|
||||
assertRunOnServiceThread();
|
||||
for (FeatureAction action : mActions) {
|
||||
for (HdmiCecFeatureAction action : mActions) {
|
||||
if (action.getClass().equals(clazz)) {
|
||||
return true;
|
||||
}
|
||||
@@ -510,10 +510,10 @@ abstract class HdmiCecLocalDevice {
|
||||
|
||||
// Returns all actions matched with given class type.
|
||||
@ServiceThreadOnly
|
||||
<T extends FeatureAction> List<T> getActions(final Class<T> clazz) {
|
||||
<T extends HdmiCecFeatureAction> List<T> getActions(final Class<T> clazz) {
|
||||
assertRunOnServiceThread();
|
||||
List<T> actions = Collections.<T>emptyList();
|
||||
for (FeatureAction action : mActions) {
|
||||
for (HdmiCecFeatureAction action : mActions) {
|
||||
if (action.getClass().equals(clazz)) {
|
||||
if (actions.isEmpty()) {
|
||||
actions = new ArrayList<T>();
|
||||
@@ -525,12 +525,12 @@ abstract class HdmiCecLocalDevice {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given {@link FeatureAction} object from the action queue.
|
||||
* Remove the given {@link HdmiCecFeatureAction} object from the action queue.
|
||||
*
|
||||
* @param action {@link FeatureAction} to remove
|
||||
* @param action {@link HdmiCecFeatureAction} to remove
|
||||
*/
|
||||
@ServiceThreadOnly
|
||||
void removeAction(final FeatureAction action) {
|
||||
void removeAction(final HdmiCecFeatureAction action) {
|
||||
assertRunOnServiceThread();
|
||||
action.finish(false);
|
||||
mActions.remove(action);
|
||||
@@ -539,19 +539,19 @@ abstract class HdmiCecLocalDevice {
|
||||
|
||||
// Remove all actions matched with the given Class type.
|
||||
@ServiceThreadOnly
|
||||
<T extends FeatureAction> void removeAction(final Class<T> clazz) {
|
||||
<T extends HdmiCecFeatureAction> void removeAction(final Class<T> clazz) {
|
||||
assertRunOnServiceThread();
|
||||
removeActionExcept(clazz, null);
|
||||
}
|
||||
|
||||
// Remove all actions matched with the given Class type besides |exception|.
|
||||
@ServiceThreadOnly
|
||||
<T extends FeatureAction> void removeActionExcept(final Class<T> clazz,
|
||||
final FeatureAction exception) {
|
||||
<T extends HdmiCecFeatureAction> void removeActionExcept(final Class<T> clazz,
|
||||
final HdmiCecFeatureAction exception) {
|
||||
assertRunOnServiceThread();
|
||||
Iterator<FeatureAction> iter = mActions.iterator();
|
||||
Iterator<HdmiCecFeatureAction> iter = mActions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
FeatureAction action = iter.next();
|
||||
HdmiCecFeatureAction action = iter.next();
|
||||
if (action != exception && action.getClass().equals(clazz)) {
|
||||
action.finish(false);
|
||||
iter.remove();
|
||||
@@ -698,9 +698,9 @@ abstract class HdmiCecLocalDevice {
|
||||
|
||||
// If all actions are not cleared in DEVICE_CLEANUP_TIMEOUT, enforce to finish them.
|
||||
// onCleard will be called at the last action's finish method.
|
||||
Iterator<FeatureAction> iter = mActions.iterator();
|
||||
Iterator<HdmiCecFeatureAction> iter = mActions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
FeatureAction action = iter.next();
|
||||
HdmiCecFeatureAction action = iter.next();
|
||||
action.finish(false);
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.List;
|
||||
* For other devices, keep 15 secs period.
|
||||
*/
|
||||
// Seq #3
|
||||
final class HotplugDetectionAction extends FeatureAction {
|
||||
final class HotplugDetectionAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "HotPlugDetectionAction";
|
||||
|
||||
private static final int POLLING_INTERVAL_MS = 5000;
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.io.UnsupportedEncodingException;
|
||||
*
|
||||
* <p>Package-private, accessed by {@link HdmiControlService} only.
|
||||
*/
|
||||
final class NewDeviceAction extends FeatureAction {
|
||||
final class NewDeviceAction extends HdmiCecFeatureAction {
|
||||
|
||||
private static final String TAG = "NewDeviceAction";
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import android.util.Slog;
|
||||
* <p>
|
||||
* Package-private, accessed by {@link HdmiControlService} only.
|
||||
*/
|
||||
final class OneTouchPlayAction extends FeatureAction {
|
||||
final class OneTouchPlayAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "OneTouchPlayAction";
|
||||
|
||||
// State in which the action is waiting for <Report Power Status>. In normal situation
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback;
|
||||
/**
|
||||
* Feature action that performs one touch record.
|
||||
*/
|
||||
public class OneTouchRecordAction extends FeatureAction {
|
||||
public class OneTouchRecordAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "OneTouchRecordAction";
|
||||
|
||||
// Timer out for waiting <Record Status> 120s
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.util.Slog;
|
||||
/**
|
||||
* Base feature action class for <Request ARC Initiation>/<Request ARC Termination>.
|
||||
*/
|
||||
abstract class RequestArcAction extends FeatureAction {
|
||||
abstract class RequestArcAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "RequestArcAction";
|
||||
|
||||
// State in which waits for ARC response.
|
||||
|
||||
@@ -38,7 +38,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback;
|
||||
* <li> Routing at CEC enable time
|
||||
* </ul>
|
||||
*/
|
||||
final class RoutingControlAction extends FeatureAction {
|
||||
final class RoutingControlAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "RoutingControlAction";
|
||||
|
||||
// State in which we wait for <Routing Information> to arrive. If timed out, we use the
|
||||
|
||||
@@ -32,7 +32,7 @@ import android.view.KeyEvent;
|
||||
*
|
||||
* <p>Package-private, accessed by {@link HdmiControlService} only.
|
||||
*/
|
||||
final class SendKeyAction extends FeatureAction {
|
||||
final class SendKeyAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "SendKeyAction";
|
||||
|
||||
// State in which the action is at work. The state is set in {@link #start()} and
|
||||
|
||||
@@ -24,7 +24,7 @@ import android.util.Slog;
|
||||
* Once TV gets <Initiate ARC>, TV sends <Report ARC Initiated> to AV Receiver.
|
||||
* If it fails or it gets <Terminate ARC>, TV just disables ARC.
|
||||
*/
|
||||
final class SetArcTransmissionStateAction extends FeatureAction {
|
||||
final class SetArcTransmissionStateAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "SetArcTransmissionStateAction";
|
||||
|
||||
// State in which the action sent <Rerpot Arc Initiated> and
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
/**
|
||||
* Base feature action class for SystemAudioActionFromTv and SystemAudioActionFromAvr.
|
||||
*/
|
||||
abstract class SystemAudioAction extends FeatureAction {
|
||||
abstract class SystemAudioAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "SystemAudioAction";
|
||||
|
||||
// Transient state to differentiate with STATE_NONE where the on-finished callback
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback;
|
||||
* Action to initiate system audio once AVR is detected on Device discovery action.
|
||||
*/
|
||||
// Seq #27
|
||||
final class SystemAudioAutoInitiationAction extends FeatureAction {
|
||||
final class SystemAudioAutoInitiationAction extends HdmiCecFeatureAction {
|
||||
private final int mAvrAddress;
|
||||
|
||||
// State that waits for <System Audio Mode Status> once send
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback;
|
||||
/**
|
||||
* Action to update audio status (volume or mute) of audio amplifier
|
||||
*/
|
||||
final class SystemAudioStatusAction extends FeatureAction {
|
||||
final class SystemAudioStatusAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "SystemAudioStatusAction";
|
||||
|
||||
// State that waits for <ReportAudioStatus>.
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.Arrays;
|
||||
/**
|
||||
* Feature action that performs timer recording.
|
||||
*/
|
||||
public class TimerRecordingAction extends FeatureAction {
|
||||
public class TimerRecordingAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "TimerRecordingAction";
|
||||
|
||||
// Timer out for waiting <Timer Status> 120s.
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.android.internal.util.Preconditions;
|
||||
* from Audio Receiver(AVR). If TV receives no <Report Audio Status> from AVR, this action
|
||||
* will be finished in {@link #IRT_MS} * {@link #VOLUME_CHANGE_TIMEOUT_MAX_COUNT} (ms).
|
||||
*/
|
||||
final class VolumeControlAction extends FeatureAction {
|
||||
final class VolumeControlAction extends HdmiCecFeatureAction {
|
||||
private static final String TAG = "VolumeControlAction";
|
||||
|
||||
private static final int VOLUME_MUTE = 101;
|
||||
|
||||
Reference in New Issue
Block a user