summaryrefslogtreecommitdiffstats
path: root/services/core/java
diff options
context:
space:
mode:
authorJinsuk Kim <jinsukkim@google.com>2014-10-13 05:16:10 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-13 05:16:11 +0000
commite46fdb43c0193cb89716600a3aa17b836502e098 (patch)
treeb0d5e7ecd6beb15778a3909ffae60d54538e6a8c /services/core/java
parent96eecf4f06f8f561b630bcb36df843b0e5b47e23 (diff)
parent6f87b4e6b6db76cb32d449ad1fdf1946ff4e96f7 (diff)
downloadframeworks_base-e46fdb43c0193cb89716600a3aa17b836502e098.zip
frameworks_base-e46fdb43c0193cb89716600a3aa17b836502e098.tar.gz
frameworks_base-e46fdb43c0193cb89716600a3aa17b836502e098.tar.bz2
Merge "CEC: Queue actions for starting later when not ready" into lmp-mr1-dev
Diffstat (limited to 'services/core/java')
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiCecFeatureAction.java9
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java15
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java7
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java1
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiControlService.java9
5 files changed, 35 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecFeatureAction.java b/services/core/java/com/android/server/hdmi/HdmiCecFeatureAction.java
index c47e0e9..d26be57 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecFeatureAction.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecFeatureAction.java
@@ -73,8 +73,9 @@ abstract class HdmiCecFeatureAction {
}
/**
- * Called right after the action is created. Initialization or first step to take
- * for the action can be done in this method.
+ * Called after the action is created. Initialization or first step to take
+ * for the action can be done in this method. Shall update {@code mState} to
+ * indicate that the action has started.
*
* @return true if the operation is successful; otherwise false.
*/
@@ -161,6 +162,10 @@ abstract class HdmiCecFeatureAction {
mActionTimer.sendTimerMessage(state, delayMillis);
}
+ boolean started() {
+ return mState != STATE_NONE;
+ }
+
protected final void sendCommand(HdmiCecMessage cmd) {
mService.sendCecCommand(cmd);
}
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java
index 2ba6cee..836a463 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java
@@ -616,14 +616,25 @@ abstract class HdmiCecLocalDevice {
@ServiceThreadOnly
void addAndStartAction(final HdmiCecFeatureAction action) {
assertRunOnServiceThread();
+ mActions.add(action);
if (mService.isPowerStandbyOrTransient()) {
- Slog.w(TAG, "Skip the action during Standby: " + action);
+ Slog.i(TAG, "Not ready to start action. Queued for deferred start:" + action);
return;
}
- mActions.add(action);
action.start();
}
+ @ServiceThreadOnly
+ void startQueuedActions() {
+ assertRunOnServiceThread();
+ for (HdmiCecFeatureAction action : mActions) {
+ if (!action.started()) {
+ Slog.i(TAG, "Starting queued action:" + action);
+ action.start();
+ }
+ }
+ }
+
// See if we have an action of a given type in progress.
@ServiceThreadOnly
<T extends HdmiCecFeatureAction> boolean hasAction(final Class<T> clazz) {
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
index b406ebd..da508e8 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
@@ -39,6 +39,12 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice {
}
@Override
+ void init() {
+ super.init();
+ mIsActiveSource = false;
+ }
+
+ @Override
@ServiceThreadOnly
protected void onAddressAllocated(int logicalAddress, int reason) {
assertRunOnServiceThread();
@@ -46,6 +52,7 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice {
mAddress, mService.getPhysicalAddress(), mDeviceType));
mService.sendCecCommand(HdmiCecMessageBuilder.buildDeviceVendorIdCommand(
mAddress, mService.getVendorId()));
+ startQueuedActions();
}
@Override
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
index f6069bb..1a5678b 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
@@ -142,6 +142,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
launchRoutingControl(reason != HdmiControlService.INITIATED_BY_ENABLE_CEC &&
reason != HdmiControlService.INITIATED_BY_BOOT_UP);
launchDeviceDiscovery();
+ startQueuedActions();
}
@Override
diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java
index c906c3c..d643172 100644
--- a/services/core/java/com/android/server/hdmi/HdmiControlService.java
+++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java
@@ -416,12 +416,17 @@ public final class HdmiControlService extends SystemService {
assertRunOnServiceThread();
// A container for [Device type, Local device info].
ArrayList<HdmiCecLocalDevice> localDevices = new ArrayList<>();
- clearLocalDevices();
for (int type : mLocalDevices) {
- final HdmiCecLocalDevice localDevice = HdmiCecLocalDevice.create(this, type);
+ HdmiCecLocalDevice localDevice = mCecController.getLocalDevice(type);
+ if (localDevice == null) {
+ localDevice = HdmiCecLocalDevice.create(this, type);
+ }
localDevice.init();
localDevices.add(localDevice);
}
+ // It's now safe to flush existing local devices from mCecController since they were
+ // already moved to 'localDevices'.
+ clearLocalDevices();
allocateLogicalAddress(localDevices, initiatedBy);
}